public static function init() { set_time_limit(0); pts_define_directories(); // Define directories pts_define('PTS_INIT_TIME', time()); if (!defined('PHP_VERSION_ID')) { $php_version = explode('.', PHP_VERSION); pts_define('PHP_VERSION_ID', $php_version[0] * 10000 + $php_version[1] * 100 + $php_version[2]); } }
public static function run($r) { foreach (pts_define(-1) as $constant => $constant_value) { if (strpos($constant, 'GSID') !== false || strpos($constant, '_ID') !== false) { continue; } echo $constant . ' = ' . $constant_value . PHP_EOL; } echo PHP_EOL . 'Variables That Can Be Used As Result Identifiers / File Names:' . PHP_EOL; foreach (pts_client::user_run_save_variables() as $var => $var_value) { echo $var . ' = ' . $var_value . PHP_EOL; } echo PHP_EOL . 'Environmental Variables (accessible via test scripts):' . PHP_EOL; foreach (pts_client::environmental_variables() as $var => $var_value) { echo $var . ' = ' . $var_value . PHP_EOL; } echo PHP_EOL; }
public static function exit_client($string = null, $exit_status = 0) { // Exit the Phoronix Test Suite client pts_define('PTS_EXIT', 1); if ($string != null) { echo PHP_EOL . $string . PHP_EOL; } exit($exit_status); }
$aliases = pts_storage_object::read_from_file(PTS_TEMP_STORAGE, 'command_alias_list'); if ($aliases == null) { $aliases = pts_documentation::client_commands_aliases(); } if (isset($aliases[$sent_command])) { $sent_command = $aliases[$sent_command]; $replaced = true; } } } 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]; }
public static function refresh_repository_lists($repos = null, $force_refresh = false) { if ($repos == null) { if ($force_refresh == false) { if (!defined('HAS_REFRESHED_OBO_LIST')) { pts_define('HAS_REFRESHED_OBO_LIST', true); } else { return true; } } $repos = self::linked_repositories(); } foreach ($repos as $repo_name) { pts_file_io::mkdir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name); if ($repo_name == 'local') { // Local is a special case, not actually a real repository continue; } if (!is_dir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name)) { mkdir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name, 0777, true); } $index_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name . '.index'; $server_index = null; if (is_file($index_file)) { $repo_index = json_decode(file_get_contents($index_file), true); $generated_time = $repo_index['main']['generated']; // Refreshing the indexes once every few days should be suffice // Refresh approximately every three days by default $index_cache_ttl = 3; if (PTS_IS_CLIENT && ($config_ttl = pts_config::read_user_config('PhoronixTestSuite/Options/OpenBenchmarking/IndexCacheTTL'))) { if ($config_ttl === 0) { // if the value is 0, only rely upon manual refreshes continue; } else { if (is_numeric($config_ttl) && $config_ttl >= 1) { $index_cache_ttl = $config_ttl; } } } if ($generated_time > time() - 86400 * $index_cache_ttl && $force_refresh == false && (!defined('FIRST_RUN_ON_PTS_UPGRADE') || FIRST_RUN_ON_PTS_UPGRADE == false)) { // The index is new enough continue; } if (pts_network::internet_support_available()) { $server_index = pts_openbenchmarking::make_openbenchmarking_request('repo_index', array('repo' => $repo_name)); self::$openbenchmarking_index_refreshed = true; } if (!$server_index && ($phoromatic_cache_index = self::phoromatic_server_ob_cache_request('index', $repo_name))) { // Ensure the Phoromatic cache has a newer version of the index than what's currently on the system $repo_index = json_decode($phoromatic_cache_index, true); if (isset($repo_index['main']['generated'])) { $cache_generated_time = $repo_index['main']['generated']; if ($cache_generated_time > $generated_time) { $server_index = $phoromatic_cache_index; } self::$openbenchmarking_index_refreshed = true; } } } else { if (pts_network::internet_support_available()) { $server_index = pts_openbenchmarking::make_openbenchmarking_request('repo_index', array('repo' => $repo_name)); self::$openbenchmarking_index_refreshed = true; } } if (!$server_index && ($phoromatic_cache_index = self::phoromatic_server_ob_cache_request('index', $repo_name))) { $server_index = $phoromatic_cache_index; } if ($server_index != null && json_decode($server_index) != false) { file_put_contents($index_file, $server_index); } else { if (PTS_IS_CLIENT && is_file('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $repo_name . '.index')) { copy('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $repo_name . '.index', $index_file); } } if (!is_file($index_file)) { static $reported_read_failure_notice; if (!isset($reported_read_failure_notice[$repo_name]) && PTS_IS_CLIENT) { trigger_error('Failed To Fetch OpenBenchmarking.org Repository Data: ' . $repo_name, E_USER_WARNING); $reported_read_failure_notice[$repo_name] = true; } } } }
function pts_define_directories() { // User's home directory for storing results, module files, test installations, etc. pts_define('PTS_CORE_PATH', PTS_PATH . 'pts-core/'); pts_define('PTS_IS_DAEMONIZED_SERVER_PROCESS', PTS_IS_CLIENT && is_dir('/var/lib/') && is_writable('/') ? true : false); if (PTS_IS_DAEMONIZED_SERVER_PROCESS) { if (!is_dir('/var/cache/phoronix-test-suite/')) { mkdir('/var/cache/phoronix-test-suite/'); } pts_define('PTS_USER_PATH', '/var/lib/phoronix-test-suite/'); pts_define('PTS_CORE_STORAGE', PTS_USER_PATH . 'core.pt2so'); pts_define('PTS_TEMP_STORAGE', PTS_USER_PATH . 'temp.pt2so'); pts_define('PTS_MODULE_LOCAL_PATH', PTS_USER_PATH . 'modules/'); pts_define('PTS_MODULE_DATA_PATH', PTS_USER_PATH . 'modules-data/'); pts_define('PTS_DOWNLOAD_CACHE_PATH', '/var/cache/phoronix-test-suite/download-cache/'); pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', '/var/cache/phoronix-test-suite/openbenchmarking.org/'); pts_define('PTS_TEST_PROFILE_PATH', PTS_USER_PATH . 'test-profiles/'); pts_define('PTS_TEST_SUITE_PATH', PTS_USER_PATH . 'test-suites/'); pts_define('PTS_RESULTS_VIEWER_PATH', PTS_CORE_PATH . 'results-viewer/'); } else { if (PTS_IS_CLIENT) { pts_define('PTS_USER_PATH', pts_client::user_home_directory() . '.phoronix-test-suite' . DIRECTORY_SEPARATOR); pts_define('PTS_CORE_STORAGE', PTS_USER_PATH . 'core.pt2so'); pts_define('PTS_TEMP_STORAGE', PTS_USER_PATH . 'temp.pt2so'); pts_define('PTS_MODULE_LOCAL_PATH', PTS_USER_PATH . 'modules/'); pts_define('PTS_MODULE_DATA_PATH', PTS_USER_PATH . 'modules-data/'); pts_define('PTS_DOWNLOAD_CACHE_PATH', PTS_USER_PATH . 'download-cache/'); pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PTS_USER_PATH . 'openbenchmarking.org/'); pts_define('PTS_TEST_PROFILE_PATH', PTS_USER_PATH . 'test-profiles/'); pts_define('PTS_TEST_SUITE_PATH', PTS_USER_PATH . 'test-suites/'); pts_define('PTS_RESULTS_VIEWER_PATH', PTS_CORE_PATH . 'results-viewer/'); } else { if (defined('PTS_STORAGE_PATH')) { pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PTS_STORAGE_PATH . 'openbenchmarking.org/'); pts_define('PTS_TEST_PROFILE_PATH', PTS_STORAGE_PATH . 'test-profiles/'); pts_define('PTS_TEST_SUITE_PATH', PTS_STORAGE_PATH . 'test-suites/'); } else { if (defined('PATH_TO_PHOROMATIC_STORAGE')) { pts_define('PTS_OPENBENCHMARKING_SCRATCH_PATH', PATH_TO_PHOROMATIC_STORAGE . 'openbenchmarking.org/'); pts_define('PTS_TEST_PROFILE_PATH', PATH_TO_PHOROMATIC_STORAGE . 'test-profiles/'); pts_define('PTS_TEST_SUITE_PATH', PATH_TO_PHOROMATIC_STORAGE . 'test-suites/'); } } } } // Misc Locations pts_define('PTS_MODULE_PATH', PTS_CORE_PATH . 'modules/'); pts_define('PTS_CORE_STATIC_PATH', PTS_CORE_PATH . 'static/'); pts_define('PTS_COMMAND_PATH', PTS_CORE_PATH . 'commands/'); pts_define('PTS_EXDEP_PATH', PTS_CORE_PATH . 'external-test-dependencies/'); pts_define('PTS_OPENBENCHMARKING_PATH', PTS_CORE_PATH . 'openbenchmarking.org/'); }