Create post-HADVAs expect files
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / fileinode_variation.php
blob57943ecefef44ab02d363ae1684b8f0329ccd1e2
1 <?hh
2 /*
3 * Prototype: int fileinode ( string $filename );
4 * Description: Returns the inode number of the file, or FALSE in case of an error.
5 */
6 <<__EntryPoint>> function main(): void {
7 echo "*** Testing fileinode() with files, links and directories ***\n";
8 $file1 = __SystemLib\hphp_test_tmppath('fileinode1_variation.tmp');
9 $file2 = __SystemLib\hphp_test_tmppath('fileinode2_variation.tmp');
10 $link1 = __SystemLib\hphp_test_tmppath('fileinode1_variation_link.tmp');
11 $link2 = __SystemLib\hphp_test_tmppath('fileinode2_variation_link.tmp');
14 echo "-- Testing with files --\n";
15 //creating the files
16 fclose( fopen( $file1, "w" ) );
17 fclose( fopen( $file2, "w" ) );
19 print( fileinode( $file1) )."\n";
20 print( fileinode( $file2) )."\n";
21 clearstatcache();
23 echo "-- Testing with links: hard link --\n";
24 link( $file1, $link1); // Creating an hard link
25 print( fileinode( $file1) )."\n";
26 clearstatcache();
27 print( fileinode( $link1) )."\n";
28 clearstatcache();
30 echo "-- Testing with links: soft link --\n";
31 symlink( $file2, $link2); // Creating a soft link
32 print( fileinode( $file2) )."\n";
33 clearstatcache();
34 print( fileinode( $link2) )."\n";
36 unlink( $link1 );
37 unlink( $link2 );
39 echo "-- Testing after copying a file --\n";
40 copy( $file1, __SystemLib\hphp_test_tmppath('fileinode1_variation_new.tmp'));
41 print( fileinode( $file1) )."\n";
42 clearstatcache();
43 print( fileinode( __SystemLib\hphp_test_tmppath('fileinode1_variation_new.tmp')) )."\n";
45 unlink( __SystemLib\hphp_test_tmppath('fileinode1_variation_new.tmp'));
46 unlink( $file1);
47 unlink( $file2);
50 echo "-- Testing after renaming the file --\n";
51 fclose( fopen(__SystemLib\hphp_test_tmppath('old.txt'), "w") );
52 print( fileinode(__SystemLib\hphp_test_tmppath('old.txt')) )."\n";
53 clearstatcache();
55 rename(
56 __SystemLib\hphp_test_tmppath('old.txt'),
57 __SystemLib\hphp_test_tmppath('new.txt')
59 print( fileinode(__SystemLib\hphp_test_tmppath('new.txt')) )."\n";
61 unlink(__SystemLib\hphp_test_tmppath('new.txt'));
63 echo "-- Testing with directories --\n";
64 mkdir(__SystemLib\hphp_test_tmppath('dir'));
65 print( fileinode(__SystemLib\hphp_test_tmppath('dir')) )."\n";
66 clearstatcache();
68 mkdir(__SystemLib\hphp_test_tmppath('dir/subdir'));
69 print( fileinode(__SystemLib\hphp_test_tmppath('dir/subdir')) )."\n";
70 clearstatcache();
72 echo "-- Testing with binary input --\n";
73 print( fileinode(__SystemLib\hphp_test_tmppath('dir')) )."\n";
74 clearstatcache();
75 print( fileinode(__SystemLib\hphp_test_tmppath('dir/subdir')) );
77 rmdir(__SystemLib\hphp_test_tmppath('dir/subdir'));
78 rmdir(__SystemLib\hphp_test_tmppath('dir'));
80 echo "\n*** Done ***";