Bug #69291 [Asn]: SPL directory tests fail under some conditions

From: Date: Fri, 03 Apr 2015 19:45:07 +0000
Subject: Bug #69291 [Asn]: SPL directory tests fail under some conditions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191808@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69291&edit=1

 ID:                 69291
 Updated by:         tyrael@php.net
 Reported by:        danack@php.net
 Summary:            SPL directory tests fail under some conditions
 Status:             Assigned
 Type:               Bug
 Package:            SPL related
 Operating System:   Centos
 PHP Version:        5.5.23
 Assigned To:        danack
 Block user comment: N
 Private report:     N

 New Comment:

I've deleted the link to the wrong PR.


Previous Comments:
------------------------------------------------------------------------
[2015-04-02 14:47:40] danack@php.net

Okay - I understand what is happening, but can't tell what the 'correct' behaviour
should be.

The code is assuming that DirectoryIterator will return objects alphabetically. It isn't doing
so. Instead the file entries are listed alphabetically within 'blocks', but the blocks are
ordered in reverse.

i.e. the first entry in the cloned iterator is SplObjectStorage_getHash.phpt, while the first entry
in the original iterator is array_001.phpt


The full output is https://gist.github.com/Danack/e9c7ca12958cdd180197.


TL:DR the test assumes that DirectoryIterator always returns values in the same alphabetical order,
it doesn't. And so the test fails sometimes.

------------------------------------------------------------------------
[2015-03-27 18:23:40] danack@php.net

Whoop - I added the PR to the wrong issue. The PR is for something else entirely, but apparently
there is no way to delete it.

------------------------------------------------------------------------
[2015-03-24 19:25:29] danack@php.net

Description:
------------
The tests ext/spl/tests/dit_004.phpt and ext/spl/tests/dit_005.phpt fail on Centos running in a
VirtualBox VM, but only under certain conditions:

* when they are run through "php run-tests.php ext/spl/tests/dit_004.phpt" - both of them
fail.

* dit_004 fails when run as "valgrind -q --tool=memcheck /usr/bin/php
ext/spl/tests/dit_004.php". dit_005.phpt doesn't fail and works fine.

Both of the tests run as expected when you just run the underlying PHP code that they are calling.

The behaviour is as if the cloned object is jumping to a random entry in the DirectoryIterator

Test script:
---------------
<?php
$a = new DirectoryIterator(__DIR__);
$b = clone $a;

$bValue = (string)$b;
$aValue = (string)$a;
if ($aValue != $bValue) {
	echo "aValue and bValue should be the same".PHP_EOL;
	echo $aValue.PHP_EOL;
	echo $bValue.PHP_EOL;
}
else {
    echo "Ok";
}


Expected result:
----------------
Ok

Actual result:
--------------
aValue and bValue should be the same
.
SplObjectStorage_offsetGet_invalid_parameter.phpt


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69291&edit=1


Thread (7 messages)

« previous php.bugs (#191808) next »