xref: /PHP-7.4/ext/sysvshm/tests/002.phpt (revision 782352c5)
1--TEST--
2shm_attach() tests
3--SKIPIF--
4<?php
5if (!extension_loaded("sysvshm")){ print 'skip'; }
6if (!function_exists('ftok')){ print 'skip'; }
7?>
8--FILE--
9<?php
10
11$key = ftok(__FILE__, 't');
12
13var_dump(shm_attach());
14var_dump(shm_attach(1,2,3,4));
15
16var_dump(shm_attach(-1, 0));
17var_dump(shm_attach(0, -1));
18var_dump(shm_attach(123, -1));
19var_dump($s = shm_attach($key, -1));
20shm_remove($s);
21var_dump($s = shm_attach($key, 0));
22shm_remove($s);
23
24var_dump($s = shm_attach($key, 1024));
25shm_remove($key);
26var_dump($s = shm_attach($key, 1024));
27shm_remove($s);
28var_dump($s = shm_attach($key, 1024, 0666));
29shm_remove($s);
30
31var_dump($s = shm_attach($key, 1024));
32shm_remove($s);
33var_dump($s = shm_attach($key));
34shm_remove($s);
35
36echo "Done\n";
37?>
38--EXPECTF--
39Warning: shm_attach() expects at least 1 parameter, 0 given in %s on line %d
40NULL
41
42Warning: shm_attach() expects at most 3 parameters, 4 given in %s on line %d
43NULL
44
45Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
46bool(false)
47
48Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
49bool(false)
50
51Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
52bool(false)
53
54Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
55bool(false)
56
57Warning: shm_remove() expects parameter 1 to be resource, bool given in %s on line %d
58
59Warning: shm_attach(): Segment size must be greater than zero in %s on line %d
60bool(false)
61
62Warning: shm_remove() expects parameter 1 to be resource, bool given in %s on line %d
63resource(%d) of type (sysvshm)
64
65Warning: shm_remove() expects parameter 1 to be resource, int given in %s on line %d
66resource(%d) of type (sysvshm)
67resource(%d) of type (sysvshm)
68resource(%d) of type (sysvshm)
69resource(%d) of type (sysvshm)
70Done
71