1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
--TEST--
shmop extension error messages
--CREDITS--
edgarsandi - <edgar.r.sandi@gmail.com>
--SKIPIF--
<?php
if (!extension_loaded("shmop")) {
die("skip shmop() extension not available");
}
?>
--FILE--
<?php
echo PHP_EOL, '## shmop_open function tests ##';
// warning outputs: invalid flag when the flags length != 1
var_dump(shmop_open(1338, '', 0644, 1024));
// warning outputs: invalid access mode
var_dump(shmop_open(1338, 'b', 0644, 1024));
// warning outputs: unable to attach or create shared memory segment
var_dump(shmop_open(null, 'a', 0644, 1024));
// warning outputs: Shared memory segment size must be greater than zero
var_dump(shmop_open(1338, "c", 0666, 0));
echo PHP_EOL, '## shmop_read function tests ##';
// warning outputs: start is out of range
$shm_id = shmop_open(1338, 'n', 0600, 1024);
var_dump(shmop_read($shm_id, -10, 0));
shmop_delete($shm_id);
// warning outputs: count is out of range
$shm_id = shmop_open(1339, 'n', 0600, 1024);
var_dump(shmop_read($shm_id, 0, -10));
shmop_delete($shm_id);
echo PHP_EOL, '## shmop_write function tests ##';
// warning outputs: offset out of range
$shm_id = shmop_open(1340, 'n', 0600, 1024);
var_dump(shmop_write($shm_id, 'text to try write', -10));
shmop_delete($shm_id);
?>
--EXPECTF--
## shmop_open function tests ##
Warning: shmop_open(): is not a valid flag in %s on line %d
bool(false)
Warning: shmop_open(): Invalid access mode in %s on line %d
bool(false)
Warning: shmop_open(): Unable to attach or create shared memory segment '%s' in %s on line %d
bool(false)
Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d
bool(false)
## shmop_read function tests ##
Warning: shmop_read(): Start is out of range in %s on line %d
bool(false)
Warning: shmop_read(): Count is out of range in %s on line %d
bool(false)
## shmop_write function tests ##
Warning: shmop_write(): Offset out of range in %s on line %d
bool(false)
|