public static function run($r) { $module = strtolower($r[0]); pts_module_manager::attach_module($module); $processes = array('__startup', '__pre_option_process', '__pre_install_process', '__pre_test_download', '__interim_test_download', '__post_test_download', '__pre_test_install', '__post_test_install', '__post_install_process', '__pre_run_process', '__pre_test_run', '__interim_test_run', '__post_test_run', '__post_run_process', '__post_option_process', '__shutdown'); foreach ($processes as $process) { echo 'Calling: ' . $process . '()' . PHP_EOL; pts_module_manager::module_process($process); sleep(1); } echo PHP_EOL; }
public static function module_framework_init() { // Process initially called when PTS starts up // Check for modules to auto-load from the configuration file $load_modules = pts_config::read_user_config('PhoronixTestSuite/Options/Modules/LoadModules', null); if (!empty($load_modules)) { foreach (pts_strings::comma_explode($load_modules) as $module) { $module_r = pts_strings::trim_explode('=', $module); if (count($module_r) == 2) { // TODO: end up hooking this into pts_module::read_variable() rather than using the real env pts_client::set_environment_variable($module_r[0], $module_r[1]); } else { pts_module_manager::attach_module($module); } } } // Check for modules to load manually in PTS_MODULES if (($load_modules = pts_client::read_env('PTS_MODULES')) !== false) { foreach (pts_strings::comma_explode($load_modules) as $module) { if (!pts_module_manager::is_module_attached($module)) { pts_module_manager::attach_module($module); } } } // Detect modules to load automatically pts_module_manager::detect_modules_to_load(); // Clean-up modules list pts_module_manager::clean_module_list(); // Reset counter pts_module_manager::set_current_module(null); // Load the modules $module_store_list = array(); foreach (pts_module_manager::attached_modules() as $module) { $class_vars = get_class_vars($module); $module_store_vars = isset($class_vars['module_store_vars']) ? $class_vars['module_store_vars'] : null; if (is_array($module_store_vars)) { foreach ($module_store_vars as $store_var) { if (!in_array($store_var, $module_store_list)) { array_push($module_store_list, $store_var); } } } } // Should any of the module options be saved to the results? foreach ($module_store_list as $var) { $var_value = pts_client::read_env($var); if (!empty($var_value)) { pts_module_manager::var_store_add($var, $var_value); } } pts_module_manager::module_process('__startup'); pts_define('PTS_STARTUP_TASK_PERFORMED', true); register_shutdown_function(array('pts_module_manager', 'module_process'), '__shutdown'); }
public static function valid_run_command($module, $command = null) { if ($command == null) { if (strpos($module, '.') != false) { list($module, $command) = explode('.', $module); } else { $command = 'run'; } } if (!pts_module_manager::is_module_attached($module)) { pts_module_manager::attach_module($module); } $all_options = pts_module_manager::module_call($module, 'user_commands'); $valid = count($all_options) > 0 && (isset($all_options[$command]) && method_exists($module, $all_options[$command]) || !empty($all_options)); return $valid ? array($module, $command) : false; }
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 phoromatic_setup_module() { if (!pts_module::is_module_setup()) { echo PHP_EOL . 'You first must run:' . PHP_EOL . PHP_EOL . 'phoronix-test-suite module-setup phoromatic' . PHP_EOL . PHP_EOL; return false; } self::$phoromatic_host = pts_module::read_option('remote_host'); self::$phoromatic_account = pts_module::read_option('remote_account'); self::$phoromatic_verifier = pts_module::read_option('remote_verifier'); self::$phoromatic_system = pts_module::read_option('remote_system'); if (extension_loaded('openssl') == false) { // OpenSSL is not supported therefore no HTTPS support self::$phoromatic_host = str_replace('https://', 'http://', self::$phoromatic_host); } $phoromatic = 'phoromatic'; pts_module_manager::attach_module($phoromatic); return true; }
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); } } } } }