summaryrefslogtreecommitdiff
path: root/ext/phar/tests/tar/bug70417.phpt
blob: 0202ca9472afebd3f0574729add7cadbdcfe2f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--TEST--
Bug #70417 (PharData::compress() doesn't close temp file)
--SKIPIF--
<?php
if (!extension_loaded('phar') || !extension_loaded('zlib')) {
    die("skip ext/phar or ext/zlib not available");
}
exec('lsof -p ' . getmypid(), $out, $status);
if ($status !== 0) {
    die("skip lsof(8) not available");
}
?>
--FILE--
<?php
function countOpenFiles() {
    exec('lsof -p ' . escapeshellarg(getmypid()) . ' 2> /dev/null', $out);
    return count($out);
}
$filename = __DIR__ . '/bug70417.tar';
@unlink("$filename.gz");
$openFiles1 = countOpenFiles();
$arch = new PharData($filename);
$arch->addFromString('foo', 'bar');
$arch->compress(Phar::GZ);
unset($arch);
$openFiles2 = countOpenFiles();
var_dump($openFiles1 === $openFiles2);
?>
--CLEAN--
<?php
$filename = __DIR__ . '/bug70417.tar';
@unlink($filename);
@unlink("$filename.gz");
?>
--EXPECT--
bool(true)