public static function run($r) { // Make sure you're debugging the latest test script... pts_test_installer::standard_install($r); // For debugging, usually running just once is sufficient, unless FORCE_TIMES_TO_RUN is preset pts_client::pts_set_environment_variable('FORCE_TIMES_TO_RUN', 1); // Run the test(s) in debug mode pts_test_run_manager::standard_run($r, pts_c::debug_mode); }
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; } }
public static function run($r) { if (isset($r[0]) && strpos($r[0], '.openbenchmarking') !== false && is_readable($r[0])) { // OpenBenchmarking.org launcher $dom = new DOMDocument(); $dom->loadHTMLFile($r[0]); $requires_core_version = self::read_openbenchmarking_dom($dom, 'requires_core_version', PTS_CORE_VERSION); if (PTS_CORE_VERSION < $requires_core_version) { echo PHP_EOL . 'An incompatible OpenBenchmarking.org file was provided. You must upgrade the Phoronix Test Suite installation.' . PHP_EOL; return false; } $payload_type = self::read_openbenchmarking_dom($dom, 'payload_type'); $payload = self::read_openbenchmarking_dom($dom, 'payload'); switch ($payload_type) { case 'benchmark': $to_benchmark = explode(' ', $payload); pts_test_installer::standard_install($to_benchmark); pts_test_run_manager::standard_run($to_benchmark); break; } } }
public static function run($r) { pts_openbenchmarking::refresh_repository_lists(); pts_client::$display->generic_heading('Interactive Benchmarking'); echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL; $reboot_on_exit = false; do { $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition'); if (count(pts_client::saved_test_results()) > 0) { $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage'; } $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit'; $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true); switch ($response) { case 'RUN_TEST': $supported_tests = pts_openbenchmarking::available_tests(); $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true); $longest_title_length = 0; foreach ($supported_tests as $i => &$test_profile) { if ($test_profile->get_title() == null) { unset($supported_tests[$i]); continue; } $longest_title_length = max($longest_title_length, strlen($test_profile->get_title())); } $t = array(); foreach ($supported_tests as $i => &$test_profile) { if ($test_profile instanceof pts_test_profile) { $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type()); } } $supported_tests = $t; asort($supported_tests); $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true); $tests_to_run = explode(',', $tests_to_run); pts_test_installer::standard_install($tests_to_run); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($tests_to_run); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'RUN_SUITE': $possible_suites = pts_openbenchmarking::available_suites(); foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) { array_push($possible_suites, 'pts/' . $subsystem); } $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true); foreach (explode(',', $suites_to_run) as $suite_to_run) { pts_test_installer::standard_install($suite_to_run); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($suite_to_run); } break; case 'SELECT_DRIVE_MOUNT': self::select_drive_mount(); break; case 'RUN_SYSTEM_TEST': pts_client::$display->generic_heading('System Test'); $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark'); pts_test_installer::standard_install($system_tests); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($system_tests); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'SHOW_INFO': pts_client::$display->generic_heading('System Software / Hardware Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; break; case 'SHOW_SENSORS': pts_client::$display->generic_heading('Detected System Sensors'); foreach (phodevi::supported_sensors() as $sensor) { echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL; } break; case 'SET_RUN_COUNT': $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false); putenv('FORCE_TIMES_TO_RUN=' . trim($run_count)); break; case 'BACKUP_RESULTS_TO_USB': pts_client::$display->generic_heading('Backing Up Test Results'); foreach (pts_file_io::glob('/media/*') as $media_dir) { if (!is_writable($media_dir)) { echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL; continue; } echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL; pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/'); break; } break; } echo PHP_EOL . PHP_EOL; } while ($response != 'EXIT'); if ($reboot_on_exit) { if (is_dir('/media/pts-auto-mount')) { pts_file_io::delete('/media/pts-auto-mount/pts', null, true); exec('umount /media/pts-auto-mount 2>&1'); } exec('reboot'); } }
public static function run($r) { // Force refresh of OB repository to ensure the latest profiles pts_openbenchmarking::refresh_repository_lists(null, true); // Determine cache location $dc_write_directory = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH))); echo PHP_EOL . 'Download Cache Directory: ' . $dc_write_directory . PHP_EOL; if ($dc_write_directory == null || !is_writable($dc_write_directory)) { echo 'No writable download cache directory was found. A download cache cannot be created.' . PHP_EOL . PHP_EOL; return false; } if (!empty($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, $dc_write_directory); } } $json_download_cache = array('phoronix-test-suite' => array('main' => array('generated' => time()), 'download-cache' => array())); foreach (pts_tests::partially_installed_tests() as $test) { $test_profile = new pts_test_profile($test); echo PHP_EOL . 'Checking Downloads For: ' . $test . PHP_EOL; foreach (pts_test_install_request::read_download_object_list($test_profile, false) as $file) { $cached_valid = false; if (is_file($dc_write_directory . $file->get_filename()) && $file->check_file_hash($dc_write_directory . $file->get_filename())) { echo ' Previously Cached: ' . $file->get_filename() . PHP_EOL; $cached_valid = true; } else { if (is_dir($test_profile->get_install_dir())) { if (is_file($test_profile->get_install_dir() . $file->get_filename()) && $file->check_file_hash($test_profile->get_install_dir() . $file->get_filename())) { echo ' Caching: ' . $file->get_filename() . PHP_EOL; if (copy($test_profile->get_install_dir() . $file->get_filename(), $dc_write_directory . $file->get_filename())) { $cached_valid = true; } } } } if ($cached_valid) { if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()])) { $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()] = array('file_name' => $file->get_filename(), 'file_size' => $file->get_filesize(), 'associated_tests' => array($test_profile->get_identifier()), 'md5' => $file->get_md5(), 'sha256' => $file->get_sha256()); } else { if ($file->get_md5() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['md5'] && $file->get_sha256() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['sha256']) { array_push($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['associated_tests'], $test_profile->get_identifier()); } } } } } // Find files in download-cache/ that weren't part of an installed test (but could have just been tossed in there) to cache foreach (glob($dc_write_directory . '/*') as $cached_file) { $file_name = basename($cached_file); if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file_name]) && $file_name != 'pts-download-cache.json') { $json_download_cache['phoronix-test-suite']['download-cache'][$file_name] = array('file_name' => $file_name, 'file_size' => filesize($cached_file), 'associated_tests' => array(), 'md5' => md5_file($cached_file), 'sha256' => hash_file('sha256', $cached_file)); } } $cached_tests = array(); foreach (pts_openbenchmarking::available_tests(true, true) as $test) { if (pts_test_install_request::test_files_in_cache($test, true, true) == false) { continue; } array_push($cached_tests, $test); } $json_download_cache['phoronix-test-suite']['cached-tests'] = $cached_tests; file_put_contents($dc_write_directory . 'pts-download-cache.json', json_encode($json_download_cache, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); echo PHP_EOL; }
public static function run($r) { pts_client::$display->generic_heading('Random Test Execution'); $allow_new_tests_to_be_installed = pts_user_io::prompt_bool_input('Allow new tests to be installed', true); $allow_new_dependencies_to_be_installed = $allow_new_tests_to_be_installed ? pts_user_io::prompt_bool_input('Allow new test external dependencies to be installed', false) : false; $limit_test_subsystem = pts_user_io::prompt_bool_input('Limit tests to a given subsystem', false); $limit_test_subsystem = $limit_test_subsystem ? pts_user_io::prompt_text_menu('Select subsystem(s) to test', pts_types::subsystem_targets(), true) : false; $upload_to_openbenchmarking = pts_user_io::prompt_bool_input('Auto-upload test results to OpenBenchmarking.org', true); while (1) { $to_test = array(); if ($limit_test_subsystem) { foreach (explode(',', $limit_test_subsystem) as $test_type) { $tests = pts_openbenchmarking_client::popular_tests(-1, $test_type); $to_test = array_merge($to_test, $tests); } if (empty($to_test)) { pts_client::$display->generic_sub_heading('No tests could be found to run.'); return false; } shuffle($to_test); $to_test = array_slice($to_test, 0, rand(1, 12)); } else { if (rand(1, 6) == 2) { $ob_ids = pts_openbenchmarking_client::popular_openbenchmarking_results(); $ob_type = rand(0, 1) == 1 ? 'recent_popular_results' : 'recent_results'; if (isset($ob_ids[$ob_type]) && !empty($ob_ids[$ob_type])) { shuffle($ob_ids[$ob_type]); $to_test = array(array_pop($ob_ids[$ob_type])); } } } if (empty($to_test)) { // Randomly pick some installed tests $installed_tests = pts_tests::installed_tests(); if ($installed_tests > 3) { shuffle($installed_tests); $to_test = array_slice($installed_tests, 0, rand(1, 8)); } if (!isset($to_test[2]) && $allow_new_tests_to_be_installed) { $available_tests = pts_openbenchmarking::available_tests(); shuffle($available_tests); $to_test = array_merge($to_test, array_slice($available_tests, 0, rand(1, 10))); } } if (empty($to_test)) { pts_client::$display->generic_sub_heading('No tests could be found to run.'); return false; } echo PHP_EOL; pts_client::$display->generic_sub_heading('Tests To Run: ' . implode(', ', $to_test)); // QUERY FROM OB $random_titles = array(phodevi::read_property('cpu', 'model') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Performance', phodevi::read_property('cpu', 'model') . ' Performance', phodevi::read_property('cpu', 'model') . ' + ' . phodevi::read_property('gpu', 'model') . ' + ' . phodevi::read_property('motherboard', 'identifier'), phodevi::read_property('motherboard', 'identifier') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('cpu', 'model') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('system', 'kernel') . ' + ' . phodevi::read_property('system', 'operating-system') . ' Tests'); shuffle($random_titles); $title = array_pop($random_titles); if ($limit_test_subsystem) { $subsystems_to_test = explode(',', $limit_test_subsystem); $subsystems_to_avoid = array_diff(pts_types::subsystem_targets(), $subsystems_to_test); pts_client::pts_set_environment_variable('SKIP_TESTING_SUBSYSTEMS', implode(',', $subsystems_to_avoid)); } if ($allow_new_tests_to_be_installed) { pts_test_installer::standard_install($to_test, false, true, $allow_new_dependencies_to_be_installed); } $batch_mode_settings = array('UploadResults' => false, 'SaveResults' => true, 'PromptForTestDescription' => false, 'RunAllTestCombinations' => false, 'PromptSaveName' => false, 'PromptForTestIdentifier' => false, 'OpenBrowser' => false); if ($upload_to_openbenchmarking) { $batch_mode_settings['UploadResults'] = true; pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true); } pts_test_run_manager::set_batch_mode($batch_mode_settings); $test_run_manager = new pts_test_run_manager($batch_mode_settings, 2); if ($test_run_manager->initial_checks($to_test) != false) { if ($test_run_manager->load_tests_to_run($to_test)) { // SETUP $test_run_manager->auto_save_results($title, null, 'Various open-source benchmarks by the ' . pts_core::program_title(true) . '.', true); $test_run_manager->auto_generate_results_identifier(); echo PHP_EOL; pts_client::$display->generic_sub_heading('Result File: ' . $test_run_manager->get_file_name()); pts_client::$display->generic_sub_heading('Result Identifier: ' . $test_run_manager->get_results_identifier()); // BENCHMARK $test_run_manager->pre_execution_process(); $test_run_manager->call_test_runs(); $test_run_manager->post_execution_process(); pts_client::remove_saved_result_file($test_run_manager->get_file_name()); } } echo PHP_EOL; sleep(30); } }
public static function run($r) { $compare_tests = array(); $compare_subsystems = array(); foreach ($r as $test_object) { $test_object = pts_types::identifier_to_object($test_object); if ($test_object instanceof pts_test_profile) { array_push($compare_tests, $test_object->get_identifier(false)); if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) { $compare_subsystems[$test_object->get_test_hardware_type()] = 1; } else { $compare_subsystems[$test_object->get_test_hardware_type()] += 1; } } } if (empty($compare_tests)) { $subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk')); } else { arsort($compare_subsystems); $compare_subsystems = array_keys($compare_subsystems); $subsystem_under_test = array_shift($compare_subsystems); } $system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false)); $to_include = array(); $to_exclude = array(); if (isset($system_info[$subsystem_under_test])) { $compare_component = $system_info[$subsystem_under_test]; } else { return; } switch ($subsystem_under_test) { case 'Processor': self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true); break; case 'Graphics': self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true); break; case 'OS': self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true); self::system_component_to_format($system_info, $to_exclude, array('OS')); break; case 'Disk': self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true); break; } $payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests)); echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL; $json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload); $json = json_decode($json, true); if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) { echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL; $compare_results = array(); foreach ($json['auto_compare']['public_ids'] as $public_id) { $result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true); if ($result_xml) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); foreach ($result_objects as $i => &$result_object) { if (!empty($compare_tests)) { if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) { unset($result_objects[$i]); } } else { if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) { unset($result_objects[$i]); } } } if (count($result_objects) == 0) { continue; } $result_file->override_result_objects($result_objects); array_push($compare_results, $result_file); } } if (count($compare_results) > 0) { $result_xml = pts_merge::merge_test_results_array($compare_results); if (count($compare_results) > 2) { $result_file = new pts_result_file($result_xml); $result_objects = $result_file->get_result_objects(); $system_count = $result_file->get_system_count(); $result_count = count($result_objects); $result_match_count = array(); if ($result_count > 3) { foreach ($result_objects as $i => &$result_object) { $result_match_count[$i] = $result_object->test_result_buffer->get_count(); } arsort($result_match_count); $biggest_size = pts_arrays::first_element($result_match_count); if ($biggest_size == $system_count || $biggest_size > 3) { foreach ($result_match_count as $key => $value) { if ($value < 2) { unset($result_objects[$key]); } } } $result_file->override_result_objects($result_objects); $result_xml = pts_merge::merge_test_results_array(array($result_file)); } } pts_client::save_test_result('auto-comparison/composite.xml', $result_xml); } } pts_test_installer::standard_install(array('auto-comparison')); pts_test_run_manager::standard_run(array('auto-comparison')); }
public static function run($r) { pts_test_installer::standard_install($r); $run_manager = new pts_test_run_manager(); $run_manager->standard_run($r); }
public function run_benchmark($user, $args) { $json_queue = json_decode(base64_decode($args), true); $json['pts']['msg']['name'] = 'run_benchmark_queue'; if (!isset($json_queue['tests']) || count($json_queue['tests']) == 0) { $json['pts']['msg']['error'] = 'No tests in the queue.'; } else { if (!isset($json_queue['title']) || $json_queue['title'] == null) { $json['pts']['msg']['error'] = 'No test title/name provided.'; } else { if (!isset($json_queue['identifier']) || $json_queue['identifier'] == null) { $json['pts']['msg']['error'] = 'No test identifier provided.'; } else { $json['pts']['msg']['go'] = 'Benchmarking.'; } } } $this->send_json_data($user->socket, $json); if (isset($json['pts']['msg']['error']) && $json['pts']['msg']['error'] != null) { exit(1); } pts_client::$display = new pts_websocket_display_mode(); pts_client::$display->set_web_socket($this, $user->id); $virtual_test_queue = array(); $virtual_test_queue[0] = new pts_virtual_test_queue(); foreach ($json_queue['tests'] as $test) { $virtual_test_queue[0]->add_to_queue($test['test_profile_id'], $test['test_options_title'], $test['test_options_value']); } $test_run_manager = new pts_test_run_manager(false, true); pts_test_installer::standard_install($virtual_test_queue, false, true); if ($test_run_manager->initial_checks($virtual_test_queue) == false) { $j['pts']['msg']['name'] = 'benchmark_state'; $j['pts']['msg']['current_state'] = 'failed'; $j['pts']['msg']['error'] = 'Failed to install test.'; $this->send_json_data($user->socket, $j); exit(1); } if ($test_run_manager->load_tests_to_run($virtual_test_queue)) { // SETUP $test_run_manager->auto_upload_to_openbenchmarking(); pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true); $test_run_manager->auto_save_results($json_queue['title'], $json_queue['identifier'], $json_queue['description'], true); // BENCHMARK $test_run_manager->pre_execution_process(); $test_run_manager->call_test_runs(); $test_run_manager->post_execution_process(); $j['pts']['msg']['name'] = 'benchmark_state'; $j['pts']['msg']['current_state'] = 'complete'; $j['pts']['msg']['result_title'] = $test_run_manager->get_title(); $j['pts']['msg']['result_file_name'] = $test_run_manager->get_file_name(); $j['pts']['msg']['result_identifier'] = $test_run_manager->get_results_identifier(); $j['pts']['msg']['result_url'] = $test_run_manager->get_results_url(); $this->send_json_data($user->socket, $j); } // exit(0); }
public static function run_connection($args) { if (pts_client::create_lock(PTS_USER_PATH . 'phoromatic_lock') == false) { trigger_error('Phoromatic is already running.', E_USER_ERROR); return false; } define('PHOROMATIC_PROCESS', true); if (pts_client::$pts_logger == false) { pts_client::$pts_logger = new pts_logger(); } pts_client::$pts_logger->log(pts_title(true) . ' [' . PTS_CORE_VERSION . '] starting Phoromatic client'); if (phodevi::system_uptime() < 60) { echo 'PHOROMATIC: Sleeping for 60 seconds as system freshly started.' . PHP_EOL; pts_client::$pts_logger->log('Sleeping for 60 seconds as system freshly started'); sleep(60); } $server_setup = self::setup_server_addressing($args); //$http_comm = new phoromatic_client_comm_http(); if (!$server_setup) { if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } } return false; } $times_failed = 0; $has_success = false; $do_exit = false; $just_started = true; self::setup_system_environment(); pts_client::$pts_logger->log('SYSTEM HARDWARE: ' . phodevi::system_hardware(true)); pts_client::$pts_logger->log('SYSTEM SOFTWARE: ' . phodevi::system_software(true)); while ($do_exit == false) { $server_response = phoromatic::upload_to_remote_server(array('r' => 'start')); if ($server_response == false) { $times_failed++; pts_client::$pts_logger->log('Server response failed'); if ($times_failed >= 2) { trigger_error('Communication with server failed.', E_USER_ERROR); if (PTS_IS_DAEMONIZED_SERVER_PROCESS == false && $times_failed > 5) { return false; } else { if (PTS_IS_DAEMONIZED_SERVER_PROCESS && $times_failed > 10) { if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } } } } } else { if (substr($server_response, 0, 1) == '[') { // Likely a notice/warning from server echo PHP_EOL . substr($server_response, 0, strpos($server_response, PHP_EOL)) . PHP_EOL; } else { if (substr($server_response, 0, 1) == '{') { $times_failed = 0; $json = json_decode($server_response, true); if ($has_success == false) { $has_success = true; pts_module::save_file('last-phoromatic-server', self::$server_address . ':' . self::$server_http_port . '/' . self::$account_id); } if ($json != null) { if (isset($json['phoromatic']['error']) && !empty($json['phoromatic']['error'])) { trigger_error($json['phoromatic']['error'], E_USER_ERROR); } if (isset($json['phoromatic']['response']) && !empty($json['phoromatic']['response'])) { echo PHP_EOL . $json['phoromatic']['response'] . PHP_EOL; } } if ($just_started) { if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { $pid = pcntl_fork(); if ($pid == 0) { // Start the tick thread self::tick_thread(); } } $just_started = false; } if (isset($json['phoromatic']['pre_set_sys_env_vars']) && !empty($json['phoromatic']['pre_set_sys_env_vars'])) { // pre_set_sys_env_vars was added during PTS 5.8 development // Sets environment variables on client as specified via the Phoromatic Server's systems page foreach (explode(';', $json['phoromatic']['pre_set_sys_env_vars']) as $i => $v_string) { $var = explode('=', $v_string); if (count($var) == 2) { putenv($var[0] . '=' . $var[1]); } } } switch (isset($json['phoromatic']['task']) ? $json['phoromatic']['task'] : null) { case 'install': phoromatic::update_system_status('Installing Tests'); pts_suite_nye_XmlReader::set_temporary_suite('pre-seed', $json['phoromatic']['test_suite']); pts_test_installer::standard_install('pre-seed'); break; case 'benchmark': // Make sure all latest tests are available pts_openbenchmarking::refresh_repository_lists(null, true); $benchmark_timer = time(); self::$is_running_as_phoromatic_node = true; $test_flags = pts_c::auto_mode | pts_c::batch_mode; $suite_identifier = sha1(time() . rand(2, 1000)); pts_suite_nye_XmlReader::set_temporary_suite($suite_identifier, $json['phoromatic']['test_suite']); self::$p_save_identifier = $json['phoromatic']['trigger_id']; $phoromatic_results_identifier = self::$p_save_identifier; $phoromatic_save_identifier = $json['phoromatic']['save_identifier']; self::$p_schedule_id = isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : false; self::$p_trigger_id = self::$p_save_identifier; $benchmark_ticket_id = isset($json['phoromatic']['benchmark_ticket_id']) ? $json['phoromatic']['benchmark_ticket_id'] : null; phoromatic::update_system_status('Running Benchmarks For: ' . $phoromatic_save_identifier); if (pts_strings::string_bool($json['phoromatic']['settings']['RunInstallCommand'])) { if (isset($json['phoromatic']['pre_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['pre_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_INSTALL'); } if (pts_strings::string_bool($json['phoromatic']['settings']['ForceInstallTests'])) { $test_flags |= pts_c::force_install; } pts_client::set_test_flags($test_flags); pts_test_installer::standard_install($suite_identifier); if (isset($json['phoromatic']['post_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_INSTALL'); } } $env_vars = isset($json['phoromatic']['environment_variables']) ? pts_strings::parse_value_string_vars($json['phoromatic']['environment_variables']) : array(); // Do the actual running phodevi::clear_cache(); if (pts_test_run_manager::initial_checks($suite_identifier, 0, 'SHORT')) { self::$test_run_manager = new pts_test_run_manager($test_flags); pts_test_run_manager::set_batch_mode(array('UploadResults' => isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']), 'SaveResults' => true, 'RunAllTestCombinations' => false, 'OpenBrowser' => false)); // Load the tests to run if (self::$test_run_manager->load_tests_to_run($suite_identifier)) { phoromatic::update_system_status('Tests In Run Queue: ' . implode(', ', self::$test_run_manager->get_tests_to_run_identifiers())); if (isset($json['phoromatic']['pre_run_set_context'])) { phoromatic::set_user_context($json['phoromatic']['pre_run_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'PRE_RUN'); } if (isset($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking']) && pts_strings::string_bool($json['phoromatic']['settings']['UploadResultsToOpenBenchmarking'])) { self::$test_run_manager->auto_upload_to_openbenchmarking(); pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs'])); } // Save results? // Run the actual tests if (isset($env_vars['PTS_CONCURRENT_TEST_RUNS']) && $env_vars['PTS_CONCURRENT_TEST_RUNS'] > 1) { $total_loop_time = isset($env_vars['TOTAL_LOOP_TIME']) ? $env_vars['TOTAL_LOOP_TIME'] : false; pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION STARTED @ ' . date('Y-m-d H:i:s')); pts_client::$pts_logger->log('CONCURRENT RUNS = ' . $env_vars['PTS_CONCURRENT_TEST_RUNS'] . ' TOTAL LOOP TIME = ' . $total_loop_time); $r = self::$test_run_manager->multi_test_stress_run_execute($env_vars['PTS_CONCURRENT_TEST_RUNS'], $total_loop_time); if ($r == false) { return; } pts_client::$pts_logger->log('STRESS / MULTI-TEST EXECUTION ENDED @ ' . date('Y-m-d H:i:s')); } else { self::$test_run_manager->auto_save_results($phoromatic_save_identifier, $phoromatic_results_identifier, isset($json['phoromatic']['test_description']) ? $json['phoromatic']['test_description'] : 'A Phoromatic run.'); self::$test_run_manager->pre_execution_process(); self::$test_run_manager->call_test_runs(); } phoromatic::update_system_status('Benchmarks Completed For: ' . $phoromatic_save_identifier); self::$test_run_manager->post_execution_process(); $elapsed_benchmark_time = time() - $benchmark_timer; // Handle uploading data to server $result_file = new pts_result_file(self::$test_run_manager->get_file_name()); $upload_system_logs = pts_strings::string_bool($json['phoromatic']['settings']['UploadSystemLogs']); $server_response = self::upload_test_result($result_file, $upload_system_logs, isset($json['phoromatic']['schedule_id']) ? $json['phoromatic']['schedule_id'] : null, $phoromatic_save_identifier, $json['phoromatic']['trigger_id'], $elapsed_benchmark_time, $benchmark_ticket_id); //pts_client::$pts_logger->log('DEBUG RESPONSE MESSAGE: ' . $server_response); if (!pts_strings::string_bool($json['phoromatic']['settings']['ArchiveResultsLocally'])) { pts_client::remove_saved_result_file(self::$test_run_manager->get_file_name()); } } if (isset($json['phoromatic']['post_install_set_context'])) { phoromatic::set_user_context($json['phoromatic']['post_install_set_context'], self::$p_trigger_id, self::$p_schedule_id, 'POST_RUN'); } } self::$p_schedule_id = null; self::$is_running_as_phoromatic_node = false; break; case 'reboot': echo PHP_EOL . 'Phoromatic received a remote command to reboot.' . PHP_EOL; phoromatic::update_system_status('Attempting System Reboot'); if (pts_client::executable_in_path('reboot')) { shell_exec('reboot'); sleep(5); } break; case 'shutdown-if-supports-wake': $supports_wol = false; foreach (pts_network::get_network_wol() as $net_device) { if (strpos($net_device, 'g') !== false) { $supports_wol = true; break; } } if (!$supports_wol) { break; } case 'shutdown': if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) { self::run_client_update_script($json['phoromatic']['client_update_script']); sleep(10); } echo PHP_EOL . 'Phoromatic received a remote command to shutdown.' . PHP_EOL; phoromatic::update_system_status('Attempting System Shutdown'); if (pts_client::executable_in_path('poweroff')) { shell_exec('poweroff'); sleep(5); } break; case 'maintenance': echo PHP_EOL . 'Idling, system maintenance mode set by Phoromatic Server.' . PHP_EOL; phoromatic::update_system_status('Maintenance Mode'); sleep(60); break; case 'idle': if (isset($json['phoromatic']['client_update_script']) && !empty($json['phoromatic']['client_update_script'])) { self::run_client_update_script($json['phoromatic']['client_update_script']); } //echo PHP_EOL . 'Idling, waiting for task.' . PHP_EOL; phoromatic::update_system_status('Idling, Waiting For Task'); break; case 'exit': echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL; phoromatic::update_system_status('Exiting Phoromatic'); $do_exit = true; break; } } } } if (!$do_exit) { if ($server_response == false) { sleep(rand(10, 30)); } else { sleep(60); } } } pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock'); }
public static function run($r) { pts_test_installer::standard_install($r, false, true); $test_run_manager = new pts_test_run_manager(true); $test_run_manager->standard_run($r); }
public static function user_system_process() { $last_communication_minute = date('i'); $communication_attempts = 0; static $current_hw = null; static $current_sw = null; if (define('PHOROMATIC_START', true)) { echo PHP_EOL . 'Registering Status With Phoromatic Server @ ' . date('H:i:s') . PHP_EOL; $times_tried = 0; do { if ($times_tried > 0) { echo PHP_EOL . 'Connection to server failed. Trying again in 60 seconds...' . PHP_EOL; sleep(60); } $update_sd = phoromatic::update_system_details(); $times_tried++; } while (!$update_sd && $times_tried < 5); if (!$update_sd) { echo 'Server connection still failed. Exiting...' . PHP_EOL; return false; } $current_hw = phodevi::system_hardware(true); $current_sw = phodevi::system_software(true); echo PHP_EOL . 'Idling 30 seconds for system to settle...' . PHP_EOL; sleep(30); } do { $exit_loop = false; echo PHP_EOL . 'Checking Status From Phoromatic Server @ ' . date('H:i:s'); if ($last_communication_minute == date('i') && $communication_attempts > 2) { // Something is wrong, Phoromatic shouldn't be communicating with server more than three times a minute $response = M_PHOROMATIC_RESPONSE_IDLE; } else { $server_response = phoromatic::upload_to_remote_server(array('r' => 'status_check')); $xml_parser = new nye_XmlReader($server_response); $response = $xml_parser->getXMLValue(M_PHOROMATIC_GEN_RESPONSE); if (date('i') != $last_communication_minute) { $last_communication_minute = date('i'); $communication_attempts = 0; } $communication_attempts++; } echo ' [' . $response . ']' . PHP_EOL; switch ($response) { case M_PHOROMATIC_RESPONSE_RUN_TEST: $test_flags = pts_c::auto_mode | pts_c::recovery_mode; do { $suite_identifier = 'phoromatic-' . rand(1000, 9999); } while (is_file(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml')); file_put_contents(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml', $server_response); $phoromatic_schedule_id = $xml_parser->getXMLValue(M_PHOROMATIC_ID); $phoromatic_results_identifier = $xml_parser->getXMLValue(M_PHOROMATIC_SYS_NAME); $phoromatic_trigger = $xml_parser->getXMLValue(M_PHOROMATIC_TRIGGER); if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_RUN_INSTALL_COMMAND, M_PHOROMATIC_RESPONSE_TRUE))) { phoromatic::set_user_context($xml_parser->getXMLValue(M_PHOROMATIC_SET_CONTEXT_PRE_INSTALL), $phoromatic_trigger, $phoromatic_schedule_id, 'INSTALL'); pts_client::set_test_flags($test_flags); pts_test_installer::standard_install($suite_identifier); } phoromatic::set_user_context($xml_parser->getXMLValue(M_PHOROMATIC_SET_CONTEXT_PRE_RUN), $phoromatic_trigger, $phoromatic_schedule_id, 'INSTALL'); // Do the actual running if (pts_test_run_manager::initial_checks($suite_identifier)) { $test_run_manager = new pts_test_run_manager($test_flags); // Load the tests to run if ($test_run_manager->load_tests_to_run($suite_identifier)) { if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_UPLOAD_TO_GLOBAL, 'FALSE'))) { $test_run_manager->auto_upload_to_openbenchmarking(); } // Save results? $test_run_manager->auto_save_results(date('Y-m-d H:i:s'), $phoromatic_results_identifier, 'A Phoromatic run.'); // Run the actual tests $test_run_manager->pre_execution_process(); $test_run_manager->call_test_runs(); $test_run_manager->post_execution_process(); // Upload to Phoromatic pts_file_io::unlink(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml'); // Upload test results if (is_file(PTS_SAVE_RESULTS_PATH . $save_identifier . '/composite.xml')) { phoromatic::update_system_status('Uploading Test Results'); $times_tried = 0; do { if ($times_tried > 0) { echo PHP_EOL . 'Connection to server failed. Trying again in 60 seconds...' . PHP_EOL; sleep(60); } $uploaded_test_results = phoromatic::upload_test_results($save_identifier, $phoromatic_schedule_id, $phoromatic_results_identifier, $phoromatic_trigger); $times_tried++; } while ($uploaded_test_results == false && $times_tried < 5); if ($uploaded_test_results == false) { echo 'Server connection failed. Exiting...' . PHP_EOL; return false; } if (pts_strings::string_bool($xml_parser->getXMLValue(M_PHOROMATIC_ARCHIVE_RESULTS_LOCALLY, M_PHOROMATIC_RESPONSE_TRUE)) == false) { pts_client::remove_saved_result_file($save_identifier); } } } } break; case M_PHOROMATIC_RESPONSE_EXIT: echo PHP_EOL . 'Phoromatic received a remote command to exit.' . PHP_EOL; phoromatic::update_system_status('Exiting Phoromatic'); pts_client::release_lock(PTS_USER_PATH . 'phoromatic_lock'); $exit_loop = true; break; case M_PHOROMATIC_RESPONSE_SERVER_MAINTENANCE: // The Phoromatic server is down for maintenance, so don't bother updating system status and wait longer before checking back echo PHP_EOL . 'The Phoromatic server is currently down for maintenance. Waiting for service to be restored.' . PHP_EOL; sleep((15 - date('i') % 15) * 60); break; case M_PHOROMATIC_RESPONSE_SHUTDOWN: echo PHP_EOL . 'Shutting down the system.' . PHP_EOL; $exit_loop = true; shell_exec('poweroff'); // Currently assuming root break; case M_PHOROMATIC_RESPONSE_REBOOT: echo PHP_EOL . 'Rebooting the system.' . PHP_EOL; $exit_loop = true; shell_exec('reboot'); // Currently assuming root break; case M_PHOROMATIC_RESPONSE_IDLE: default: phoromatic::update_system_status('Idling, Waiting For Task'); sleep((10 - date('i') % 10) * 60); // Check with server every 10 minutes break; } if (phodevi::system_hardware(true) != $current_hw || phodevi::system_software(true) != $current_sw) { // Hardware and/or software has changed while PTS/Phoromatic has been running, update the Phoromatic Server echo 'Updating Installed Hardware / Software With Phoromatic Server' . PHP_EOL; phoromatic::update_system_details(); $current_hw = phodevi::system_hardware(true); $current_sw = phodevi::system_software(true); } } while ($exit_loop == false); phoromatic::update_system_status('Offline'); }
public static function run($r) { $is_moscow = pts_flags::os_identifier_hash() == 'b28d6a7148b34595c5b397dfcf5b12ac7932b3dc'; if ($is_moscow) { // Auto mount? $drives = pts_file_io::glob('/dev/sda*'); sort($drives); if (false && count($drives) > 0 && !is_dir('/media/pts-auto-mount') && is_writable('/media/')) { $last_drive = array_pop($drives); echo PHP_EOL . 'Attempting to auto-mount drive: ' . $last_drive . PHP_EOL; mkdir('/media/pts-auto-mount'); exec('mount ' . $last_drive . ' /media/pts-auto-mount'); putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/'); } // Auto save results $test_results_name = phodevi::read_property('motherboard', 'serial-number'); if ($test_results_name == null) { $test_results_name = phodevi::read_name('motherboard'); } if ($test_results_name == null) { $test_results_name = phodevi::read_property('system', 'vendor-identifier'); } putenv('TEST_RESULTS_NAME=' . str_replace(' ', null, $test_results_name)); putenv('TEST_RESULTS_IDENTIFIER=' . $test_results_name); putenv('TEST_RESULTS_DESCRIPTION=Tests using ' . phodevi::read_property('system', 'operating-system') . ' on ' . date('d F Y') . ' of ' . $test_results_name . '.'); self::select_drive_mount(); } pts_openbenchmarking::refresh_repository_lists(); pts_client::$display->generic_heading('Interactive Benchmarking'); echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL; $reboot_on_exit = pts_flags::is_live_cd() && pts_client::user_home_directory() == '/root/'; do { $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition'); if ($is_moscow) { unset($options['RUN_SUITE']); // $options['SELECT_DRIVE_MOUNT'] = 'Select Disk Drive To Use For Testing'; } if (count(pts_client::saved_test_results()) > 0) { $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage'; } $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit'; $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true); switch ($response) { case 'RUN_TEST': $supported_tests = pts_openbenchmarking::available_tests(); $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true); $longest_title_length = 0; foreach ($supported_tests as $i => &$test_profile) { if ($test_profile->get_title() == null || pts_test_run_manager::test_profile_system_compatibility_check($test_profile) == false) { unset($supported_tests[$i]); continue; } if ($is_moscow && pts_test_install_request::test_files_available_locally($test_profile) == false) { // Don't show tests where files need to be downloaded unset($supported_tests[$i]); continue; } $longest_title_length = max($longest_title_length, strlen($test_profile->get_title())); } $t = array(); foreach ($supported_tests as $i => &$test_profile) { if ($test_profile instanceof pts_test_profile) { $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type()); } } $supported_tests = $t; asort($supported_tests); $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true); $tests_to_run = explode(',', $tests_to_run); pts_test_installer::standard_install($tests_to_run); $run_manager = pts_test_run_manager::standard_run($tests_to_run, pts_c::defaults_mode | pts_c::auto_mode); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'RUN_SUITE': $possible_suites = pts_openbenchmarking::available_suites(); foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) { array_push($possible_suites, 'pts/' . $subsystem); } $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true); foreach (explode(',', $suites_to_run) as $suite_to_run) { pts_test_installer::standard_install($suite_to_run); pts_test_run_manager::standard_run($suite_to_run, pts_c::defaults_mode | pts_c::auto_mode); } break; case 'SELECT_DRIVE_MOUNT': self::select_drive_mount(); break; case 'RUN_SYSTEM_TEST': pts_client::$display->generic_heading('System Test'); $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark'); pts_test_installer::standard_install($system_tests); $run_manager = pts_test_run_manager::standard_run($system_tests, pts_c::defaults_mode | pts_c::auto_mode); if ($run_manager != false) { pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true); } break; case 'SHOW_INFO': pts_client::$display->generic_heading('System Software / Hardware Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; break; case 'SHOW_SENSORS': pts_client::$display->generic_heading('Detected System Sensors'); foreach (phodevi::supported_sensors() as $sensor) { echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL; } break; case 'SET_RUN_COUNT': $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false); putenv('FORCE_TIMES_TO_RUN=' . trim($run_count)); break; case 'BACKUP_RESULTS_TO_USB': pts_client::$display->generic_heading('Backing Up Test Results'); if ($is_moscow) { $drives = pts_file_io::glob('/dev/sd*'); sort($drives); if (count($drives) > 0 && is_writable('/media/')) { $select_drive = pts_user_io::prompt_text_menu('Select Drive / Partition To Save Results', $drives); echo PHP_EOL . 'Attempting to mount: ' . $select_drive . PHP_EOL; mkdir('/media/00-results-backup'); exec('mount ' . $select_drive . ' /media/00-results-backup'); } } foreach (pts_file_io::glob('/media/*') as $media_dir) { if (!is_writable($media_dir)) { echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL; continue; } echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL; pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/'); break; } if ($is_moscow && is_dir('/media/00-results-backup')) { exec('umount /media/00-results-backup'); rmdir('/media/00-results-backup'); } break; } echo PHP_EOL . PHP_EOL; } while ($response != 'EXIT'); if ($reboot_on_exit) { if (is_dir('/media/pts-auto-mount')) { pts_file_io::delete('/media/pts-auto-mount/pts', null, true); exec('umount /media/pts-auto-mount 2>&1'); } exec('reboot'); } }
public static function run($r) { pts_client::set_debug_mode(true); pts_test_installer::standard_install($r, true); }
public static function run($r) { pts_test_installer::standard_install($r); pts_test_run_manager::standard_run($r, pts_c::defaults_mode); }
public static function run($items_to_install) { pts_test_installer::standard_install($items_to_install); }
public static function cleanup_tests_to_run(&$to_run_objects) { $skip_tests = ($e = pts_client::read_env('SKIP_TESTS')) ? pts_strings::comma_explode($e) : false; $tests_verified = array(); $tests_missing = array(); foreach ($to_run_objects as &$run_object) { if ($skip_tests && (in_array($run_object->get_identifier(false), $skip_tests) || $run_object instanceof pts_test_profile && in_array($run_object->get_identifier_base_name(), $skip_tests))) { pts_client::$display->generic_sub_heading('Skipping: ' . $run_object->get_identifier()); continue; } else { if ($run_object instanceof pts_test_profile) { if ($run_object->get_title() == null) { pts_client::$display->generic_sub_heading('Not A Test: ' . $run_object); continue; } else { if ($run_object->is_supported(false) == false) { continue; } if ($run_object->is_test_installed() == false) { // Check to see if older version of test is currently installed // TODO: show change-log between installed versions and upstream array_push($tests_missing, $run_object); continue; } } } else { if ($run_object instanceof pts_result_file) { $num_installed = 0; foreach ($run_object->get_contained_test_profiles() as $test_profile) { if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) { continue; } else { if ($test_profile->is_test_installed() == false) { array_push($tests_missing, $test_profile); } else { $num_installed++; } } } if ($num_installed == 0) { continue; } } else { if ($run_object instanceof pts_test_suite || $run_object instanceof pts_virtual_test_suite || $run_object instanceof pts_virtual_test_queue) { if ($run_object->is_core_version_supported() == false) { pts_client::$display->generic_sub_heading($run_object->get_title() . ' is a suite not supported by this version of the Phoronix Test Suite.'); continue; } $num_installed = 0; foreach ($run_object->get_contained_test_profiles() as $test_profile) { if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) { continue; } if ($test_profile->is_test_installed() == false) { array_push($tests_missing, $test_profile); } else { $num_installed++; } } if ($num_installed == 0) { continue; } } else { pts_client::$display->generic_sub_heading('Not Recognized: ' . $run_object); continue; } } } } array_push($tests_verified, $run_object); } $to_run_objects = $tests_verified; if (count($tests_missing) > 0 && !defined('PHOROMATIC_PROCESS')) { $tests_missing = array_unique($tests_missing); if (count($tests_missing) == 1) { trigger_error($tests_missing[0] . ' is not installed.', E_USER_ERROR); // PHP_EOL . 'To install, run: phoronix-test-suite install ' . $tests_missing[0] } else { $message = PHP_EOL . PHP_EOL . 'Multiple tests are not installed:' . PHP_EOL . PHP_EOL; $message .= pts_user_io::display_text_list($tests_missing); //$message .= PHP_EOL . 'To install, run: phoronix-test-suite install ' . implode(' ', $tests_missing) . PHP_EOL . PHP_EOL; echo $message; } if (!$this->batch_mode && !$this->auto_mode && pts_client::current_command() != 'benchmark') { $stop_and_install = pts_user_io::prompt_bool_input('Would you like to stop and install these tests now', true); if ($stop_and_install) { pts_test_installer::standard_install($tests_missing); self::cleanup_tests_to_run($to_run_objects); } } } return true; }
public static function run($r) { pts_test_installer::standard_install($r, pts_c::force_install); }
public static function run($r) { pts_test_installer::standard_install($r, false, true); }
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 static function run($r) { pts_test_installer::standard_install($r, pts_c::batch_mode); }
public static function run($r) { if (pts_openbenchmarking_client::user_name() == false) { echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL; echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/'; echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL; return false; } ini_set('memory_limit', '2048M'); foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) { $qualified_identifier = $test_profile->get_identifier(); // First make sure the test profile is already in the OpenBenchmarking.org database... $json = pts_openbenchmarking::make_openbenchmarking_request('is_test_profile', array('i' => $qualified_identifier)); $json = json_decode($json, true); if (!isset($json['openbenchmarking']['test']['valid']) || $json['openbenchmarking']['test']['valid'] != 'TRUE') { echo PHP_EOL . $qualified_identifier . ' must first be uploaded to OpenBenchmarking.org.' . PHP_EOL; // break; } // Set some other things... pts_client::pts_set_environment_variable('FORCE_TIMES_TO_RUN', 1); pts_client::pts_set_environment_variable('TEST_RESULTS_NAME', $test_profile->get_title() . ' Testing ' . date('Y-m-d')); pts_client::pts_set_environment_variable('TEST_RESULTS_IDENTIFIER', 'Sample Run'); pts_client::pts_set_environment_variable('TEST_RESULTS_DESCRIPTION', 1); pts_openbenchmarking_client::override_client_setting('AutoUploadResults', true); pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true); // Take screenshots pts_client::pts_set_environment_variable('SCREENSHOT_INTERVAL', 9); pts_module_manager::attach_module('timed_screenshot'); $force_ss = true; $reference_ss_file = pts_module_manager::module_call('timed_screenshot', 'take_screenshot', $force_ss); sleep(2); $apitrace = pts_file_io::glob('/usr/local/lib/*/apitrace/wrappers/glxtrace.so'); if (!empty($apitrace) && pts_client::executable_in_path('apitrace')) { $apitrace = array_shift($apitrace); putenv('LD_PRELOAD=' . $apitrace); } else { $apitrace = false; } // So for any compiling tasks they will try to use the most aggressive instructions possible putenv('CFLAGS=-march=native -O3'); putenv('CXXFLAGS=-march=native -O3'); pts_test_installer::standard_install($qualified_identifier, true); $run_manager = new pts_test_run_manager(false, 2); $run_manager->standard_run($qualified_identifier); if ($apitrace) { putenv('LD_PRELOAD='); } if ($reference_ss_file) { $reference_ss = pts_image::image_file_to_gd($reference_ss_file); unlink($reference_ss_file); $screenshots_gd = array(); $screenshots = pts_module_manager::module_call('timed_screenshot', 'get_screenshots'); var_dump($screenshots); foreach ($screenshots as $ss_file) { $screenshots_gd[$ss_file] = pts_image::image_file_to_gd($ss_file); if ($screenshots_gd[$ss_file] == false) { continue; } $ss_delta = pts_image::gd_image_delta_composite($reference_ss, $screenshots_gd[$ss_file], true); if (count($ss_delta) < floor(imagesx($reference_ss) * 0.5600000000000001) || filesize($ss_file) > 2097152) { // If less than 56% of the pixels are changing on X, then likely not much to show off... (CLI only likely) // Or if filesize of image is beyond 2MB //echo 'dropping' . $ss_file . PHP_EOL; unset($screenshots_gd[$ss_file]); pts_file_io::unlink($ss_file); } } $ss_files = array_keys($screenshots_gd); shuffle($ss_files); // Don't upload more than 4MB worth of screenshots while (pts_file_io::array_filesize($ss_files) > 1048576 * 2) { $f = array_pop($ss_files); unlink($f); } if (count($ss_files) > 0) { $c = 1; foreach ($ss_files as $i => $file) { $new_file = dirname($file) . '/screenshot-' . $c . '.png'; rename($file, $new_file); $ss_files[$i] = $new_file; $c++; } $ss_zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . 'screenshots-' . $test_profile->get_identifier_base_name() . '-' . $test_profile->get_test_profile_version() . '.zip'; $zip_created = pts_compression::zip_archive_create($ss_zip_file, $ss_files); if ($zip_created) { echo count($ss_files) . ' screenshots captured for use.'; //'tp_sha1' => sha1_file($zip_file), //'tp_zip' => base64_encode(file_get_contents($zip_file)), } foreach ($ss_files as $file) { // pts_file_io::unlink($file); } } } $test_binary = self::locate_test_profile_lead_binary($test_profile); $shared_library_dependencies = array(); $instruction_usage = array(); $gl_calls = null; if (is_executable($test_binary)) { if ($apitrace) { // Find the trace... $test_binary_dir = dirname($test_binary); $trace_file = glob($test_binary_dir . '/*.trace'); if ($trace_file) { echo 'Analyzing GL traces'; $trace_file = array_shift($trace_file); $gl_usage = self::analyze_apitrace_trace_glpop($trace_file); if (!empty($gl_usage)) { $gl_calls = implode(',', $gl_usage); } } } $ldd = trim(shell_exec('ldd ' . $test_binary)); foreach (explode(PHP_EOL, $ldd) as $line) { $line = explode(' => ', $line); if (count($line) == 2) { $shared_library_dependencies[] = trim(basename($line[0])); } } echo PHP_EOL . 'SHARED LIBRARY DEPENDENCIES: ' . PHP_EOL; print_r($shared_library_dependencies); foreach (array('core-avx-i', 'bdver2') as $march) { // So for any compiling tasks they will try to use the most aggressive instructions possible putenv('CFLAGS=-march=' . $march . ' -O3'); putenv('CXXFLAGS=-march=' . $march . ' -O3'); pts_test_installer::standard_install($qualified_identifier, true); $instruction_usage[$march] = self::analyze_binary_instruction_usage($test_binary); if ($instruction_usage[$march] == null) { unset($instruction_usage[$march]); } } if (!empty($instruction_usage) && count(array_unique($instruction_usage)) == 1) { $generic = array_pop($instruction_usage); $instruction_usage = array('generic' => $generic); } var_dump($instruction_usage); } else { echo PHP_EOL . $test_binary; echo PHP_EOL . 'Test binary could not be found.' . PHP_EOL; // return false; } } sleep(10); var_dump($shared_library_dependencies); var_dump($instruction_usage); var_dump($gl_calls); $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_meta', array('i' => $test_profile->get_identifier(), 'screenshots_zip' => $ss_zip_conts = base64_encode(file_get_contents($ss_zip_file)), 'screenshots_zip_sha1' => sha1($ss_zip_conts), 'ldd_libraries' => implode(',', $shared_library_dependencies), 'opengl_calls' => $gl_calls, 'instruction_set_usage' => base64_encode(json_encode($instruction_usage)))); var_dump($server_response); $json = json_decode($server_response, true); pts_file_io::unlink($ss_zip_file); }
protected static function install_test_process(&$test_install_request, $no_prompts) { // Install a test $identifier = $test_install_request->test_profile->get_identifier(); $test_install_directory = $test_install_request->test_profile->get_install_dir(); pts_file_io::mkdir(dirname($test_install_directory)); pts_file_io::mkdir($test_install_directory); $installed = false; if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_download_size() + 128) { self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for the test files.'); } else { if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_environment_size(false) + 128) { self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for this test.'); } else { pts_test_installer::setup_test_install_directory($test_install_request, true); // Download test files $download_test_files = pts_test_installer::download_test_files($test_install_request, false, $no_prompts); if ($download_test_files == false) { self::test_install_error(null, $test_install_request, 'Downloading of needed test files failed.'); return false; } if ($test_install_request->test_profile->get_file_installer() != false) { self::create_compiler_mask($test_install_request); pts_module_manager::module_process('__pre_test_install', $identifier); pts_client::$display->test_install_begin($test_install_request); $pre_install_message = $test_install_request->test_profile->get_pre_install_message(); $post_install_message = $test_install_request->test_profile->get_post_install_message(); $install_agreement = $test_install_request->test_profile->get_installation_agreement_message(); if (!empty($install_agreement)) { if (pts_strings::is_url($install_agreement)) { $install_agreement = pts_network::http_get_contents($install_agreement); if (empty($install_agreement)) { self::test_install_error(null, $test_install_request, 'The user agreement could not be found. Test installation aborted.'); return false; } } echo $install_agreement . PHP_EOL; if (!$no_prompts) { $user_agrees = pts_user_io::prompt_bool_input('Do you agree to these terms', false, 'INSTALL_AGREEMENT'); if (!$user_agrees) { self::test_install_error(null, $test_install_request, 'User agreement failed; this test will not be installed.'); return false; } } } pts_client::$display->display_interrupt_message($pre_install_message); $install_time_length_start = microtime(true); $install_log = pts_tests::call_test_script($test_install_request->test_profile, 'install', null, $test_install_directory, $test_install_request->special_environment_vars, false); $test_install_request->install_time_duration = ceil(microtime(true) - $install_time_length_start); pts_client::$display->display_interrupt_message($post_install_message); if (!empty($install_log)) { file_put_contents($test_install_directory . 'install.log', $install_log); pts_file_io::unlink($test_install_directory . 'install-failed.log'); pts_client::$display->test_install_output($install_log); } if (is_file($test_install_directory . 'install-exit-status')) { // If the installer writes its exit status to ~/install-exit-status, if it's non-zero the install failed $install_exit_status = pts_file_io::file_get_contents($test_install_directory . 'install-exit-status'); unlink($test_install_directory . 'install-exit-status'); if ($install_exit_status != 0 && phodevi::is_windows() == false) { $install_error = null; // TODO: perhaps better way to handle this than to remove pts-install.xml pts_file_io::unlink($test_install_directory . 'pts-install.xml'); if (is_file($test_install_directory . 'install.log')) { $install_log = pts_file_io::file_get_contents($test_install_directory . 'install.log'); $install_error = pts_tests::scan_for_error($install_log, $test_install_directory); copy($test_install_directory . 'install.log', $test_install_directory . 'install-failed.log'); } //pts_test_installer::setup_test_install_directory($test_install_request, true); // Remove installed files from the bunked installation self::test_install_error(null, $test_install_request, 'The installer exited with a non-zero exit status.'); if ($install_error != null) { $test_install_request->install_error = pts_tests::pretty_error_string($install_error); if ($test_install_request->install_error != null) { self::test_install_error(null, $test_install_request, 'ERROR: ' . $test_install_request->install_error); } } pts_client::$display->test_install_error('LOG: ' . str_replace(pts_core::user_home_directory(), '~/', $test_install_directory) . 'install-failed.log' . PHP_EOL); if (pts_client::do_anonymous_usage_reporting()) { // If anonymous usage reporting enabled, report test install failure to OpenBenchmarking.org pts_openbenchmarking_client::upload_usage_data('test_install_failure', array($test_install_request, $install_error)); } return false; } } pts_module_manager::module_process('__post_test_install', $identifier); $installed = true; if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', 'FALSE')) { // Remove original downloaded files foreach ($test_install_request->get_download_objects() as $download_object) { pts_file_io::unlink($test_install_directory . $download_object->get_filename()); } } } else { pts_client::$display->test_install_error('No installation script found.'); $installed = true; } // Additional validation checks? $custom_validated_output = pts_tests::call_test_script($test_install_request->test_profile, 'validate-install', PHP_EOL . 'Validating Installation...' . PHP_EOL, $test_install_directory, null, false); if (!empty($custom_validated_output) && !pts_strings::string_bool($custom_validated_output)) { $installed = false; } } } echo PHP_EOL; return $installed; }
public static function run($r) { pts_test_installer::standard_install($r); pts_test_run_manager::standard_run($r); }