1--TEST--
2Test lstat() and stat() functions: usage variations - effects of touch() on link
3--SKIPIF--
4<?php
5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6if (!(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
11exec("mount", $mount_output);
12foreach( $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__);
30require "$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
37fclose($fp);
38$link_name = "$file_path/lstat_stat_variation_link6.tmp";
39symlink($file_name, $link_name);  // temp link
40
41// touch a link, check stat, there should be difference in atime
42echo "*** Testing lstat() for link after using touch() on the link ***\n";
43$old_stat = lstat($link_name);
44sleep(2);
45
46// clear the cache
47clearstatcache();
48
49var_dump( touch($link_name) );
50
51$new_stat = stat($file_name);
52
53// compare self stats
54var_dump( compare_self_stat($old_stat) );
55var_dump( compare_self_stat($new_stat) );
56
57// compare the stat
58$affected_members = array(8, 'atime');
59var_dump( compare_stats($old_stat, $new_stat, $affected_members, "<") );
60// clear the stat
61clearstatcache();
62
63echo "\n--- Done ---";
64?>
65--CLEAN--
66<?php
67$file_path = dirname(__FILE__);
68unlink("$file_path/lstat_stat_variation6.tmp");
69unlink("$file_path/lstat_stat_variation_link6.tmp");
70?>
71--EXPECTF--
72*** Testing lstat() for link after using touch() on the link ***
73bool(true)
74bool(true)
75bool(true)
76bool(true)
77
78--- Done ---
79