| 1 | Patch-Source: https://github.com/NoiseByNorthwest/php-spx/pull/343
|
| 2 |
|
| 3 | Give every test that writes a profiling report its own spx.data_dir.
|
| 4 |
|
| 5 | Six tests write full reports into the shared, hardcoded default data dir
|
| 6 | /tmp/spx (src/php_spx.c:113 - "spx.data_dir", "/tmp/spx", PHP_INI_SYSTEM), and
|
| 7 | two of them wipe that whole directory in their --CLEAN-- section:
|
| 8 |
|
| 9 | tests/spx_ini_params_profiling_enabled.phpt:18: exec("rm -rf /tmp/spx");
|
| 10 | tests/spx_ini_params_not_overridden.phpt:28: exec("rm -rf /tmp/spx");
|
| 11 |
|
| 12 | while tests/spx_custom_metadata.phpt reads its own reports back with
|
| 13 | file_get_contents('/tmp/spx/' . $key . '.json').
|
| 14 |
|
| 15 | Since php-src 1d2ea5ce22c ("Run tests in parallel by default", GH-22939, first
|
| 16 | released in php-8.6.0beta1) run-tests.php spawns min(nproc, 10) workers by
|
| 17 | default, so the readers race the wipers and spx_custom_metadata.phpt fails with
|
| 18 | "file_get_contents(): Failed to open stream: No such file or directory".
|
| 19 | On an 8-core builder this reproduced in 15 out of 15 parallel runs.
|
| 20 |
|
| 21 | spx.data_dir is PHP_INI_SYSTEM and is therefore settable per test from --INI--,
|
| 22 | exactly the way tests/spx_ui_report_access.phpt already does it. Point each
|
| 23 | report-producing test at its own {PWD}/data_dir_<test> and remove only that
|
| 24 | directory in --CLEAN--, so no test can ever clobber another's reports, nothing
|
| 25 | is left behind in /tmp, and the suite stays fully parallel.
|
| 26 |
|
| 27 | Note --CLEAN-- scripts are executed with the *global* ini settings, not the
|
| 28 | test's --INI-- section, so the clean-up path is spelled out with __DIR__ rather
|
| 29 | than read back via ini_get().
|
| 30 |
|
| 31 | |
| 32 | |
| 33 | @@ -1,5 +1,7 @@
|
| 34 | --TEST--
|
| 35 | Auto start disabled, full report & span report keys printed
|
| 36 | +--INI--
|
| 37 | +spx.data_dir="{PWD}/data_dir_auto_start_005"
|
| 38 | --ENV--
|
| 39 | return <<<END
|
| 40 | SPX_ENABLED=1
|
| 41 | @@ -28,4 +30,10 @@
|
| 42 | --EXPECTF--
|
| 43 | spx-full-%s
|
| 44 | spx-full-%s
|
| 45 | -spx-full-%s
|
| 46 | \ No newline at end of file
|
| 47 | +spx-full-%s
|
| 48 | +--CLEAN--
|
| 49 | +<?php
|
| 50 | +
|
| 51 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_auto_start_005"));
|
| 52 | +
|
| 53 | +?>
|
| 54 | |
| 55 | |
| 56 | @@ -3,6 +3,7 @@
|
| 57 | --CGI--
|
| 58 | --INI--
|
| 59 | spx.debug=1
|
| 60 | +spx.data_dir="{PWD}/data_dir_auto_start_007"
|
| 61 | spx.http_enabled=1
|
| 62 | spx.http_key="dev"
|
| 63 | spx.http_ip_whitelist="127.0.0.1"
|
| 64 | @@ -33,4 +34,10 @@
|
| 65 | --EXPECTF--
|
| 66 | spx-full-%s
|
| 67 | spx-full-%s
|
| 68 | -spx-full-%s
|
| 69 | \ No newline at end of file
|
| 70 | +spx-full-%s
|
| 71 | +--CLEAN--
|
| 72 | +<?php
|
| 73 | +
|
| 74 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_auto_start_007"));
|
| 75 | +
|
| 76 | +?>
|
| 77 | |
| 78 | |
| 79 | @@ -2,6 +2,7 @@
|
| 80 | Custom metadata
|
| 81 | --INI--
|
| 82 | log_errors=on
|
| 83 | +spx.data_dir="{PWD}/data_dir_custom_metadata"
|
| 84 | --ENV--
|
| 85 | return <<<END
|
| 86 | SPX_ENABLED=1
|
| 87 | @@ -32,7 +33,7 @@
|
| 88 | foo();
|
| 89 |
|
| 90 | $key = spx_profiler_stop();
|
| 91 | - echo file_get_contents('/tmp/spx/' . $key . '.json');
|
| 92 | + echo file_get_contents(__DIR__ . '/data_dir_custom_metadata/' . $key . '.json');
|
| 93 | }
|
| 94 |
|
| 95 | ?>
|
| 96 | @@ -154,4 +155,10 @@
|
| 97 | "wt"
|
| 98 | ,"zm"
|
| 99 | ]
|
| 100 | -}
|
| 101 | \ No newline at end of file
|
| 102 | +}
|
| 103 | +--CLEAN--
|
| 104 | +<?php
|
| 105 | +
|
| 106 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_custom_metadata"));
|
| 107 | +
|
| 108 | +?>
|
| 109 | |
| 110 | |
| 111 | @@ -3,6 +3,7 @@
|
| 112 | --CGI--
|
| 113 | --INI--
|
| 114 | spx.debug=1
|
| 115 | +spx.data_dir="{PWD}/data_dir_ini_params_no_unnecessary_access_check"
|
| 116 | spx.http_profiling_enabled=1
|
| 117 | spx.http_enabled=1
|
| 118 | spx.http_key="dev"
|
| 119 | @@ -16,3 +17,9 @@
|
| 120 | SPX-Debug-Profiling-Triggered: 1
|
| 121 | --EXPECT--
|
| 122 | Normal output
|
| 123 | +--CLEAN--
|
| 124 | +<?php
|
| 125 | +
|
| 126 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_ini_params_no_unnecessary_access_check"));
|
| 127 | +
|
| 128 | +?>
|
| 129 | |
| 130 | |
| 131 | @@ -3,6 +3,7 @@
|
| 132 | --CGI--
|
| 133 | --INI--
|
| 134 | spx.debug=1
|
| 135 | +spx.data_dir="{PWD}/data_dir_ini_params_not_overridden"
|
| 136 | spx.http_profiling_enabled=1
|
| 137 | spx.http_enabled=1
|
| 138 | spx.http_key="dev"
|
| 139 | @@ -25,6 +26,6 @@
|
| 140 | --CLEAN--
|
| 141 | <?php
|
| 142 |
|
| 143 | -exec("rm -rf /tmp/spx");
|
| 144 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_ini_params_not_overridden"));
|
| 145 |
|
| 146 | ?>
|
| 147 | \ No newline at end of file
|
| 148 | |
| 149 | |
| 150 | @@ -3,6 +3,7 @@
|
| 151 | --CGI--
|
| 152 | --INI--
|
| 153 | spx.debug=1
|
| 154 | +spx.data_dir="{PWD}/data_dir_ini_params_profiling_enabled"
|
| 155 | spx.http_profiling_enabled=1
|
| 156 | --FILE--
|
| 157 | <?php
|
| 158 | @@ -15,6 +16,6 @@
|
| 159 | --CLEAN--
|
| 160 | <?php
|
| 161 |
|
| 162 | -exec("rm -rf /tmp/spx");
|
| 163 | +exec("rm -rf " . escapeshellarg(__DIR__ . "/data_dir_ini_params_profiling_enabled"));
|
| 164 |
|
| 165 | ?>
|
| 166 | \ No newline at end of file
|