Index: run-tests.php =================================================================== RCS file: /repository/php-src/run-tests.php,v retrieving revision 1.226.2.37.2.32 diff -u -r1.226.2.37.2.32 run-tests.php --- run-tests.php 4 Jul 2007 10:16:22 -0000 1.226.2.37.2.32 +++ run-tests.php 25 Jul 2007 15:31:12 -0000 @@ -534,6 +534,36 @@ $exts_skipped = 0; $ignored_by_ext = 0; sort($exts_to_test); + + +$num_of_threads = 4; // TODO: make this configurable from outside +$exts_each_thread = intval(($exts_tested+4)/$num_of_threads); //+4 because of the dirs below +$thread_id = 0; + + +if ($num_of_threads > 1 && function_exists('pcntl_fork')) { + var_dump($exts_each_thread); + print_r($exts_to_test); + + // spawn the processes + for ($i=1; $i < $num_of_threads; ++$i) { + switch (pcntl_fork()) { + case -1: + die("fork() failed\n"); + + case 0: // child + $thread_id = $i; + break 2; + + default: // parent + // just continue creating threads + } + + } + +} + + $test_dirs = array(); $optionals = array('tests', 'ext', 'Zend', 'ZendEngine2', 'sapi/cli', 'sapi/cgi'); foreach($optionals as $dir) { @@ -557,16 +587,21 @@ function find_files($dir,$is_ext_dir=FALSE,$ignore=FALSE) { - global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested; + global $test_files, $exts_to_test, $ignored_by_ext, $exts_skipped, $exts_tested, $thread_id, $num_of_threads, $exts_each_thread; $o = opendir($dir) or error("cannot open directory: $dir"); while (($name = readdir($o)) !== FALSE) { - if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS'))) { - $skip_ext = ($is_ext_dir && !in_array(strtolower($name), $exts_to_test)); + if (is_dir("{$dir}/{$name}") && !in_array($name, array('.', '..', 'CVS', '.libs'))) { + + $skip_ext = ($is_ext_dir == 1 && + (($pos=array_search(strtolower($name), $exts_to_test)) === false || + ($pos < ($thread_id*$exts_each_thread) || ($pos >= (($thread_id+1)*$exts_each_thread) && $thread_id != ($num_of_threads-1))))); + $skip_ext |= (!$is_ext_dir && $thread_id != 0); + if ($skip_ext) { $exts_skipped++; } - find_files("{$dir}/{$name}", FALSE, $ignore || $skip_ext); + find_files("{$dir}/{$name}", $is_ext_dir ? 2 : 0, $ignore || $skip_ext); } // Cleanup any left-over tmp files from last run. @@ -1911,10 +1946,12 @@ function show_test($test_idx, $shortname) { - global $test_cnt; + global $test_cnt, $num_of_threads; - echo "TEST $test_idx/$test_cnt [$shortname]\r"; - flush(); + if ($num_of_threads == 1) { // don't screw the output + echo "TEST $test_idx/$test_cnt [$shortname]\r"; + flush(); + } } function show_result($result, $tested, $tested_file, $extra = '', $temp_filenames = null)