1--TEST--
2Test flock() function: Variations
3--FILE--
4<?php
5echo "*** Testing flock() fun with the various operation and
6    wouldblock values                                ***\n";
7
8$file = preg_replace("~\.phpt?$~", '', __FILE__);
9$fp = fopen($file, "w");
10
11/* array of operations */
12$operations = array(
13  LOCK_SH,
14  LOCK_EX,
15  LOCK_SH|LOCK_NB,
16  LOCK_EX|LOCK_NB,
17  LOCK_SH|LOCK_EX,
18  LOCK_UN,
19  1,
20  2,
21  TRUE
22);
23
24/* array of wouldblocks */
25$wouldblocks = array(
26  0,
27  1,
28  2,
29  1.234,
30  TRUE,
31  FALSE,
32  NULL,
33  array(1,2,3),
34  array(),
35  "string",
36  "",
37  /* binary input */
38  b"string",
39  b"",
40  "\0"
41);
42
43$i = 0;
44foreach($operations as $operation) {
45  echo "--- Outer iteration $i ---\n";
46  var_dump(flock($fp, $operation));
47  $j = 0;
48  foreach($wouldblocks as $wouldblock) {
49    echo "-- Inner iteration $j in $i --\n";
50    var_dump(flock($fp, $operation, $wouldblock));
51    $j++;
52  }
53  $i++;
54}
55
56fclose($fp);
57@unlink($file);
58
59echo "\n*** Done ***\n";
60?>
61--EXPECT--
62*** Testing flock() fun with the various operation and
63    wouldblock values                                ***
64--- Outer iteration 0 ---
65bool(true)
66-- Inner iteration 0 in 0 --
67bool(true)
68-- Inner iteration 1 in 0 --
69bool(true)
70-- Inner iteration 2 in 0 --
71bool(true)
72-- Inner iteration 3 in 0 --
73bool(true)
74-- Inner iteration 4 in 0 --
75bool(true)
76-- Inner iteration 5 in 0 --
77bool(true)
78-- Inner iteration 6 in 0 --
79bool(true)
80-- Inner iteration 7 in 0 --
81bool(true)
82-- Inner iteration 8 in 0 --
83bool(true)
84-- Inner iteration 9 in 0 --
85bool(true)
86-- Inner iteration 10 in 0 --
87bool(true)
88-- Inner iteration 11 in 0 --
89bool(true)
90-- Inner iteration 12 in 0 --
91bool(true)
92-- Inner iteration 13 in 0 --
93bool(true)
94--- Outer iteration 1 ---
95bool(true)
96-- Inner iteration 0 in 1 --
97bool(true)
98-- Inner iteration 1 in 1 --
99bool(true)
100-- Inner iteration 2 in 1 --
101bool(true)
102-- Inner iteration 3 in 1 --
103bool(true)
104-- Inner iteration 4 in 1 --
105bool(true)
106-- Inner iteration 5 in 1 --
107bool(true)
108-- Inner iteration 6 in 1 --
109bool(true)
110-- Inner iteration 7 in 1 --
111bool(true)
112-- Inner iteration 8 in 1 --
113bool(true)
114-- Inner iteration 9 in 1 --
115bool(true)
116-- Inner iteration 10 in 1 --
117bool(true)
118-- Inner iteration 11 in 1 --
119bool(true)
120-- Inner iteration 12 in 1 --
121bool(true)
122-- Inner iteration 13 in 1 --
123bool(true)
124--- Outer iteration 2 ---
125bool(true)
126-- Inner iteration 0 in 2 --
127bool(true)
128-- Inner iteration 1 in 2 --
129bool(true)
130-- Inner iteration 2 in 2 --
131bool(true)
132-- Inner iteration 3 in 2 --
133bool(true)
134-- Inner iteration 4 in 2 --
135bool(true)
136-- Inner iteration 5 in 2 --
137bool(true)
138-- Inner iteration 6 in 2 --
139bool(true)
140-- Inner iteration 7 in 2 --
141bool(true)
142-- Inner iteration 8 in 2 --
143bool(true)
144-- Inner iteration 9 in 2 --
145bool(true)
146-- Inner iteration 10 in 2 --
147bool(true)
148-- Inner iteration 11 in 2 --
149bool(true)
150-- Inner iteration 12 in 2 --
151bool(true)
152-- Inner iteration 13 in 2 --
153bool(true)
154--- Outer iteration 3 ---
155bool(true)
156-- Inner iteration 0 in 3 --
157bool(true)
158-- Inner iteration 1 in 3 --
159bool(true)
160-- Inner iteration 2 in 3 --
161bool(true)
162-- Inner iteration 3 in 3 --
163bool(true)
164-- Inner iteration 4 in 3 --
165bool(true)
166-- Inner iteration 5 in 3 --
167bool(true)
168-- Inner iteration 6 in 3 --
169bool(true)
170-- Inner iteration 7 in 3 --
171bool(true)
172-- Inner iteration 8 in 3 --
173bool(true)
174-- Inner iteration 9 in 3 --
175bool(true)
176-- Inner iteration 10 in 3 --
177bool(true)
178-- Inner iteration 11 in 3 --
179bool(true)
180-- Inner iteration 12 in 3 --
181bool(true)
182-- Inner iteration 13 in 3 --
183bool(true)
184--- Outer iteration 4 ---
185bool(true)
186-- Inner iteration 0 in 4 --
187bool(true)
188-- Inner iteration 1 in 4 --
189bool(true)
190-- Inner iteration 2 in 4 --
191bool(true)
192-- Inner iteration 3 in 4 --
193bool(true)
194-- Inner iteration 4 in 4 --
195bool(true)
196-- Inner iteration 5 in 4 --
197bool(true)
198-- Inner iteration 6 in 4 --
199bool(true)
200-- Inner iteration 7 in 4 --
201bool(true)
202-- Inner iteration 8 in 4 --
203bool(true)
204-- Inner iteration 9 in 4 --
205bool(true)
206-- Inner iteration 10 in 4 --
207bool(true)
208-- Inner iteration 11 in 4 --
209bool(true)
210-- Inner iteration 12 in 4 --
211bool(true)
212-- Inner iteration 13 in 4 --
213bool(true)
214--- Outer iteration 5 ---
215bool(true)
216-- Inner iteration 0 in 5 --
217bool(true)
218-- Inner iteration 1 in 5 --
219bool(true)
220-- Inner iteration 2 in 5 --
221bool(true)
222-- Inner iteration 3 in 5 --
223bool(true)
224-- Inner iteration 4 in 5 --
225bool(true)
226-- Inner iteration 5 in 5 --
227bool(true)
228-- Inner iteration 6 in 5 --
229bool(true)
230-- Inner iteration 7 in 5 --
231bool(true)
232-- Inner iteration 8 in 5 --
233bool(true)
234-- Inner iteration 9 in 5 --
235bool(true)
236-- Inner iteration 10 in 5 --
237bool(true)
238-- Inner iteration 11 in 5 --
239bool(true)
240-- Inner iteration 12 in 5 --
241bool(true)
242-- Inner iteration 13 in 5 --
243bool(true)
244--- Outer iteration 6 ---
245bool(true)
246-- Inner iteration 0 in 6 --
247bool(true)
248-- Inner iteration 1 in 6 --
249bool(true)
250-- Inner iteration 2 in 6 --
251bool(true)
252-- Inner iteration 3 in 6 --
253bool(true)
254-- Inner iteration 4 in 6 --
255bool(true)
256-- Inner iteration 5 in 6 --
257bool(true)
258-- Inner iteration 6 in 6 --
259bool(true)
260-- Inner iteration 7 in 6 --
261bool(true)
262-- Inner iteration 8 in 6 --
263bool(true)
264-- Inner iteration 9 in 6 --
265bool(true)
266-- Inner iteration 10 in 6 --
267bool(true)
268-- Inner iteration 11 in 6 --
269bool(true)
270-- Inner iteration 12 in 6 --
271bool(true)
272-- Inner iteration 13 in 6 --
273bool(true)
274--- Outer iteration 7 ---
275bool(true)
276-- Inner iteration 0 in 7 --
277bool(true)
278-- Inner iteration 1 in 7 --
279bool(true)
280-- Inner iteration 2 in 7 --
281bool(true)
282-- Inner iteration 3 in 7 --
283bool(true)
284-- Inner iteration 4 in 7 --
285bool(true)
286-- Inner iteration 5 in 7 --
287bool(true)
288-- Inner iteration 6 in 7 --
289bool(true)
290-- Inner iteration 7 in 7 --
291bool(true)
292-- Inner iteration 8 in 7 --
293bool(true)
294-- Inner iteration 9 in 7 --
295bool(true)
296-- Inner iteration 10 in 7 --
297bool(true)
298-- Inner iteration 11 in 7 --
299bool(true)
300-- Inner iteration 12 in 7 --
301bool(true)
302-- Inner iteration 13 in 7 --
303bool(true)
304--- Outer iteration 8 ---
305bool(true)
306-- Inner iteration 0 in 8 --
307bool(true)
308-- Inner iteration 1 in 8 --
309bool(true)
310-- Inner iteration 2 in 8 --
311bool(true)
312-- Inner iteration 3 in 8 --
313bool(true)
314-- Inner iteration 4 in 8 --
315bool(true)
316-- Inner iteration 5 in 8 --
317bool(true)
318-- Inner iteration 6 in 8 --
319bool(true)
320-- Inner iteration 7 in 8 --
321bool(true)
322-- Inner iteration 8 in 8 --
323bool(true)
324-- Inner iteration 9 in 8 --
325bool(true)
326-- Inner iteration 10 in 8 --
327bool(true)
328-- Inner iteration 11 in 8 --
329bool(true)
330-- Inner iteration 12 in 8 --
331bool(true)
332-- Inner iteration 13 in 8 --
333bool(true)
334
335*** Done ***
336