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