Exemplo n.º 1
0
 public static function user_home_directory()
 {
     // Gets the system user's home directory
     static $userhome = null;
     if ($userhome == null) {
         if (function_exists('posix_getpwuid') && function_exists('posix_getuid')) {
             $userinfo = posix_getpwuid(posix_getuid());
             $userhome = $userinfo['dir'];
         } else {
             if ($home = pts_client::read_env('HOME')) {
                 $userhome = $home;
             } else {
                 if ($home = pts_client::read_env('HOMEPATH')) {
                     $userhome = pts_client::read_env('HOMEDRIVE') . $home;
                 } else {
                     if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
                         $userhome = PTS_USER_PATH;
                     } else {
                         if (!is_writable('/')) {
                             echo PHP_EOL . 'ERROR: Cannot find home directory.' . PHP_EOL;
                         }
                         $userhome = null;
                     }
                 }
             }
         }
         $userhome = pts_strings::add_trailing_slash($userhome);
     }
     return $userhome;
 }
 public static function set_amd_pcsdb($attribute, $value)
 {
     // Sets a value for AMD's PCSDB, Persistent Configuration Store Database
     if (phodevi::is_ati_graphics() && phodevi::is_linux() && !empty($value)) {
         $DISPLAY = substr(pts_client::read_env("DISPLAY"), 1, 1);
         $info = shell_exec("DISPLAY=:" . $DISPLAY . " aticonfig --set-pcs-val=" . $attribute . "," . $value . "  2>&1");
     }
 }
 public static function run($r)
 {
     $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
     if (count($test_profiles) > 0) {
         echo PHP_EOL . 'Downloading Test Files For: ' . implode(' ', $test_profiles);
         pts_test_installer::only_download_test_files($test_profiles, pts_client::read_env('DOWNLOAD_CACHE_LOCATION'));
     } else {
         echo PHP_EOL . 'Nothing found to download.' . PHP_EOL;
     }
 }
Exemplo n.º 4
0
 public static function run($r)
 {
     $module = strtolower($r[0]);
     $pre_message = null;
     if (!class_exists($module)) {
         pts_module_manager::load_module($module);
     }
     $module_name = pts_module_manager::module_call($module, 'module_name');
     $module_description = pts_module_manager::module_call($module, 'module_description');
     $module_setup = pts_module_manager::module_call($module, 'module_setup');
     pts_client::$display->generic_heading($module_name . ' Module Configuration');
     echo $module_description . PHP_EOL;
     if (count($module_setup) == 0) {
         echo PHP_EOL . 'There are no options available for configuring with the ' . $module . ' module.' . PHP_EOL;
     } else {
         if (($module_presets = pts_client::read_env('PTS_MODULE_SETUP')) != false) {
             $module_presets = pts_client::parse_value_string_double_identifier($module_presets);
         }
         $set_options = array();
         foreach ($module_setup as $module_option) {
             if ($module_option instanceof pts_module_option) {
                 $option_identifier = $module_option->get_identifier();
                 if (isset($module_presets[$module][$option_identifier]) && $module_option->is_supported_value($module_presets[$module][$option_identifier])) {
                     echo PHP_EOL . $module_option->get_formatted_question();
                     echo $module_presets[$module][$option_identifier] . PHP_EOL;
                     $input = $module_presets[$module][$option_identifier];
                 } else {
                     do {
                         echo PHP_EOL . $module_option->get_formatted_question();
                         $input = pts_user_io::read_user_input();
                     } while (!$module_option->is_supported_value($input));
                 }
                 if (empty($input)) {
                     $input = $module_option->get_default_value();
                 }
                 $set_options[$option_identifier] = $input;
             }
         }
         $set_options = pts_module_manager::module_call($module, 'module_setup_validate', $set_options);
         if (!empty($set_options)) {
             pts_module::module_config_save($module, $set_options);
         }
     }
     echo PHP_EOL;
 }
Exemplo n.º 5
0
 public static function run($to_run)
 {
     pts_test_run_manager::set_batch_mode(array('UploadResults' => false, 'SaveResults' => false, 'PromptForTestDescription' => false, 'RunAllTestCombinations' => false, 'PromptSaveName' => false, 'PromptForTestIdentifier' => false, 'OpenBrowser' => false));
     $tests_to_run_concurrently = 2;
     if (($j = getenv('PTS_CONCURRENT_TEST_RUNS')) && is_numeric($j) && $j > 1) {
         $tests_to_run_concurrently = $j;
         echo 'PTS_CONCURRENT_TEST_RUNS set; running ' . $tests_to_run_concurrently . ' tests concurrently.' . PHP_EOL;
     }
     $test_flags = pts_c::batch_mode;
     if (pts_test_run_manager::initial_checks($to_run, $test_flags, 'SHORT') == false) {
         return false;
     }
     /*
     if(count($to_run) < $tests_to_run_concurrently)
     {
     	echo PHP_EOL . 'More tests must be specified in order to run ' . $tests_to_run_concurrently . ' tests concurrently.';
     	return false;
     }
     */
     $test_run_manager = new pts_test_run_manager($test_flags);
     // Load the tests to run
     if ($test_run_manager->load_tests_to_run($to_run) == false) {
         return false;
     }
     // Run the actual tests
     $total_loop_time = pts_client::read_env('TOTAL_LOOP_TIME');
     if ($total_loop_time == 'infinite') {
         $total_loop_time = 'infinite';
         echo 'TOTAL_LOOP_TIME set; running tests in an infinite loop until otherwise triggered' . PHP_EOL;
     } else {
         if ($total_loop_time && is_numeric($total_loop_time) && $total_loop_time > 9) {
             $total_loop_time = $total_loop_time * 60;
             echo 'TOTAL_LOOP_TIME set; running tests for ' . $total_loop_time / 60 . ' minutes' . PHP_EOL;
         } else {
             $total_loop_time = false;
         }
     }
     //$test_run_manager->pre_execution_process();
     $test_run_manager->multi_test_stress_run_execute($tests_to_run_concurrently, $total_loop_time);
 }
Exemplo n.º 6
0
 public static function init()
 {
     self::$flags = 0;
     self::$os_identifier_sha1 = sha1(phodevi::read_property('system', 'vendor-identifier'));
     self::$is_live_cd = 1 << 1;
     self::$no_network_communication = 1 << 2;
     self::$no_openbenchmarking_reporting = 1 << 3;
     self::$user_agreement_skip = 1 << 4;
     self::$skip_md5_checks = 1 << 5;
     self::$remove_test_on_completion = 1 << 6;
     self::$no_phodevi_cache = 1 << 7;
     self::$no_external_dependencies = 1 << 8;
     self::$upload_to_openbenchmarking = 1 << 9;
     switch (self::$os_identifier_sha1) {
         case 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc':
             // Moscow 2011-04 client
             self::$flags = self::$is_live_cd | self::$no_network_communication | self::$no_openbenchmarking_reporting | self::$user_agreement_skip | self::$skip_md5_checks | self::$remove_test_on_completion;
             break;
     }
     if (pts_client::read_env('NO_FILE_HASH_CHECKS') != false || pts_client::read_env('NO_MD5_CHECKS') != false) {
         self::$flags |= self::$skip_md5_checks;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', 'FALSE')) {
         self::$flags |= self::$remove_test_on_completion;
     }
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
         self::$flags |= self::$upload_to_openbenchmarking;
     }
     if (pts_client::read_env('NO_PHODEVI_CACHE') != false) {
         self::$flags |= self::$no_phodevi_cache;
     }
     if (pts_client::read_env('NO_EXTERNAL_DEPENDENCIES') != false || pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES') == 1) {
         // NO_EXTERNAL_DEPENDENCIES was deprecated in PTS 3.6 and replaced by more versatile SKIP_EXTERNAL_DEPENDENCIES
         self::$flags |= self::$no_external_dependencies;
     }
 }
 public static function run_test(&$test_run_manager, &$test_run_request)
 {
     $test_identifier = $test_run_request->test_profile->get_identifier();
     $extra_arguments = $test_run_request->get_arguments();
     $arguments_description = $test_run_request->get_arguments_description();
     $full_output = pts_config::read_bool_config('PhoronixTestSuite/Options/General/FullOutput', 'FALSE');
     // Do the actual test running process
     $test_directory = $test_run_request->test_profile->get_install_dir();
     if (!is_dir($test_directory)) {
         return false;
     }
     $lock_file = $test_directory . 'run_lock';
     if (pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false) {
         self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');
         return false;
     }
     $active_result_buffer = new pts_test_result_buffer_active();
     $test_run_request->active =& $active_result_buffer;
     $execute_binary = $test_run_request->test_profile->get_test_executable();
     $times_to_run = $test_run_request->test_profile->get_times_to_run();
     $ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();
     $test_type = $test_run_request->test_profile->get_test_hardware_type();
     $allow_cache_share = $test_run_request->test_profile->allow_cache_share();
     $min_length = $test_run_request->test_profile->get_min_length();
     $max_length = $test_run_request->test_profile->get_max_length();
     if ($test_run_request->test_profile->get_environment_testing_size() > 1 && ceil(disk_free_space($test_directory) / 1048576) < $test_run_request->test_profile->get_environment_testing_size()) {
         // Ensure enough space is available on disk during testing process
         self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');
         pts_client::release_lock($lock_file);
         return false;
     }
     $to_execute = $test_run_request->test_profile->get_test_executable_dir();
     $pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());
     $extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);
     // Start
     $cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';
     $cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);
     $test_run_request->set_used_arguments_description($arguments_description);
     pts_module_manager::module_process('__pre_test_run', $test_run_request);
     $time_test_start = time();
     pts_client::$display->test_run_start($test_run_manager, $test_run_request);
     if (!$cache_share_present) {
         $pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
         if ($pre_output != null && (pts_client::is_debug_mode() || $full_output)) {
             pts_client::$display->test_run_instance_output($pre_output);
         }
         if (is_file($test_directory . 'pre-test-exit-status')) {
             // If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');
             unlink($test_directory . 'pre-test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script exited with a non-zero exit status.' . PHP_EOL);
                 self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
                 return false;
             }
         }
     }
     pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());
     $runtime_identifier = time();
     $execute_binary_prepend = '';
     if ($test_run_request->exec_binary_prepend != null) {
         $execute_binary_prepend = $test_run_request->exec_binary_prepend;
     }
     if (!$cache_share_present && $test_run_request->test_profile->is_root_required()) {
         if (phodevi::is_root() == false) {
             pts_client::$display->test_run_error('This test must be run as the root / administrator account.');
         }
         $execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';
     }
     if ($allow_cache_share && !is_file($cache_share_pt2so)) {
         $cache_share = new pts_storage_object(false, false);
     }
     if ($test_run_manager->get_results_identifier() != null && $test_run_manager->get_file_name() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveTestLogs', 'FALSE')) {
         $backup_test_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/test-logs/active/' . $test_run_manager->get_results_identifier() . '/';
         pts_file_io::delete($backup_test_log_dir);
         pts_file_io::mkdir($backup_test_log_dir, 0777, true);
     } else {
         $backup_test_log_dir = false;
     }
     for ($i = 0, $abort_testing = false, $time_test_start_actual = time(), $defined_times_to_run = $times_to_run; $i < $times_to_run && $i < 256 && !$abort_testing; $i++) {
         pts_client::$display->test_run_instance_header($test_run_request);
         $test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';
         $is_expected_last_run = $i == $times_to_run - 1;
         $test_extra_runtime_variables = array_merge($extra_runtime_variables, array('LOG_FILE' => $test_log_file, 'DISPLAY' => getenv('DISPLAY'), 'PATH' => getenv('PATH')));
         $restored_from_cache = false;
         if ($cache_share_present) {
             $cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);
             if ($cache_share) {
                 $test_result = $cache_share->read_object('test_results_output_' . $i);
                 $test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);
                 if ($test_extra_runtime_variables['LOG_FILE'] != null) {
                     file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));
                     $test_run_time = 0;
                     // This wouldn't be used for a cache share since it would always be the same, but declare the value so the variable is at least initialized
                     $restored_from_cache = true;
                 }
             }
             unset($cache_share);
         }
         if ($restored_from_cache == false) {
             $test_run_command = 'cd ' . $to_execute . ' && ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1';
             pts_client::test_profile_debug_message('Test Run Command: ' . $test_run_command);
             $is_monitoring = pts_test_result_parser::system_monitor_task_check($test_run_request->test_profile);
             $test_run_time_start = time();
             if (phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false) {
                 $phoroscript = new pts_phoroscript_interpreter($to_execute . '/' . $execute_binary, $test_extra_runtime_variables, $to_execute);
                 $phoroscript->execute_script($pts_test_arguments);
                 $test_result = null;
             } else {
                 //$test_result = pts_client::shell_exec($test_run_command, $test_extra_runtime_variables);
                 $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
                 $test_process = proc_open('exec ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1', $descriptorspec, $pipes, $to_execute, array_merge($_ENV, pts_client::environmental_variables(), $test_extra_runtime_variables));
                 if (is_resource($test_process)) {
                     //echo proc_get_status($test_process)['pid'];
                     pts_module_manager::module_process('__test_running', $test_process);
                     $test_result = stream_get_contents($pipes[1]);
                     fclose($pipes[1]);
                     fclose($pipes[2]);
                     $return_value = proc_close($test_process);
                 }
             }
             $test_run_time = time() - $test_run_time_start;
             $monitor_result = $is_monitoring ? pts_test_result_parser::system_monitor_task_post_test($test_run_request->test_profile) : 0;
         }
         if (!isset($test_result[10240]) || pts_client::is_debug_mode() || $full_output) {
             pts_client::$display->test_run_instance_output($test_result);
         }
         if (is_file($test_log_file) && trim($test_result) == null && (filesize($test_log_file) < 10240 || pts_client::is_debug_mode() || $full_output)) {
             $test_log_file_contents = file_get_contents($test_log_file);
             pts_client::$display->test_run_instance_output($test_log_file_contents);
             unset($test_log_file_contents);
         }
         $test_run_request->test_result_standard_output = $test_result;
         $exit_status_pass = true;
         if (is_file($test_directory . 'test-exit-status')) {
             // If the test script writes its exit status to ~/test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'test-exit-status');
             unlink($test_directory . 'test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The test exited with a non-zero exit status.');
                 if ($is_expected_last_run && is_file($test_log_file)) {
                     $scan_log = pts_file_io::file_get_contents($test_log_file);
                     $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                     if ($test_run_error) {
                         self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                     }
                 }
                 $exit_status_pass = false;
             }
         }
         if (!in_array($i + 1, $ignore_runs) && $exit_status_pass) {
             if (isset($monitor_result) && $monitor_result != 0) {
                 $test_run_request->active->active_result = $monitor_result;
             } else {
                 pts_test_result_parser::parse_result($test_run_request, $test_extra_runtime_variables['LOG_FILE']);
             }
             pts_client::test_profile_debug_message('Test Result Value: ' . $test_run_request->active->active_result);
             if (!empty($test_run_request->active->active_result)) {
                 if ($test_run_time < 2 && intval($test_run_request->active->active_result) == $test_run_request->active->active_result && $test_run_request->test_profile->get_estimated_run_time() > 60 && !$restored_from_cache) {
                     // If the test ended in less than two seconds, outputted some int, and normally the test takes much longer, then it's likely some invalid run
                     self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run ended prematurely.');
                     if ($is_expected_last_run && is_file($test_log_file)) {
                         $scan_log = pts_file_io::file_get_contents($test_log_file);
                         $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                         if ($test_run_error) {
                             self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                         }
                     }
                 } else {
                     // TODO integrate active_result into active buffer
                     $active_result_buffer->add_trial_run_result($test_run_request->active->active_result, $test_run_request->active->active_min_result, $test_run_request->active->active_max_result);
                 }
             } else {
                 if ($test_run_request->test_profile->get_display_format() != 'NO_RESULT') {
                     self::test_run_instance_error($test_run_manager, $test_run_request, 'The test run did not produce a result.');
                     if ($is_expected_last_run && is_file($test_log_file)) {
                         $scan_log = pts_file_io::file_get_contents($test_log_file);
                         $test_run_error = pts_tests::scan_for_error($scan_log, $test_run_request->test_profile->get_test_executable_dir());
                         if ($test_run_error) {
                             self::test_run_instance_error($test_run_manager, $test_run_request, 'E: ' . $test_run_error);
                         }
                     }
                 }
             }
             if ($allow_cache_share && !is_file($cache_share_pt2so)) {
                 $cache_share->add_object('test_results_output_' . $i, $test_run_request->active->active_result);
                 $cache_share->add_object('log_file_location_' . $i, $test_extra_runtime_variables['LOG_FILE']);
                 $cache_share->add_object('log_file_' . $i, is_file($test_log_file) ? file_get_contents($test_log_file) : null);
             }
         }
         if ($is_expected_last_run && $active_result_buffer->get_trial_run_count() > floor(($i - 2) / 2) && !$cache_share_present && $test_run_manager->do_dynamic_run_count()) {
             // The later check above ensures if the test is failing often the run count won't uselessly be increasing
             // Should we increase the run count?
             $increase_run_count = false;
             if ($defined_times_to_run == $i + 1 && $active_result_buffer->get_trial_run_count() > 0 && $active_result_buffer->get_trial_run_count() < $defined_times_to_run && $i < 64) {
                 // At least one run passed, but at least one run failed to produce a result. Increase count to try to get more successful runs
                 $increase_run_count = $defined_times_to_run - $active_result_buffer->get_trial_run_count();
             } else {
                 if ($active_result_buffer->get_trial_run_count() >= 2) {
                     // Dynamically increase run count if needed for statistical significance or other reasons
                     $increase_run_count = $test_run_manager->increase_run_count_check($active_result_buffer, $defined_times_to_run, $test_run_time);
                     if ($increase_run_count === -1) {
                         $abort_testing = true;
                     } else {
                         if ($increase_run_count == true) {
                             // Just increase the run count one at a time
                             $increase_run_count = 1;
                         }
                     }
                 }
             }
             if ($increase_run_count > 0) {
                 $times_to_run += $increase_run_count;
                 $is_expected_last_run = false;
                 //$test_run_request->test_profile->set_times_to_run($times_to_run);
             }
         }
         if ($times_to_run > 1 && $i < $times_to_run - 1) {
             if ($cache_share_present == false) {
                 $interim_output = pts_tests::call_test_script($test_run_request->test_profile, 'interim', 'Running Interim Test Script', $pts_test_arguments, $extra_runtime_variables, true);
                 if ($interim_output != null && (pts_client::is_debug_mode() || $full_output)) {
                     pts_client::$display->test_run_instance_output($interim_output);
                 }
                 //sleep(2); // Rest for a moment between tests
             }
             pts_module_manager::module_process('__interim_test_run', $test_run_request);
         }
         if (is_file($test_log_file)) {
             if ($is_expected_last_run) {
                 // For now just passing the last test log file...
                 // TODO XXX: clean this up with log files to preserve when needed, let multiple log files exist for extra_data, etc
                 pts_test_result_parser::generate_extra_data($test_run_request, $test_log_file);
             }
             if ($backup_test_log_dir) {
                 copy($test_log_file, $backup_test_log_dir . basename($test_log_file));
             }
             if (pts_client::test_profile_debug_message('Log File At: ' . $test_log_file) == false) {
                 unlink($test_log_file);
             }
         }
         if (is_file(PTS_USER_PATH . 'halt-testing') || is_file(PTS_USER_PATH . 'skip-test')) {
             pts_client::release_lock($lock_file);
             return false;
         }
         pts_client::$display->test_run_instance_complete($test_run_request);
     }
     $time_test_end_actual = time();
     if ($cache_share_present == false) {
         $post_output = pts_tests::call_test_script($test_run_request->test_profile, 'post', 'Running Post-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
         if ($post_output != null && (pts_client::is_debug_mode() || $full_output)) {
             pts_client::$display->test_run_instance_output($post_output);
         }
         if (is_file($test_directory . 'post-test-exit-status')) {
             // If the post script writes its exit status to ~/post-test-exit-status, if it's non-zero the test run failed
             $exit_status = pts_file_io::file_get_contents($test_directory . 'post-test-exit-status');
             unlink($test_directory . 'post-test-exit-status');
             if ($exit_status != 0) {
                 self::test_run_instance_error($test_run_manager, $test_run_request, 'The post run script exited with a non-zero exit status.' . PHP_EOL);
                 $abort_testing = true;
             }
         }
     }
     if ($abort_testing) {
         self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
         return false;
     }
     // End
     $time_test_end = time();
     $time_test_elapsed = $time_test_end - $time_test_start;
     $time_test_elapsed_actual = $time_test_end_actual - $time_test_start_actual;
     if (!empty($min_length)) {
         if ($min_length > $time_test_elapsed_actual) {
             // The test ended too quickly, results are not valid
             self::test_run_error($test_run_manager, $test_run_request, 'This test ended prematurely.');
             return false;
         }
     }
     if (!empty($max_length)) {
         if ($max_length < $time_test_elapsed_actual) {
             // The test took too much time, results are not valid
             self::test_run_error($test_run_manager, $test_run_request, 'This test run was exhausted.');
             return false;
         }
     }
     if ($allow_cache_share && !is_file($cache_share_pt2so) && $cache_share instanceof pts_storage_object) {
         $cache_share->save_to_file($cache_share_pt2so);
         unset($cache_share);
     }
     if ($test_run_manager->get_results_identifier() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', 'FALSE')) {
         if (is_file($test_run_request->test_profile->get_install_dir() . 'install.log')) {
             $backup_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/installation-logs/' . $test_run_manager->get_results_identifier() . '/';
             pts_file_io::mkdir($backup_log_dir, 0777, true);
             copy($test_run_request->test_profile->get_install_dir() . 'install.log', $backup_log_dir . basename($test_identifier) . '.log');
         }
     }
     // Fill in missing test details
     if (empty($arguments_description)) {
         $arguments_description = $test_run_request->test_profile->get_test_subtitle();
     }
     $file_var_checks = array(array('pts-results-scale', 'set_result_scale', null), array('pts-results-proportion', 'set_result_proportion', null), array('pts-results-quantifier', 'set_result_quantifier', null), array('pts-test-version', 'set_version', null), array('pts-test-description', null, 'set_used_arguments_description'), array('pts-footnote', null, null));
     foreach ($file_var_checks as &$file_check) {
         list($file, $set_function, $result_set_function) = $file_check;
         if (is_file($test_directory . $file)) {
             $file_contents = pts_file_io::file_get_contents($test_directory . $file);
             unlink($test_directory . $file);
             if (!empty($file_contents)) {
                 if ($set_function != null) {
                     call_user_func(array($test_run_request->test_profile, $set_function), $file_contents);
                 } else {
                     if ($result_set_function != null) {
                         if ($result_set_function == 'set_used_arguments_description') {
                             $arguments_description = $file_contents;
                         } else {
                             call_user_func(array($test_run_request, $result_set_function), $file_contents);
                         }
                     } else {
                         if ($file == 'pts-footnote') {
                             $test_run_request->test_profile->test_installation->set_install_footnote($file_contents);
                         }
                     }
                 }
             }
         }
     }
     if (empty($arguments_description)) {
         $arguments_description = 'Phoronix Test Suite v' . PTS_VERSION;
     }
     foreach (pts_client::environmental_variables() as $key => $value) {
         $arguments_description = str_replace('$' . $key, $value, $arguments_description);
         if (!in_array($key, array('VIDEO_MEMORY', 'NUM_CPU_CORES', 'NUM_CPU_JOBS'))) {
             $extra_arguments = str_replace('$' . $key, $value, $extra_arguments);
         }
     }
     // Any device notes to add to PTS test notes area?
     foreach (phodevi::read_device_notes($test_type) as $note) {
         pts_test_notes_manager::add_note($note);
     }
     // As of PTS 4.4, this is removed and superceded effectively by reporting the notes to table
     // Any special information (such as forced AA/AF levels for graphics) to add to the description string of the result?
     /*
     if(($special_string = phodevi::read_special_settings_string($test_type)) != null)
     {
     	if(strpos($arguments_description, $special_string) === false)
     	{
     		if($arguments_description != null)
     		{
     			$arguments_description .= ' | ';
     		}
     
     		$arguments_description .= $special_string;
     	}
     }
     */
     // Result Calculation
     $test_run_request->set_used_arguments_description($arguments_description);
     $test_run_request->set_used_arguments($extra_arguments);
     pts_test_result_parser::calculate_end_result($test_run_request, $active_result_buffer);
     // Process results
     pts_client::$display->test_run_end($test_run_request);
     pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_post_run_message());
     pts_module_manager::module_process('__post_test_run', $test_run_request);
     $report_elapsed_time = $cache_share_present == false && $test_run_request->active->get_result() != 0;
     pts_tests::update_test_install_xml($test_run_request->test_profile, $report_elapsed_time ? $time_test_elapsed : 0);
     pts_storage_object::add_in_file(PTS_CORE_STORAGE, 'total_testing_time', $time_test_elapsed / 60);
     if ($report_elapsed_time && pts_client::do_anonymous_usage_reporting() && $time_test_elapsed >= 60) {
         // If anonymous usage reporting enabled, report test run-time to OpenBenchmarking.org
         pts_openbenchmarking_client::upload_usage_data('test_complete', array($test_run_request, $time_test_elapsed));
     }
     // Remove lock
     pts_client::release_lock($lock_file);
     return $active_result_buffer;
 }
Exemplo n.º 8
0
 public static function display_web_page($URL, $alt_text = null, $default_open = true, $auto_open = false)
 {
     if (pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false || defined('PHOROMATIC_PROCESS')) {
         return;
     }
     if ($auto_open == false) {
         $view_results = pts_user_io::prompt_bool_input($alt_text == null ? 'Do you want to view the results in your web browser' : $alt_text, $default_open);
     } else {
         $view_results = true;
     }
     if ($view_results) {
         static $browser = null;
         if ($browser == null) {
             $config_browser = pts_config::read_user_config('PhoronixTestSuite/Options/General/DefaultBrowser', null);
             if ($config_browser != null && (is_executable($config_browser) || ($config_browser = pts_client::executable_in_path($config_browser)))) {
                 $browser = $config_browser;
             } else {
                 if (phodevi::is_windows()) {
                     $windows_browsers = array('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', 'C:\\Program Files\\Internet Explorer\\iexplore.exe');
                     foreach ($windows_browsers as $browser_test) {
                         if (is_executable($browser_test)) {
                             $browser = $browser_test;
                             break;
                         }
                     }
                     if (substr($URL, 0, 1) == '\\') {
                         $URL = 'file:///C:' . str_replace('/', '\\', $URL);
                     }
                 } else {
                     $possible_browsers = array('firefox', 'mozilla', 'x-www-browser', 'open', 'xdg-open', 'iceweasel', 'konqueror', 'epiphany', 'google-chrome');
                     foreach ($possible_browsers as &$b) {
                         if ($b = pts_client::executable_in_path($b)) {
                             $browser = $b;
                             break;
                         }
                     }
                 }
             }
         }
         if ($browser != null) {
             shell_exec($browser . ' "' . $URL . '" 2> /dev/null &');
         } else {
             echo PHP_EOL . 'No Web Browser Found.' . PHP_EOL;
         }
     }
 }
 public static function install_dependencies(&$test_profiles)
 {
     // PTS External Dependencies install on distribution
     if (phodevi::is_windows() || phodevi::is_macosx() || pts_flags::no_external_dependencies()) {
         // Windows doesn't use any external dependencies
         return true;
     }
     // Find all the tests that need to be checked
     $tests_to_check = array();
     foreach ($test_profiles as $test_profile) {
         if (!in_array($test_profile, $tests_to_check) && $test_profile->is_supported()) {
             array_push($tests_to_check, $test_profile);
         }
     }
     // Find all of the POSSIBLE test dependencies
     $required_test_dependencies = array();
     foreach ($tests_to_check as &$test_profile) {
         foreach ($test_profile->get_dependencies() as $test_dependency) {
             if (empty($test_dependency)) {
                 continue;
             }
             if (isset($required_test_dependencies[$test_dependency]) == false) {
                 $required_test_dependencies[$test_dependency] = array();
             }
             array_push($required_test_dependencies[$test_dependency], $test_profile);
         }
     }
     if (pts_c::$test_flags & pts_c::skip_tests_with_missing_dependencies) {
         // Remove tests that have external dependencies that aren't satisfied and then return
         $generic_packages_needed = array();
         $required_test_dependencies_copy = $required_test_dependencies;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
         return true;
     }
     if (!empty($required_test_dependencies)) {
         // The 'common-dependencies' package is any general non-explicitly-required but nice-to-have packages like mesa-utils for providing glxinfo about the system
         // So if we're going to be installing external dependencies anyways, might as well try to see the common-dependencies are satisfied
         $required_test_dependencies['common-dependencies'] = array();
     }
     // Does the user wish to skip any particular dependencies?
     if (pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES')) {
         $dependencies_to_skip = explode(',', pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES'));
         foreach ($dependencies_to_skip as $dependency_name) {
             if (isset($required_test_dependencies[$dependency_name])) {
                 unset($required_test_dependencies[$dependency_name]);
             }
         }
     }
     // Make a copy for use to check at end of process to see if all dependencies were actually found
     $required_test_dependencies_copy = $required_test_dependencies;
     // Find the dependencies that are actually missing from the system
     $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies);
     // If it's automated and can't install without root, return true if there are no dependencies to do otherwise false
     if (pts_c::$test_flags & pts_c::auto_mode && phodevi::is_root() == false) {
         return count($dependencies_to_install) == 0;
     }
     // Do the actual dependency install process
     if (count($dependencies_to_install) > 0) {
         self::install_packages_on_system($dependencies_to_install);
     }
     // There were some dependencies not supported on this OS or are missing from the distro's XML file
     if (count($required_test_dependencies) > 0 && count($dependencies_to_install) == 0) {
         $exdep_generic_parser = new pts_exdep_generic_parser();
         $to_report = array();
         foreach (array_keys($required_test_dependencies) as $dependency) {
             $dependency_data = $exdep_generic_parser->get_package_data($dependency);
             if ($dependency_data['possible_packages'] != null) {
                 array_push($to_report, $dependency_data['title'] . PHP_EOL . 'Possible Package Names: ' . $dependency_data['possible_packages']);
             }
         }
         if (count($to_report) > 0) {
             echo PHP_EOL . 'Some additional dependencies are required, but they could not be installed automatically for your operating system.' . PHP_EOL . 'Below are the software packages that must be installed.' . PHP_EOL . PHP_EOL;
             foreach ($to_report as $report) {
                 pts_client::$display->generic_heading($report);
             }
             if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode) {
                 echo 'The above dependencies should be installed before proceeding. Press any key when you\'re ready to continue.';
                 pts_user_io::read_user_input();
                 echo PHP_EOL;
             }
         }
     }
     // Find the dependencies that are still missing from the system
     if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode && !defined('PHOROMATIC_PROCESS')) {
         $generic_packages_needed = array();
         $required_test_dependencies = $required_test_dependencies_copy;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         if (count($generic_packages_needed) > 0) {
             echo PHP_EOL . 'There are dependencies still missing from the system:' . PHP_EOL;
             echo pts_user_io::display_text_list(self::generic_names_to_titles($generic_packages_needed));
             $actions = array('IGNORE' => 'Ignore missing dependencies and proceed with installation.', 'SKIP_TESTS_WITH_MISSING_DEPS' => 'Skip installing the tests with missing dependencies.', 'REATTEMPT_DEP_INSTALL' => 'Re-attempt to install the missing dependencies.', 'QUIT' => 'Quit the current Phoronix Test Suite process.');
             $selected_action = pts_user_io::prompt_text_menu('Missing dependencies action', $actions, false, true);
             switch ($selected_action) {
                 case 'IGNORE':
                     break;
                 case 'SKIP_TESTS_WITH_MISSING_DEPS':
                     // Unset the tests that have dependencies still missing
                     self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
                     break;
                 case 'REATTEMPT_DEP_INSTALL':
                     self::install_packages_on_system($dependencies_to_install);
                     break;
                 case 'QUIT':
                     exit(0);
             }
         }
     }
     return true;
 }
Exemplo n.º 10
0
 public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null)
 {
     if (isset($extra_attributes['sort_result_buffer'])) {
         $result_object->test_result_buffer->sort_buffer_items();
     }
     if (isset($extra_attributes['reverse_result_buffer'])) {
         $result_object->test_result_buffer->buffer_values_reverse();
     }
     if (isset($extra_attributes['normalize_result_buffer'])) {
         if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) {
             $normalize_against = $extra_attributes['highlight_graph_values'][0];
         } else {
             $normalize_against = false;
         }
         $result_object->normalize_buffer_values($normalize_against);
     }
     if ($result_file != null) {
         // Cache the redundant words on identifiers so it's not re-computed on every graph
         static $redundant_word_cache;
         if (!isset($redundant_word_cache[$result_file->get_title()])) {
             $redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers());
         }
         if ($redundant_word_cache[$result_file->get_title()]) {
             $result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]);
         }
     }
     self::multi_way_compact($result_file, $result_object, $extra_attributes);
     $display_format = $result_object->test_profile->get_display_format();
     $bar_orientation = 'HORIZONTAL';
     // default to horizontal bar graph
     switch ($display_format) {
         case 'LINE_GRAPH':
             if (false && $result_object->test_result_buffer->get_count() > 5) {
                 // If there's too many lines close to each other, it's likely to look cluttered so turn it into horizontal range bar / box chart graph
                 $display_format = 'HORIZONTAL_BOX_PLOT';
                 $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file);
             } else {
                 $graph = new pts_LineGraph($result_object, $result_file);
             }
             break;
         case 'HORIZONTAL_BOX_PLOT':
             $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file);
             break;
         case 'BAR_ANALYZE_GRAPH':
         case 'BAR_GRAPH':
             if ($bar_orientation == 'VERTICAL') {
                 $graph = new pts_VerticalBarGraph($result_object, $result_file);
             } else {
                 $graph = new pts_HorizontalBarGraph($result_object, $result_file);
             }
             break;
         case 'PASS_FAIL':
             $graph = new pts_PassFailGraph($result_object, $result_file);
             break;
         case 'MULTI_PASS_FAIL':
             $graph = new pts_MultiPassFailGraph($result_object, $result_file);
             break;
         case 'TEST_COUNT_PASS':
             $graph = new pts_TestCountPassGraph($result_object, $result_file);
             break;
         case 'PIE_CHART':
             $graph = new pts_PieChart($result_object, $result_file);
             break;
         case 'IMAGE_COMPARISON':
             $graph = new pts_ImageComparisonGraph($result_object, $result_file);
             break;
         case 'FILLED_LINE_GRAPH':
             $graph = new pts_FilledLineGraph($result_object, $result_file);
             break;
         case 'SCATTER_PLOT':
             $graph = new pts_ScatterPlot($result_object, $result_file);
             break;
         default:
             if (isset($extra_attributes['graph_render_type'])) {
                 $requested_graph_type = $extra_attributes['graph_render_type'];
             } else {
                 if (defined('GRAPH_RENDER_TYPE')) {
                     $requested_graph_type = GRAPH_RENDER_TYPE;
                 } else {
                     $requested_graph_type = null;
                 }
             }
             switch ($requested_graph_type) {
                 case 'CANDLESTICK':
                     $graph = new pts_CandleStickGraph($result_object, $result_file);
                     break;
                 case 'LINE_GRAPH':
                     $graph = new pts_LineGraph($result_object, $result_file);
                     break;
                 case 'FILLED_LINE_GRAPH':
                     $graph = new pts_FilledLineGraph($result_object, $result_file);
                     break;
                 default:
                     if ($bar_orientation == 'VERTICAL') {
                         $graph = new pts_VerticalBarGraph($result_object, $result_file);
                     } else {
                         $graph = new pts_HorizontalBarGraph($result_object, $result_file);
                     }
                     break;
             }
             break;
     }
     if (isset($extra_attributes['regression_marker_threshold'])) {
         $graph->markResultRegressions($extra_attributes['regression_marker_threshold']);
     }
     if (isset($extra_attributes['set_alternate_view'])) {
         $graph->setAlternateView($extra_attributes['set_alternate_view']);
     }
     if (isset($extra_attributes['sort_result_buffer_values'])) {
         $result_object->test_result_buffer->buffer_values_sort();
         if ($result_object->test_profile->get_result_proportion() == 'HIB') {
             $result_object->test_result_buffer->buffer_values_reverse();
         }
     }
     if (isset($extra_attributes['highlight_graph_values'])) {
         $graph->highlight_values($extra_attributes['highlight_graph_values']);
     }
     if (isset($extra_attributes['force_simple_keys'])) {
         $graph->override_i_value('force_simple_keys', true);
     } else {
         if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) {
             $graph->highlight_values(pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT')));
         }
     }
     switch ($display_format) {
         case 'LINE_GRAPH':
             if (isset($extra_attributes['no_overview_text']) && $graph instanceof pts_LineGraph) {
                 $graph->plot_overview_text = false;
             }
         case 'FILLED_LINE_GRAPH':
         case 'BAR_ANALYZE_GRAPH':
         case 'SCATTER_PLOT':
             //$graph->hideGraphIdentifiers();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 $graph->loadGraphValues(pts_strings::comma_explode($buffer_item->get_result_value()), $buffer_item->get_result_identifier());
                 $graph->loadGraphRawValues(pts_strings::comma_explode($buffer_item->get_result_raw()));
             }
             $scale_special = $result_object->test_profile->get_result_scale_offset();
             if (!empty($scale_special) && count($ss = pts_strings::comma_explode($scale_special)) > 0) {
                 $graph->loadGraphIdentifiers($ss);
             }
             break;
         case 'HORIZONTAL_BOX_PLOT':
             // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
             $identifiers = array();
             $values = array();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 array_push($identifiers, $buffer_item->get_result_identifier());
                 array_push($values, pts_strings::comma_explode($buffer_item->get_result_value()));
             }
             $graph->loadGraphIdentifiers($identifiers);
             $graph->loadGraphValues($values);
             break;
         default:
             // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
             $identifiers = array();
             $values = array();
             $raw_values = array();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 array_push($identifiers, $buffer_item->get_result_identifier());
                 array_push($values, $buffer_item->get_result_value());
                 array_push($raw_values, $buffer_item->get_result_raw());
             }
             $graph->loadGraphIdentifiers($identifiers);
             $graph->loadGraphValues($values);
             $graph->loadGraphRawValues($raw_values);
             break;
     }
     self::report_test_notes_to_graph($graph, $result_object);
     return $graph;
 }
Exemplo n.º 11
0
 public static function sw_wine_version()
 {
     $wine_version = null;
     if (pts_client::executable_in_path('wine') != false) {
         $wine_version = trim(shell_exec('wine --version 2>&1'));
     } else {
         if (pts_client::executable_in_path('winecfg.exe') != false && pts_client::read_env('WINE_VERSION')) {
             $wine_version = trim(pts_client::read_env('WINE_VERSION'));
             if (stripos($wine_version, 'wine') === false) {
                 $wine_version = 'wine-' . $wine_version;
             }
         }
     }
     return $wine_version;
 }
 public static function prompt_user_options(&$test_profile, $preset_selections = null)
 {
     $user_args = array();
     $text_args = array();
     if (($cli_presets_env = pts_client::read_env('PRESET_OPTIONS')) != false) {
         // To specify test options externally from an environment variable
         // i.e. PRESET_OPTIONS='stream.run-type=Add' ./phoronix-test-suite benchmark stream
         // The string format is <test-name>.<test-option-name-from-XML-file>=<test-option-value>
         // The test-name can either be the short/base name (e.g. stream) or the full identifier (pts/stream) without version postfix
         // Multiple preset options can be delimited with the PRESET_OPTIONS environment variable via a semicolon ;
         $preset_selections = pts_client::parse_value_string_double_identifier($cli_presets_env);
     }
     $identifier_short = $test_profile->get_identifier_base_name();
     $identifier_full = $test_profile->get_identifier(false);
     if (count($test_profile->get_test_option_objects()) > 0) {
         pts_client::$display->test_run_configure($test_profile);
     }
     foreach ($test_profile->get_test_option_objects() as $i => $o) {
         $option_identifier = $o->get_identifier();
         if ($o->option_count() == 0) {
             // User inputs their option as there is nothing to select
             if (isset($preset_selections[$identifier_short][$option_identifier])) {
                 $value = $preset_selections[$identifier_short][$option_identifier];
                 echo PHP_EOL . '    Using Pre-Set Run Option: ' . $value . PHP_EOL;
             } else {
                 if (isset($preset_selections[$identifier_full][$option_identifier])) {
                     $value = $preset_selections[$identifier_full][$option_identifier];
                     echo PHP_EOL . '    Using Pre-Set Run Option: ' . $value . PHP_EOL;
                 } else {
                     echo PHP_EOL . $o->get_name() . PHP_EOL;
                     $value = pts_user_io::prompt_user_input('Enter Value');
                 }
             }
             array_push($text_args, array($o->format_option_display_from_input($value)));
             array_push($user_args, array($o->format_option_value_from_input($value)));
         } else {
             // Have the user select the desired option
             if (isset($preset_selections[$identifier_short][$option_identifier])) {
                 $bench_choice = $preset_selections[$identifier_short][$option_identifier];
                 echo PHP_EOL . '    Using Pre-Set Run Option: ' . $bench_choice . PHP_EOL;
             } else {
                 if (isset($preset_selections[$identifier_full][$option_identifier])) {
                     $bench_choice = $preset_selections[$identifier_full][$option_identifier];
                     echo PHP_EOL . '    Using Pre-Set Run Option: ' . $bench_choice . PHP_EOL;
                 } else {
                     $option_names = $o->get_all_option_names_with_messages();
                     if (count($option_names) > 1) {
                         //echo PHP_EOL . $o->get_name() . ':' . PHP_EOL;
                         array_push($option_names, 'Test All Options');
                     }
                     $bench_choice = pts_user_io::prompt_text_menu($o->get_name(), $option_names, true, true, pts_client::$display->get_tab() . pts_client::$display->get_tab());
                     echo PHP_EOL;
                 }
             }
             $bench_choice = $o->parse_selection_choice_input($bench_choice);
             // Format the selected option(s)
             $option_args = array();
             $option_args_description = array();
             foreach ($bench_choice as $c) {
                 array_push($option_args, $o->format_option_value_from_select($c));
                 array_push($option_args_description, $o->format_option_display_from_select($c));
             }
             array_push($text_args, $option_args_description);
             array_push($user_args, $option_args);
         }
     }
     $test_args = array();
     $test_args_description = array();
     self::compute_all_combinations($test_args, null, $user_args, 0);
     self::compute_all_combinations($test_args_description, null, $text_args, 0, ' - ');
     return array($test_args, $test_args_description);
 }
Exemplo n.º 13
0
    public static function run_matisk($args)
    {
        echo PHP_EOL . 'MATISK For The Phoronix Test Suite' . PHP_EOL;
        if (!isset($args[0]) || !is_file($args[0])) {
            echo PHP_EOL . 'You must specify a MATISK INI file to load.' . PHP_EOL . PHP_EOL;
            return false;
        }
        self::$matisk_config_dir = dirname($args[0]) . '/';
        pts_file_io::mkdir(pts_module::save_dir());
        $ini = parse_ini_file($args[0], true);
        foreach (self::$ini_struct as $section => $items) {
            foreach ($items as $key => $r) {
                if (is_array($r) && !isset($ini[$section][$key])) {
                    $ini[$section][$key] = $r[0];
                }
            }
        }
        // Checks
        if (pts_test_suite::is_suite($ini['workload']['suite']) == false) {
            // See if the XML suite-definition was just tossed into the same directory
            if (($xml_file = self::find_file($ini['workload']['suite'] . '.xml')) !== false) {
                pts_file_io::mkdir(PTS_TEST_SUITE_PATH . 'local/' . $ini['workload']['suite']);
                copy($xml_file, PTS_TEST_SUITE_PATH . 'local/' . $ini['workload']['suite'] . '/suite-definition.xml');
            }
            if (pts_test_suite::is_suite($ini['workload']['suite']) == false) {
                echo PHP_EOL . 'A test suite must be specified to execute. If a suite needs to be constructed, run: ' . PHP_EOL . 'phoronix-test-suite build-suite' . PHP_EOL . PHP_EOL;
                return false;
            }
        }
        if ($ini['set_context']['external_contexts'] != null) {
            switch ($ini['set_context']['external_contexts_delimiter']) {
                case 'EOL':
                case '':
                    $ini['set_context']['external_contexts_delimiter'] = PHP_EOL;
                    break;
                case 'TAB':
                    $ini['set_context']['external_contexts_delimiter'] = "\t";
                    break;
            }
            if ($ff = self::find_file($ini['set_context']['external_contexts'])) {
                if (is_executable($ff)) {
                    $ini['set_context']['context'] = shell_exec($ff . ' 2> /dev/null');
                } else {
                    $ini['set_context']['context'] = file_get_contents($ff);
                }
            } else {
                // Hopefully it's a command to execute then...
                $ini['set_context']['context'] = shell_exec($ini['set_context']['external_contexts'] . ' 2> /dev/null');
            }
            $ini['set_context']['context'] = explode($ini['set_context']['external_contexts_delimiter'], $ini['set_context']['context']);
        } else {
            if ($ini['set_context']['context'] != null && !is_array($ini['set_context']['context'])) {
                $ini['set_context']['context'] = array($ini['set_context']['context']);
            }
        }
        if (is_array($ini['set_context']['context']) && count($ini['set_context']['context']) > 0) {
            foreach ($ini['set_context']['context'] as $i => $context) {
                if ($context == null) {
                    unset($ini['set_context']['context'][$i]);
                }
            }
            // Context testing
            if (count($ini['set_context']['context']) > 0 && $ini['set_context']['pre_run'] == null && $ini['set_context']['pre_install'] == null) {
                echo PHP_EOL . 'The pre_run or pre_install set_context fields must be set in order to set the system\'s context.' . PHP_EOL;
                return false;
            }
            if ($ini['set_context']['reverse_context_order']) {
                $ini['set_context']['context'] = array_reverse($ini['set_context']['context']);
            }
        }
        if (pts_strings::string_bool($ini['workload']['save_results'])) {
            if ($ini['workload']['save_name'] == null) {
                echo PHP_EOL . 'The save_name field cannot be left empty when saving the test results.' . PHP_EOL;
                return false;
            }
            /*
            if($ini['workload']['result_identifier'] == null)
            {
            	echo PHP_EOL . 'The result_identifier field cannot be left empty when saving the test results.' . PHP_EOL;
            	return false;
            }
            */
        }
        if (!empty($ini['environmental_variables']) && is_array($ini['environmental_variables'])) {
            foreach ($ini['environmental_variables'] as $key => $value) {
                putenv(trim($key) . '=' . trim($value));
            }
        }
        if (empty($ini['set_context']['context'])) {
            $ini['set_context']['context'] = array($ini['workload']['result_identifier']);
        }
        if (pts_strings::string_bool($ini['set_context']['log_context_outputs'])) {
            pts_file_io::mkdir(pts_module::save_dir() . $ini['workload']['save_name']);
        }
        $spent_context_file = pts_module::save_dir() . $ini['workload']['save_name'] . '.spent-contexts';
        if (!is_file($spent_context_file)) {
            touch($spent_context_file);
        } else {
            // If recovering from an existing run, don't rerun contexts that were already executed
            $spent_contexts = pts_file_io::file_get_contents($spent_context_file);
            $spent_contexts = explode(PHP_EOL, $spent_contexts);
            foreach ($spent_contexts as $sc) {
                if (($key = array_search($sc, $ini['set_context']['context'])) !== false) {
                    unset($ini['set_context']['context'][$key]);
                }
            }
        }
        if ($ini['set_context']['reboot_support'] && phodevi::is_linux()) {
            // In case a set-context involves a reboot, auto-recover
            $xdg_config_home = is_dir('/etc/xdg/autostart') && is_writable('/etc/xdg/autostart') ? '/etc/xdg/autostart' : pts_client::read_env('XDG_CONFIG_HOME');
            if ($xdg_config_home == false) {
                $xdg_config_home = pts_client::user_home_directory() . '.config';
            }
            if ($xdg_config_home != false && is_dir($xdg_config_home)) {
                $autostart_dir = $xdg_config_home . '/autostart/';
                pts_file_io::mkdir($xdg_config_home . '/autostart/');
            }
            file_put_contents($xdg_config_home . '/autostart/phoronix-test-suite-matisk.desktop', '
[Desktop Entry]
Name=Phoronix Test Suite Matisk Recovery
GenericName=Phoronix Test Suite
Comment=Matisk Auto-Recovery Support
Exec=gnome-terminal -e \'phoronix-test-suite matisk ' . $args[0] . '\'
Icon=phoronix-test-suite
Type=Application
Encoding=UTF-8
Categories=System;Monitor;');
        }
        if ($ini['installation']['block_phodevi_caching']) {
            // Block Phodevi caching if changing out system components and there is a chance one of the strings of changed contexts might be cached (e.g. OpenGL user-space driver)
            phodevi::$allow_phodevi_caching = false;
        }
        if (phodevi::system_uptime() < 60) {
            echo PHP_EOL . 'Sleeping 45 seconds while waiting for the system to settle...' . PHP_EOL;
            sleep(45);
        }
        self::$ini = $ini;
        $total_context_count = count(self::$ini['set_context']['context']);
        while (($context = array_shift(self::$ini['set_context']['context'])) !== null) {
            echo PHP_EOL . ($total_context_count - count(self::$ini['set_context']['context'])) . ' of ' . $total_context_count . ' in test execution queue [' . $context . ']' . PHP_EOL . PHP_EOL;
            self::$context = $context;
            if (pts_strings::string_bool(self::$ini['installation']['install_check']) || $ini['set_context']['pre_install'] != null) {
                self::process_user_config_external_hook_process('pre_install');
                $force_install = false;
                $no_prompts = true;
                if (pts_strings::string_bool(self::$ini['installation']['force_install'])) {
                    $force_install = true;
                }
                if (self::$ini['installation']['external_download_cache'] != null) {
                    pts_test_install_manager::add_external_download_cache(self::$ini['installation']['external_download_cache']);
                }
                // Do the actual test installation
                pts_test_installer::standard_install(self::$ini['workload']['suite'], $force_install, $no_prompts);
                self::process_user_config_external_hook_process('post_install');
            }
            $batch_mode = false;
            $auto_mode = true;
            $test_run_manager = new pts_test_run_manager($batch_mode, $auto_mode);
            if ($test_run_manager->initial_checks(self::$ini['workload']['suite']) == false) {
                return false;
            }
            if (self::$skip_test_set == false) {
                self::process_user_config_external_hook_process('pre_run');
                // Load the tests to run
                if ($test_run_manager->load_tests_to_run(self::$ini['workload']['suite']) == false) {
                    return false;
                }
                // Save results?
                $result_identifier = $ini['workload']['result_identifier'];
                if ($result_identifier == null) {
                    $result_identifier = '$MATISK_CONTEXT';
                }
                // Allow $MATIISK_CONTEXT as a valid user variable to pass it...
                $result_identifier = str_replace('$MATISK_CONTEXT', self::$context, $result_identifier);
                $test_run_manager->set_save_name(self::$ini['workload']['save_name']);
                $test_run_manager->set_results_identifier($result_identifier);
                $test_run_manager->set_description(self::$ini['workload']['description']);
                // Don't upload results unless it's the last in queue where the context count is now 0
                $test_run_manager->auto_upload_to_openbenchmarking(count(self::$ini['set_context']['context']) == 0 && self::$ini['general']['upload_to_openbenchmarking']);
                // Run the actual tests
                $test_run_manager->pre_execution_process();
                $test_run_manager->call_test_runs();
                $test_run_manager->post_execution_process();
            }
            self::$skip_test_set = false;
            file_put_contents($spent_context_file, self::$context . PHP_EOL, FILE_APPEND);
            pts_file_io::unlink(pts_module::save_dir() . self::$context . '.last-call');
            self::process_user_config_external_hook_process('post_run');
        }
        unlink($spent_context_file);
        isset($xdg_config_home) && pts_file_io::unlink($xdg_config_home . '/autostart/phoronix-test-suite-matisk.desktop');
    }
 public function check_file_hash($file)
 {
     if (!is_file($file)) {
         return false;
     } else {
         if (pts_client::read_env('NO_FILE_HASH_CHECKS') != false || pts_flags::skip_md5_checks()) {
             return true;
         } else {
             if ($this->sha256) {
                 return hash_file('sha256', $file) == $this->sha256;
             } else {
                 if ($this->md5) {
                     return md5_file($file) == $this->md5;
                 } else {
                     if (filesize($file) > 0) {
                         return true;
                     } else {
                         return false;
                     }
                 }
             }
         }
     }
 }
 public static function detect_modules_to_load()
 {
     // Auto detect modules to load
     $env_vars = pts_storage_object::read_from_file(PTS_TEMP_STORAGE, 'environmental_variables_for_modules');
     if ($env_vars == false) {
         $env_vars = pts_module_manager::modules_environmental_variables();
     }
     foreach ($env_vars as $env_var => $modules) {
         if (($e = pts_client::read_env($env_var)) != false && !empty($e)) {
             foreach ($modules as $module) {
                 if (!pts_module_manager::is_module_attached($module)) {
                     pts_module_manager::attach_module($module);
                 }
             }
         }
     }
 }
 public function is_supported($report_warnings = true)
 {
     $test_supported = true;
     if (PTS_IS_CLIENT && pts_client::read_env('SKIP_TEST_SUPPORT_CHECKS')) {
         // set SKIP_TEST_SUPPORT_CHECKS=1 environment variable for debugging purposes to run tests on unsupported platforms
         return true;
     } else {
         if ($this->is_test_architecture_supported() == false) {
             PTS_IS_CLIENT && $report_warnings && pts_client::$display->test_run_error($this->get_identifier() . ' is not supported on this architecture: ' . phodevi::read_property('system', 'kernel-architecture'));
             $test_supported = false;
         } else {
             if ($this->is_test_platform_supported() == false) {
                 PTS_IS_CLIENT && $report_warnings && pts_client::$display->test_run_error($this->get_identifier() . ' is not supported by this operating system: ' . phodevi::operating_system());
                 $test_supported = false;
             } else {
                 if ($this->is_core_version_supported() == false) {
                     PTS_IS_CLIENT && $report_warnings && pts_client::$display->test_run_error($this->get_identifier() . ' is not supported by this version of the Phoronix Test Suite: ' . PTS_VERSION);
                     $test_supported = false;
                 } else {
                     if (PTS_IS_CLIENT && ($custom_support_check = $this->custom_test_support_check()) !== true) {
                         // A custom-self-generated error occurred, see code comments in custom_test_support_check()
                         PTS_IS_CLIENT && $report_warnings && is_callable(array(pts_client::$display, 'test_run_error')) && pts_client::$display->test_run_error($this->get_identifier() . ': ' . $custom_support_check);
                         $test_supported = false;
                     } else {
                         if (PTS_IS_CLIENT) {
                             foreach ($this->extended_test_profiles() as $extension) {
                                 if ($extension->is_supported($report_warnings) == false) {
                                     $test_supported = false;
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $test_supported;
 }
 public static function download_cache_locations()
 {
     static $cache_directories = null;
     if ($cache_directories == null) {
         $cache_directories = array();
         // Phoronix Test Suite System Cache Directories
         $additional_dir_checks = array('/var/cache/phoronix-test-suite/download-cache/', '/var/cache/phoronix-test-suite/');
         foreach ($additional_dir_checks as $dir_check) {
             if (is_dir($dir_check)) {
                 $cache_directories[] = $dir_check;
                 break;
             }
         }
         // User Defined Directory Checking
         $dir_string = ($dir = pts_client::read_env('PTS_DOWNLOAD_CACHE')) != false ? $dir : null;
         foreach (array_merge(self::$extra_caches, pts_strings::colon_explode($dir_string)) as $dir_check) {
             if ($dir_check == null) {
                 continue;
             }
             $dir_check = pts_strings::parse_for_home_directory($dir_check);
             if (pts_strings::is_url($dir_check) == false && !is_dir($dir_check)) {
                 continue;
             }
             $cache_directories[] = pts_strings::add_trailing_slash($dir_check);
         }
         if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SearchMediaForCache', 'TRUE')) {
             $download_cache_dirs = array_merge(pts_file_io::glob('/media/*/download-cache/'), pts_file_io::glob('/media/*/*/download-cache/'), pts_file_io::glob('/run/media/*/*/download-cache/'), pts_file_io::glob('/Volumes/*/download-cache/'));
             foreach ($download_cache_dirs as $dir) {
                 $cache_directories[] = $dir;
             }
         }
     }
     return $cache_directories;
 }
Exemplo n.º 18
0
 public function __construct(&$result_object = null, &$result_file = null, $extra_attributes = null)
 {
     // Initalize Colors
     $this->i['identifier_size'] = self::$c['size']['identifiers'];
     // Copy this since it's commonly overwritten
     $this->i['graph_orientation'] = 'VERTICAL';
     $this->i['graph_value_type'] = 'NUMERICAL';
     $this->i['hide_graph_identifiers'] = false;
     $this->i['show_graph_key'] = false;
     $this->i['show_background_lines'] = false;
     $this->i['iveland_view'] = false;
     $this->i['graph_max_value_multiplier'] = 1.285;
     $this->i['graph_max_value'] = 0;
     $this->i['bottom_offset'] = 0;
     $this->i['hide_y_title'] = false;
     $this->i['compact_result_view'] = false;
     $this->i['key_line_height'] = 0;
     $this->i['graph_height'] = 0;
     $this->i['graph_width'] = 0;
     $this->i['left_start'] = 10;
     $this->i['left_end_right'] = 10;
     $this->i['top_start'] = 62;
     $this->i['top_end_bottom'] = 22;
     $this->i['mark_count'] = 6;
     // Number of marks to make on vertical axis
     $this->i['notes'] = array();
     // Reset of setup besides config
     if ($result_object != null) {
         $test_version = $result_object->test_profile->get_app_version();
         if (isset($test_version[2]) && is_numeric($test_version[0])) {
             $test_version = 'v' . $test_version;
         }
         $this->graph_title = trim($result_object->test_profile->get_title() . ' ' . $test_version);
         $this->graph_y_title = $result_object->test_profile->get_result_scale_formatted();
         $this->test_identifier = $result_object->test_profile->get_identifier();
         $this->i['graph_proportion'] = $result_object->test_profile->get_result_proportion();
         $this->addSubTitle($result_object->get_arguments_description());
     }
     $this->update_graph_dimensions(self::$c['graph']['width'], self::$c['graph']['height'], true);
     if (isset($extra_attributes['force_tracking_line_graph'])) {
         // Phoromatic result tracker
         $this->is_multi_way_comparison = true;
     } else {
         $this->is_multi_way_comparison = phx_graph_render::multi_way_identifier_check($result_object->test_result_buffer->get_identifiers());
     }
     $this->i['graph_version'] = 'Phoronix Test Suite ' . PTS_VERSION;
     if (isset($extra_attributes['regression_marker_threshold'])) {
         $this->d['regression_marker_threshold'] = $extra_attributes['regression_marker_threshold'];
     }
     if (isset($extra_attributes['set_alternate_view'])) {
         $this->d['link_alternate_view'] = $extra_attributes['set_alternate_view'];
     }
     if (isset($extra_attributes['highlight_graph_values'])) {
         $this->value_highlights = $extra_attributes['highlight_graph_values'];
     } else {
         if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) {
             $this->value_highlights = pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT'));
         }
     }
     if (isset($extra_attributes['force_simple_keys'])) {
         $this->override_i_value('force_simple_keys', true);
     }
     $this->test_result =& $result_object;
     $this->generate_results_var();
 }
Exemplo n.º 19
0
 public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null)
 {
     if (isset($extra_attributes['sort_result_buffer'])) {
         $result_object->test_result_buffer->sort_buffer_items();
     }
     if (isset($extra_attributes['reverse_result_buffer'])) {
         $result_object->test_result_buffer->buffer_values_reverse();
     }
     if (isset($extra_attributes['normalize_result_buffer'])) {
         if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) {
             $normalize_against = $extra_attributes['highlight_graph_values'][0];
         } else {
             $normalize_against = false;
         }
         $result_object->normalize_buffer_values($normalize_against);
     }
     if ($result_file != null) {
         // Cache the redundant words on identifiers so it's not re-computed on every graph
         static $redundant_word_cache;
         if (!isset($redundant_word_cache[$result_file->get_title()])) {
             $redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers());
         }
         if ($redundant_word_cache[$result_file->get_title()]) {
             $result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]);
         }
         // COMPACT PROCESS
         if (!isset($extra_attributes['compact_to_scalar']) && $result_object->test_profile->get_display_format() == 'LINE_GRAPH' && $result_file->get_system_count() > 10) {
             // If there's too many lines being plotted on line graph, likely to look messy, so convert to scalar automatically
             $extra_attributes['compact_to_scalar'] = true;
         }
         // XXX: removed || $result_file->is_results_tracker() from below and should be added
         // Removing the command fixes cases like: 1210053-BY-MYRESULTS43
         $result_identifiers = $result_object->test_result_buffer->get_identifiers();
         if ($result_file->is_multi_way_comparison($result_identifiers, $extra_attributes) || isset($extra_attributes['compact_to_scalar']) || isset($extra_attributes['compact_scatter'])) {
             if ((isset($extra_attributes['compact_to_scalar']) || false && $result_file->is_multi_way_comparison($result_identifiers, $extra_attributes)) && in_array($result_object->test_profile->get_display_format(), array('FILLED_LINE_GRAPH'))) {
                 // Convert multi-way line graph into horizontal box plot
                 if (true) {
                     $result_object->test_profile->set_display_format('HORIZONTAL_BOX_PLOT');
                 }
                 /*	else // XXX commented out during PTS 6.0 development, TODO decide if to delete
                 					{
                 						// Turn a multi-way line graph into an averaged bar graph
                 						$buffer_items = $result_object->test_result_buffer->get_buffer_items();
                 						$result_object->test_result_buffer = new pts_test_result_buffer();
                 
                 						foreach($buffer_items as $buffer_item)
                 						{
                 							$values = pts_strings::comma_explode($buffer_item->get_result_value());
                 							$avg_value = pts_math::set_precision(array_sum($values) / count($values), 2);
                 							$j = null;
                 							if(count($values) > 2)
                 							{
                 								$j['min-result'] = min($values);
                 								$j['max-result'] = max($values);
                 
                 								if($j['min-result'] == $j['max-result'])
                 								{
                 									$json = null;
                 								}
                 							}
                 
                 							$result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $avg_value, null, $j, $j['min-result'], $j['max-result']);
                 						}
                 
                 						$result_object->test_profile->set_display_format('BAR_GRAPH');
                 					} */
             }
             if ($result_object->test_profile->get_display_format() != 'PIE_CHART') {
                 $result_table = false;
                 pts_render::compact_result_file_test_object($result_object, $result_table, $result_file, $extra_attributes);
             }
         } else {
             if (in_array($result_object->test_profile->get_display_format(), array('LINE_GRAPH'))) {
                 // Check to see for line graphs if every result is an array of the same result (i.e. a flat line for every result).
                 // If all the results are just flat lines, you might as well convert it to a bar graph
                 $buffer_items = $result_object->test_result_buffer->get_buffer_items();
                 $all_values_are_flat = false;
                 $flat_values = array();
                 foreach ($buffer_items as $i => $buffer_item) {
                     $unique_in_buffer = array_unique(explode(',', $buffer_item->get_result_value()));
                     $all_values_are_flat = count($unique_in_buffer) == 1;
                     if ($all_values_are_flat == false) {
                         break;
                     }
                     $flat_values[$i] = array_pop($unique_in_buffer);
                 }
                 if ($all_values_are_flat) {
                     $result_object->test_result_buffer = new pts_test_result_buffer();
                     foreach ($buffer_items as $i => $buffer_item) {
                         $result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $flat_values[$i]);
                     }
                     $result_object->test_profile->set_display_format('BAR_GRAPH');
                 }
             }
         }
     }
     $display_format = $result_object->test_profile->get_display_format();
     $bar_orientation = 'HORIZONTAL';
     // default to horizontal bar graph
     switch ($display_format) {
         case 'LINE_GRAPH':
             if (false && $result_object->test_result_buffer->get_count() > 5) {
                 // If there's too many lines close to each other, it's likely to look cluttered so turn it into horizontal range bar / box chart graph
                 $display_format = 'HORIZONTAL_BOX_PLOT';
                 $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file);
             } else {
                 $graph = new pts_LineGraph($result_object, $result_file);
             }
             break;
         case 'HORIZONTAL_BOX_PLOT':
             $graph = new pts_HorizontalBoxPlotGraph($result_object, $result_file);
             break;
         case 'BAR_ANALYZE_GRAPH':
         case 'BAR_GRAPH':
             if ($bar_orientation == 'VERTICAL') {
                 $graph = new pts_VerticalBarGraph($result_object, $result_file);
             } else {
                 $graph = new pts_HorizontalBarGraph($result_object, $result_file);
             }
             break;
         case 'PASS_FAIL':
             $graph = new pts_PassFailGraph($result_object, $result_file);
             break;
         case 'MULTI_PASS_FAIL':
             $graph = new pts_MultiPassFailGraph($result_object, $result_file);
             break;
         case 'TEST_COUNT_PASS':
             $graph = new pts_TestCountPassGraph($result_object, $result_file);
             break;
         case 'PIE_CHART':
             $graph = new pts_PieChart($result_object, $result_file);
             break;
         case 'IMAGE_COMPARISON':
             $graph = new pts_ImageComparisonGraph($result_object, $result_file);
             break;
         case 'SCATTER_PLOT':
             $graph = new pts_ScatterPlot($result_object, $result_file);
             break;
         default:
             if (isset($extra_attributes['graph_render_type'])) {
                 $requested_graph_type = $extra_attributes['graph_render_type'];
             } else {
                 if (defined('GRAPH_RENDER_TYPE')) {
                     $requested_graph_type = GRAPH_RENDER_TYPE;
                 } else {
                     $requested_graph_type = null;
                 }
             }
             switch ($requested_graph_type) {
                 case 'CANDLESTICK':
                     $graph = new pts_CandleStickGraph($result_object, $result_file);
                     break;
                 case 'LINE_GRAPH':
                     $graph = new pts_LineGraph($result_object, $result_file);
                     break;
                 default:
                     if ($bar_orientation == 'VERTICAL') {
                         $graph = new pts_VerticalBarGraph($result_object, $result_file);
                     } else {
                         $graph = new pts_HorizontalBarGraph($result_object, $result_file);
                     }
                     break;
             }
             break;
     }
     if (isset($extra_attributes['regression_marker_threshold'])) {
         $graph->markResultRegressions($extra_attributes['regression_marker_threshold']);
     }
     if (isset($extra_attributes['set_alternate_view'])) {
         $graph->setAlternateView($extra_attributes['set_alternate_view']);
     }
     if (isset($extra_attributes['sort_result_buffer_values'])) {
         $result_object->test_result_buffer->buffer_values_sort();
         if ($result_object->test_profile->get_result_proportion() == 'HIB') {
             $result_object->test_result_buffer->buffer_values_reverse();
         }
     }
     if (isset($extra_attributes['highlight_graph_values'])) {
         $graph->highlight_values($extra_attributes['highlight_graph_values']);
     }
     if (isset($extra_attributes['force_simple_keys'])) {
         $graph->override_i_value('force_simple_keys', true);
     } else {
         if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) {
             $graph->highlight_values(pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT')));
         }
     }
     switch ($display_format) {
         case 'LINE_GRAPH':
             if (isset($extra_attributes['no_overview_text']) && $graph instanceof pts_LineGraph) {
                 $graph->plot_overview_text = false;
             }
         case 'BAR_ANALYZE_GRAPH':
         case 'SCATTER_PLOT':
             //$graph->hideGraphIdentifiers();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 $graph->loadGraphValues(pts_strings::comma_explode($buffer_item->get_result_value()), $buffer_item->get_result_identifier());
                 $graph->loadGraphRawValues(pts_strings::comma_explode($buffer_item->get_result_raw()));
             }
             $scale_special = $result_object->test_profile->get_result_scale_offset();
             if (!empty($scale_special) && count($ss = pts_strings::comma_explode($scale_special)) > 0) {
                 $graph->loadGraphIdentifiers($ss);
             }
             break;
         case 'HORIZONTAL_BOX_PLOT':
             // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
             $identifiers = array();
             $values = array();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 array_push($identifiers, $buffer_item->get_result_identifier());
                 array_push($values, pts_strings::comma_explode($buffer_item->get_result_value()));
             }
             $graph->loadGraphIdentifiers($identifiers);
             $graph->loadGraphValues($values);
             break;
         default:
             // TODO: should be able to load pts_test_result_buffer_item objects more cleanly into pts_Graph
             $identifiers = array();
             $values = array();
             $raw_values = array();
             foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
                 array_push($identifiers, $buffer_item->get_result_identifier());
                 array_push($values, $buffer_item->get_result_value());
                 array_push($raw_values, $buffer_item->get_result_raw());
             }
             $graph->loadGraphIdentifiers($identifiers);
             $graph->loadGraphValues($values);
             $graph->loadGraphRawValues($raw_values);
             break;
     }
     self::report_test_notes_to_graph($graph, $result_object);
     return $graph;
 }
Exemplo n.º 20
0
 public static function call_test_script($test_profile, $script_name, $print_string = null, $pass_argument = null, $extra_vars_append = null, $use_ctp = true)
 {
     $extra_vars = pts_tests::extra_environmental_variables($test_profile);
     if (isset($extra_vars_append['PATH'])) {
         // Special case variable where you likely want the two merged rather than overwriting
         $extra_vars['PATH'] = $extra_vars_append['PATH'] . (substr($extra_vars_append['PATH'], -1) != ':' ? ':' : null) . $extra_vars['PATH'];
         unset($extra_vars_append['PATH']);
     }
     if (is_array($extra_vars_append)) {
         $extra_vars = array_merge($extra_vars, $extra_vars_append);
     }
     // TODO: call_test_script could be better cleaned up to fit more closely with new pts_test_profile functions
     $result = null;
     $test_directory = $test_profile->get_install_dir();
     pts_file_io::mkdir($test_directory, 0777, true);
     $os_postfix = '_' . strtolower(phodevi::operating_system());
     $test_profiles = array($test_profile);
     if ($use_ctp) {
         $test_profiles = array_merge($test_profiles, $test_profile->extended_test_profiles());
     }
     if (pts_client::executable_in_path('bash')) {
         $sh = 'bash';
     } else {
         $sh = 'sh';
     }
     foreach ($test_profiles as &$this_test_profile) {
         $test_resources_location = $this_test_profile->get_resource_dir();
         if (is_file($run_file = $test_resources_location . $script_name . $os_postfix . '.sh') || is_file($run_file = $test_resources_location . $script_name . '.sh')) {
             if (!empty($print_string)) {
                 pts_client::$display->test_run_message($print_string);
             }
             if (phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false) {
                 $phoroscript = new pts_phoroscript_interpreter($run_file, $extra_vars, $test_directory);
                 $phoroscript->execute_script($pass_argument);
                 $this_result = null;
             } else {
                 $this_result = pts_client::shell_exec('cd ' . $test_directory . ' && ' . $sh . ' ' . $run_file . ' "' . $pass_argument . '" 2>&1', $extra_vars);
             }
             if (trim($this_result) != null) {
                 $result = $this_result;
             }
         }
     }
     return $result;
 }
 public function check_file_hash($file)
 {
     if (!is_file($file)) {
         return false;
     } else {
         if (pts_client::read_env('NO_FILE_HASH_CHECKS') != false || pts_client::read_env('NO_MD5_CHECKS') != false) {
             return true;
         } else {
             if ($this->sha256 && function_exists('hash_file')) {
                 return hash_file('sha256', $file) == $this->sha256;
             } else {
                 if ($this->md5) {
                     return md5_file($file) == $this->md5;
                 } else {
                     if (filesize($file) > 0) {
                         return true;
                     } else {
                         return false;
                     }
                 }
             }
         }
     }
 }
            }
        }
    }
    if ($replaced == false) {
        // Show help command, since there are no valid commands
        $sent_command = 'help';
    }
}
pts_define('PTS_USER_LOCK', function_exists('posix_getpid') ? PTS_USER_PATH . 'run-lock-' . posix_getpid() : tempnam(PTS_USER_PATH, 'run-lock-'));
if (QUICK_START == false) {
    if (pts_client::create_lock(PTS_USER_LOCK) == false) {
        //trigger_error('It appears that the Phoronix Test Suite is already running.' . PHP_EOL . 'For proper results, only run one instance at a time.', E_USER_WARNING);
    }
    register_shutdown_function(array('pts_client', 'process_shutdown_tasks'));
    //pcntl_signal(SIGTERM, array('pts_client', 'exit_client'));
    if (pts_client::read_env('PTS_IGNORE_MODULES') == false) {
        pts_client::module_framework_init();
        // Initialize the PTS module system
    }
}
// Read passed arguments
for ($i = 2; $i < $argc && isset($argv[$i]); $i++) {
    $pass_args[] = $argv[$i];
}
if (QUICK_START == false) {
    pts_client::user_agreement_check($sent_command);
    // OpenBenchmarking.org
    pts_openbenchmarking::refresh_repository_lists();
}
pts_client::execute_command($sent_command, $pass_args);
// Run command
 public static function create_compiler_mask(&$test_install_request)
 {
     if (phodevi::is_bsd()) {
         // XXX: Using the compiler-mask causes a number of tests to fail to properly install due to compiler issues with at least PC-BSD 10.0
         return false;
     }
     // or pass false to $test_install_request to bypass the test checks
     $compilers = array();
     $external_dependencies = $test_install_request != false ? $test_install_request->test_profile->get_external_dependencies() : false;
     if ($test_install_request === false || in_array('build-utilities', $external_dependencies)) {
         // Handle C/C++ compilers for this external dependency
         $compilers['CC'] = array(pts_strings::first_in_string(pts_client::read_env('CC'), ' '), 'gcc', 'clang', 'icc', 'pcc');
         $compilers['CXX'] = array(pts_strings::first_in_string(pts_client::read_env('CXX'), ' '), 'g++', 'clang++', 'cpp');
     }
     if ($test_install_request === false || in_array('fortran-compiler', $external_dependencies)) {
         // Handle Fortran for this external dependency
         $compilers['F9X'] = array(pts_strings::first_in_string(pts_client::read_env('F9X'), ' '), pts_strings::first_in_string(pts_client::read_env('F95'), ' '), 'gfortran', 'f90', 'f95', 'fortran');
     }
     if (empty($compilers)) {
         // If the test profile doesn't request a compiler external dependency, probably not compiling anything
         return false;
     }
     foreach ($compilers as $compiler_type => $possible_compilers) {
         // Compilers to check for, listed in order of priority
         $compiler_found = false;
         foreach ($possible_compilers as $i => $possible_compiler) {
             // first check to ensure not null sent to executable_in_path from env variable
             if ($possible_compiler && (($compiler_path = is_executable($possible_compiler)) || ($compiler_path = pts_client::executable_in_path($possible_compiler, 'ccache')))) {
                 // Replace the array of possible compilers with a string to the detected compiler executable
                 $compilers[$compiler_type] = $compiler_path;
                 $compiler_found = true;
                 break;
             }
         }
         if ($compiler_found == false) {
             unset($compilers[$compiler_type]);
         }
     }
     if (!empty($compilers)) {
         // Create a temporary directory that will be at front of PATH and serve for masking the actual compiler
         if ($test_install_request instanceof pts_test_install_request) {
             $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . $test_install_request->test_profile->get_identifier_base_name() . $test_install_request->test_profile->get_test_profile_version() . '/';
         } else {
             $mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . rand(100, 999) . '/';
         }
         pts_file_io::mkdir($mask_dir);
         $compiler_extras = array('CC' => array('safeguard-names' => array('gcc', 'cc'), 'environment-variables' => 'CFLAGS'), 'CXX' => array('safeguard-names' => array('g++', 'c++'), 'environment-variables' => 'CXXFLAGS'), 'F9X' => array('safeguard-names' => array('gfortran', 'f95'), 'environment-variables' => 'F9XFLAGS'));
         foreach ($compilers as $compiler_type => $compiler_path) {
             $compiler_name = basename($compiler_path);
             $main_compiler = $mask_dir . $compiler_name;
             // take advantage of environment-variables to be sure they're found in the string
             $env_var_check = PHP_EOL;
             /*
             foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['environment-variables']) as $env_var)
             {
             	// since it's a dynamic check in script could probably get rid of this check...
             	if(true || getenv($env_var))
             	{
             		$env_var_check .= 'if [[ $COMPILER_OPTIONS != "*$' . $env_var . '*" ]]' . PHP_EOL . 'then ' . PHP_EOL . 'COMPILER_OPTIONS="$COMPILER_OPTIONS $' . $env_var . '"' . PHP_EOL . 'fi' . PHP_EOL;
             	}
             }
             */
             // Write the main mask for the compiler
             file_put_contents($main_compiler, '#!/bin/bash' . PHP_EOL . 'COMPILER_OPTIONS="$@"' . PHP_EOL . $env_var_check . PHP_EOL . 'echo $COMPILER_OPTIONS >> ' . $mask_dir . $compiler_type . '-options-' . $compiler_name . PHP_EOL . $compiler_path . ' "$@"' . PHP_EOL);
             // Make executable
             chmod($main_compiler, 0755);
             // The two below code chunks ensure the proper compiler is always hit
             if ($test_install_request instanceof pts_test_install_request && !in_array($compiler_name, pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names'])) && getenv($compiler_type) == false) {
                 // So if e.g. clang becomes the default compiler, since it's not GCC, it will ensure CC is also set to clang beyond the masking below
                 $test_install_request->special_environment_vars[$compiler_type] = $compiler_name;
             }
             // Just in case any test profile script is statically always calling 'gcc' or anything not CC, try to make sure it hits one of the safeguard-names so it redirects to the intended compiler under test
             foreach (pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names']) as $safe_name) {
                 if (!is_file($mask_dir . $safe_name)) {
                     symlink($main_compiler, $mask_dir . $safe_name);
                 }
             }
         }
         if ($test_install_request instanceof pts_test_install_request) {
             $test_install_request->compiler_mask_dir = $mask_dir;
             // Appending the rest of the path will be done automatically within call_test_script
             $test_install_request->special_environment_vars['PATH'] = $mask_dir;
         }
         return $mask_dir;
     }
     return false;
 }
 public static function test_profile_system_compatibility_check(&$test_profile, $report_errors = false)
 {
     $valid_test_profile = true;
     $test_type = $test_profile->get_test_hardware_type();
     $skip_tests = pts_client::read_env('SKIP_TESTS') ? pts_strings::comma_explode(pts_client::read_env('SKIP_TESTS')) : false;
     $skip_test_subsystems = pts_client::read_env('SKIP_TESTING_SUBSYSTEMS') ? pts_strings::comma_explode(strtolower(pts_client::read_env('SKIP_TESTING_SUBSYSTEMS'))) : false;
     $display_driver = phodevi::read_property('system', 'display-driver');
     $gpu = phodevi::read_name('gpu');
     if ($test_profile->is_supported(false) == false) {
         $valid_test_profile = false;
     } else {
         if ($test_type == 'Graphics' && pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false) {
             $report_errors && pts_client::$display->test_run_error('No display server was found, cannot run ' . $test_profile);
             $valid_test_profile = false;
         } else {
             if ($test_type == 'Graphics' && in_array($display_driver, array('vesa', 'nv', 'cirrus')) && stripos($gpu, 'LLVM') === false) {
                 // These display drivers end up being in known configurations without 3D hardware support so unless an LLVM-based string is reported as the GPU, don't advertise 3D tests
                 $report_errors && pts_client::$display->test_run_error('3D acceleration support not available, cannot run ' . $test_profile);
                 $valid_test_profile = false;
             } else {
                 if ($test_type == 'Disk' && stripos(phodevi::read_property('system', 'filesystem'), 'SquashFS') !== false) {
                     $report_errors && pts_client::$display->test_run_error('Running on a RAM-based live file-system, cannot run ' . $test_profile);
                     $valid_test_profile = false;
                 } else {
                     if (pts_client::read_env('NO_' . strtoupper($test_type) . '_TESTS') || $skip_tests && (in_array($test_profile, $skip_tests) || in_array($test_type, $skip_tests) || in_array($test_profile->get_identifier(false), $skip_tests) || in_array($test_profile->get_identifier_base_name(), $skip_tests))) {
                         $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile);
                         $valid_test_profile = false;
                     } else {
                         if ($skip_test_subsystems && in_array(strtolower($test_profile->get_test_hardware_type()), $skip_test_subsystems)) {
                             $report_errors && pts_client::$display->test_run_error('Due to a pre-set environmental variable, skipping ' . $test_profile);
                             $valid_test_profile = false;
                         } else {
                             if ($test_profile->is_root_required() && $this->batch_mode && phodevi::is_root() == false) {
                                 $report_errors && pts_client::$display->test_run_error('Cannot run ' . $test_profile . ' in batch mode as root access is required.');
                                 $valid_test_profile = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($valid_test_profile == false && pts_client::read_env('SKIP_ALL_TEST_SUPPORT_CHECKS')) {
         $report_errors && pts_client::$display->test_run_error('SKIP_ALL_TEST_SUPPORT_CHECKS is set for ' . $test_profile . '.');
         $valid_test_profile = true;
     }
     return $valid_test_profile;
 }