summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-05-13 23:09:57 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-05-13 23:25:28 +0200
commit1892e3abaaecff13e7b124ec4b19c2f23e2d8f69 (patch)
tree7ef2423ab2a3963f2d5ed5303b4140f2c6cdb400
parent129fd647a16b2353dd5a92edccc904619e68ab77 (diff)
downloadphp-git-1892e3abaaecff13e7b124ec4b19c2f23e2d8f69.tar.gz
Fix brittle shmop test
To solve bug #70886, the test uses random keys to prevent collisions; however, this is not guaranteed, and as such it may even collide with other tests in the shmop test suite. The proper solution would be to use a single key (which could be randomly generated), but to actually `shmop_close()` after each `shmop_delete()`. This would, however, not work on Windows due to bug #65987. Therefore we use three different keys for now.
-rw-r--r--ext/shmop/tests/002.phpt15
1 files changed, 6 insertions, 9 deletions
diff --git a/ext/shmop/tests/002.phpt b/ext/shmop/tests/002.phpt
index 3206f90776..94d536a175 100644
--- a/ext/shmop/tests/002.phpt
+++ b/ext/shmop/tests/002.phpt
@@ -13,37 +13,34 @@ edgarsandi - <edgar.r.sandi@gmail.com>
?>
--FILE--
<?php
- $hex_shm_id = function(){
- return mt_rand(1338, 9999);
- };
echo PHP_EOL, '## shmop_open function tests ##';
// warning outputs: 4 parameters expected
var_dump($shm_id = shmop_open());
// warning outputs: invalid flag when the flags length != 1
- var_dump(shmop_open($hex_shm_id(), '', 0644, 1024));
+ var_dump(shmop_open(1338, '', 0644, 1024));
// warning outputs: invalid access mode
- var_dump(shmop_open($hex_shm_id(), 'b', 0644, 1024));
+ 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($hex_shm_id(), "c", 0666, 0));
+ var_dump(shmop_open(1338, "c", 0666, 0));
echo PHP_EOL, '## shmop_read function tests ##';
// warning outputs: 3 parameters expected
var_dump(shmop_read());
// warning outputs: start is out of range
- $shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
+ $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($hex_shm_id(), 'n', 0600, 1024);
+ $shm_id = shmop_open(1339, 'n', 0600, 1024);
var_dump(shmop_read($shm_id, 0, -10));
shmop_delete($shm_id);
@@ -52,7 +49,7 @@ echo PHP_EOL, '## shmop_write function tests ##';
var_dump(shmop_write());
// warning outputs: offset out of range
- $shm_id = shmop_open($hex_shm_id(), 'n', 0600, 1024);
+ $shm_id = shmop_open(1340, 'n', 0600, 1024);
var_dump(shmop_write($shm_id, 'text to try write', -10));
shmop_delete($shm_id);