--- /dev/null
+--TEST--
+Test fileatime(),filemtime(),filectime() & touch() functions : basic functionality
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+echo "*** Testing the basic functionality with file ***\n";
+print( @date('Y:M:D:H:i:s', fileatime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', filemtime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', filectime(__FILE__)) )."\n";
+print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic.tmp")) )."\n";
+
+echo "*** Testing the basic functionality with dir ***\n";
+print( @date('Y:M:D:H:i:s', fileatime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', filemtime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', filectime(".")) )."\n";
+print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic")) )."\n";
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/005_basic.tmp");
+unlink(dirname(__FILE__)."/005_basic");
+?>
+--EXPECTF--
+*** Testing the basic functionality with file ***
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+*** Testing the basic functionality with dir ***
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+%d:%s:%s:%d:%d:%d
+
+*** Done ***
--- /dev/null
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions: error conditions
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+echo "*** Testing error conditions ***\n";
+
+echo "\n-- Testing with Non-existing files --";
+/* Both invalid argumetns */
+var_dump( fileatime("/no/such/file/or/dir") );
+var_dump( filemtime("/no/such/file/or/dir") );
+var_dump( filectime("/no/such/file/or/dir") );
+var_dump( touch("/no/such/file/or/dir", 10) );
+
+/* Only one invalid argument */
+var_dump( fileatime(__FILE__, "string") );
+var_dump( filemtime(__FILE__, 100) );
+var_dump( filectime(__FILE__, TRUE) );
+var_dump( touch(__FILE__, 10, 100, 123) );
+
+echo "\n-- Testing No.of arguments less than expected --";
+var_dump( fileatime() );
+var_dump( filemtime() );
+var_dump( filectime() );
+var_dump( touch() );
+
+echo "\n-- Testing No.of arguments greater than expected --";
+/* Both invalid arguments */
+var_dump( fileatime("/no/such/file/or/dir", "string") );
+var_dump( filemtime("/no/such/file/or/dir", 100) );
+var_dump( filectime("/no/such/file/or/dir", TRUE) );
+var_dump( touch("/no/such/file/or/dir", 10, 100, 123) );
+
+/* Only one invalid argument */
+var_dump( fileatime(__FILE__, "string") );
+var_dump( filemtime(__FILE__, 100) );
+var_dump( filectime(__FILE__, TRUE) );
+var_dump( touch(__FILE__, 10, 100, 123) );
+
+echo "\n*** Done ***\n";
+?>
+--EXPECTF--
+*** Testing error conditions ***
+
+-- Testing with Non-existing files --
+Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filemtime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d
+bool(false)
+
+Warning: touch(): Unable to create file /no/such/file/or/dir because No such file or directory in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for fileatime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filemtime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filectime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for touch() in %s on line %d
+NULL
+
+-- Testing No.of arguments less than expected --
+Warning: Wrong parameter count for fileatime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filemtime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filectime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for touch() in %s on line %d
+NULL
+
+-- Testing No.of arguments greater than expected --
+Warning: Wrong parameter count for fileatime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filemtime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filectime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for touch() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fileatime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filemtime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for filectime() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for touch() in %s on line %d
+NULL
+
+*** Done ***
--- /dev/null
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Do not run on Linux');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "-- File access time is => ";
+ print( @date( 'Y:M:D:H:i:s', fileatime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ print( @date( 'Y:M:D:H:i:s', filemtime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n";
+ clearstatcache();
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+$file_path = dirname(__FILE__);
+// create files
+$file_handle = fopen("$file_path/005_variation1.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation1.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation2.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation2.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation3.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation3.tmp");
+
+// delete files
+unlink("$file_path/005_variation1.tmp");
+unlink("$file_path/005_variation2.tmp");
+unlink("$file_path/005_variation3.tmp");
+
+echo "\n-- Checking different times, just after creating the file --\n";
+$file_name = "$file_path/005_variation1.tmp";
+$file_write_handle = fopen($file_name, "w");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after changing the file permission --\n";
+chmod($file_name, 0777);
+stat_fn($file_name);
+sleep(2);
+
+/* filemtime + 2 & filectime + 2 */
+echo "\n-- Checking different times, after writing into the file --\n";
+$file_write_handle = fopen($file_name, "w");
+fwrite($file_write_handle, b"Hello, world");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after reading from the file --\n";
+$file_read_handle = fopen($file_name ,"r");
+fread($file_read_handle, 10);
+fclose( $file_read_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after making a copy of the file --\n";
+$file_copy = "$file_path/005_variation_copy.tmp";
+copy($file_name, $file_copy);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after performing is_file() operation on the file --\n";
+is_file($file_name);
+stat_fn($file_name);
+sleep(2);
+
+
+echo "\n*** Testing touch() function with different time values ***\n";
+$file_name2 = $file_path."/005_variation_touch.tmp";
+$file_handle = fopen($file_name2, "w");
+fclose($file_handle);
+sleep(2);
+
+/* Time is not mentioned */
+var_dump( touch($file_name2) ); //set to current system time
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access(creation time of the file) time */
+var_dump( touch($file_name2, @date(fileatime($file_name2))) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access time of $file_name2 */
+var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to default value, with Invalid timestamps */
+var_dump( touch($file_name2, 10) );
+stat_fn($file_name2);
+var_dump( touch($file_name2, 10, 20) );
+stat_fn($file_name2);
+
+/* touch() after renaming the file */
+rename($file_name2, "$file_path/005_variation_touch_new.tmp");
+stat_fn("$file_path/005_variation_touch_new.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/005_variation_softlink.tmp");
+unlink($file_path."/005_variation_hardlink.tmp");
+unlink($file_path."/005_variation1.tmp");
+unlink($file_path."/005_variation_copy.tmp");
+unlink($file_path."/005_variation_touch.tmp");
+unlink($file_path."/005_variation_touch_fly.tmp");
+unlink($file_path."/005_variation_touch_new.tmp");
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, just after creating the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after changing the file permission --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after writing into the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after reading from the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after making a copy of the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after performing is_file() operation on the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+*** Testing touch() function with different time values ***
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+Done
--- /dev/null
+--TEST--
+Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Do not run on Windows');
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileatime ( string $filename );
+ Description: Returns the time the file was last accessed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: int filemtime ( string $filename );
+ Description: Returns the time the file was last modified, or FALSE
+ in case of an error.
+
+ Prototype: int filectime ( string $filename );
+ Description: Returns the time the file was last changed, or FALSE
+ in case of an error. The time is returned as a Unix timestamp.
+
+ Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
+ Description: Attempts to set the access and modification times of the file
+ named in the filename parameter to the value given in time.
+*/
+
+/*
+ Prototype: void stat_fn(string $filename);
+ Description: Prints access, modification and change times of a file
+*/
+function stat_fn( $filename ) {
+ echo "-- File access time is => ";
+ print( @date( 'Y:M:D:H:i:s', fileatime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- File modification time is => ";
+ print( @date( 'Y:M:D:H:i:s', filemtime($filename) ) )."\n";
+ clearstatcache();
+ echo "-- inode change time is => ";
+ print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n";
+ clearstatcache();
+
+}
+
+echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
+$file_path = dirname(__FILE__);
+// create files
+$file_handle = fopen("$file_path/005_variation1.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation1.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation2.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation2.tmp");
+sleep(2);
+
+$file_handle = fopen("$file_path/005_variation3.tmp", "w");
+fclose($file_handle);
+stat_fn("$file_path/005_variation3.tmp");
+
+// delete files
+unlink("$file_path/005_variation1.tmp");
+unlink("$file_path/005_variation2.tmp");
+unlink("$file_path/005_variation3.tmp");
+
+echo "\n-- Checking different times, just after creating the file --\n";
+$file_name = "$file_path/005_variation1.tmp";
+$file_write_handle = fopen($file_name, "w");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after changing the file permission --\n";
+chmod($file_name, 0777);
+stat_fn($file_name);
+sleep(2);
+
+/* filemtime + 2 & filectime + 2 */
+echo "\n-- Checking different times, after writing into the file --\n";
+$file_write_handle = fopen($file_name, "w");
+fwrite($file_write_handle, "Hello, world");
+fclose($file_write_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after reading from the file --\n";
+$file_read_handle = fopen($file_name ,"r");
+fread($file_read_handle, 10);
+fclose( $file_read_handle);
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after creating a softlink to the file --\n";
+symlink($file_name, "$file_path/005_variation_softlink.tmp");
+stat_fn($file_name);
+sleep(2);
+
+/* filectime + 2 */
+echo "\n-- Checking different times, after creating a hardlink to the file --\n";
+link($file_name, "$file_path/005_variation_hardlink.tmp");
+stat_fn($file_name);
+sleep(2);
+
+/* No change */
+echo "\n-- Checking different times, after making a copy of the file --\n";
+$file_copy = "$file_path/005_variation_copy.tmp";
+copy($file_name, $file_copy);
+stat_fn($file_name);
+sleep(2);
+
+/* fileatime + 2 */
+echo "\n-- Checking different times, after performing is_file() operation on the file --\n";
+is_file($file_name);
+stat_fn($file_name);
+sleep(2);
+
+
+echo "\n*** Testing touch() function with different time values ***\n";
+$file_name2 = $file_path."/005_variation_touch.tmp";
+$file_handle = fopen($file_name2, "w");
+fclose($file_handle);
+sleep(2);
+
+/* Time is not mentioned */
+var_dump( touch($file_name2) ); //set to current system time
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access(creation time of the file) time */
+var_dump( touch($file_name2, @date(fileatime($file_name2))) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to access time of $file_name2 */
+var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) );
+stat_fn($file_name2);
+sleep(2);
+
+/* set to default value, with Invalid timestamps */
+var_dump( touch($file_name2, 10) );
+stat_fn($file_name2);
+var_dump( touch($file_name2, 10, 20) );
+stat_fn($file_name2);
+
+/* touch() after renaming the file */
+rename($file_name2, "$file_path/005_variation_touch_new.tmp");
+stat_fn("$file_path/005_variation_touch_new.tmp");
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/005_variation_softlink.tmp");
+unlink($file_path."/005_variation_hardlink.tmp");
+unlink($file_path."/005_variation1.tmp");
+unlink($file_path."/005_variation_copy.tmp");
+unlink($file_path."/005_variation_touch.tmp");
+unlink($file_path."/005_variation_touch_fly.tmp");
+unlink($file_path."/005_variation_touch_new.tmp");
+?>
+--EXPECTF--
+*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, just after creating the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after changing the file permission --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after writing into the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after reading from the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after creating a softlink to the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after creating a hardlink to the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after making a copy of the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+-- Checking different times, after performing is_file() operation on the file --
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+
+*** Testing touch() function with different time values ***
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+bool(true)
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+-- File access time is => %d:%s:%s:%d:%d:%d
+-- File modification time is => %d:%s:%s:%d:%d:%d
+-- inode change time is => %d:%s:%s:%d:%d:%d
+Done
--- /dev/null
+--TEST--
+Test fileperms() & chmod() functions: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+elseif (get_current_user() == 'root') {
+ die( "skip Do not run with root permissions" );
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename );
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode );
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+$path = dirname(__FILE__);
+
+echo "*** Testing fileperms(), chmod() with files and dirs ***\n";
+fopen($path."/perm.tmp", "w");
+var_dump( chmod($path."/perm.tmp", 0755 ) );
+printf("%o", fileperms($path."/perm.tmp") );
+echo "\n";
+clearstatcache();
+
+mkdir($path."/perm");
+var_dump( chmod( $path."/perm", 0777 ) );
+printf("%o", fileperms($path."/perm") );
+echo "\n";
+clearstatcache();
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/perm.tmp");
+rmdir(dirname(__FILE__)."/perm");
+?>
+--EXPECTF--
+*** Testing fileperms(), chmod() with files and dirs ***
+bool(true)
+100755
+bool(true)
+40777
+Done
--- /dev/null
+--TEST--
+Test fileperms(), chmod() functions: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+elseif (get_current_user() == 'root') {
+ die( "skip Do not run with root permissions" );
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename )
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode )
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+
+echo "*** Testing error conditions for fileperms(), chmod() ***\n";
+
+/* With standard files and dirs */
+var_dump( chmod("/etc/passwd", 0777) );
+printf("%o", fileperms("/etc/passwd") );
+echo "\n";
+clearstatcache();
+
+var_dump( chmod("/etc", 0777) );
+printf("%o", fileperms("/etc") );
+echo "\n";
+clearstatcache();
+
+/* With non-existing file or dir */
+var_dump( chmod("/no/such/file/dir", 0777) );
+var_dump( fileperms("/no/such/file/dir") );
+echo "\n";
+
+/* With args less than expected */
+$fp = fopen(dirname(__FILE__)."/006_error.tmp", "w");
+fclose($fp);
+var_dump( chmod(dirname(__FILE__)."/006_error.tmp") );
+var_dump( chmod("nofile") );
+var_dump( chmod() );
+var_dump( fileperms() );
+
+/* With args greater than expected */
+var_dump( chmod(dirname(__FILE__)."/006_error.tmp", 0755, TRUE) );
+var_dump( fileperms(dirname(__FILE__)."/006_error.tmp", 0777) );
+var_dump( fileperms("nofile", 0777) );
+
+echo "\n*** Done ***\n";
+?>
+--CLEAN--
+<?php
+unlink( dirname(__FILE__)."/006_error.tmp");
+?>
+--EXPECTF--
+*** Testing error conditions for fileperms(), chmod() ***
+
+Warning: chmod(): Operation not permitted in %s on line %d
+bool(false)
+100644
+
+Warning: chmod(): Operation not permitted in %s on line %d
+bool(false)
+40755
+
+Warning: chmod(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: fileperms(): stat failed for /no/such/file/dir in %s on line %d
+bool(false)
+
+
+Warning: Wrong parameter count for chmod() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for chmod() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for chmod() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fileperms() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for chmod() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fileperms() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for fileperms() in %s on line %d
+NULL
+
+*** Done ***
--- /dev/null
+--TEST--
+Test fileperms() & chmod() functions: usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip Not on Windows');
+}
+elseif (get_current_user() == 'root') {
+ die( "skip Do not run with root permissions" );
+}
+?>
+--FILE--
+<?php
+/*
+ Prototype: int fileperms ( string $filename );
+ Description: Returns the permissions on the file, or FALSE in case of an error
+
+ Prototype: bool chmod ( string $filename, int $mode );
+ Description: Attempts to change the mode of the file specified by
+ filename to that given in mode
+*/
+
+echo "*** Testing fileperms() & chmod() : usage variations ***\n";
+
+$file_name = dirname(__FILE__)."/006_variation.tmp";
+$file_handle = fopen($file_name, "w");
+fclose($file_handle);
+$dir_name = dirname(__FILE__)."/006_variation";
+mkdir($dir_name);
+
+$count = 1;
+echo "-- Testing all permission from octal 0000 to octal 0777 on file and dir --\n";
+for($mode = 0000; $mode <= 0777; $mode++) {
+ echo "-- Iteration $count --\n";
+ var_dump( chmod($file_name, $mode) );
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+ clearstatcache();
+
+ var_dump( chmod($dir_name, $mode) );
+ printf("%o", fileperms($dir_name) );
+ echo "\n";
+ clearstatcache();
+ $count++;
+}
+
+echo "\n*** Testing fileperms(), chmod() with miscellaneous permissions ***\n";
+$perms_array = array(
+ /* testing sticky bit */
+ 07777,
+ 00000,
+ 01000,
+ 011111,
+ /* negative values as permission */
+ -0777, // permissions will be given as 2's complement form of -0777
+ -07777, // permissions will be given as 2's complement form of -07777
+
+ /* decimal values as permission */
+ 777, // permissions will be given as octal equivalent value of 777
+ 7777, // permissions will be given as octal equivalent value of 7777
+ -7777, // permissions are given as 2's complement of octal equivalent of 7777
+
+ /* hex value as permission */
+ 0x777, // permissions will be given as ocatal equivalent value of 0x777
+ 0x7777,
+
+ /* strings notation of permission, wont work properly */
+ "r+w",
+ "r+w+x",
+ "u+rwx",
+ "u+rwx, g+rw, o+wx"
+);
+
+$count = 1;
+foreach($perms_array as $permission) {
+ echo "-- Iteration $count --\n";
+ var_dump( chmod($file_name, $permission) );
+ printf("%o", fileperms($file_name) );
+ echo "\n";
+ clearstatcache();
+
+ var_dump( chmod($dir_name, $permission) );
+ printf("%o", fileperms($dir_name) );
+ echo "\n";
+ clearstatcache();
+ $count++;
+}
+echo "*** Done ***\n";
+?>
+--CLEAN--
+<?php
+unlink(dirname(__FILE__)."/006_variation.tmp");
+rmdir(dirname(__FILE__)."/006_variation");
+?>
+--EXPECTF--
+*** Testing fileperms() & chmod() : usage variations ***
+-- Testing all permission from octal 0000 to octal 0777 on file and dir --
+-- Iteration 1 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 2 --
+bool(true)
+100001
+bool(true)
+40001
+-- Iteration 3 --
+bool(true)
+100002
+bool(true)
+40002
+-- Iteration 4 --
+bool(true)
+100003
+bool(true)
+40003
+-- Iteration 5 --
+bool(true)
+100004
+bool(true)
+40004
+-- Iteration 6 --
+bool(true)
+100005
+bool(true)
+40005
+-- Iteration 7 --
+bool(true)
+100006
+bool(true)
+40006
+-- Iteration 8 --
+bool(true)
+100007
+bool(true)
+40007
+-- Iteration 9 --
+bool(true)
+100010
+bool(true)
+40010
+-- Iteration 10 --
+bool(true)
+100011
+bool(true)
+40011
+-- Iteration 11 --
+bool(true)
+100012
+bool(true)
+40012
+-- Iteration 12 --
+bool(true)
+100013
+bool(true)
+40013
+-- Iteration 13 --
+bool(true)
+100014
+bool(true)
+40014
+-- Iteration 14 --
+bool(true)
+100015
+bool(true)
+40015
+-- Iteration 15 --
+bool(true)
+100016
+bool(true)
+40016
+-- Iteration 16 --
+bool(true)
+100017
+bool(true)
+40017
+-- Iteration 17 --
+bool(true)
+100020
+bool(true)
+40020
+-- Iteration 18 --
+bool(true)
+100021
+bool(true)
+40021
+-- Iteration 19 --
+bool(true)
+100022
+bool(true)
+40022
+-- Iteration 20 --
+bool(true)
+100023
+bool(true)
+40023
+-- Iteration 21 --
+bool(true)
+100024
+bool(true)
+40024
+-- Iteration 22 --
+bool(true)
+100025
+bool(true)
+40025
+-- Iteration 23 --
+bool(true)
+100026
+bool(true)
+40026
+-- Iteration 24 --
+bool(true)
+100027
+bool(true)
+40027
+-- Iteration 25 --
+bool(true)
+100030
+bool(true)
+40030
+-- Iteration 26 --
+bool(true)
+100031
+bool(true)
+40031
+-- Iteration 27 --
+bool(true)
+100032
+bool(true)
+40032
+-- Iteration 28 --
+bool(true)
+100033
+bool(true)
+40033
+-- Iteration 29 --
+bool(true)
+100034
+bool(true)
+40034
+-- Iteration 30 --
+bool(true)
+100035
+bool(true)
+40035
+-- Iteration 31 --
+bool(true)
+100036
+bool(true)
+40036
+-- Iteration 32 --
+bool(true)
+100037
+bool(true)
+40037
+-- Iteration 33 --
+bool(true)
+100040
+bool(true)
+40040
+-- Iteration 34 --
+bool(true)
+100041
+bool(true)
+40041
+-- Iteration 35 --
+bool(true)
+100042
+bool(true)
+40042
+-- Iteration 36 --
+bool(true)
+100043
+bool(true)
+40043
+-- Iteration 37 --
+bool(true)
+100044
+bool(true)
+40044
+-- Iteration 38 --
+bool(true)
+100045
+bool(true)
+40045
+-- Iteration 39 --
+bool(true)
+100046
+bool(true)
+40046
+-- Iteration 40 --
+bool(true)
+100047
+bool(true)
+40047
+-- Iteration 41 --
+bool(true)
+100050
+bool(true)
+40050
+-- Iteration 42 --
+bool(true)
+100051
+bool(true)
+40051
+-- Iteration 43 --
+bool(true)
+100052
+bool(true)
+40052
+-- Iteration 44 --
+bool(true)
+100053
+bool(true)
+40053
+-- Iteration 45 --
+bool(true)
+100054
+bool(true)
+40054
+-- Iteration 46 --
+bool(true)
+100055
+bool(true)
+40055
+-- Iteration 47 --
+bool(true)
+100056
+bool(true)
+40056
+-- Iteration 48 --
+bool(true)
+100057
+bool(true)
+40057
+-- Iteration 49 --
+bool(true)
+100060
+bool(true)
+40060
+-- Iteration 50 --
+bool(true)
+100061
+bool(true)
+40061
+-- Iteration 51 --
+bool(true)
+100062
+bool(true)
+40062
+-- Iteration 52 --
+bool(true)
+100063
+bool(true)
+40063
+-- Iteration 53 --
+bool(true)
+100064
+bool(true)
+40064
+-- Iteration 54 --
+bool(true)
+100065
+bool(true)
+40065
+-- Iteration 55 --
+bool(true)
+100066
+bool(true)
+40066
+-- Iteration 56 --
+bool(true)
+100067
+bool(true)
+40067
+-- Iteration 57 --
+bool(true)
+100070
+bool(true)
+40070
+-- Iteration 58 --
+bool(true)
+100071
+bool(true)
+40071
+-- Iteration 59 --
+bool(true)
+100072
+bool(true)
+40072
+-- Iteration 60 --
+bool(true)
+100073
+bool(true)
+40073
+-- Iteration 61 --
+bool(true)
+100074
+bool(true)
+40074
+-- Iteration 62 --
+bool(true)
+100075
+bool(true)
+40075
+-- Iteration 63 --
+bool(true)
+100076
+bool(true)
+40076
+-- Iteration 64 --
+bool(true)
+100077
+bool(true)
+40077
+-- Iteration 65 --
+bool(true)
+100100
+bool(true)
+40100
+-- Iteration 66 --
+bool(true)
+100101
+bool(true)
+40101
+-- Iteration 67 --
+bool(true)
+100102
+bool(true)
+40102
+-- Iteration 68 --
+bool(true)
+100103
+bool(true)
+40103
+-- Iteration 69 --
+bool(true)
+100104
+bool(true)
+40104
+-- Iteration 70 --
+bool(true)
+100105
+bool(true)
+40105
+-- Iteration 71 --
+bool(true)
+100106
+bool(true)
+40106
+-- Iteration 72 --
+bool(true)
+100107
+bool(true)
+40107
+-- Iteration 73 --
+bool(true)
+100110
+bool(true)
+40110
+-- Iteration 74 --
+bool(true)
+100111
+bool(true)
+40111
+-- Iteration 75 --
+bool(true)
+100112
+bool(true)
+40112
+-- Iteration 76 --
+bool(true)
+100113
+bool(true)
+40113
+-- Iteration 77 --
+bool(true)
+100114
+bool(true)
+40114
+-- Iteration 78 --
+bool(true)
+100115
+bool(true)
+40115
+-- Iteration 79 --
+bool(true)
+100116
+bool(true)
+40116
+-- Iteration 80 --
+bool(true)
+100117
+bool(true)
+40117
+-- Iteration 81 --
+bool(true)
+100120
+bool(true)
+40120
+-- Iteration 82 --
+bool(true)
+100121
+bool(true)
+40121
+-- Iteration 83 --
+bool(true)
+100122
+bool(true)
+40122
+-- Iteration 84 --
+bool(true)
+100123
+bool(true)
+40123
+-- Iteration 85 --
+bool(true)
+100124
+bool(true)
+40124
+-- Iteration 86 --
+bool(true)
+100125
+bool(true)
+40125
+-- Iteration 87 --
+bool(true)
+100126
+bool(true)
+40126
+-- Iteration 88 --
+bool(true)
+100127
+bool(true)
+40127
+-- Iteration 89 --
+bool(true)
+100130
+bool(true)
+40130
+-- Iteration 90 --
+bool(true)
+100131
+bool(true)
+40131
+-- Iteration 91 --
+bool(true)
+100132
+bool(true)
+40132
+-- Iteration 92 --
+bool(true)
+100133
+bool(true)
+40133
+-- Iteration 93 --
+bool(true)
+100134
+bool(true)
+40134
+-- Iteration 94 --
+bool(true)
+100135
+bool(true)
+40135
+-- Iteration 95 --
+bool(true)
+100136
+bool(true)
+40136
+-- Iteration 96 --
+bool(true)
+100137
+bool(true)
+40137
+-- Iteration 97 --
+bool(true)
+100140
+bool(true)
+40140
+-- Iteration 98 --
+bool(true)
+100141
+bool(true)
+40141
+-- Iteration 99 --
+bool(true)
+100142
+bool(true)
+40142
+-- Iteration 100 --
+bool(true)
+100143
+bool(true)
+40143
+-- Iteration 101 --
+bool(true)
+100144
+bool(true)
+40144
+-- Iteration 102 --
+bool(true)
+100145
+bool(true)
+40145
+-- Iteration 103 --
+bool(true)
+100146
+bool(true)
+40146
+-- Iteration 104 --
+bool(true)
+100147
+bool(true)
+40147
+-- Iteration 105 --
+bool(true)
+100150
+bool(true)
+40150
+-- Iteration 106 --
+bool(true)
+100151
+bool(true)
+40151
+-- Iteration 107 --
+bool(true)
+100152
+bool(true)
+40152
+-- Iteration 108 --
+bool(true)
+100153
+bool(true)
+40153
+-- Iteration 109 --
+bool(true)
+100154
+bool(true)
+40154
+-- Iteration 110 --
+bool(true)
+100155
+bool(true)
+40155
+-- Iteration 111 --
+bool(true)
+100156
+bool(true)
+40156
+-- Iteration 112 --
+bool(true)
+100157
+bool(true)
+40157
+-- Iteration 113 --
+bool(true)
+100160
+bool(true)
+40160
+-- Iteration 114 --
+bool(true)
+100161
+bool(true)
+40161
+-- Iteration 115 --
+bool(true)
+100162
+bool(true)
+40162
+-- Iteration 116 --
+bool(true)
+100163
+bool(true)
+40163
+-- Iteration 117 --
+bool(true)
+100164
+bool(true)
+40164
+-- Iteration 118 --
+bool(true)
+100165
+bool(true)
+40165
+-- Iteration 119 --
+bool(true)
+100166
+bool(true)
+40166
+-- Iteration 120 --
+bool(true)
+100167
+bool(true)
+40167
+-- Iteration 121 --
+bool(true)
+100170
+bool(true)
+40170
+-- Iteration 122 --
+bool(true)
+100171
+bool(true)
+40171
+-- Iteration 123 --
+bool(true)
+100172
+bool(true)
+40172
+-- Iteration 124 --
+bool(true)
+100173
+bool(true)
+40173
+-- Iteration 125 --
+bool(true)
+100174
+bool(true)
+40174
+-- Iteration 126 --
+bool(true)
+100175
+bool(true)
+40175
+-- Iteration 127 --
+bool(true)
+100176
+bool(true)
+40176
+-- Iteration 128 --
+bool(true)
+100177
+bool(true)
+40177
+-- Iteration 129 --
+bool(true)
+100200
+bool(true)
+40200
+-- Iteration 130 --
+bool(true)
+100201
+bool(true)
+40201
+-- Iteration 131 --
+bool(true)
+100202
+bool(true)
+40202
+-- Iteration 132 --
+bool(true)
+100203
+bool(true)
+40203
+-- Iteration 133 --
+bool(true)
+100204
+bool(true)
+40204
+-- Iteration 134 --
+bool(true)
+100205
+bool(true)
+40205
+-- Iteration 135 --
+bool(true)
+100206
+bool(true)
+40206
+-- Iteration 136 --
+bool(true)
+100207
+bool(true)
+40207
+-- Iteration 137 --
+bool(true)
+100210
+bool(true)
+40210
+-- Iteration 138 --
+bool(true)
+100211
+bool(true)
+40211
+-- Iteration 139 --
+bool(true)
+100212
+bool(true)
+40212
+-- Iteration 140 --
+bool(true)
+100213
+bool(true)
+40213
+-- Iteration 141 --
+bool(true)
+100214
+bool(true)
+40214
+-- Iteration 142 --
+bool(true)
+100215
+bool(true)
+40215
+-- Iteration 143 --
+bool(true)
+100216
+bool(true)
+40216
+-- Iteration 144 --
+bool(true)
+100217
+bool(true)
+40217
+-- Iteration 145 --
+bool(true)
+100220
+bool(true)
+40220
+-- Iteration 146 --
+bool(true)
+100221
+bool(true)
+40221
+-- Iteration 147 --
+bool(true)
+100222
+bool(true)
+40222
+-- Iteration 148 --
+bool(true)
+100223
+bool(true)
+40223
+-- Iteration 149 --
+bool(true)
+100224
+bool(true)
+40224
+-- Iteration 150 --
+bool(true)
+100225
+bool(true)
+40225
+-- Iteration 151 --
+bool(true)
+100226
+bool(true)
+40226
+-- Iteration 152 --
+bool(true)
+100227
+bool(true)
+40227
+-- Iteration 153 --
+bool(true)
+100230
+bool(true)
+40230
+-- Iteration 154 --
+bool(true)
+100231
+bool(true)
+40231
+-- Iteration 155 --
+bool(true)
+100232
+bool(true)
+40232
+-- Iteration 156 --
+bool(true)
+100233
+bool(true)
+40233
+-- Iteration 157 --
+bool(true)
+100234
+bool(true)
+40234
+-- Iteration 158 --
+bool(true)
+100235
+bool(true)
+40235
+-- Iteration 159 --
+bool(true)
+100236
+bool(true)
+40236
+-- Iteration 160 --
+bool(true)
+100237
+bool(true)
+40237
+-- Iteration 161 --
+bool(true)
+100240
+bool(true)
+40240
+-- Iteration 162 --
+bool(true)
+100241
+bool(true)
+40241
+-- Iteration 163 --
+bool(true)
+100242
+bool(true)
+40242
+-- Iteration 164 --
+bool(true)
+100243
+bool(true)
+40243
+-- Iteration 165 --
+bool(true)
+100244
+bool(true)
+40244
+-- Iteration 166 --
+bool(true)
+100245
+bool(true)
+40245
+-- Iteration 167 --
+bool(true)
+100246
+bool(true)
+40246
+-- Iteration 168 --
+bool(true)
+100247
+bool(true)
+40247
+-- Iteration 169 --
+bool(true)
+100250
+bool(true)
+40250
+-- Iteration 170 --
+bool(true)
+100251
+bool(true)
+40251
+-- Iteration 171 --
+bool(true)
+100252
+bool(true)
+40252
+-- Iteration 172 --
+bool(true)
+100253
+bool(true)
+40253
+-- Iteration 173 --
+bool(true)
+100254
+bool(true)
+40254
+-- Iteration 174 --
+bool(true)
+100255
+bool(true)
+40255
+-- Iteration 175 --
+bool(true)
+100256
+bool(true)
+40256
+-- Iteration 176 --
+bool(true)
+100257
+bool(true)
+40257
+-- Iteration 177 --
+bool(true)
+100260
+bool(true)
+40260
+-- Iteration 178 --
+bool(true)
+100261
+bool(true)
+40261
+-- Iteration 179 --
+bool(true)
+100262
+bool(true)
+40262
+-- Iteration 180 --
+bool(true)
+100263
+bool(true)
+40263
+-- Iteration 181 --
+bool(true)
+100264
+bool(true)
+40264
+-- Iteration 182 --
+bool(true)
+100265
+bool(true)
+40265
+-- Iteration 183 --
+bool(true)
+100266
+bool(true)
+40266
+-- Iteration 184 --
+bool(true)
+100267
+bool(true)
+40267
+-- Iteration 185 --
+bool(true)
+100270
+bool(true)
+40270
+-- Iteration 186 --
+bool(true)
+100271
+bool(true)
+40271
+-- Iteration 187 --
+bool(true)
+100272
+bool(true)
+40272
+-- Iteration 188 --
+bool(true)
+100273
+bool(true)
+40273
+-- Iteration 189 --
+bool(true)
+100274
+bool(true)
+40274
+-- Iteration 190 --
+bool(true)
+100275
+bool(true)
+40275
+-- Iteration 191 --
+bool(true)
+100276
+bool(true)
+40276
+-- Iteration 192 --
+bool(true)
+100277
+bool(true)
+40277
+-- Iteration 193 --
+bool(true)
+100300
+bool(true)
+40300
+-- Iteration 194 --
+bool(true)
+100301
+bool(true)
+40301
+-- Iteration 195 --
+bool(true)
+100302
+bool(true)
+40302
+-- Iteration 196 --
+bool(true)
+100303
+bool(true)
+40303
+-- Iteration 197 --
+bool(true)
+100304
+bool(true)
+40304
+-- Iteration 198 --
+bool(true)
+100305
+bool(true)
+40305
+-- Iteration 199 --
+bool(true)
+100306
+bool(true)
+40306
+-- Iteration 200 --
+bool(true)
+100307
+bool(true)
+40307
+-- Iteration 201 --
+bool(true)
+100310
+bool(true)
+40310
+-- Iteration 202 --
+bool(true)
+100311
+bool(true)
+40311
+-- Iteration 203 --
+bool(true)
+100312
+bool(true)
+40312
+-- Iteration 204 --
+bool(true)
+100313
+bool(true)
+40313
+-- Iteration 205 --
+bool(true)
+100314
+bool(true)
+40314
+-- Iteration 206 --
+bool(true)
+100315
+bool(true)
+40315
+-- Iteration 207 --
+bool(true)
+100316
+bool(true)
+40316
+-- Iteration 208 --
+bool(true)
+100317
+bool(true)
+40317
+-- Iteration 209 --
+bool(true)
+100320
+bool(true)
+40320
+-- Iteration 210 --
+bool(true)
+100321
+bool(true)
+40321
+-- Iteration 211 --
+bool(true)
+100322
+bool(true)
+40322
+-- Iteration 212 --
+bool(true)
+100323
+bool(true)
+40323
+-- Iteration 213 --
+bool(true)
+100324
+bool(true)
+40324
+-- Iteration 214 --
+bool(true)
+100325
+bool(true)
+40325
+-- Iteration 215 --
+bool(true)
+100326
+bool(true)
+40326
+-- Iteration 216 --
+bool(true)
+100327
+bool(true)
+40327
+-- Iteration 217 --
+bool(true)
+100330
+bool(true)
+40330
+-- Iteration 218 --
+bool(true)
+100331
+bool(true)
+40331
+-- Iteration 219 --
+bool(true)
+100332
+bool(true)
+40332
+-- Iteration 220 --
+bool(true)
+100333
+bool(true)
+40333
+-- Iteration 221 --
+bool(true)
+100334
+bool(true)
+40334
+-- Iteration 222 --
+bool(true)
+100335
+bool(true)
+40335
+-- Iteration 223 --
+bool(true)
+100336
+bool(true)
+40336
+-- Iteration 224 --
+bool(true)
+100337
+bool(true)
+40337
+-- Iteration 225 --
+bool(true)
+100340
+bool(true)
+40340
+-- Iteration 226 --
+bool(true)
+100341
+bool(true)
+40341
+-- Iteration 227 --
+bool(true)
+100342
+bool(true)
+40342
+-- Iteration 228 --
+bool(true)
+100343
+bool(true)
+40343
+-- Iteration 229 --
+bool(true)
+100344
+bool(true)
+40344
+-- Iteration 230 --
+bool(true)
+100345
+bool(true)
+40345
+-- Iteration 231 --
+bool(true)
+100346
+bool(true)
+40346
+-- Iteration 232 --
+bool(true)
+100347
+bool(true)
+40347
+-- Iteration 233 --
+bool(true)
+100350
+bool(true)
+40350
+-- Iteration 234 --
+bool(true)
+100351
+bool(true)
+40351
+-- Iteration 235 --
+bool(true)
+100352
+bool(true)
+40352
+-- Iteration 236 --
+bool(true)
+100353
+bool(true)
+40353
+-- Iteration 237 --
+bool(true)
+100354
+bool(true)
+40354
+-- Iteration 238 --
+bool(true)
+100355
+bool(true)
+40355
+-- Iteration 239 --
+bool(true)
+100356
+bool(true)
+40356
+-- Iteration 240 --
+bool(true)
+100357
+bool(true)
+40357
+-- Iteration 241 --
+bool(true)
+100360
+bool(true)
+40360
+-- Iteration 242 --
+bool(true)
+100361
+bool(true)
+40361
+-- Iteration 243 --
+bool(true)
+100362
+bool(true)
+40362
+-- Iteration 244 --
+bool(true)
+100363
+bool(true)
+40363
+-- Iteration 245 --
+bool(true)
+100364
+bool(true)
+40364
+-- Iteration 246 --
+bool(true)
+100365
+bool(true)
+40365
+-- Iteration 247 --
+bool(true)
+100366
+bool(true)
+40366
+-- Iteration 248 --
+bool(true)
+100367
+bool(true)
+40367
+-- Iteration 249 --
+bool(true)
+100370
+bool(true)
+40370
+-- Iteration 250 --
+bool(true)
+100371
+bool(true)
+40371
+-- Iteration 251 --
+bool(true)
+100372
+bool(true)
+40372
+-- Iteration 252 --
+bool(true)
+100373
+bool(true)
+40373
+-- Iteration 253 --
+bool(true)
+100374
+bool(true)
+40374
+-- Iteration 254 --
+bool(true)
+100375
+bool(true)
+40375
+-- Iteration 255 --
+bool(true)
+100376
+bool(true)
+40376
+-- Iteration 256 --
+bool(true)
+100377
+bool(true)
+40377
+-- Iteration 257 --
+bool(true)
+100400
+bool(true)
+40400
+-- Iteration 258 --
+bool(true)
+100401
+bool(true)
+40401
+-- Iteration 259 --
+bool(true)
+100402
+bool(true)
+40402
+-- Iteration 260 --
+bool(true)
+100403
+bool(true)
+40403
+-- Iteration 261 --
+bool(true)
+100404
+bool(true)
+40404
+-- Iteration 262 --
+bool(true)
+100405
+bool(true)
+40405
+-- Iteration 263 --
+bool(true)
+100406
+bool(true)
+40406
+-- Iteration 264 --
+bool(true)
+100407
+bool(true)
+40407
+-- Iteration 265 --
+bool(true)
+100410
+bool(true)
+40410
+-- Iteration 266 --
+bool(true)
+100411
+bool(true)
+40411
+-- Iteration 267 --
+bool(true)
+100412
+bool(true)
+40412
+-- Iteration 268 --
+bool(true)
+100413
+bool(true)
+40413
+-- Iteration 269 --
+bool(true)
+100414
+bool(true)
+40414
+-- Iteration 270 --
+bool(true)
+100415
+bool(true)
+40415
+-- Iteration 271 --
+bool(true)
+100416
+bool(true)
+40416
+-- Iteration 272 --
+bool(true)
+100417
+bool(true)
+40417
+-- Iteration 273 --
+bool(true)
+100420
+bool(true)
+40420
+-- Iteration 274 --
+bool(true)
+100421
+bool(true)
+40421
+-- Iteration 275 --
+bool(true)
+100422
+bool(true)
+40422
+-- Iteration 276 --
+bool(true)
+100423
+bool(true)
+40423
+-- Iteration 277 --
+bool(true)
+100424
+bool(true)
+40424
+-- Iteration 278 --
+bool(true)
+100425
+bool(true)
+40425
+-- Iteration 279 --
+bool(true)
+100426
+bool(true)
+40426
+-- Iteration 280 --
+bool(true)
+100427
+bool(true)
+40427
+-- Iteration 281 --
+bool(true)
+100430
+bool(true)
+40430
+-- Iteration 282 --
+bool(true)
+100431
+bool(true)
+40431
+-- Iteration 283 --
+bool(true)
+100432
+bool(true)
+40432
+-- Iteration 284 --
+bool(true)
+100433
+bool(true)
+40433
+-- Iteration 285 --
+bool(true)
+100434
+bool(true)
+40434
+-- Iteration 286 --
+bool(true)
+100435
+bool(true)
+40435
+-- Iteration 287 --
+bool(true)
+100436
+bool(true)
+40436
+-- Iteration 288 --
+bool(true)
+100437
+bool(true)
+40437
+-- Iteration 289 --
+bool(true)
+100440
+bool(true)
+40440
+-- Iteration 290 --
+bool(true)
+100441
+bool(true)
+40441
+-- Iteration 291 --
+bool(true)
+100442
+bool(true)
+40442
+-- Iteration 292 --
+bool(true)
+100443
+bool(true)
+40443
+-- Iteration 293 --
+bool(true)
+100444
+bool(true)
+40444
+-- Iteration 294 --
+bool(true)
+100445
+bool(true)
+40445
+-- Iteration 295 --
+bool(true)
+100446
+bool(true)
+40446
+-- Iteration 296 --
+bool(true)
+100447
+bool(true)
+40447
+-- Iteration 297 --
+bool(true)
+100450
+bool(true)
+40450
+-- Iteration 298 --
+bool(true)
+100451
+bool(true)
+40451
+-- Iteration 299 --
+bool(true)
+100452
+bool(true)
+40452
+-- Iteration 300 --
+bool(true)
+100453
+bool(true)
+40453
+-- Iteration 301 --
+bool(true)
+100454
+bool(true)
+40454
+-- Iteration 302 --
+bool(true)
+100455
+bool(true)
+40455
+-- Iteration 303 --
+bool(true)
+100456
+bool(true)
+40456
+-- Iteration 304 --
+bool(true)
+100457
+bool(true)
+40457
+-- Iteration 305 --
+bool(true)
+100460
+bool(true)
+40460
+-- Iteration 306 --
+bool(true)
+100461
+bool(true)
+40461
+-- Iteration 307 --
+bool(true)
+100462
+bool(true)
+40462
+-- Iteration 308 --
+bool(true)
+100463
+bool(true)
+40463
+-- Iteration 309 --
+bool(true)
+100464
+bool(true)
+40464
+-- Iteration 310 --
+bool(true)
+100465
+bool(true)
+40465
+-- Iteration 311 --
+bool(true)
+100466
+bool(true)
+40466
+-- Iteration 312 --
+bool(true)
+100467
+bool(true)
+40467
+-- Iteration 313 --
+bool(true)
+100470
+bool(true)
+40470
+-- Iteration 314 --
+bool(true)
+100471
+bool(true)
+40471
+-- Iteration 315 --
+bool(true)
+100472
+bool(true)
+40472
+-- Iteration 316 --
+bool(true)
+100473
+bool(true)
+40473
+-- Iteration 317 --
+bool(true)
+100474
+bool(true)
+40474
+-- Iteration 318 --
+bool(true)
+100475
+bool(true)
+40475
+-- Iteration 319 --
+bool(true)
+100476
+bool(true)
+40476
+-- Iteration 320 --
+bool(true)
+100477
+bool(true)
+40477
+-- Iteration 321 --
+bool(true)
+100500
+bool(true)
+40500
+-- Iteration 322 --
+bool(true)
+100501
+bool(true)
+40501
+-- Iteration 323 --
+bool(true)
+100502
+bool(true)
+40502
+-- Iteration 324 --
+bool(true)
+100503
+bool(true)
+40503
+-- Iteration 325 --
+bool(true)
+100504
+bool(true)
+40504
+-- Iteration 326 --
+bool(true)
+100505
+bool(true)
+40505
+-- Iteration 327 --
+bool(true)
+100506
+bool(true)
+40506
+-- Iteration 328 --
+bool(true)
+100507
+bool(true)
+40507
+-- Iteration 329 --
+bool(true)
+100510
+bool(true)
+40510
+-- Iteration 330 --
+bool(true)
+100511
+bool(true)
+40511
+-- Iteration 331 --
+bool(true)
+100512
+bool(true)
+40512
+-- Iteration 332 --
+bool(true)
+100513
+bool(true)
+40513
+-- Iteration 333 --
+bool(true)
+100514
+bool(true)
+40514
+-- Iteration 334 --
+bool(true)
+100515
+bool(true)
+40515
+-- Iteration 335 --
+bool(true)
+100516
+bool(true)
+40516
+-- Iteration 336 --
+bool(true)
+100517
+bool(true)
+40517
+-- Iteration 337 --
+bool(true)
+100520
+bool(true)
+40520
+-- Iteration 338 --
+bool(true)
+100521
+bool(true)
+40521
+-- Iteration 339 --
+bool(true)
+100522
+bool(true)
+40522
+-- Iteration 340 --
+bool(true)
+100523
+bool(true)
+40523
+-- Iteration 341 --
+bool(true)
+100524
+bool(true)
+40524
+-- Iteration 342 --
+bool(true)
+100525
+bool(true)
+40525
+-- Iteration 343 --
+bool(true)
+100526
+bool(true)
+40526
+-- Iteration 344 --
+bool(true)
+100527
+bool(true)
+40527
+-- Iteration 345 --
+bool(true)
+100530
+bool(true)
+40530
+-- Iteration 346 --
+bool(true)
+100531
+bool(true)
+40531
+-- Iteration 347 --
+bool(true)
+100532
+bool(true)
+40532
+-- Iteration 348 --
+bool(true)
+100533
+bool(true)
+40533
+-- Iteration 349 --
+bool(true)
+100534
+bool(true)
+40534
+-- Iteration 350 --
+bool(true)
+100535
+bool(true)
+40535
+-- Iteration 351 --
+bool(true)
+100536
+bool(true)
+40536
+-- Iteration 352 --
+bool(true)
+100537
+bool(true)
+40537
+-- Iteration 353 --
+bool(true)
+100540
+bool(true)
+40540
+-- Iteration 354 --
+bool(true)
+100541
+bool(true)
+40541
+-- Iteration 355 --
+bool(true)
+100542
+bool(true)
+40542
+-- Iteration 356 --
+bool(true)
+100543
+bool(true)
+40543
+-- Iteration 357 --
+bool(true)
+100544
+bool(true)
+40544
+-- Iteration 358 --
+bool(true)
+100545
+bool(true)
+40545
+-- Iteration 359 --
+bool(true)
+100546
+bool(true)
+40546
+-- Iteration 360 --
+bool(true)
+100547
+bool(true)
+40547
+-- Iteration 361 --
+bool(true)
+100550
+bool(true)
+40550
+-- Iteration 362 --
+bool(true)
+100551
+bool(true)
+40551
+-- Iteration 363 --
+bool(true)
+100552
+bool(true)
+40552
+-- Iteration 364 --
+bool(true)
+100553
+bool(true)
+40553
+-- Iteration 365 --
+bool(true)
+100554
+bool(true)
+40554
+-- Iteration 366 --
+bool(true)
+100555
+bool(true)
+40555
+-- Iteration 367 --
+bool(true)
+100556
+bool(true)
+40556
+-- Iteration 368 --
+bool(true)
+100557
+bool(true)
+40557
+-- Iteration 369 --
+bool(true)
+100560
+bool(true)
+40560
+-- Iteration 370 --
+bool(true)
+100561
+bool(true)
+40561
+-- Iteration 371 --
+bool(true)
+100562
+bool(true)
+40562
+-- Iteration 372 --
+bool(true)
+100563
+bool(true)
+40563
+-- Iteration 373 --
+bool(true)
+100564
+bool(true)
+40564
+-- Iteration 374 --
+bool(true)
+100565
+bool(true)
+40565
+-- Iteration 375 --
+bool(true)
+100566
+bool(true)
+40566
+-- Iteration 376 --
+bool(true)
+100567
+bool(true)
+40567
+-- Iteration 377 --
+bool(true)
+100570
+bool(true)
+40570
+-- Iteration 378 --
+bool(true)
+100571
+bool(true)
+40571
+-- Iteration 379 --
+bool(true)
+100572
+bool(true)
+40572
+-- Iteration 380 --
+bool(true)
+100573
+bool(true)
+40573
+-- Iteration 381 --
+bool(true)
+100574
+bool(true)
+40574
+-- Iteration 382 --
+bool(true)
+100575
+bool(true)
+40575
+-- Iteration 383 --
+bool(true)
+100576
+bool(true)
+40576
+-- Iteration 384 --
+bool(true)
+100577
+bool(true)
+40577
+-- Iteration 385 --
+bool(true)
+100600
+bool(true)
+40600
+-- Iteration 386 --
+bool(true)
+100601
+bool(true)
+40601
+-- Iteration 387 --
+bool(true)
+100602
+bool(true)
+40602
+-- Iteration 388 --
+bool(true)
+100603
+bool(true)
+40603
+-- Iteration 389 --
+bool(true)
+100604
+bool(true)
+40604
+-- Iteration 390 --
+bool(true)
+100605
+bool(true)
+40605
+-- Iteration 391 --
+bool(true)
+100606
+bool(true)
+40606
+-- Iteration 392 --
+bool(true)
+100607
+bool(true)
+40607
+-- Iteration 393 --
+bool(true)
+100610
+bool(true)
+40610
+-- Iteration 394 --
+bool(true)
+100611
+bool(true)
+40611
+-- Iteration 395 --
+bool(true)
+100612
+bool(true)
+40612
+-- Iteration 396 --
+bool(true)
+100613
+bool(true)
+40613
+-- Iteration 397 --
+bool(true)
+100614
+bool(true)
+40614
+-- Iteration 398 --
+bool(true)
+100615
+bool(true)
+40615
+-- Iteration 399 --
+bool(true)
+100616
+bool(true)
+40616
+-- Iteration 400 --
+bool(true)
+100617
+bool(true)
+40617
+-- Iteration 401 --
+bool(true)
+100620
+bool(true)
+40620
+-- Iteration 402 --
+bool(true)
+100621
+bool(true)
+40621
+-- Iteration 403 --
+bool(true)
+100622
+bool(true)
+40622
+-- Iteration 404 --
+bool(true)
+100623
+bool(true)
+40623
+-- Iteration 405 --
+bool(true)
+100624
+bool(true)
+40624
+-- Iteration 406 --
+bool(true)
+100625
+bool(true)
+40625
+-- Iteration 407 --
+bool(true)
+100626
+bool(true)
+40626
+-- Iteration 408 --
+bool(true)
+100627
+bool(true)
+40627
+-- Iteration 409 --
+bool(true)
+100630
+bool(true)
+40630
+-- Iteration 410 --
+bool(true)
+100631
+bool(true)
+40631
+-- Iteration 411 --
+bool(true)
+100632
+bool(true)
+40632
+-- Iteration 412 --
+bool(true)
+100633
+bool(true)
+40633
+-- Iteration 413 --
+bool(true)
+100634
+bool(true)
+40634
+-- Iteration 414 --
+bool(true)
+100635
+bool(true)
+40635
+-- Iteration 415 --
+bool(true)
+100636
+bool(true)
+40636
+-- Iteration 416 --
+bool(true)
+100637
+bool(true)
+40637
+-- Iteration 417 --
+bool(true)
+100640
+bool(true)
+40640
+-- Iteration 418 --
+bool(true)
+100641
+bool(true)
+40641
+-- Iteration 419 --
+bool(true)
+100642
+bool(true)
+40642
+-- Iteration 420 --
+bool(true)
+100643
+bool(true)
+40643
+-- Iteration 421 --
+bool(true)
+100644
+bool(true)
+40644
+-- Iteration 422 --
+bool(true)
+100645
+bool(true)
+40645
+-- Iteration 423 --
+bool(true)
+100646
+bool(true)
+40646
+-- Iteration 424 --
+bool(true)
+100647
+bool(true)
+40647
+-- Iteration 425 --
+bool(true)
+100650
+bool(true)
+40650
+-- Iteration 426 --
+bool(true)
+100651
+bool(true)
+40651
+-- Iteration 427 --
+bool(true)
+100652
+bool(true)
+40652
+-- Iteration 428 --
+bool(true)
+100653
+bool(true)
+40653
+-- Iteration 429 --
+bool(true)
+100654
+bool(true)
+40654
+-- Iteration 430 --
+bool(true)
+100655
+bool(true)
+40655
+-- Iteration 431 --
+bool(true)
+100656
+bool(true)
+40656
+-- Iteration 432 --
+bool(true)
+100657
+bool(true)
+40657
+-- Iteration 433 --
+bool(true)
+100660
+bool(true)
+40660
+-- Iteration 434 --
+bool(true)
+100661
+bool(true)
+40661
+-- Iteration 435 --
+bool(true)
+100662
+bool(true)
+40662
+-- Iteration 436 --
+bool(true)
+100663
+bool(true)
+40663
+-- Iteration 437 --
+bool(true)
+100664
+bool(true)
+40664
+-- Iteration 438 --
+bool(true)
+100665
+bool(true)
+40665
+-- Iteration 439 --
+bool(true)
+100666
+bool(true)
+40666
+-- Iteration 440 --
+bool(true)
+100667
+bool(true)
+40667
+-- Iteration 441 --
+bool(true)
+100670
+bool(true)
+40670
+-- Iteration 442 --
+bool(true)
+100671
+bool(true)
+40671
+-- Iteration 443 --
+bool(true)
+100672
+bool(true)
+40672
+-- Iteration 444 --
+bool(true)
+100673
+bool(true)
+40673
+-- Iteration 445 --
+bool(true)
+100674
+bool(true)
+40674
+-- Iteration 446 --
+bool(true)
+100675
+bool(true)
+40675
+-- Iteration 447 --
+bool(true)
+100676
+bool(true)
+40676
+-- Iteration 448 --
+bool(true)
+100677
+bool(true)
+40677
+-- Iteration 449 --
+bool(true)
+100700
+bool(true)
+40700
+-- Iteration 450 --
+bool(true)
+100701
+bool(true)
+40701
+-- Iteration 451 --
+bool(true)
+100702
+bool(true)
+40702
+-- Iteration 452 --
+bool(true)
+100703
+bool(true)
+40703
+-- Iteration 453 --
+bool(true)
+100704
+bool(true)
+40704
+-- Iteration 454 --
+bool(true)
+100705
+bool(true)
+40705
+-- Iteration 455 --
+bool(true)
+100706
+bool(true)
+40706
+-- Iteration 456 --
+bool(true)
+100707
+bool(true)
+40707
+-- Iteration 457 --
+bool(true)
+100710
+bool(true)
+40710
+-- Iteration 458 --
+bool(true)
+100711
+bool(true)
+40711
+-- Iteration 459 --
+bool(true)
+100712
+bool(true)
+40712
+-- Iteration 460 --
+bool(true)
+100713
+bool(true)
+40713
+-- Iteration 461 --
+bool(true)
+100714
+bool(true)
+40714
+-- Iteration 462 --
+bool(true)
+100715
+bool(true)
+40715
+-- Iteration 463 --
+bool(true)
+100716
+bool(true)
+40716
+-- Iteration 464 --
+bool(true)
+100717
+bool(true)
+40717
+-- Iteration 465 --
+bool(true)
+100720
+bool(true)
+40720
+-- Iteration 466 --
+bool(true)
+100721
+bool(true)
+40721
+-- Iteration 467 --
+bool(true)
+100722
+bool(true)
+40722
+-- Iteration 468 --
+bool(true)
+100723
+bool(true)
+40723
+-- Iteration 469 --
+bool(true)
+100724
+bool(true)
+40724
+-- Iteration 470 --
+bool(true)
+100725
+bool(true)
+40725
+-- Iteration 471 --
+bool(true)
+100726
+bool(true)
+40726
+-- Iteration 472 --
+bool(true)
+100727
+bool(true)
+40727
+-- Iteration 473 --
+bool(true)
+100730
+bool(true)
+40730
+-- Iteration 474 --
+bool(true)
+100731
+bool(true)
+40731
+-- Iteration 475 --
+bool(true)
+100732
+bool(true)
+40732
+-- Iteration 476 --
+bool(true)
+100733
+bool(true)
+40733
+-- Iteration 477 --
+bool(true)
+100734
+bool(true)
+40734
+-- Iteration 478 --
+bool(true)
+100735
+bool(true)
+40735
+-- Iteration 479 --
+bool(true)
+100736
+bool(true)
+40736
+-- Iteration 480 --
+bool(true)
+100737
+bool(true)
+40737
+-- Iteration 481 --
+bool(true)
+100740
+bool(true)
+40740
+-- Iteration 482 --
+bool(true)
+100741
+bool(true)
+40741
+-- Iteration 483 --
+bool(true)
+100742
+bool(true)
+40742
+-- Iteration 484 --
+bool(true)
+100743
+bool(true)
+40743
+-- Iteration 485 --
+bool(true)
+100744
+bool(true)
+40744
+-- Iteration 486 --
+bool(true)
+100745
+bool(true)
+40745
+-- Iteration 487 --
+bool(true)
+100746
+bool(true)
+40746
+-- Iteration 488 --
+bool(true)
+100747
+bool(true)
+40747
+-- Iteration 489 --
+bool(true)
+100750
+bool(true)
+40750
+-- Iteration 490 --
+bool(true)
+100751
+bool(true)
+40751
+-- Iteration 491 --
+bool(true)
+100752
+bool(true)
+40752
+-- Iteration 492 --
+bool(true)
+100753
+bool(true)
+40753
+-- Iteration 493 --
+bool(true)
+100754
+bool(true)
+40754
+-- Iteration 494 --
+bool(true)
+100755
+bool(true)
+40755
+-- Iteration 495 --
+bool(true)
+100756
+bool(true)
+40756
+-- Iteration 496 --
+bool(true)
+100757
+bool(true)
+40757
+-- Iteration 497 --
+bool(true)
+100760
+bool(true)
+40760
+-- Iteration 498 --
+bool(true)
+100761
+bool(true)
+40761
+-- Iteration 499 --
+bool(true)
+100762
+bool(true)
+40762
+-- Iteration 500 --
+bool(true)
+100763
+bool(true)
+40763
+-- Iteration 501 --
+bool(true)
+100764
+bool(true)
+40764
+-- Iteration 502 --
+bool(true)
+100765
+bool(true)
+40765
+-- Iteration 503 --
+bool(true)
+100766
+bool(true)
+40766
+-- Iteration 504 --
+bool(true)
+100767
+bool(true)
+40767
+-- Iteration 505 --
+bool(true)
+100770
+bool(true)
+40770
+-- Iteration 506 --
+bool(true)
+100771
+bool(true)
+40771
+-- Iteration 507 --
+bool(true)
+100772
+bool(true)
+40772
+-- Iteration 508 --
+bool(true)
+100773
+bool(true)
+40773
+-- Iteration 509 --
+bool(true)
+100774
+bool(true)
+40774
+-- Iteration 510 --
+bool(true)
+100775
+bool(true)
+40775
+-- Iteration 511 --
+bool(true)
+100776
+bool(true)
+40776
+-- Iteration 512 --
+bool(true)
+100777
+bool(true)
+40777
+
+*** Testing fileperms(), chmod() with miscellaneous permissions ***
+-- Iteration 1 --
+bool(true)
+107777
+bool(true)
+47777
+-- Iteration 2 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 3 --
+bool(true)
+101000
+bool(true)
+41000
+-- Iteration 4 --
+bool(true)
+101111
+bool(true)
+41111
+-- Iteration 5 --
+bool(true)
+107001
+bool(true)
+47001
+-- Iteration 6 --
+bool(true)
+100001
+bool(true)
+40001
+-- Iteration 7 --
+bool(true)
+101411
+bool(true)
+41411
+-- Iteration 8 --
+bool(true)
+107141
+bool(true)
+47141
+-- Iteration 9 --
+bool(true)
+100637
+bool(true)
+40637
+-- Iteration 10 --
+bool(true)
+103567
+bool(true)
+43567
+-- Iteration 11 --
+bool(true)
+103567
+bool(true)
+43567
+-- Iteration 12 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 13 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 14 --
+bool(true)
+100000
+bool(true)
+40000
+-- Iteration 15 --
+bool(true)
+100000
+bool(true)
+40000
+*** Done ***
\ No newline at end of file
--- /dev/null
+--TEST--
+Test fopen(), fclose() & feof() functions: basic functionality
+--FILE--
+<?php
+/*
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+
+ Prototype: bool feof ( resource $handle );
+ Description: Tests for end-of-file on a file pointer
+*/
+
+echo "*** Testing basic operations of fopen() and fclose() functions ***\n";
+$modes = array(
+ "w",
+ "wb",
+ "wt",
+ "w+",
+ "w+b",
+ "w+t",
+
+ "r",
+ "rb",
+ "rt",
+ "r+",
+ "r+b",
+ "r+t",
+
+ "a",
+ "ab",
+ "at",
+ "a+",
+ "a+t",
+ "a+b"
+);
+
+for( $i=0; $i<count($modes); $i++ ) {
+ echo "\n-- Iteration with mode '$modes[$i]' --\n";
+
+ $filename = dirname(__FILE__)."/007_basic.tmp";
+ // check fopen()
+ $handle = fopen($filename, $modes[$i]);
+ var_dump($handle );
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+
+ // check fclose()
+ var_dump( fclose($handle) );
+ var_dump( $handle );
+ // confirm the closure, using ftell() and feof(), expect, false
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+}
+
+// remove the temp file
+unlink($filename);
+
+$x_modes = array(
+ "x",
+ "xb",
+ "xt",
+ "x+",
+ "x+b",
+ "x+t"
+);
+
+for( $i=0; $i<count($x_modes); $i++ ) {
+ echo "\n-- Iteration with mode '$x_modes[$i]' --\n";
+ $handle = fopen($filename, $x_modes[$i]);
+ var_dump($handle );
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+
+ // check fclose()
+ var_dump( fclose($handle) );
+ var_dump( $handle );
+ // confirm the closure, using ftell() and feof(), expect, false
+ var_dump( ftell($handle) );
+ var_dump( feof($handle) );
+ var_dump( $handle );
+
+ // remove the file
+ unlink( $filename );
+}
+
+echo "\n*** Done ***\n";
+--EXPECTF--
+*** Testing basic operations of fopen() and fclose() functions ***
+
+-- Iteration with mode 'w' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'wb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'wt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'w+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'rb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'rt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'r+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'ab' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'at' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'a+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+-- Iteration with mode 'x' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'xb' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'xt' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+b' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+-- Iteration with mode 'x+t' --
+resource(%d) of type (stream)
+int(0)
+bool(false)
+bool(true)
+resource(%d) of type (Unknown)
+
+Warning: ftell(): %d is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): %d is not a valid stream resource in %s on line %d
+bool(false)
+resource(%d) of type (Unknown)
+
+*** Done ***
--- /dev/null
+--TEST--
+Test fopen, fclose() & feof() functions: error conditions
+--FILE--
+<?php
+/*
+ Prototype: resource fopen(string $filename, string $mode
+ [, bool $use_include_path [, resource $context]] );
+ Description: Opens file or URL.
+
+ Prototype: bool fclose ( resource $handle );
+ Description: Closes an open file pointer
+
+ Prototype: bool feof ( resource $handle )
+ Description: Returns TRUE if the file pointer is at EOF or an error occurs
+ (including socket timeout); otherwise returns FALSE.
+*/
+
+echo "*** Testing error conditions for fopen(), fclsoe() & feof() ***\n";
+/* Arguments less than minimum no.of args */
+
+// fopen ()
+var_dump(fopen(__FILE__)); // one valid argument
+var_dump(fopen()); // zero argument
+
+// fclose()
+$fp = fopen(__FILE__, "r");
+fclose($fp);
+var_dump( fclose($fp) ); // closed handle
+var_dump( fclose(__FILE__) ); // invalid handle
+var_dump( fclose() ); // zero argument
+
+//feof()
+var_dump( feof($fp) ); // closed handle
+var_dump( feof(__FILE__) ); // invalid handle
+var_dump( feof() ); //zero argument
+
+/* Arguments greater than maximum no.of ags */
+var_dump(fopen(__FILE__, "r", TRUE, "www.example.com", 100));
+
+$fp = fopen(__FILE__, "r");
+var_dump( fclose($fp, "handle") );
+
+var_dump( feof($fp, "handle"));
+fclose($fp);
+
+/* test invalid arguments : non-resources */
+echo "-- Testing fopen(), fclose() & feof() with invalid arguments --\n";
+$invalid_args = array (
+ "string",
+ 10,
+ 10.5,
+ true,
+ array(1,2,3),
+ new stdclass,
+ NULL,
+ ""
+);
+
+/* loop to test fclose with different invalid type of args */
+for($loop_counter = 1; $loop_counter <= count($invalid_args); $loop_counter++) {
+ echo "-- Iteration $loop_counter --\n";
+ var_dump( fopen($invalid_args[$loop_counter - 1], "r") );
+ var_dump( fclose($invalid_args[$loop_counter - 1]) );
+ var_dump( feof($invalid_args[$loop_counter - 1]) );
+}
+
+?>
+--EXPECTF--
+*** Testing error conditions for fopen(), fclsoe() & feof() ***
+
+Warning: fopen() expects at least 2 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: fopen() expects at least 2 parameters, 0 given in %s on line %d
+bool(false)
+
+Warning: fclose(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for fclose() in %s on line %d
+NULL
+
+Warning: feof(): 5 is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for feof() in %s on line %d
+NULL
+
+Warning: fopen() expects at most 4 parameters, 5 given in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for fclose() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for feof() in %s on line %d
+NULL
+-- Testing fopen(), fclose() & feof() with invalid arguments --
+-- Iteration 1 --
+
+Warning: fopen(string): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 2 --
+
+Warning: fopen(10): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 3 --
+
+Warning: fopen(10.5): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 4 --
+
+Warning: fopen(1): failed to open stream: No such file or directory in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 5 --
+
+Warning: fopen() expects parameter 1 to be string, array given in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 6 --
+
+Warning: fopen() expects parameter 1 to be string, object given in %s on line %d
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 7 --
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+-- Iteration 8 --
+bool(false)
+
+Warning: fclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+Warning: feof(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
--- /dev/null
+--TEST--
+Test popen() and pclose function: basic functionality
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' )
+ die("skip Not Valid for Linux");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+
+echo "*** Testing popen(): reading from the pipe ***\n";
+
+$file_path = dirname(__FILE__);
+
+$string = "Sample String";
+$file_handle = popen(" echo $string", "r");
+fpassthru($file_handle);
+pclose($file_handle);
+
+echo "*** Testing popen(): writing to the pipe ***\n";
+$arr = array("ggg", "ddd", "aaa", "sss");
+$file_handle = popen("sort", "w");
+$newline = "\n";
+foreach($arr as $str) {
+ fwrite($file_handle, $str);
+ fwrite($file_handle, $newline);
+}
+pclose($file_handle);
+
+echo "*** Testing popen() and pclose(): return type ***\n";
+$return_value_popen = popen("echo $string", "r");
+fpassthru($return_value_popen);
+var_dump( is_resource($return_value_popen) );
+$return_value_pclose = pclose($return_value_popen);
+var_dump( is_int($return_value_pclose) );
+
+echo "\n--- Done ---";
+?>
+--EXPECTF--
+*** Testing popen(): reading from the pipe ***
+Sample String
+*** Testing popen(): writing to the pipe ***
+aaa
+ddd
+ggg
+sss
+*** Testing popen() and pclose(): return type ***
+Sample String
+bool(true)
+bool(true)
+
+--- Done ---
--- /dev/null
+--TEST--
+Test popen() and pclose function: basic functionality
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+ die("skip Not Valid for Windows");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+ *
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+
+$file_path = dirname(__FILE__);
+require($file_path."/file.inc");
+
+echo "*** Testing popen() and pclose() with different processes ***\n";
+
+echo "-- Testing popen(): reading from the pipe --\n";
+$dirpath = $file_path."/popen_basic";
+mkdir($dirpath);
+touch($dirpath."/popen_basic.tmp");
+define('CMD', "ls $dirpath");
+$file_handle = popen(CMD, 'r');
+fpassthru($file_handle);
+pclose($file_handle);
+
+echo "-- Testing popen(): reading from a file using 'cat' command --\n";
+create_files($dirpath, 1, "text_with_new_line", 0755, 100, "w", "popen_basic", 1, "bytes");
+$filename = $dirpath."/popen_basic1.tmp";
+$command = "cat $filename";
+$file_handle = popen($command, "r");
+$return_value = fpassthru($file_handle);
+echo "\n";
+var_dump($return_value);
+pclose($file_handle);
+delete_files($dirpath, 1);
+
+echo "*** Testing popen(): writing to the pipe ***\n";
+$arr = array("ggg", "ddd", "aaa", "sss");
+$file_handle = popen("sort", "w");
+$counter = 0;
+$newline = "\n";
+foreach($arr as $str) {
+ fwrite($file_handle, $str);
+ fwrite($file_handle, $newline);
+}
+pclose($file_handle);
+
+
+echo "*** Testing for return type of popen() and pclose() functions ***\n";
+$string = "Test String";
+$return_value_popen = popen("echo $string", "r");
+var_dump( is_resource($return_value_popen) );
+fpassthru($return_value_popen);
+$return_value_pclose = pclose($return_value_popen);
+var_dump( is_int($return_value_pclose) );
+
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+$dirpath = $file_path."/popen_basic";
+unlink($dirpath."/popen_basic.tmp");
+unlink($dirpath."/popen_basic1.tmp");
+rmdir($dirpath);
+?>
+
+--EXPECTF--
+*** Testing popen() and pclose() with different processes ***
+-- Testing popen(): reading from the pipe --
+popen_basic.tmp
+-- Testing popen(): reading from a file using 'cat' command --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+*** Testing popen(): writing to the pipe ***
+aaa
+ddd
+ggg
+sss
+*** Testing for return type of popen() and pclose() functions ***
+bool(true)
+Test String
+bool(true)
+
+--- Done ---
+--UEXPECTF--
+*** Testing popen() and pclose() with different processes ***
+-- Testing popen(): reading from the pipe --
+popen_basic.tmp
+-- Testing popen(): reading from a file using 'cat' command --
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line of text
+line
+line
+int(100)
+*** Testing popen(): writing to the pipe ***
+aaa
+ddd
+ggg
+sss
+*** Testing for return type of popen() and pclose() functions ***
+bool(true)
+Test String
+bool(true)
+
+--- Done ---
--- /dev/null
+--TEST--
+Test popen() and pclose function: error conditions
+
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) != 'WIN' )
+ die("skip Not Valid for Linux");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***\n";
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+pclose($file_handle);
+var_dump( pclose(1) );
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+resource(%d) of type (stream)
+'abc.txt' is not recognized as an internal or external command,
+operable program or batch file.
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: pclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+--- Done ---
--- /dev/null
+--TEST--
+Test popen() and pclose function: error conditions
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == 'WIN' )
+ die("skip Not Valid for Windows");
+?>
+
+--FILE--
+<?php
+/*
+ * Prototype: resource popen ( string command, string mode )
+ * Description: Opens process file pointer.
+
+ * Prototype: int pclose ( resource handle );
+ * Description: Closes process file pointer.
+ */
+$file_path = dirname(__FILE__);
+echo "*** Testing for error conditions ***\n";
+var_dump( popen() ); // Zero Arguments
+var_dump( popen("abc.txt") ); // Single Argument
+var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument
+var_dump( pclose() );
+$file_handle = fopen($file_path."/popen.tmp", "w");
+var_dump( pclose($file_handle, $file_handle) );
+fclose($file_handle);
+var_dump( pclose(1) );
+echo "\n--- Done ---";
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__);
+unlink($file_path."/popen.tmp");
+?>
+--EXPECTF--
+*** Testing for error conditions ***
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for popen() in %s on line %d
+NULL
+
+Warning: popen(abc.txt,rw): Invalid argument in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for pclose() in %s on line %d
+NULL
+
+Warning: pclose(): supplied argument is not a valid stream resource in %s on line %d
+bool(false)
+
+--- Done ---
--- /dev/null
+--TEST--
+Test readlink() and realpath functions: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+/* creating directories, symbolic links and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/readlink_realpath_basic/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp", "w");
+$file_handle2 = fopen("$file_path/readlink_realpath_basic/home/readlink_realpath_basic.tmp", "w");
+$file_handle3 = fopen("$file_path/readlink_realpath_basic/readlink_realpath_basic.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+symlink("$file_path/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/home/test/readlink_realpath_basic_link.tmp");
+symlink("$file_path/readlink_realpath_basic/home/readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/home/readlink_realpath_basic_link.tmp");
+
+
+echo "*** Testing readlink() and realpath(): with valid and invalid path ***\n";
+$linknames = array (
+ /* linknames resulting in valid paths */
+ "$file_path/readlink_realpath_basic/home/readlink_realpath_basic_link.tmp",
+ "$file_path/readlink_realpath_basic/home/test/readlink_realpath_basic_link.tmp",
+ "$file_path/readlink_realpath_basic//home/test//../test/./readlink_realpath_basic_link.tmp",
+
+ // checking for binary safe
+ b"$file_path/readlink_realpath_basic/home/readlink_realpath_basic_link.tmp",
+
+ /* linknames with invalid linkpath */
+ "$file_path///readlink_realpath_basic/home//..//././test//readlink_realpath_basic_link.tmp",
+ "$file_path/readlink_realpath_basic/home/../home/../test/../readlink_realpath_basic_link.tmp",
+ "$file_path/readlink_realpath_basic/..readlink_realpath_basic_link.tmp",
+ "$file_path/readlink_realpath_basic/home/test/readlink_realpath_basic_link.tmp/"
+);
+
+$counter = 1;
+/* loop through $files to read the linkpath of
+ the link created from each $file in the above array */
+foreach($linknames as $link) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( readlink($link) );
+ var_dump( realpath($link) );
+ $counter++;
+}
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+ /* filenames resulting in valid paths */
+ "$file_path/readlink_realpath_basic/home/readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic//home/test//../test/./readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/home//../././readlink_realpath_basic.tmp",
+
+ // checking for binary safe
+ b"$file_path/readlink_realpath_basic/home/readlink_realpath_basic.tmp",
+
+ /* filenames with invalid path */
+ "$file_path///readlink_realpath_basic/home//..//././test//readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/home/../home/../test/../readlink_realpath_basic.tmp",
+ "$file_path/readlink_realpath_basic/readlink_realpath_basic.tmp/"
+);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( realpath($file) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_basic";
+unlink("$name_prefix/home/test/readlink_realpath_basic.tmp");
+unlink("$name_prefix/home/readlink_realpath_basic.tmp");
+unlink("$name_prefix/readlink_realpath_basic.tmp");
+unlink("$name_prefix/home/test/readlink_realpath_basic_link.tmp");
+unlink("$name_prefix/home/readlink_realpath_basic_link.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing readlink() and realpath(): with valid and invalid path ***
+
+-- Iteration 1 --
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic.tmp"
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic_link.tmp"
+
+-- Iteration 2 --
+string(%d) "%s/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp"
+string(%d) "%s/readlink_realpath_basic/home/test/readlink_realpath_basic_link.tmp"
+
+-- Iteration 3 --
+string(%d) "%s/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp"
+string(%d) "%s/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp"
+
+-- Iteration 4 --
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic.tmp"
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic_link.tmp"
+
+-- Iteration 5 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+-- Iteration 6 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+-- Iteration 7 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+
+-- Iteration 8 --
+
+Warning: readlink(): Not a directory in %s on line %d
+bool(false)
+bool(false)
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic.tmp"
+
+-- Iteration 2 --
+string(%d) "%s/readlink_realpath_basic/readlink_realpath_basic.tmp"
+
+-- Iteration 3 --
+string(%d) "%s/readlink_realpath_basic/home/test/readlink_realpath_basic.tmp"
+
+-- Iteration 4 --
+string(%d) "%s/readlink_realpath_basic/readlink_realpath_basic.tmp"
+
+-- Iteration 5 --
+string(%d) "%s/readlink_realpath_basic/home/readlink_realpath_basic.tmp"
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+
+-- Iteration 8 --
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test readlink() and realpath() functions: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing readlink(): error conditions ***\n";
+var_dump( readlink() ); // args < expected
+var_dump( readlink(__FILE__, 2) ); // args > expected
+
+echo "\n*** Testing readlink() on a non-existent link ***\n";
+var_dump( readlink(dirname(__FILE__)."/readlink_error.tmp") );
+
+echo "\n*** Testing readlink() on existing file ***\n";
+var_dump( readlink(__FILE__) );
+
+echo "\n*** Testing readlink() on existing directory ***\n";
+var_dump( readlink(dirname(__FILE__)) );
+
+echo "*** Testing realpath(): error conditions ***\n";
+var_dump( realpath() ); // args < expected
+var_dump( realpath(1, 2) ); // args > expected
+
+echo "\n*** Testing realpath() on a non-existent file ***\n";
+var_dump( realpath(dirname(__FILE__)."/realpath_error.tmp") );
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing readlink(): error conditions ***
+
+Warning: Wrong parameter count for readlink() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for readlink() in %s on line %d
+NULL
+
+*** Testing readlink() on a non-existent link ***
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+
+*** Testing readlink() on existing file ***
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+
+*** Testing readlink() on existing directory ***
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+*** Testing realpath(): error conditions ***
+
+Warning: Wrong parameter count for realpath() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for realpath() in %s on line %d
+NULL
+
+*** Testing realpath() on a non-existent file ***
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test readlink() and realpath() functions: usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+ die('skip no symlinks on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string readlink ( string $path );
+ Description: Returns the target of a symbolic link
+
+ Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing readlink() and realpath() : usage variations ***\n";
+$name_prefix = dirname(__FILE__);
+$filename = "$name_prefix/readlink_realpath_variation/home/tests/link/readlink_realpath_variation.tmp";
+mkdir("$name_prefix/readlink_realpath_variation/home/tests/link/", 0777, true);
+
+echo "\n*** Testing readlink() and realpath() with linkname stored inside a object ***\n";
+// create a temp file
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+
+// creating object with members as linkname
+class object_temp {
+ public $linkname;
+ function object_temp($link) {
+ $this->linkname = $link;
+ }
+}
+$obj1 = new object_temp("$name_prefix/readlink_realpath_variation/../././readlink_realpath_variation/home/readlink_realpath_variation_link.tmp");
+$obj2 = new object_temp("$name_prefix/readlink_realpath_variation/home/../..///readlink_realpath_variation_link.tmp");
+
+echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an object --\n";
+// creating the links
+var_dump( symlink($filename, $obj1->linkname) );
+var_dump( readlink($obj1->linkname) );
+var_dump( realpath($obj1->linkname) );
+var_dump( symlink($filename, $obj2->linkname) );
+var_dump( readlink($obj2->linkname) );
+var_dump( realpath($obj2->linkname) );
+
+// deleting the link
+unlink($obj1->linkname);
+unlink($obj2->linkname);
+
+echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --\n";
+// creating hard links
+var_dump( link($filename, $obj1->linkname) );
+var_dump( readlink($obj1->linkname) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($obj1->linkname) );
+var_dump( link($filename, $obj2->linkname) );
+var_dump( readlink($obj2->linkname) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($obj2->linkname) );
+
+// delete the links
+unlink($obj1->linkname);
+unlink($obj2->linkname);
+
+echo "\n*** Testing readlink() and realpath() with linkname stored in an array ***\n";
+$link_arr = array (
+ "$name_prefix////readlink_realpath_variation/home/tests/link/readlink_realpath_variation_link.tmp",
+ "$name_prefix/./readlink_realpath_variation/home/../home//tests//..//..//..//home//readlink_realpath_variation_link.tmp/"
+);
+
+echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an array --\n";
+// creating the links
+var_dump( symlink($filename, $link_arr[0]) );
+var_dump( readlink($link_arr[0]) );
+var_dump( realpath($link_arr[0]) );
+var_dump( symlink($filename, $link_arr[1]) );
+var_dump( readlink($link_arr[1]) );
+var_dump( realpath($link_arr[1]) );
+
+// deleting the link
+unlink($link_arr[0]);
+unlink($link_arr[1]);
+
+echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --\n";
+// creating hard links
+var_dump( link($filename, $link_arr[0]) );
+var_dump( readlink($link_arr[0]) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($link_arr[0]) );
+var_dump( link($filename, $link_arr[1]) );
+var_dump( readlink($link_arr[1]) ); // invalid because readlink doesn't work with hardlink
+var_dump( realpath($link_arr[1]) );
+
+// delete the links
+unlink($link_arr[0]);
+unlink($link_arr[1]);
+
+echo "\n*** Testing readlink() and realpath() with linkname as empty string, NULL and single space ***\n";
+$link_string = array (
+ /* linkname as spaces */
+ " ",
+ ' ',
+
+ /* empty linkname */
+ "",
+ '',
+ NULL,
+ null
+ );
+for($loop_counter = 0; $loop_counter < count($link_string); $loop_counter++) {
+ echo "-- Iteration";
+ echo $loop_counter + 1;
+ echo " --\n";
+
+ var_dump( readlink($link_string[$loop_counter]) );
+ var_dump( realpath($link_string[$loop_counter]) );
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/readlink_realpath_variation";
+unlink("$name_prefix/home/tests/link/readlink_realpath_variation.tmp");
+rmdir("$name_prefix/home/tests/link/");
+rmdir("$name_prefix/home/tests/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing readlink() and realpath() : usage variations ***
+
+*** Testing readlink() and realpath() with linkname stored inside a object ***
+
+-- Testing readlink() and realpath() with softlink, linkname stored inside an object --
+bool(true)
+string(%d) "%s/readlink_realpath_variation/home/tests/link/readlink_realpath_variation.tmp"
+string(%d) "%s/readlink_realpath_variation/home/readlink_realpath_variation_link.tmp"
+bool(true)
+string(%d) "%s/readlink_realpath_variation/home/tests/link/readlink_realpath_variation.tmp"
+string(%d) "%s/readlink_realpath_variation_link.tmp"
+
+-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation/home/readlink_realpath_variation_link.tmp"
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation_link.tmp"
+
+*** Testing readlink() and realpath() with linkname stored in an array ***
+
+-- Testing readlink() and realpath() with softlink, linkname stored inside an array --
+bool(true)
+string(%d) "%s/readlink_realpath_variation/home/tests/link/readlink_realpath_variation.tmp"
+string(%d) "%s/readlink_realpath_variation/home/tests/link/readlink_realpath_variation_link.tmp"
+
+Warning: symlink(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s/home/readlink_realpath_variation_link.tmp"
+
+Warning: unlink(%s/./readlink_realpath_variation/home/../home//tests//..//..//..//home//readlink_realpath_variation_link.tmp/): No such file or directory in %s on line %d
+
+-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --
+bool(true)
+
+Warning: readlink(): Invalid argument in %s on line %d
+bool(false)
+string(%d) "%s/readlink_realpath_variation/home/tests/link/readlink_realpath_variation_link.tmp"
+
+Warning: link(): No such file or directory in %s on line %d
+bool(false)
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s/home/readlink_realpath_variation_link.tmp"
+
+Warning: unlink(%s/./readlink_realpath_variation/home/../home//tests//..//..//..//home//readlink_realpath_variation_link.tmp/): No such file or directory in %s on line %d
+
+*** Testing readlink() and realpath() with linkname as empty string, NULL and single space ***
+-- Iteration1 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+-- Iteration2 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+bool(false)
+-- Iteration3 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration4 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration5 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s"
+-- Iteration6 --
+
+Warning: readlink(): No such file or directory in %s on line %d
+bool(false)
+string(%d) "%s"
+Done
--- /dev/null
+--TEST--
+Test realpath() function: basic functionality
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "\n*** Testing basic functions of realpath() with files ***\n";
+
+/* creating directories and files */
+$file_path = dirname(__FILE__);
+mkdir("$file_path/realpath_basic/home/test/", 0777, true);
+
+$file_handle1 = fopen("$file_path/realpath_basic/home/test/realpath_basic.tmp", "w");
+$file_handle2 = fopen("$file_path/realpath_basic/home/realpath_basic.tmp", "w");
+$file_handle3 = fopen("$file_path/realpath_basic/realpath_basic.tmp", "w");
+fclose($file_handle1);
+fclose($file_handle2);
+fclose($file_handle3);
+
+echo "\n*** Testing realpath() on filenames ***\n";
+$filenames = array (
+ /* filenames resulting in valid paths */
+ "$file_path/realpath_basic/home/realpath_basic.tmp",
+ "$file_path/realpath_basic/realpath_basic.tmp/",
+ "$file_path/realpath_basic//home/test//../test/./realpath_basic.tmp",
+ "$file_path/realpath_basic/home//../././realpath_basic.tmp//",
+
+ /* filenames with invalid path */
+ // checking for binary safe
+ "$file_path/realpath_basicx000/home/realpath_basic.tmp",
+
+ "$file_path///realpath_basic/home//..//././test//realpath_basic.tmp",
+ "$file_path/realpath_basic/home/../home/../test/..realpath_basic.tmp"
+);
+
+$counter = 1;
+/* loop through $files to read the filepath of $file in the above array */
+foreach($filenames as $file) {
+ echo "\n-- Iteration $counter --\n";
+ var_dump( realpath($file) );
+ $counter++;
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_basic";
+unlink("$name_prefix/home/test/realpath_basic.tmp");
+unlink("$name_prefix/home/realpath_basic.tmp");
+unlink("$name_prefix/realpath_basic.tmp");
+rmdir("$name_prefix/home/test/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing basic functions of realpath() with files ***
+
+*** Testing realpath() on filenames ***
+
+-- Iteration 1 --
+string(%d) "%s\realpath_basic\home\realpath_basic.tmp"
+
+-- Iteration 2 --
+string(%d) "%s\realpath_basic\realpath_basic.tmp"
+
+-- Iteration 3 --
+string(%d) "%s\realpath_basic\home\test\realpath_basic.tmp"
+
+-- Iteration 4 --
+string(%d) "%s\realpath_basic\realpath_basic.tmp"
+
+-- Iteration 5 --
+bool(false)
+
+-- Iteration 6 --
+bool(false)
+
+-- Iteration 7 --
+bool(false)
+Done
--- /dev/null
+--TEST--
+Test realpath() function: error conditions
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+echo "*** Testing realpath() for error conditions ***\n";
+var_dump( realpath() ); // args < expected
+var_dump( realpath(1, 2) ); // args > expected
+
+echo "Done\n";
+?>
+--EXPECTF--
+*** Testing realpath() for error conditions ***
+
+Warning: Wrong parameter count for realpath() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for realpath() in %s on line %d
+NULL
+Done
--- /dev/null
+--TEST--
+Test realpath() function: usage variation
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip only on Windows');
+}
+?>/
+--FILE--
+<?php
+/* Prototype: string realpath ( string $path );
+ Description: Returns canonicalized absolute pathname
+*/
+
+require dirname(__FILE__).'/file.inc';
+
+echo "*** Testing realpath(): usage variations ***\n";
+$name_prefix = dirname(__FILE__);
+$filename = "$name_prefix/realpath_variation/home/tests/realpath_variation.tmp";
+mkdir("$name_prefix/realpath_variation/home/tests/", 0777, true);
+
+echo "\n*** Testing realpath() with filename stored inside a object ***\n";
+// create a temp file
+$file_handle = fopen($filename, "w");
+fclose($file_handle);
+
+// creating object with members as filename
+class object_temp {
+ public $filename;
+ function object_temp($file) {
+ $this->filename = $file;
+ }
+}
+$obj1 = new object_temp("$name_prefix/realpath_variation/../././realpath_variation/home/tests/realpath_variation.tmp");
+$obj2 = new object_temp("$name_prefix/realpath_variation/home/..///realpath_variation.tmp");
+
+var_dump( realpath($obj1->filename) );
+var_dump( realpath($obj2->filename) );
+
+echo "\n*** Testing realpath() with filename stored in an array ***\n";
+$file_arr = array (
+ "$name_prefix////realpath_variation/home/tests/realpath_variation.tmp",
+ "$name_prefix/./realpath_variation/home/../home//tests//..//..//..//home//realpath_variation.tmp/"
+);
+
+var_dump( realpath($file_arr[0]) );
+var_dump( realpath($file_arr[1]) );
+
+echo "\n*** Testing realpath() with filename as empty string, NULL and single space ***\n";
+$file_string = array (
+ /* filename as spaces */
+ " ",
+ ' ',
+
+ /* empty filename */
+ "",
+ '',
+ NULL,
+ null
+ );
+for($loop_counter = 0; $loop_counter < count($file_string); $loop_counter++) {
+ echo "-- Iteration";
+ echo $loop_counter + 1;
+ echo " --\n";
+ var_dump( realpath($file_string[$loop_counter]) );
+}
+
+echo "Done\n";
+?>
+--CLEAN--
+<?php
+$name_prefix = dirname(__FILE__)."/realpath_variation";
+unlink("$name_prefix/home/tests/realpath_variation.tmp");
+rmdir("$name_prefix/home/tests/");
+rmdir("$name_prefix/home/");
+rmdir("$name_prefix/");
+?>
+--EXPECTF--
+*** Testing realpath(): usage variations ***
+
+*** Testing realpath() with filename stored inside a object ***
+string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
+bool(false)
+
+*** Testing realpath() with filename stored in an array ***
+string(%d) "%s\realpath_variation\home\tests\realpath_variation.tmp"
+bool(false)
+
+*** Testing realpath() with filename as empty string, NULL and single space ***
+-- Iteration1 --
+bool(false)
+-- Iteration2 --
+bool(false)
+-- Iteration3 --
+string(%d) "%s"
+-- Iteration4 --
+string(%d) "%s"
+-- Iteration5 --
+string(%d) "%s"
+-- Iteration6 --
+string(%d) "%s"
+Done