本文整理汇总了PHP中pts_client::temporary_directory方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::temporary_directory方法的具体用法?PHP pts_client::temporary_directory怎么用?PHP pts_client::temporary_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::temporary_directory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_compiler_mask
public static function create_compiler_mask(&$test_install_request)
{
if (phodevi::is_bsd()) {
// XXX: Using the compiler-mask causes a number of tests to fail to properly install due to compiler issues with at least PC-BSD 10.0
return false;
}
// or pass false to $test_install_request to bypass the test checks
$compilers = array();
$external_dependencies = $test_install_request != false ? $test_install_request->test_profile->get_external_dependencies() : false;
if ($test_install_request === false || in_array('build-utilities', $external_dependencies)) {
// Handle C/C++ compilers for this external dependency
$compilers['CC'] = array(pts_strings::first_in_string(pts_client::read_env('CC'), ' '), 'gcc', 'clang', 'icc', 'pcc');
$compilers['CXX'] = array(pts_strings::first_in_string(pts_client::read_env('CXX'), ' '), 'g++', 'clang++', 'cpp');
}
if ($test_install_request === false || in_array('fortran-compiler', $external_dependencies)) {
// Handle Fortran for this external dependency
$compilers['F9X'] = array(pts_strings::first_in_string(pts_client::read_env('F9X'), ' '), pts_strings::first_in_string(pts_client::read_env('F95'), ' '), 'gfortran', 'f90', 'f95', 'fortran');
}
if (empty($compilers)) {
// If the test profile doesn't request a compiler external dependency, probably not compiling anything
return false;
}
foreach ($compilers as $compiler_type => $possible_compilers) {
// Compilers to check for, listed in order of priority
$compiler_found = false;
foreach ($possible_compilers as $i => $possible_compiler) {
// first check to ensure not null sent to executable_in_path from env variable
if ($possible_compiler && (($compiler_path = is_executable($possible_compiler)) || ($compiler_path = pts_client::executable_in_path($possible_compiler, 'ccache')))) {
// Replace the array of possible compilers with a string to the detected compiler executable
$compilers[$compiler_type] = $compiler_path;
$compiler_found = true;
break;
}
}
if ($compiler_found == false) {
unset($compilers[$compiler_type]);
}
}
if (!empty($compilers)) {
// Create a temporary directory that will be at front of PATH and serve for masking the actual compiler
if ($test_install_request instanceof pts_test_install_request) {
$mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . $test_install_request->test_profile->get_identifier_base_name() . $test_install_request->test_profile->get_test_profile_version() . '/';
} else {
$mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . rand(100, 999) . '/';
}
pts_file_io::mkdir($mask_dir);
$compiler_extras = array('CC' => array('safeguard-names' => array('gcc', 'cc'), 'environment-variables' => 'CFLAGS'), 'CXX' => array('safeguard-names' => array('g++', 'c++'), 'environment-variables' => 'CXXFLAGS'), 'F9X' => array('safeguard-names' => array('gfortran', 'f95'), 'environment-variables' => 'F9XFLAGS'));
foreach ($compilers as $compiler_type => $compiler_path) {
$compiler_name = basename($compiler_path);
$main_compiler = $mask_dir . $compiler_name;
// take advantage of environment-variables to be sure they're found in the string
$env_var_check = PHP_EOL;
/*
foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['environment-variables']) as $env_var)
{
// since it's a dynamic check in script could probably get rid of this check...
if(true || getenv($env_var))
{
$env_var_check .= 'if [[ $COMPILER_OPTIONS != "*$' . $env_var . '*" ]]' . PHP_EOL . 'then ' . PHP_EOL . 'COMPILER_OPTIONS="$COMPILER_OPTIONS $' . $env_var . '"' . PHP_EOL . 'fi' . PHP_EOL;
}
}
*/
// Write the main mask for the compiler
file_put_contents($main_compiler, '#!/bin/bash' . PHP_EOL . 'COMPILER_OPTIONS="$@"' . PHP_EOL . $env_var_check . PHP_EOL . 'echo $COMPILER_OPTIONS >> ' . $mask_dir . $compiler_type . '-options-' . $compiler_name . PHP_EOL . $compiler_path . ' "$@"' . PHP_EOL);
// Make executable
chmod($main_compiler, 0755);
// The two below code chunks ensure the proper compiler is always hit
if ($test_install_request instanceof pts_test_install_request && !in_array($compiler_name, pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names'])) && getenv($compiler_type) == false) {
// So if e.g. clang becomes the default compiler, since it's not GCC, it will ensure CC is also set to clang beyond the masking below
$test_install_request->special_environment_vars[$compiler_type] = $compiler_name;
}
// Just in case any test profile script is statically always calling 'gcc' or anything not CC, try to make sure it hits one of the safeguard-names so it redirects to the intended compiler under test
foreach (pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names']) as $safe_name) {
if (!is_file($mask_dir . $safe_name)) {
symlink($main_compiler, $mask_dir . $safe_name);
}
}
}
if ($test_install_request instanceof pts_test_install_request) {
$test_install_request->compiler_mask_dir = $mask_dir;
// Appending the rest of the path will be done automatically within call_test_script
$test_install_request->special_environment_vars['PATH'] = $mask_dir;
}
return $mask_dir;
}
return false;
}
示例2: create_temporary_directory
public static function create_temporary_directory($prefix = null)
{
$tmpdir = pts_client::temporary_directory();
do {
$randname = '/pts-' . $prefix . rand(0, 9999);
} while (is_dir($tmpdir . $randname));
mkdir($tmpdir . $randname);
return $tmpdir . $randname . '/';
}
示例3: call_test_runs
public function call_test_runs()
{
// Create a lock
$lock_path = pts_client::temporary_directory() . '/phoronix-test-suite.active';
pts_client::create_lock($lock_path);
if ($this->pre_run_message != null) {
pts_client::$display->display_interrupt_message($this->pre_run_message);
}
// Hook into the module framework
self::$test_run_process_active = true;
pts_module_manager::module_process('__pre_run_process', $this);
pts_file_io::unlink(PTS_USER_PATH . 'halt-testing');
pts_file_io::unlink(PTS_USER_PATH . 'skip-test');
$continue_test_flag = true;
$tests_to_run_count = $this->get_test_count();
pts_client::$display->test_run_process_start($this);
$total_loop_count = ($t = pts_client::read_env('TOTAL_LOOP_COUNT')) && is_numeric($t) && $t > 0 ? $t : 1;
$total_loop_time = ($t = pts_client::read_env('TOTAL_LOOP_TIME')) && is_numeric($t) && $t > 9 ? $t * 60 : -1;
$loop_end_time = $total_loop_time != -1 ? time() + $total_loop_time : false;
$this->test_run_count = $tests_to_run_count * $total_loop_count;
for ($loop = 1; $loop <= $total_loop_count && $continue_test_flag; $loop++) {
for ($i = 0; $i < $tests_to_run_count && $continue_test_flag; $i++) {
$this->test_run_pos = $i;
$continue_test_flag = $this->process_test_run_request($i);
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/RemoveTestInstallOnCompletion', 'FALSE')) {
// Remove the installed test if it's no longer needed in this run queue
$this_test_profile_identifier = $this->get_test_to_run($this->test_run_pos)->test_profile->get_identifier();
$still_in_queue = false;
for ($j = $this->test_run_pos + 1; $j < $tests_to_run_count && $still_in_queue == false; $j++) {
if ($this->get_test_to_run($j)->test_profile->get_identifier() == $this_test_profile_identifier) {
$still_in_queue = true;
}
}
if ($still_in_queue == false) {
pts_client::remove_installed_test($this->get_test_to_run($this->test_run_pos)->test_profile);
}
}
if ($loop_end_time) {
if (time() > $loop_end_time) {
$continue_test_flag = false;
} else {
if ($this->test_run_count == $i + 1) {
// There's still time remaining so increase the run count....
$this->test_run_count += $tests_to_run_count;
}
}
}
}
}
pts_file_io::unlink(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/active.xml');
foreach ($this->tests_to_run as &$run_request) {
// Remove cache shares
foreach (pts_file_io::glob($run_request->test_profile->get_install_dir() . 'cache-share-*.pt2so') as $cache_share_file) {
unlink($cache_share_file);
}
}
if ($this->post_run_message != null) {
pts_client::$display->display_interrupt_message($this->post_run_message);
}
self::$test_run_process_active = -1;
pts_module_manager::module_process('__post_run_process', $this);
pts_client::release_lock($lock_path);
// Report any tests that failed to properly run
if (pts_client::is_debug_mode() || $this->get_test_count() > 3) {
if (count($this->failed_tests_to_run) > 0) {
echo PHP_EOL . PHP_EOL . 'The following tests failed to properly run:' . PHP_EOL . PHP_EOL;
foreach ($this->failed_tests_to_run as &$run_request) {
echo "\t- " . $run_request->test_profile->get_identifier() . ($run_request->get_arguments_description() != null ? ': ' . $run_request->get_arguments_description() : null) . PHP_EOL;
}
echo PHP_EOL;
}
}
}
示例4: custom_test_support_check
public function custom_test_support_check()
{
/*
As of Phoronix Test Suite 4.4, the software will check for the presence of a 'support-check' file.
Any test profile can optionally include a support-check.sh file to check for arbitrary commands not covered by
the rest of the PTS testing architecture, e.g. to check for the presence of systemd on the target system. If
the script finds that the system is incompatible with the test, it can write a custom error message to the file
specified by the $TEST_CUSTOM_ERROR environment variable. If the $TEST_CUSTOM_ERROR target is written to, the PTS
client will abort the test installation with the specified error message.
*/
$support_check_file = $this->get_resource_dir() . 'support-check.sh';
if (PTS_IS_CLIENT && is_file($support_check_file)) {
$environment['TEST_CUSTOM_ERROR'] = pts_client::temporary_directory() . '/PTS-' . $this->get_identifier_base_name() . '-' . rand(1000, 9999);
$support_check = pts_tests::call_test_script($this, 'support-check', null, null, $environment, false);
if (is_file($environment['TEST_CUSTOM_ERROR'])) {
$support_result = pts_file_io::file_get_contents($environment['TEST_CUSTOM_ERROR']);
pts_file_io::delete($environment['TEST_CUSTOM_ERROR']);
return $support_result;
}
}
return true;
}
示例5: run
public static function run($r)
{
$render_dir = pts_client::temporary_directory() . '/pts-render-test-310815/';
if (!is_file($render_dir . 'mega-render-test.tar.bz2')) {
pts_file_io::mkdir($render_dir);
pts_network::download_file('http://linuxbenchmarking.com/misc/mega-render-test-310815.tar.bz2', $render_dir . 'mega-render-test.tar.bz2');
pts_compression::archive_extract($render_dir . 'mega-render-test.tar.bz2');
}
define('PATH_TO_EXPORTED_PHOROMATIC_DATA', $render_dir . 'mega-render-test-310815/');
error_reporting(E_ALL);
ini_set('memory_limit', '2048M');
$export_index_json = file_get_contents(PATH_TO_EXPORTED_PHOROMATIC_DATA . 'export-index.json');
$export_index_json = json_decode($export_index_json, true);
$dump_size = 0;
$start = microtime(true);
foreach (array_keys($export_index_json['phoromatic']) as $REQUESTED) {
$this_render_test = time();
$tracker =& $export_index_json['phoromatic'][$REQUESTED];
$triggers = $tracker['triggers'];
echo PHP_EOL . 'STARTING RENDER TEST ON: ' . $REQUESTED . ' (' . count($triggers) . ' Triggers)' . PHP_EOL;
$length = count($tracker['triggers']);
$result_files = array();
foreach ($triggers as $trigger) {
$results_for_trigger = glob(PATH_TO_EXPORTED_PHOROMATIC_DATA . '/' . $REQUESTED . '/' . $trigger . '/*/composite.xml');
echo '.';
if ($results_for_trigger == false) {
continue;
}
foreach ($results_for_trigger as $composite_xml) {
// Add to result file
$system_name = basename(dirname($composite_xml)) . ': ' . $trigger;
array_push($result_files, new pts_result_merge_select($composite_xml, null, $system_name));
}
}
echo 'STARTING MERGE; ';
$result_file = new pts_result_file(null, true);
$result_file->merge($result_files);
echo 'MAKING NEW RESULT FILE; ';
$extra_attributes = array('reverse_result_buffer' => true, 'force_simple_keys' => true, 'force_line_graph_compact' => true, 'force_tracking_line_graph' => true);
//$extra_attributes['normalize_result_buffer'] = true;
$intent = null;
//$table = new pts_ResultFileTable($result_file, $intent);
//echo '<p style="text-align: center; overflow: auto;" class="result_object">' . pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes) . '</p>';
echo 'STARTING RESULT LOOP; ';
$html_dump = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>';
foreach ($result_file->get_result_objects(isset($_POST['show_only_changed_results']) ? 'ONLY_CHANGED_RESULTS' : -1) as $i => $result_object) {
echo $result_object->test_profile->get_title() . ' ';
$html_dump .= '<h3>' . $result_object->get_arguments_description() . '</h3>';
$html_dump .= pts_render::render_graph_inline_embed($result_object, $result_file, $extra_attributes);
unset($result_object);
}
$table = new pts_ResultFileSystemsTable($result_file);
$html_dump .= pts_render::render_graph_inline_embed($table, $result_file, $extra_attributes);
echo PHP_EOL . PHP_EOL . 'RENDER TEST ON: ' . $REQUESTED . ' TOOK ' . (time() - $this_render_test) . PHP_EOL;
$dump_size += strlen($html_dump);
file_put_contents(PATH_TO_EXPORTED_PHOROMATIC_DATA . $REQUESTED . '.html', $html_dump . '</body></html>');
}
echo PHP_EOL . 'RENDER TEST TOOK: ' . (time() - $start) . PHP_EOL . PHP_EOL;
echo PHP_EOL . 'PEAK MEMORY USAGE: ' . round(memory_get_peak_usage(true) / 1048576, 3) . ' MB';
echo PHP_EOL . 'PEAK MEMORY USAGE (emalloc): ' . round(memory_get_peak_usage() / 1048576, 3) . ' MB';
echo PHP_EOL . 'TOTAL FILE SIZE: ' . ceil($dump_size / 1000) . ' KB';
echo PHP_EOL;
}