Skip to content

Commit e130e6d

Browse files
committed
tests: give each test its own spx.data_dir
Several tests share a report directory: - spx_auto_start_005, spx_auto_start_007, spx_full_report_custom_metadata and spx_full_report_data write "full" reports into the default data dir /tmp/spx (src/php_spx.c: "spx.data_dir", "/tmp/spx"), and the last two read them back; - spx_ini_params_not_overridden and spx_ini_params_profiling_enabled rm -rf that same /tmp/spx in their --CLEAN-- section; - the five spx_ui_report_delete_* tests all point spx.data_dir at {PWD}/tmp_data_dir, and each of them rm -rf's it both on entry and on exit. That was harmless while run-tests.php was serial. Since php-src 1d2ea5ce22c ("Run tests in parallel by default", GH-22939, first released in 8.6.0beta1) it spawns min(nproc, 10) workers, so those tests race and a sibling wipes the reports a test is still reading or writing. Measured on PHP 8.6.0beta1, 8 cores, run-tests.php -j10, 20 runs of the suite (83 tests, 16 skipped, 67 run): before 18/20 runs had failures spx_full_report_custom_metadata 18/20 spx_ui_report_delete_all 4/20 spx_ui_report_delete_one 2/20 spx_ui_report_delete_nonexistent 1/20 spx_full_report_data 1/20 after 0/20, plus 0/30 in a second batch Give each of them its own data dir with --INI--, the way spx_ui_report_access.phpt already does, and add the missing --CLEAN-- sections: four of them had none, so they were leaving reports behind after every run. spx_ini_params_no_unnecessary_access_check enables the same HTTP profiling as its two siblings and gets the same treatment, so the three stay consistent. Note --CLEAN-- is run with the original INI settings rather than the test's --INI-- (run-tests.php passes $orig_ini_settings_args), so ini_get() yields the default there and the cleanup paths have to be spelled out with __DIR__. The read-only fixture directory tests/data_dir, shared by spx_ui_report_access and spx_ui_report_metadata_access, is left as it is: no test writes to it.
1 parent 5c6271d commit e130e6d

12 files changed

Lines changed: 49 additions & 12 deletions

tests/spx_auto_start_005.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Auto start disabled, full report & span report keys printed
3+
--INI--
4+
spx.data_dir="{PWD}/tmp_data_dir_auto_start_005"
35
--ENV--
46
return <<<END
57
SPX_ENABLED=1
@@ -28,4 +30,10 @@ for ($i = 0; $i < 3; $i++) {
2830
--EXPECTF--
2931
spx-full-%s
3032
spx-full-%s
31-
spx-full-%s
33+
spx-full-%s
34+
--CLEAN--
35+
<?php
36+
37+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_auto_start_005')));
38+
39+
?>

tests/spx_auto_start_007.phpt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Auto start disabled, full report & span report keys printed
33
--CGI--
44
--INI--
55
spx.debug=1
6+
spx.data_dir="{PWD}/tmp_data_dir_auto_start_007"
67
spx.http_enabled=1
78
spx.http_key="dev"
89
spx.http_ip_whitelist="127.0.0.1"
@@ -33,4 +34,10 @@ for ($i = 0; $i < 3; $i++) {
3334
--EXPECTF--
3435
spx-full-%s
3536
spx-full-%s
36-
spx-full-%s
37+
spx-full-%s
38+
--CLEAN--
39+
<?php
40+
41+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_auto_start_007')));
42+
43+
?>

tests/spx_full_report_custom_metadata.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"full" report custom metadata
33
--INI--
44
log_errors=on
5+
spx.data_dir="{PWD}/tmp_data_dir_full_report_custom_metadata"
56
--ENV--
67
return <<<END
78
SPX_ENABLED=1
@@ -155,3 +156,9 @@ Notice: SPX: spx_profiler_full_report_set_custom_metadata_str(): too large $cust
155156
,"zm"
156157
]
157158
}
159+
--CLEAN--
160+
<?php
161+
162+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_full_report_custom_metadata')));
163+
164+
?>

tests/spx_full_report_data.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
"full" report data
3+
--INI--
4+
spx.data_dir="{PWD}/tmp_data_dir_full_report_data"
35
--ENV--
46
return <<<END
57
SPX_ENABLED=1
@@ -78,3 +80,9 @@ b|2|%S|
7880
%s/tests/spx_full_report_data.php:9:foo
7981
%s/spx_full_report_data.php:5:bar
8082
%s/spx_full_report_data.php:2:baz
83+
--CLEAN--
84+
<?php
85+
86+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_full_report_data')));
87+
88+
?>

tests/spx_ini_params_no_unnecessary_access_check.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ INI profiling parameters: no unnecessary access check (no related log expected)
33
--CGI--
44
--INI--
55
spx.debug=1
6+
spx.data_dir="{PWD}/tmp_data_dir_ini_params_no_unnecessary_access_check"
67
spx.http_profiling_enabled=1
78
spx.http_enabled=1
89
spx.http_key="dev"
@@ -16,3 +17,9 @@ echo 'Normal output';
1617
SPX-Debug-Profiling-Triggered: 1
1718
--EXPECT--
1819
Normal output
20+
--CLEAN--
21+
<?php
22+
23+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_ini_params_no_unnecessary_access_check')));
24+
25+
?>

tests/spx_ini_params_not_overridden.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ INI profiling parameters: not overridden by query string (bad auth)s
33
--CGI--
44
--INI--
55
spx.debug=1
6+
spx.data_dir="{PWD}/tmp_data_dir_ini_params_not_overridden"
67
spx.http_profiling_enabled=1
78
spx.http_enabled=1
89
spx.http_key="dev"
@@ -25,7 +26,6 @@ Normal output
2526
--CLEAN--
2627
<?php
2728

28-
$data_dir = ini_get('spx.data_dir');
29-
exec(sprintf('rm -rf %s', escapeshellarg($data_dir)));
29+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_ini_params_not_overridden')));
3030

3131
?>

tests/spx_ini_params_profiling_enabled.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ INI profiling parameters: profiling enabled
33
--CGI--
44
--INI--
55
spx.debug=1
6+
spx.data_dir="{PWD}/tmp_data_dir_ini_params_profiling_enabled"
67
spx.http_profiling_enabled=1
78
--FILE--
89
<?php
@@ -15,7 +16,6 @@ Normal output
1516
--CLEAN--
1617
<?php
1718

18-
$data_dir = ini_get('spx.data_dir');
19-
exec(sprintf('rm -rf %s', escapeshellarg($data_dir)));
19+
exec(sprintf('rm -rf %s', escapeshellarg(__DIR__ . '/tmp_data_dir_ini_params_profiling_enabled')));
2020

2121
?>

tests/spx_ui_report_delete_all.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UI: delete all reports
44
spx.http_enabled=1
55
spx.http_key="dev"
66
spx.http_ip_whitelist="127.0.0.1"
7-
spx.data_dir="{PWD}/tmp_data_dir"
7+
spx.data_dir="{PWD}/tmp_data_dir_delete_all"
88
log_errors=on
99
--FILE--
1010
<?php
@@ -34,4 +34,4 @@ $clean();
3434
--EXPECTF--
3535
{"success": true}
3636
Remaining files:
37-
%s/tmp_data_dir/keep.txt
37+
%s/tmp_data_dir_delete_all/keep.txt

tests/spx_ui_report_delete_all_empty.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UI: delete all reports (empty directory)
44
spx.http_enabled=1
55
spx.http_key="dev"
66
spx.http_ip_whitelist="127.0.0.1"
7-
spx.data_dir="{PWD}/tmp_data_dir"
7+
spx.data_dir="{PWD}/tmp_data_dir_delete_all_empty"
88
log_errors=on
99
--FILE--
1010
<?php

tests/spx_ui_report_delete_confinement.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ UI: delete confinement check
44
spx.http_enabled=1
55
spx.http_key="dev"
66
spx.http_ip_whitelist="127.0.0.1"
7-
spx.data_dir="{PWD}/tmp_data_dir"
7+
spx.data_dir="{PWD}/tmp_data_dir_delete_confinement"
88
log_errors=on
99
--FILE--
1010
<?php

0 commit comments

Comments
 (0)