Edit report at https://bugs.php.net/bug.php?id=64060&edit=1
ID: 64060
Updated by: [email protected]
Reported by: m dot voelker at gmail dot com
Summary: Test lstat_stat_variation7 incorrectly fails on
certain file systems
-Status: Open
+Status: Closed
Type: Bug
Package: Testing related
Operating System: Linux
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=54435c9b43fb568590b223a24dcf582f1292a5d8
Log: Fix #64060: lstat_stat_variation7.phpt fails on certain file systems
Previous Comments:
------------------------------------------------------------------------
[2020-09-23 13:36:42] [email protected]
The following pull request has been associated:
Patch Name: Fix #64060: Test lstat_stat_variation7 incorrectly fails on certain f…
On GitHub: https://github.com/php/php-src/pull/6194
Patch: https://github.com/php/php-src/pull/6194.patch
------------------------------------------------------------------------
[2013-01-23 23:13:07] m dot voelker at gmail dot com
Description:
------------
This applies to PHP 5.4.11 as well as 5.3.21.
Test ext/standard/tests/file/lstat_stat_variation7.phpt may incorrectly fail on delayed allocation file systems (in this case XFS on Linux).
Problem:
http://php.net/manual/en/function.stat.php
field 12 is "number of 512-byte blocks allocated"
The test does not fclose() the test file after writing to it, therefore zero 512-byte blocks are allocated even though the file size is 45056 bytes.
Fix:
Change lstat_stat_variation7.phpt from
// writing to an empty file
echo "*** Testing stat() on file after data is written in it ***\n";
$fh = fopen($file_name,"w");
$old_stat = stat($file_name);
clearstatcache();
fwrite($fh, str_repeat((binary)"Hello World", $old_stat['blksize']));
$new_stat = stat($file_name);
to
// writing to an empty file
echo "*** Testing stat() on file after data is written in it ***\n";
$fh = fopen($file_name,"w");
$old_stat = stat($file_name);
clearstatcache();
fwrite($fh, str_repeat((binary)"Hello World", $old_stat['blksize']));
fclose($fh);
$new_stat = stat($file_name);
and the test succeeds.
Test script:
---------------
File: ext/standard/tests/file/lstat_stat_variation7.php
To confirm, modify $file_name = "$file_path/lstat_stat_variation7.tmp"; to use a different file system and run ext/standard/tests/file/lstat_stat_variation7.sh.
Expected result:
----------------
Build of PHP 5.4.11
Test executed on ext2:
*** Testing stat() on file after data is written in it ***
bool(true)
bool(true)
bool(true)
--- Done ---
Actual result:
--------------
Same test executed on XFS:
*** Testing stat() on file after data is written in it ***
bool(true)
bool(true)
Error: stat1 is not lesser than stat2 at key value: 12
Error: stat1 is not lesser than stat2 at key value: blocks
Dumping stat array 1...
...
["size"]=>
int(0)
...
["blocks"]=>
int(0)
Dumping stat array 2...
...
["size"]=>
int(45056)
...
["blocks"]=>
int(0)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64060&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.