1--TEST--
2pcntl_getcpuaffinity() and pcntl_setcpuaffinity()
3--EXTENSIONS--
4pcntl
5--SKIPIF--
6<?php
7if (!function_exists("pcntl_setcpuaffinity")) die("skip pcntl_setcpuaffinity is not available");
8?>
9--FILE--
10<?php
11$mask = [0, 1];
12var_dump(pcntl_setcpuaffinity(null, $mask));
13$act_mask = pcntl_getcpuaffinity();
14var_dump(array_diff($mask, $act_mask));
15$n_act_mask = pcntl_getcpuaffinity();
16var_dump(array_diff($act_mask, $n_act_mask));
17var_dump(pcntl_setcpuaffinity(null, ["0", "1"]));
18
19try {
20	pcntl_setcpuaffinity(null, []);
21} catch (\ValueError $e) {
22	echo $e->getMessage() . PHP_EOL;
23}
24
25try {
26	pcntl_setcpuaffinity(null, ["abc" => "def", 0 => "cpuid"]);
27} catch (\ValueError $e) {
28	echo $e->getMessage() . PHP_EOL;
29}
30
31try {
32	pcntl_setcpuaffinity(null, [PHP_INT_MAX]);
33} catch (\ValueError $e) {
34	echo $e->getMessage() . PHP_EOL;
35}
36
37try {
38	pcntl_setcpuaffinity(null, [-1024, 64, -2]);
39} catch (\ValueError $e) {
40	echo $e->getMessage() . PHP_EOL;
41}
42
43try {
44	pcntl_getcpuaffinity(-1024);
45} catch (\ValueError $e) {
46	echo $e->getMessage() . PHP_EOL;
47}
48
49try {
50	pcntl_setcpuaffinity(null, [1, array(1)]);
51} catch (\ValueError $e) {
52	echo $e->getMessage();
53}
54?>
55--EXPECTF--
56bool(true)
57array(0) {
58}
59array(0) {
60}
61bool(true)
62pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) must not be empty
63pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id invalid value (def)
64pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id must be between 0 and %d (%d)
65pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id must be between 0 and %d (-1024)
66pcntl_getcpuaffinity(): Argument #1 ($process_id) invalid process (-1024)
67
68Warning: Array to string conversion in %s on line %d
69pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id invalid type (Array)
70