Create post-HADVAs expect files
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / file / flock_variation.php
blob343f481367f0f8889db510cc85972691de2c815c
1 <?hh
2 /*
3 Prototype: bool flock(resource $handle, int $operation [, int &$wouldblock]);
4 Description: PHP supports a portable way of locking complete files
5 in an advisory way
6 */
7 <<__EntryPoint>> function main(): void {
8 echo "*** Testing flock() fun with the various operation and
9 wouldblock values ***\n";
10 $file = __SystemLib\hphp_test_tmppath('flock.tmp');
11 $fp = fopen($file, "w");
13 /* array of operatons */
14 $operations = varray[
15 LOCK_SH,
16 LOCK_EX,
17 LOCK_SH|LOCK_NB,
18 LOCK_EX|LOCK_NB,
19 LOCK_SH|LOCK_EX,
20 LOCK_UN,
23 2.234,
24 TRUE
27 /* array of wouldblocks */
28 $wouldblocks = varray[
32 1.234,
33 TRUE,
34 FALSE,
35 NULL,
36 varray[1,2,3],
37 varray[],
38 "string",
39 "",
40 /* binary input */
41 b"string",
42 b"",
43 "\0"
46 $i = 0;
47 foreach($operations as $operation) {
48 echo "--- Outer iteration $i ---\n";
49 $wouldblock = false;
50 var_dump(flock($fp, (int)$operation, inout $wouldblock));
51 $j = 0;
52 foreach($wouldblocks as $wouldblock) {
53 echo "-- Inner iteration $j in $i --\n";
54 var_dump(flock($fp, (int)$operation, inout $wouldblock));
55 $j++;
57 $i++;
60 fclose($fp);
61 @unlink($file);
63 echo "\n*** Done ***\n";