Annotation of embedaddon/php/ext/standard/tests/file/lstat_stat_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test lstat() and stat() functions: usage variations - effects of touch() on link
3: --SKIPIF--
4: <?php
5: if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6: if (!(stristr(PHP_OS, 'linux'))) {
7: die('skip.. test valid for linux only');
8: }
9:
10: // checking for atime update whether it is enabled or disabled
11: exec("mount", $mount_output);
12: foreach( $mount_output as $out ) {
13: if( stristr($out, "noatime") )
14: die('skip.. atime update is disabled, hence skip the test');
15: }
16:
17: ?>
18: --FILE--
19: <?php
20: /* Prototype: array lstat ( string $filename );
21: Description: Gives information about a file or symbolic link
22:
23: Prototype: array stat ( string $filename );
24: Description: Gives information about a file
25: */
26:
27: /* test the effects of touch() on stats of link */
28:
29: $file_path = dirname(__FILE__);
30: require "$file_path/file.inc";
31:
32:
33: /* create temp file, link and directory */
34:
35: $file_name = "$file_path/lstat_stat_variation6.tmp";
36: $fp = fopen($file_name, "w"); // temp file
37: fclose($fp);
38: $link_name = "$file_path/lstat_stat_variation_link6.tmp";
39: symlink($file_name, $link_name); // temp link
40:
41: // touch a link, check stat, there should be difference in atime
42: echo "*** Testing lstat() for link after using touch() on the link ***\n";
43: $old_stat = lstat($link_name);
44: sleep(2);
45:
46: // clear the cache
47: clearstatcache();
48:
49: var_dump( touch($link_name) );
50:
51: $new_stat = stat($file_name);
52:
53: // compare self stats
54: var_dump( compare_self_stat($old_stat) );
55: var_dump( compare_self_stat($new_stat) );
56:
57: // compare the stat
58: $affected_members = array(8, 'atime');
59: var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
60: // clear the stat
61: clearstatcache();
62:
63: echo "\n--- Done ---";
64: ?>
65:
66: --CLEAN--
67: <?php
68: $file_path = dirname(__FILE__);
69: unlink("$file_path/lstat_stat_variation6.tmp");
70: unlink("$file_path/lstat_stat_variation_link6.tmp");
71: ?>
72: --EXPECTF--
73: *** Testing lstat() for link after using touch() on the link ***
74: bool(true)
75: bool(true)
76: bool(true)
77: bool(true)
78:
79: --- Done ---
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>