本文整理汇总了PHP中pts_client::environmental_variables方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::environmental_variables方法的具体用法?PHP pts_client::environmental_variables怎么用?PHP pts_client::environmental_variables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::environmental_variables方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($script, $env_vars = null, $set_current_path = null)
{
if (!isset($env_vars['HOME'])) {
$env_vars['HOME'] = $set_current_path;
}
$this->environmental_variables = $env_vars == null ? pts_client::environmental_variables() : array_merge(pts_client::environmental_variables(), $env_vars);
$this->script_file = is_file($script) ? $script : null;
$this->var_current_directory = $set_current_path;
}
示例2: run
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;
}
示例3: shell_exec
public static function shell_exec($exec, $extra_vars = null)
{
// Same as shell_exec() but with the PTS env variables added in
// Convert pts_client::environmental_variables() into shell export variable syntax
$var_string = '';
$extra_vars = $extra_vars == null ? pts_client::environmental_variables() : array_merge(pts_client::environmental_variables(), $extra_vars);
foreach (array_keys($extra_vars) as $key) {
$var_string .= 'export ' . $key . '=' . $extra_vars[$key] . ';';
}
$var_string .= ' ';
return shell_exec($var_string . $exec);
}
示例4: run_test
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) {
//.........这里部分代码省略.........