当前位置: 首页>>代码示例>>PHP>>正文


PHP pts_client::shell_exec方法代码示例

本文整理汇总了PHP中pts_client::shell_exec方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::shell_exec方法的具体用法?PHP pts_client::shell_exec怎么用?PHP pts_client::shell_exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pts_client的用法示例。


在下文中一共展示了pts_client::shell_exec方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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();
     // 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;
     }
     $test_run_request->test_result_buffer = new pts_test_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_c::$test_flags & pts_c::debug_mode) {
             pts_client::$display->test_run_instance_output($pre_output);
         }
     }
     pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());
     $runtime_identifier = time();
     $execute_binary_prepend = '';
     if (!$cache_share_present && $test_run_request->test_profile->is_root_required()) {
         $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));
         $restored_from_cache = false;
         if ($cache_share_present) {
             $cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);
             if ($cache_share) {
                 $test_result = $cache_share->read_object('test_results_output_' . $i);
                 $test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);
                 if ($test_extra_runtime_variables['LOG_FILE'] != null) {
                     file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));
                     $test_run_time = 0;
                     // This wouldn't be used for a cache share since it would always be the same, but declare the value so the variable is at least initialized
                     $restored_from_cache = true;
                 }
             }
             unset($cache_share);
         }
         if ($restored_from_cache == false) {
             $test_run_command = 'cd ' . $to_execute . ' && ' . $execute_binary_prepend . './' . $execute_binary . ' ' . $pts_test_arguments . ' 2>&1';
             pts_client::test_profile_debug_message('Test Run Command: ' . $test_run_command);
             $is_monitoring = pts_test_result_parser::system_monitor_task_check($test_run_request->test_profile);
             $test_run_time_start = time();
             if (phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false) {
                 $phoroscript = new pts_phoroscript_interpreter($to_execute . '/' . $execute_binary, $test_extra_runtime_variables, $to_execute);
                 $phoroscript->execute_script($pts_test_arguments);
                 $test_result = null;
             } else {
                 $test_result = pts_client::shell_exec($test_run_command, $test_extra_runtime_variables);
             }
             $test_run_time = time() - $test_run_time_start;
             $monitor_result = $is_monitoring ? pts_test_result_parser::system_monitor_task_post_test($test_run_request->test_profile) : 0;
         }
         if (!isset($test_result[10240]) || pts_c::$test_flags & pts_c::debug_mode) {
             pts_client::$display->test_run_instance_output($test_result);
         }
         if (is_file($test_log_file) && trim($test_result) == null && (filesize($test_log_file) < 10240 || pts_c::$test_flags & pts_c::debug_mode)) {
//.........这里部分代码省略.........
开发者ID:pchiruma,项目名称:phoronix-test-suite,代码行数:101,代码来源:pts_test_execution.php

示例2: call_test_script

 public static function call_test_script($test_profile, $script_name, $print_string = null, $pass_argument = null, $extra_vars_append = null, $use_ctp = true)
 {
     $extra_vars = pts_tests::extra_environmental_variables($test_profile);
     if (isset($extra_vars_append['PATH'])) {
         // Special case variable where you likely want the two merged rather than overwriting
         $extra_vars['PATH'] = $extra_vars_append['PATH'] . (substr($extra_vars_append['PATH'], -1) != ':' ? ':' : null) . $extra_vars['PATH'];
         unset($extra_vars_append['PATH']);
     }
     if (is_array($extra_vars_append)) {
         $extra_vars = array_merge($extra_vars, $extra_vars_append);
     }
     // TODO: call_test_script could be better cleaned up to fit more closely with new pts_test_profile functions
     $result = null;
     $test_directory = $test_profile->get_install_dir();
     pts_file_io::mkdir($test_directory, 0777, true);
     $os_postfix = '_' . strtolower(phodevi::operating_system());
     $test_profiles = array($test_profile);
     if ($use_ctp) {
         $test_profiles = array_merge($test_profiles, $test_profile->extended_test_profiles());
     }
     if (pts_client::executable_in_path('bash')) {
         $sh = 'bash';
     } else {
         $sh = 'sh';
     }
     foreach ($test_profiles as &$this_test_profile) {
         $test_resources_location = $this_test_profile->get_resource_dir();
         if (is_file($run_file = $test_resources_location . $script_name . $os_postfix . '.sh') || is_file($run_file = $test_resources_location . $script_name . '.sh')) {
             if (!empty($print_string)) {
                 pts_client::$display->test_run_message($print_string);
             }
             if (phodevi::is_windows() || pts_client::read_env('USE_PHOROSCRIPT_INTERPRETER') != false) {
                 $phoroscript = new pts_phoroscript_interpreter($run_file, $extra_vars, $test_directory);
                 $phoroscript->execute_script($pass_argument);
                 $this_result = null;
             } else {
                 $this_result = pts_client::shell_exec('cd ' . $test_directory . ' && ' . $sh . ' ' . $run_file . ' "' . $pass_argument . '" 2>&1', $extra_vars);
             }
             if (trim($this_result) != null) {
                 $result = $this_result;
             }
         }
     }
     return $result;
 }
开发者ID:ptzafrir,项目名称:phoronix-test-suite,代码行数:45,代码来源:pts_tests.php

示例3: set_user_context

 private static function set_user_context($context_script, $trigger, $schedule_id, $process)
 {
     if (!empty($context_script)) {
         $context_file = pts_client::create_temporary_file();
         file_put_contents($context_file, $context_script);
         chmod($context_file, 0755);
         pts_file_io::mkdir(pts_module::save_dir());
         $storage_path = pts_module::save_dir() . 'memory.pt2so';
         $storage_object = pts_storage_object::recover_from_file($storage_path);
         $notes_log_file = pts_module::save_dir() . sha1($trigger . $schedule_id . $process);
         // We check to see if the context was already set but the system rebooted or something in that script
         if ($storage_object == false) {
             $storage_object = new pts_storage_object(true, true);
         } else {
             if ($storage_object->read_object('last_set_context_trigger') == $trigger && $storage_object->read_object('last_set_context_schedule') == $schedule_id && $storage_object->read_object('last_set_context_process') == $process) {
                 // If the script already ran once for this trigger, don't run it again
                 self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, null);
                 return false;
             }
         }
         $storage_object->add_object('last_set_context_trigger', $trigger);
         $storage_object->add_object('last_set_context_schedule', $schedule_id);
         $storage_object->add_object('last_set_context_process', $process);
         $storage_object->save_to_file($storage_path);
         phoromatic::update_system_status('Setting context for: ' . $schedule_id . ' - ' . $trigger . ' - ' . $process);
         // Run the set context script
         $env_vars['PHOROMATIC_TRIGGER'] = $trigger;
         $env_vars['PHOROMATIC_SCHEDULE_ID'] = $schedule_id;
         $env_vars['PHOROMATIC_SCHEDULE_PROCESS'] = $process;
         $env_vars['PHOROMATIC_LOG_FILE'] = $notes_log_file;
         $log_output = pts_client::shell_exec('./' . $context_script . ' ' . $trigger . ' 2>&1', $env_vars);
         self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, $log_output);
         // Just simply return true for now, perhaps check exit code status and do something
         return true;
     }
     return false;
 }
开发者ID:abartol,项目名称:phoronix-test-suite,代码行数:37,代码来源:phoromatic.php


注:本文中的pts_client::shell_exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。