flock_variation.phpt 6.4 KB

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