xref: /PHP-7.1/ext/sysvmsg/tests/004.phpt (revision 3be50a26)
1--TEST--
2msg_set_queue() and msg_stat_queue()
3--SKIPIF--
4<?php if (!extension_loaded("sysvmsg")) die("skip sysvmsg extension is not available")?>
5--FILE--
6<?php
7$id = ftok(__FILE__, 'r');
8
9$q = msg_get_queue($id);
10
11echo "Set mode:\n";
12$arr = array('msg_perm.mode' => 0600);
13var_dump(msg_set_queue($q, $arr));
14echo "Did really work:\n";
15var_dump(count(array_diff_assoc($arr, msg_stat_queue($q))) == 0);
16
17echo "Set uid:\n"; // same as the running user to make it succeed
18$arr = array('msg_perm.uid' => getmyuid());
19var_dump(msg_set_queue($q, $arr));
20echo "Did really work:\n";
21var_dump(count(array_diff_assoc($arr, msg_stat_queue($q))) == 0);
22
23echo "Set gid:\n"; // same as the running user to make it succeed
24$arr = array('msg_perm.gid' => getmygid());
25var_dump(msg_set_queue($q, $arr));
26echo "Did really work:\n";
27var_dump(count(array_diff_assoc($arr, msg_stat_queue($q))) == 0);
28
29echo "Set smaller qbytes:\n";
30$res = msg_stat_queue($q);
31$arr = array('msg_qbytes' => ($res['msg_qbytes'] -1));
32var_dump(msg_set_queue($q, $arr));
33echo "Did really work:\n";
34var_dump(count(array_diff_assoc($arr, msg_stat_queue($q))) == 0);
35
36if (!msg_remove_queue($q)) {
37        echo "BAD: queue removal failed\n";
38}
39
40echo "Done\n";
41?>
42--EXPECTF--
43Set mode:
44bool(true)
45Did really work:
46bool(true)
47Set uid:
48bool(true)
49Did really work:
50bool(true)
51Set gid:
52bool(true)
53Did really work:
54bool(true)
55Set smaller qbytes:
56bool(true)
57Did really work:
58bool(true)
59Done
60