]> granicus.if.org Git - php/commitdiff
Fix brittle test
authorChristoph M. Becker <cmbecker69@gmx.de>
Mon, 1 Jul 2019 14:41:20 +0000 (16:41 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 1 Jul 2019 14:42:55 +0000 (16:42 +0200)
This test is easily tripped by former test runs with other PHP
versions.  To avoid such false positives, we check that there is at
least one respective OPcache file, and that all found OPcache user ID
folders have exactly 32 hexadecimal digits.

ext/opcache/tests/bug78189.phpt

index 49891c8d63bdc532ef162ee8b0be1ae789beffc9..d97d8e94706f26f551613f620b8f998e83a6d302 100644 (file)
@@ -14,9 +14,16 @@ opcache.file_cache_only=1
 <?php
 $tmpdir = sys_get_temp_dir();
 $pattern = $tmpdir . '/*/*/' . str_replace(':', '', __DIR__) . '/bug78189.php.bin';
-foreach (glob($pattern) as $filename) {
-    var_dump(preg_match('~/[0-9a-f]{32}/~', substr($filename, strlen($tmpdir), 34)));
+$filenames = glob($pattern);
+if (count($filenames)) {
+    foreach ($filenames as $filename) {
+        $part = substr($filename, strlen($tmpdir), 34);
+        if (!preg_match('~/[0-9a-f]{32}/~', $part)) {
+            echo "invalid opcache folder: $part\n";
+        }
+    }
+} else {
+    echo "no opcache file found!\n";
 }
 ?>
 --EXPECT--
-int(1)