From: Greg Beaver Date: Sat, 5 Jan 2008 23:26:24 +0000 (+0000) Subject: new test, exposes some memleaks, but not yet sure where they are (done for today) X-Git-Tag: RELEASE_2_0_0a1~1011 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f94226b71f88aff292f65b6cb6041550fe049ea;p=php new test, exposes some memleaks, but not yet sure where they are (done for today) --- diff --git a/ext/phar/tests/tar/tar_003.phpt b/ext/phar/tests/tar/tar_003.phpt new file mode 100644 index 0000000000..d4a98432fa --- /dev/null +++ b/ext/phar/tests/tar/tar_003.phpt @@ -0,0 +1,45 @@ +--TEST-- +Phar: tar-based phar, valid 1 +--SKIPIF-- + + +--INI-- +phar.readonly=0 +--FILE-- +init(); +$a->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r')); +$a->addFile('internal/file/here', "hi there!\n"); +$a->mkDir('internal/dir'); +$a->mkDir('dir'); +$a->close(); +fclose($g); + +echo file_get_contents($pname . '/internal/file/here'); +$a = opendir($pname . '/'); +while (false !== ($v = readdir($a))) { + echo (is_file($pname . $v) ? "file\n" : "dir\n"); + echo $v . "\n"; +} +closedir($a); + +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +hi there! +dir +dir +dir +internal +file +tar_003.phpt +===DONE=== \ No newline at end of file diff --git a/ext/phar/tests/tar/tarmaker.php.inc b/ext/phar/tests/tar/tarmaker.php.inc index 9b75d9be12..566f3bdcc1 100644 --- a/ext/phar/tests/tar/tarmaker.php.inc +++ b/ext/phar/tests/tar/tarmaker.php.inc @@ -38,19 +38,21 @@ class tarmaker * @param string relative path within the package * @param string|resource file contents or open file handle */ - function addFile($path, $fileOrStream) + function addFile($path, $fileOrStream, $stat = null) { clearstatcache(); - if (is_resource($fileOrStream)) { - $stat = fstat($fileOrStream); - } else { - $stat = array( - 'mode' => 0x8000 + 0644, - 'uid' => 0, - 'gid' => 0, - 'size' => strlen($fileOrStream), - 'mtime' => time(), - ); + if ($stat === null) { + if (is_resource($fileOrStream)) { + $stat = fstat($fileOrStream); + } else { + $stat = array( + 'mode' => 0x8000 + 0644, + 'uid' => 0, + 'gid' => 0, + 'size' => strlen($fileOrStream), + 'mtime' => time(), + ); + } } $link = null; @@ -143,11 +145,17 @@ class tarmaker /** * Create an internal directory, creating parent directories as needed * - * This is a no-op for the tar creator * @param string $dir */ function mkdir($dir) { + $this->addFile($dir, "", array( + 'mode' => 0x4000 + 0644, + 'uid' => 0, + 'gid' => 0, + 'size' => 0, + 'mtime' => time(), + )); } /**