Skip to content

Commit

Permalink
Added test for files when unpacked size bigger than 2 GiB (it will ta…
Browse files Browse the repository at this point in the history
…ke some effort to do the same for packed size > 2 GiB).

Relaxed test #12 (changes to the unpacking algorithm in unrar 3.9.10 have apparently changed the output stream for corrupted entries).

git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@298254 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
cataphract committed Apr 21, 2010
1 parent 2fb18b2 commit 3c8d037
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/012.phpt
Expand Up @@ -20,7 +20,7 @@ foreach ($entries as $e) {
echo "Could not get stream.\n\n";
continue;
}
while (!feof($stream)) {
while (!feof($stream) && $i != 2) {
echo fread($stream, 8192);
}
fclose($stream);
Expand All @@ -37,6 +37,5 @@ test%s: The great battle of Gunprex versus Optiter!!!!!1
Gunprex, Fire!
So long, Optiter!

test%s: it,greIater!
%s
test%s:
Done
26 changes: 26 additions & 0 deletions tests/040.phpt
@@ -0,0 +1,26 @@
--TEST--
RarEntry::getUnpackedSize() on platforms with 32-bit longs
--SKIPIF--
<?php
if(!extension_loaded("rar")) die("skip");
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
--FILE--
<?php
$fn1 = dirname(__FILE__) . '/sparsefiles_rar.rar';
$fn2 = dirname(__FILE__) . '/sparsefiles.tmp.rar';
$rarF = RarArchive::open($fn1);
$t = $rarF->getEntries();
reset($t)->extract(false, $fn2);
$rarF2 = RarArchive::open($fn2);
$t = $rarF2->getEntries();
var_dump($t[0]->getUnpackedSize());
var_dump($t[1]->getUnpackedSize());
echo "Done.\n";
--CLEAN--
<?php
$fn2 = dirname(__FILE__) . '/sparsefiles.tmp.rar';
@unlink($fn2);
--EXPECTF--
int(2147483647)
int(2147483647)
Done.
26 changes: 26 additions & 0 deletions tests/041.phpt
@@ -0,0 +1,26 @@
--TEST--
RarEntry::getUnpackedSize() on platforms with 64-bit longs
--SKIPIF--
<?php
if(!extension_loaded("rar")) die("skip");
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
--FILE--
<?php
$fn1 = dirname(__FILE__) . '/sparsefiles_rar.rar';
$fn2 = dirname(__FILE__) . '/sparsefiles.tmp.rar';
$rarF = RarArchive::open($fn1);
$t = $rarF->getEntries();
reset($t)->extract(false, $fn2);
$rarF2 = RarArchive::open($fn2);
$t = $rarF2->getEntries();
var_dump($t[0]->getUnpackedSize());
var_dump($t[1]->getUnpackedSize());
echo "Done.\n";
--CLEAN--
<?php
$fn2 = dirname(__FILE__) . '/sparsefiles.tmp.rar';
@unlink($fn2);
--EXPECTF--
int(2621440000)
int(5368709120)
Done.
Binary file added tests/sparsefiles_rar.rar
Binary file not shown.

0 comments on commit 3c8d037

Please sign in to comment.