]> granicus.if.org Git - php/commitdiff
Split shmop/tests/002.phpt in two (all + non-root)
authorMatteo Beccati <mbeccati@php.net>
Tue, 10 Nov 2015 08:02:40 +0000 (09:02 +0100)
committerMatteo Beccati <mbeccati@php.net>
Tue, 10 Nov 2015 08:10:10 +0000 (09:10 +0100)
One of the conditions tested was expected to fail with "Permission denied",
but it doesn't when running as root. The memory segment was also leaked, hence
the split.

ext/shmop/tests/002.phpt
ext/shmop/tests/003.phpt [new file with mode: 0644]

index 872fc934fe25d3af455eabda200705546998e515..3206f90776b15c86a614f5596752721049688d2f 100644 (file)
@@ -33,9 +33,6 @@ echo PHP_EOL, '## shmop_open function tests ##';
        // warning outputs: Shared memory segment size must be greater than zero
        var_dump(shmop_open($hex_shm_id(), "c", 0666, 0));
 
-       // warning outputs: unable to get shared memory segment information
-       var_dump(shmop_open($hex_shm_id(), 'n', 0, 1024));
-
 echo PHP_EOL, '## shmop_read function tests ##';
        // warning outputs: 3 parameters expected
        var_dump(shmop_read());
@@ -88,9 +85,6 @@ bool(false)
 Warning: shmop_open(): Shared memory segment size must be greater than zero in %s on line %d
 bool(false)
 
-Warning: shmop_open(): unable to get shared memory segment information 'Permission denied' in %s on line %d
-bool(false)
-
 ## shmop_read function tests ##
 Warning: shmop_read() expects exactly 3 parameters, 0 given in %s on line %d
 NULL
diff --git a/ext/shmop/tests/003.phpt b/ext/shmop/tests/003.phpt
new file mode 100644 (file)
index 0000000..1c154f0
--- /dev/null
@@ -0,0 +1,33 @@
+--TEST--
+shmop extension error messages (non-root)
+--SKIPIF--
+<?php
+       if( substr(PHP_OS, 0, 3) == "WIN") {
+               die('skip not for Windows');
+       }
+       if (!extension_loaded("shmop")) {
+               die("skip shmop extension not available");
+       }
+       if (!extension_loaded("posix")) {
+               die("skip posix extension not available");
+       }
+       if (!posix_geteuid()) {
+               die("skip cannot run test as root");
+       }
+?>
+--FILE--
+<?php
+       $hex_shm_id = function(){
+               return mt_rand(1338, 9999);
+       };
+
+echo '## shmop_open function tests ##', PHP_EOL;
+       // warning outputs: unable to get shared memory segment information
+       var_dump(shmop_open($hex_shm_id(), 'n', 0, 1024));
+
+?>
+--EXPECTF--
+## shmop_open function tests ##
+
+Warning: shmop_open(): unable to get shared memory segment information 'Permission denied' in %s on line %d
+bool(false)