Skip to content

Commit 0ed6e25

Browse files
committed
Merge branch 'PHP-7.0'
* PHP-7.0: Split shmop/tests/002.phpt in two (all + non-root) Fix bug #70886 in shmop/tests/002.phpt
2 parents 2d750a7 + 3cb3979 commit 0ed6e25

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

ext/shmop/tests/002.phpt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ edgarsandi - <[email protected]>
88
die('skip not for Windows');
99
}
1010
if (!extension_loaded("shmop")) {
11-
1211
die("skip shmop() extension not available");
1312
}
1413
?>
1514
--FILE--
1615
<?php
1716
$hex_shm_id = function(){
18-
return rand(0, 9999);
17+
return mt_rand(1338, 9999);
1918
};
2019

2120
echo PHP_EOL, '## shmop_open function tests ##';
@@ -34,20 +33,19 @@ echo PHP_EOL, '## shmop_open function tests ##';
3433
// warning outputs: Shared memory segment size must be greater than zero
3534
var_dump(shmop_open($hex_shm_id(), "c", 0666, 0));
3635

37-
// warning outputs: unable to get shared memory segment information
38-
var_dump(shmop_open($hex_shm_id(), 'n', 0, 1024));
39-
4036
echo PHP_EOL, '## shmop_read function tests ##';
4137
// warning outputs: 3 parameters expected
4238
var_dump(shmop_read());
4339

4440
// warning outputs: start is out of range
4541
$shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
4642
var_dump(shmop_read($shm_id, -10, 0));
43+
shmop_delete($shm_id);
4744

4845
// warning outputs: count is out of range
4946
$shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
5047
var_dump(shmop_read($shm_id, 0, -10));
48+
shmop_delete($shm_id);
5149

5250
echo PHP_EOL, '## shmop_write function tests ##';
5351
// warning outputs: 3 parameters expected
@@ -56,6 +54,7 @@ echo PHP_EOL, '## shmop_write function tests ##';
5654
// warning outputs: offset out of range
5755
$shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
5856
var_dump(shmop_write($shm_id, 'text to try write', -10));
57+
shmop_delete($shm_id);
5958

6059
echo PHP_EOL, '## shmop_size function tests ##';
6160
// warning outputs: 1 parameter expected
@@ -86,9 +85,6 @@ bool(false)
8685
Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d
8786
bool(false)
8887

89-
Warning: shmop_open(): unable to get shared memory segment information 'Permission denied' in %s on line %d
90-
bool(false)
91-
9288
## shmop_read function tests ##
9389
Warning: shmop_read() expects exactly 3 parameters, 0 given in %s on line %d
9490
NULL

ext/shmop/tests/003.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
shmop extension error messages (non-root)
3+
--SKIPIF--
4+
<?php
5+
if( substr(PHP_OS, 0, 3) == "WIN") {
6+
die('skip not for Windows');
7+
}
8+
if (!extension_loaded("shmop")) {
9+
die("skip shmop extension not available");
10+
}
11+
if (!extension_loaded("posix")) {
12+
die("skip posix extension not available");
13+
}
14+
if (!posix_geteuid()) {
15+
die("skip cannot run test as root");
16+
}
17+
?>
18+
--FILE--
19+
<?php
20+
$hex_shm_id = function(){
21+
return mt_rand(1338, 9999);
22+
};
23+
24+
echo '## shmop_open function tests ##', PHP_EOL;
25+
// warning outputs: unable to get shared memory segment information
26+
var_dump(shmop_open($hex_shm_id(), 'n', 0, 1024));
27+
28+
?>
29+
--EXPECTF--
30+
## shmop_open function tests ##
31+
32+
Warning: shmop_open(): unable to get shared memory segment information 'Permission denied' in %s on line %d
33+
bool(false)

0 commit comments

Comments
 (0)