1--TEST--
2chmod() basic functionality
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6    die('skip Windows only chmod test');
7}
8?>
9--FILE--
10<?php
11
12define("PERMISSIONS_MASK", 0777);
13
14$filename = __FILE__ . "私はガラスを食べられます.tmp";
15
16$fd = fopen($filename, "w+");
17fclose($fd);
18
19for ($perms_to_set = 0777; $perms_to_set >= 0; $perms_to_set--) {
20	chmod($filename, $perms_to_set);
21	$set_perms = (fileperms($filename) & PERMISSIONS_MASK);
22	clearstatcache();
23	printf("Setting mode %o gives mode %o\n", $perms_to_set, $set_perms);
24}
25var_dump(chmod($filename, 0777));
26
27unlink($filename);
28echo "done";
29
30?>
31--EXPECT--
32Setting mode 777 gives mode 666
33Setting mode 776 gives mode 666
34Setting mode 775 gives mode 666
35Setting mode 774 gives mode 666
36Setting mode 773 gives mode 666
37Setting mode 772 gives mode 666
38Setting mode 771 gives mode 666
39Setting mode 770 gives mode 666
40Setting mode 767 gives mode 666
41Setting mode 766 gives mode 666
42Setting mode 765 gives mode 666
43Setting mode 764 gives mode 666
44Setting mode 763 gives mode 666
45Setting mode 762 gives mode 666
46Setting mode 761 gives mode 666
47Setting mode 760 gives mode 666
48Setting mode 757 gives mode 666
49Setting mode 756 gives mode 666
50Setting mode 755 gives mode 666
51Setting mode 754 gives mode 666
52Setting mode 753 gives mode 666
53Setting mode 752 gives mode 666
54Setting mode 751 gives mode 666
55Setting mode 750 gives mode 666
56Setting mode 747 gives mode 666
57Setting mode 746 gives mode 666
58Setting mode 745 gives mode 666
59Setting mode 744 gives mode 666
60Setting mode 743 gives mode 666
61Setting mode 742 gives mode 666
62Setting mode 741 gives mode 666
63Setting mode 740 gives mode 666
64Setting mode 737 gives mode 666
65Setting mode 736 gives mode 666
66Setting mode 735 gives mode 666
67Setting mode 734 gives mode 666
68Setting mode 733 gives mode 666
69Setting mode 732 gives mode 666
70Setting mode 731 gives mode 666
71Setting mode 730 gives mode 666
72Setting mode 727 gives mode 666
73Setting mode 726 gives mode 666
74Setting mode 725 gives mode 666
75Setting mode 724 gives mode 666
76Setting mode 723 gives mode 666
77Setting mode 722 gives mode 666
78Setting mode 721 gives mode 666
79Setting mode 720 gives mode 666
80Setting mode 717 gives mode 666
81Setting mode 716 gives mode 666
82Setting mode 715 gives mode 666
83Setting mode 714 gives mode 666
84Setting mode 713 gives mode 666
85Setting mode 712 gives mode 666
86Setting mode 711 gives mode 666
87Setting mode 710 gives mode 666
88Setting mode 707 gives mode 666
89Setting mode 706 gives mode 666
90Setting mode 705 gives mode 666
91Setting mode 704 gives mode 666
92Setting mode 703 gives mode 666
93Setting mode 702 gives mode 666
94Setting mode 701 gives mode 666
95Setting mode 700 gives mode 666
96Setting mode 677 gives mode 666
97Setting mode 676 gives mode 666
98Setting mode 675 gives mode 666
99Setting mode 674 gives mode 666
100Setting mode 673 gives mode 666
101Setting mode 672 gives mode 666
102Setting mode 671 gives mode 666
103Setting mode 670 gives mode 666
104Setting mode 667 gives mode 666
105Setting mode 666 gives mode 666
106Setting mode 665 gives mode 666
107Setting mode 664 gives mode 666
108Setting mode 663 gives mode 666
109Setting mode 662 gives mode 666
110Setting mode 661 gives mode 666
111Setting mode 660 gives mode 666
112Setting mode 657 gives mode 666
113Setting mode 656 gives mode 666
114Setting mode 655 gives mode 666
115Setting mode 654 gives mode 666
116Setting mode 653 gives mode 666
117Setting mode 652 gives mode 666
118Setting mode 651 gives mode 666
119Setting mode 650 gives mode 666
120Setting mode 647 gives mode 666
121Setting mode 646 gives mode 666
122Setting mode 645 gives mode 666
123Setting mode 644 gives mode 666
124Setting mode 643 gives mode 666
125Setting mode 642 gives mode 666
126Setting mode 641 gives mode 666
127Setting mode 640 gives mode 666
128Setting mode 637 gives mode 666
129Setting mode 636 gives mode 666
130Setting mode 635 gives mode 666
131Setting mode 634 gives mode 666
132Setting mode 633 gives mode 666
133Setting mode 632 gives mode 666
134Setting mode 631 gives mode 666
135Setting mode 630 gives mode 666
136Setting mode 627 gives mode 666
137Setting mode 626 gives mode 666
138Setting mode 625 gives mode 666
139Setting mode 624 gives mode 666
140Setting mode 623 gives mode 666
141Setting mode 622 gives mode 666
142Setting mode 621 gives mode 666
143Setting mode 620 gives mode 666
144Setting mode 617 gives mode 666
145Setting mode 616 gives mode 666
146Setting mode 615 gives mode 666
147Setting mode 614 gives mode 666
148Setting mode 613 gives mode 666
149Setting mode 612 gives mode 666
150Setting mode 611 gives mode 666
151Setting mode 610 gives mode 666
152Setting mode 607 gives mode 666
153Setting mode 606 gives mode 666
154Setting mode 605 gives mode 666
155Setting mode 604 gives mode 666
156Setting mode 603 gives mode 666
157Setting mode 602 gives mode 666
158Setting mode 601 gives mode 666
159Setting mode 600 gives mode 666
160Setting mode 577 gives mode 444
161Setting mode 576 gives mode 444
162Setting mode 575 gives mode 444
163Setting mode 574 gives mode 444
164Setting mode 573 gives mode 444
165Setting mode 572 gives mode 444
166Setting mode 571 gives mode 444
167Setting mode 570 gives mode 444
168Setting mode 567 gives mode 444
169Setting mode 566 gives mode 444
170Setting mode 565 gives mode 444
171Setting mode 564 gives mode 444
172Setting mode 563 gives mode 444
173Setting mode 562 gives mode 444
174Setting mode 561 gives mode 444
175Setting mode 560 gives mode 444
176Setting mode 557 gives mode 444
177Setting mode 556 gives mode 444
178Setting mode 555 gives mode 444
179Setting mode 554 gives mode 444
180Setting mode 553 gives mode 444
181Setting mode 552 gives mode 444
182Setting mode 551 gives mode 444
183Setting mode 550 gives mode 444
184Setting mode 547 gives mode 444
185Setting mode 546 gives mode 444
186Setting mode 545 gives mode 444
187Setting mode 544 gives mode 444
188Setting mode 543 gives mode 444
189Setting mode 542 gives mode 444
190Setting mode 541 gives mode 444
191Setting mode 540 gives mode 444
192Setting mode 537 gives mode 444
193Setting mode 536 gives mode 444
194Setting mode 535 gives mode 444
195Setting mode 534 gives mode 444
196Setting mode 533 gives mode 444
197Setting mode 532 gives mode 444
198Setting mode 531 gives mode 444
199Setting mode 530 gives mode 444
200Setting mode 527 gives mode 444
201Setting mode 526 gives mode 444
202Setting mode 525 gives mode 444
203Setting mode 524 gives mode 444
204Setting mode 523 gives mode 444
205Setting mode 522 gives mode 444
206Setting mode 521 gives mode 444
207Setting mode 520 gives mode 444
208Setting mode 517 gives mode 444
209Setting mode 516 gives mode 444
210Setting mode 515 gives mode 444
211Setting mode 514 gives mode 444
212Setting mode 513 gives mode 444
213Setting mode 512 gives mode 444
214Setting mode 511 gives mode 444
215Setting mode 510 gives mode 444
216Setting mode 507 gives mode 444
217Setting mode 506 gives mode 444
218Setting mode 505 gives mode 444
219Setting mode 504 gives mode 444
220Setting mode 503 gives mode 444
221Setting mode 502 gives mode 444
222Setting mode 501 gives mode 444
223Setting mode 500 gives mode 444
224Setting mode 477 gives mode 444
225Setting mode 476 gives mode 444
226Setting mode 475 gives mode 444
227Setting mode 474 gives mode 444
228Setting mode 473 gives mode 444
229Setting mode 472 gives mode 444
230Setting mode 471 gives mode 444
231Setting mode 470 gives mode 444
232Setting mode 467 gives mode 444
233Setting mode 466 gives mode 444
234Setting mode 465 gives mode 444
235Setting mode 464 gives mode 444
236Setting mode 463 gives mode 444
237Setting mode 462 gives mode 444
238Setting mode 461 gives mode 444
239Setting mode 460 gives mode 444
240Setting mode 457 gives mode 444
241Setting mode 456 gives mode 444
242Setting mode 455 gives mode 444
243Setting mode 454 gives mode 444
244Setting mode 453 gives mode 444
245Setting mode 452 gives mode 444
246Setting mode 451 gives mode 444
247Setting mode 450 gives mode 444
248Setting mode 447 gives mode 444
249Setting mode 446 gives mode 444
250Setting mode 445 gives mode 444
251Setting mode 444 gives mode 444
252Setting mode 443 gives mode 444
253Setting mode 442 gives mode 444
254Setting mode 441 gives mode 444
255Setting mode 440 gives mode 444
256Setting mode 437 gives mode 444
257Setting mode 436 gives mode 444
258Setting mode 435 gives mode 444
259Setting mode 434 gives mode 444
260Setting mode 433 gives mode 444
261Setting mode 432 gives mode 444
262Setting mode 431 gives mode 444
263Setting mode 430 gives mode 444
264Setting mode 427 gives mode 444
265Setting mode 426 gives mode 444
266Setting mode 425 gives mode 444
267Setting mode 424 gives mode 444
268Setting mode 423 gives mode 444
269Setting mode 422 gives mode 444
270Setting mode 421 gives mode 444
271Setting mode 420 gives mode 444
272Setting mode 417 gives mode 444
273Setting mode 416 gives mode 444
274Setting mode 415 gives mode 444
275Setting mode 414 gives mode 444
276Setting mode 413 gives mode 444
277Setting mode 412 gives mode 444
278Setting mode 411 gives mode 444
279Setting mode 410 gives mode 444
280Setting mode 407 gives mode 444
281Setting mode 406 gives mode 444
282Setting mode 405 gives mode 444
283Setting mode 404 gives mode 444
284Setting mode 403 gives mode 444
285Setting mode 402 gives mode 444
286Setting mode 401 gives mode 444
287Setting mode 400 gives mode 444
288Setting mode 377 gives mode 666
289Setting mode 376 gives mode 666
290Setting mode 375 gives mode 666
291Setting mode 374 gives mode 666
292Setting mode 373 gives mode 666
293Setting mode 372 gives mode 666
294Setting mode 371 gives mode 666
295Setting mode 370 gives mode 666
296Setting mode 367 gives mode 666
297Setting mode 366 gives mode 666
298Setting mode 365 gives mode 666
299Setting mode 364 gives mode 666
300Setting mode 363 gives mode 666
301Setting mode 362 gives mode 666
302Setting mode 361 gives mode 666
303Setting mode 360 gives mode 666
304Setting mode 357 gives mode 666
305Setting mode 356 gives mode 666
306Setting mode 355 gives mode 666
307Setting mode 354 gives mode 666
308Setting mode 353 gives mode 666
309Setting mode 352 gives mode 666
310Setting mode 351 gives mode 666
311Setting mode 350 gives mode 666
312Setting mode 347 gives mode 666
313Setting mode 346 gives mode 666
314Setting mode 345 gives mode 666
315Setting mode 344 gives mode 666
316Setting mode 343 gives mode 666
317Setting mode 342 gives mode 666
318Setting mode 341 gives mode 666
319Setting mode 340 gives mode 666
320Setting mode 337 gives mode 666
321Setting mode 336 gives mode 666
322Setting mode 335 gives mode 666
323Setting mode 334 gives mode 666
324Setting mode 333 gives mode 666
325Setting mode 332 gives mode 666
326Setting mode 331 gives mode 666
327Setting mode 330 gives mode 666
328Setting mode 327 gives mode 666
329Setting mode 326 gives mode 666
330Setting mode 325 gives mode 666
331Setting mode 324 gives mode 666
332Setting mode 323 gives mode 666
333Setting mode 322 gives mode 666
334Setting mode 321 gives mode 666
335Setting mode 320 gives mode 666
336Setting mode 317 gives mode 666
337Setting mode 316 gives mode 666
338Setting mode 315 gives mode 666
339Setting mode 314 gives mode 666
340Setting mode 313 gives mode 666
341Setting mode 312 gives mode 666
342Setting mode 311 gives mode 666
343Setting mode 310 gives mode 666
344Setting mode 307 gives mode 666
345Setting mode 306 gives mode 666
346Setting mode 305 gives mode 666
347Setting mode 304 gives mode 666
348Setting mode 303 gives mode 666
349Setting mode 302 gives mode 666
350Setting mode 301 gives mode 666
351Setting mode 300 gives mode 666
352Setting mode 277 gives mode 666
353Setting mode 276 gives mode 666
354Setting mode 275 gives mode 666
355Setting mode 274 gives mode 666
356Setting mode 273 gives mode 666
357Setting mode 272 gives mode 666
358Setting mode 271 gives mode 666
359Setting mode 270 gives mode 666
360Setting mode 267 gives mode 666
361Setting mode 266 gives mode 666
362Setting mode 265 gives mode 666
363Setting mode 264 gives mode 666
364Setting mode 263 gives mode 666
365Setting mode 262 gives mode 666
366Setting mode 261 gives mode 666
367Setting mode 260 gives mode 666
368Setting mode 257 gives mode 666
369Setting mode 256 gives mode 666
370Setting mode 255 gives mode 666
371Setting mode 254 gives mode 666
372Setting mode 253 gives mode 666
373Setting mode 252 gives mode 666
374Setting mode 251 gives mode 666
375Setting mode 250 gives mode 666
376Setting mode 247 gives mode 666
377Setting mode 246 gives mode 666
378Setting mode 245 gives mode 666
379Setting mode 244 gives mode 666
380Setting mode 243 gives mode 666
381Setting mode 242 gives mode 666
382Setting mode 241 gives mode 666
383Setting mode 240 gives mode 666
384Setting mode 237 gives mode 666
385Setting mode 236 gives mode 666
386Setting mode 235 gives mode 666
387Setting mode 234 gives mode 666
388Setting mode 233 gives mode 666
389Setting mode 232 gives mode 666
390Setting mode 231 gives mode 666
391Setting mode 230 gives mode 666
392Setting mode 227 gives mode 666
393Setting mode 226 gives mode 666
394Setting mode 225 gives mode 666
395Setting mode 224 gives mode 666
396Setting mode 223 gives mode 666
397Setting mode 222 gives mode 666
398Setting mode 221 gives mode 666
399Setting mode 220 gives mode 666
400Setting mode 217 gives mode 666
401Setting mode 216 gives mode 666
402Setting mode 215 gives mode 666
403Setting mode 214 gives mode 666
404Setting mode 213 gives mode 666
405Setting mode 212 gives mode 666
406Setting mode 211 gives mode 666
407Setting mode 210 gives mode 666
408Setting mode 207 gives mode 666
409Setting mode 206 gives mode 666
410Setting mode 205 gives mode 666
411Setting mode 204 gives mode 666
412Setting mode 203 gives mode 666
413Setting mode 202 gives mode 666
414Setting mode 201 gives mode 666
415Setting mode 200 gives mode 666
416Setting mode 177 gives mode 444
417Setting mode 176 gives mode 444
418Setting mode 175 gives mode 444
419Setting mode 174 gives mode 444
420Setting mode 173 gives mode 444
421Setting mode 172 gives mode 444
422Setting mode 171 gives mode 444
423Setting mode 170 gives mode 444
424Setting mode 167 gives mode 444
425Setting mode 166 gives mode 444
426Setting mode 165 gives mode 444
427Setting mode 164 gives mode 444
428Setting mode 163 gives mode 444
429Setting mode 162 gives mode 444
430Setting mode 161 gives mode 444
431Setting mode 160 gives mode 444
432Setting mode 157 gives mode 444
433Setting mode 156 gives mode 444
434Setting mode 155 gives mode 444
435Setting mode 154 gives mode 444
436Setting mode 153 gives mode 444
437Setting mode 152 gives mode 444
438Setting mode 151 gives mode 444
439Setting mode 150 gives mode 444
440Setting mode 147 gives mode 444
441Setting mode 146 gives mode 444
442Setting mode 145 gives mode 444
443Setting mode 144 gives mode 444
444Setting mode 143 gives mode 444
445Setting mode 142 gives mode 444
446Setting mode 141 gives mode 444
447Setting mode 140 gives mode 444
448Setting mode 137 gives mode 444
449Setting mode 136 gives mode 444
450Setting mode 135 gives mode 444
451Setting mode 134 gives mode 444
452Setting mode 133 gives mode 444
453Setting mode 132 gives mode 444
454Setting mode 131 gives mode 444
455Setting mode 130 gives mode 444
456Setting mode 127 gives mode 444
457Setting mode 126 gives mode 444
458Setting mode 125 gives mode 444
459Setting mode 124 gives mode 444
460Setting mode 123 gives mode 444
461Setting mode 122 gives mode 444
462Setting mode 121 gives mode 444
463Setting mode 120 gives mode 444
464Setting mode 117 gives mode 444
465Setting mode 116 gives mode 444
466Setting mode 115 gives mode 444
467Setting mode 114 gives mode 444
468Setting mode 113 gives mode 444
469Setting mode 112 gives mode 444
470Setting mode 111 gives mode 444
471Setting mode 110 gives mode 444
472Setting mode 107 gives mode 444
473Setting mode 106 gives mode 444
474Setting mode 105 gives mode 444
475Setting mode 104 gives mode 444
476Setting mode 103 gives mode 444
477Setting mode 102 gives mode 444
478Setting mode 101 gives mode 444
479Setting mode 100 gives mode 444
480Setting mode 77 gives mode 444
481Setting mode 76 gives mode 444
482Setting mode 75 gives mode 444
483Setting mode 74 gives mode 444
484Setting mode 73 gives mode 444
485Setting mode 72 gives mode 444
486Setting mode 71 gives mode 444
487Setting mode 70 gives mode 444
488Setting mode 67 gives mode 444
489Setting mode 66 gives mode 444
490Setting mode 65 gives mode 444
491Setting mode 64 gives mode 444
492Setting mode 63 gives mode 444
493Setting mode 62 gives mode 444
494Setting mode 61 gives mode 444
495Setting mode 60 gives mode 444
496Setting mode 57 gives mode 444
497Setting mode 56 gives mode 444
498Setting mode 55 gives mode 444
499Setting mode 54 gives mode 444
500Setting mode 53 gives mode 444
501Setting mode 52 gives mode 444
502Setting mode 51 gives mode 444
503Setting mode 50 gives mode 444
504Setting mode 47 gives mode 444
505Setting mode 46 gives mode 444
506Setting mode 45 gives mode 444
507Setting mode 44 gives mode 444
508Setting mode 43 gives mode 444
509Setting mode 42 gives mode 444
510Setting mode 41 gives mode 444
511Setting mode 40 gives mode 444
512Setting mode 37 gives mode 444
513Setting mode 36 gives mode 444
514Setting mode 35 gives mode 444
515Setting mode 34 gives mode 444
516Setting mode 33 gives mode 444
517Setting mode 32 gives mode 444
518Setting mode 31 gives mode 444
519Setting mode 30 gives mode 444
520Setting mode 27 gives mode 444
521Setting mode 26 gives mode 444
522Setting mode 25 gives mode 444
523Setting mode 24 gives mode 444
524Setting mode 23 gives mode 444
525Setting mode 22 gives mode 444
526Setting mode 21 gives mode 444
527Setting mode 20 gives mode 444
528Setting mode 17 gives mode 444
529Setting mode 16 gives mode 444
530Setting mode 15 gives mode 444
531Setting mode 14 gives mode 444
532Setting mode 13 gives mode 444
533Setting mode 12 gives mode 444
534Setting mode 11 gives mode 444
535Setting mode 10 gives mode 444
536Setting mode 7 gives mode 444
537Setting mode 6 gives mode 444
538Setting mode 5 gives mode 444
539Setting mode 4 gives mode 444
540Setting mode 3 gives mode 444
541Setting mode 2 gives mode 444
542Setting mode 1 gives mode 444
543Setting mode 0 gives mode 444
544bool(true)
545done
546