Skip to content

Commit a2e9534

Browse files
committed
Add a --preload testing mode to run-tests.php
Not intended for general use, it has many false positives.
1 parent 3cafa7f commit a2e9534

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

run-tests.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ function verify_config()
264264
'log_errors_max_len=0',
265265
'opcache.fast_shutdown=0',
266266
'opcache.file_update_protection=0',
267-
'opcache.preload=',
268267
'zend.assertions=1',
269268
);
270269

@@ -510,6 +509,7 @@ function save_or_mail_results()
510509
$conf_passed = null;
511510
$no_clean = false;
512511
$slow_min_ms = INF;
512+
$preload = false;
513513

514514
$cfgtypes = array('show', 'keep');
515515
$cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp', 'mem');
@@ -625,6 +625,9 @@ function save_or_mail_results()
625625
case 'e':
626626
$pass_options .= ' -e';
627627
break;
628+
case '--preload':
629+
$preload = true;
630+
break;
628631
case '--no-clean':
629632
$no_clean = true;
630633
break;
@@ -1256,6 +1259,7 @@ function run_test($php, $file, $env)
12561259
global $SHOW_ONLY_GROUPS;
12571260
global $no_file_cache;
12581261
global $slow_min_ms;
1262+
global $preload;
12591263
$temp_filenames = null;
12601264
$org_file = $file;
12611265

@@ -1496,6 +1500,7 @@ function run_test($php, $file, $env)
14961500
$test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php';
14971501
$temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
14981502
$test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
1503+
$preload_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'preload.php';
14991504
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
15001505
$tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't';
15011506

@@ -1546,6 +1551,7 @@ function run_test($php, $file, $env)
15461551
@unlink($tmp_post);
15471552
@unlink($temp_clean);
15481553
@unlink($test_clean);
1554+
@unlink($preload_filename);
15491555

15501556
// Reset environment from any previous test.
15511557
$env['REDIRECT_STATUS'] = '';
@@ -1790,6 +1796,14 @@ function run_test($php, $file, $env)
17901796

17911797
$args = isset($section_text['ARGS']) ? ' -- ' . $section_text['ARGS'] : '';
17921798

1799+
if ($preload) {
1800+
save_text($preload_filename, "<?php\nerror_reporting(0);\nopcache_compile_file('" . $test_file . "');");
1801+
$local_pass_options = $pass_options;
1802+
unset($pass_options);
1803+
$pass_options = $local_pass_options;
1804+
$pass_options .= " -d opcache.preload=" . $preload_filename;
1805+
}
1806+
17931807
if (array_key_exists('POST_RAW', $section_text) && !empty($section_text['POST_RAW'])) {
17941808

17951809
$post = trim($section_text['POST_RAW']);
@@ -1975,6 +1989,7 @@ function run_test($php, $file, $env)
19751989
}
19761990

19771991
@unlink($tmp_post);
1992+
@unlink($preload_filename);
19781993

19791994
$leaked = false;
19801995
$passed = false;

0 commit comments

Comments
 (0)