本文整理汇总了PHP中pts_client::do_anonymous_usage_reporting方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::do_anonymous_usage_reporting方法的具体用法?PHP pts_client::do_anonymous_usage_reporting怎么用?PHP pts_client::do_anonymous_usage_reporting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::do_anonymous_usage_reporting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_test_process
protected static function install_test_process(&$test_install_request, $no_prompts)
{
// Install a test
$identifier = $test_install_request->test_profile->get_identifier();
$test_install_directory = $test_install_request->test_profile->get_install_dir();
pts_file_io::mkdir(dirname($test_install_directory));
pts_file_io::mkdir($test_install_directory);
$installed = false;
if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_download_size() + 128) {
self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for the test files.');
} else {
if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_environment_size(false) + 128) {
self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for this test.');
} else {
pts_test_installer::setup_test_install_directory($test_install_request, true);
// Download test files
$download_test_files = pts_test_installer::download_test_files($test_install_request, false, $no_prompts);
if ($download_test_files == false) {
self::test_install_error(null, $test_install_request, 'Downloading of needed test files failed.');
return false;
}
if ($test_install_request->test_profile->get_file_installer() != false) {
self::create_compiler_mask($test_install_request);
pts_module_manager::module_process('__pre_test_install', $identifier);
pts_client::$display->test_install_begin($test_install_request);
$pre_install_message = $test_install_request->test_profile->get_pre_install_message();
$post_install_message = $test_install_request->test_profile->get_post_install_message();
$install_agreement = $test_install_request->test_profile->get_installation_agreement_message();
if (!empty($install_agreement)) {
if (pts_strings::is_url($install_agreement)) {
$install_agreement = pts_network::http_get_contents($install_agreement);
if (empty($install_agreement)) {
self::test_install_error(null, $test_install_request, 'The user agreement could not be found. Test installation aborted.');
return false;
}
}
echo $install_agreement . PHP_EOL;
if (!$no_prompts) {
$user_agrees = pts_user_io::prompt_bool_input('Do you agree to these terms', false, 'INSTALL_AGREEMENT');
if (!$user_agrees) {
self::test_install_error(null, $test_install_request, 'User agreement failed; this test will not be installed.');
return false;
}
}
}
pts_client::$display->display_interrupt_message($pre_install_message);
$install_time_length_start = microtime(true);
$install_log = pts_tests::call_test_script($test_install_request->test_profile, 'install', null, $test_install_directory, $test_install_request->special_environment_vars, false);
$test_install_request->install_time_duration = ceil(microtime(true) - $install_time_length_start);
pts_client::$display->display_interrupt_message($post_install_message);
if (!empty($install_log)) {
file_put_contents($test_install_directory . 'install.log', $install_log);
pts_file_io::unlink($test_install_directory . 'install-failed.log');
pts_client::$display->test_install_output($install_log);
}
if (is_file($test_install_directory . 'install-exit-status')) {
// If the installer writes its exit status to ~/install-exit-status, if it's non-zero the install failed
$install_exit_status = pts_file_io::file_get_contents($test_install_directory . 'install-exit-status');
unlink($test_install_directory . 'install-exit-status');
if ($install_exit_status != 0 && phodevi::is_windows() == false) {
$install_error = null;
// TODO: perhaps better way to handle this than to remove pts-install.xml
pts_file_io::unlink($test_install_directory . 'pts-install.xml');
if (is_file($test_install_directory . 'install.log')) {
$install_log = pts_file_io::file_get_contents($test_install_directory . 'install.log');
$install_error = pts_tests::scan_for_error($install_log, $test_install_directory);
copy($test_install_directory . 'install.log', $test_install_directory . 'install-failed.log');
}
//pts_test_installer::setup_test_install_directory($test_install_request, true); // Remove installed files from the bunked installation
self::test_install_error(null, $test_install_request, 'The installer exited with a non-zero exit status.');
if ($install_error != null) {
$test_install_request->install_error = pts_tests::pretty_error_string($install_error);
if ($test_install_request->install_error != null) {
self::test_install_error(null, $test_install_request, 'ERROR: ' . $test_install_request->install_error);
}
}
pts_client::$display->test_install_error('LOG: ' . str_replace(pts_core::user_home_directory(), '~/', $test_install_directory) . 'install-failed.log' . PHP_EOL);
if (pts_client::do_anonymous_usage_reporting()) {
// If anonymous usage reporting enabled, report test install failure to OpenBenchmarking.org
pts_openbenchmarking_client::upload_usage_data('test_install_failure', array($test_install_request, $install_error));
}
return false;
}
}
pts_module_manager::module_process('__post_test_install', $identifier);
$installed = true;
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', 'FALSE')) {
// Remove original downloaded files
foreach ($test_install_request->get_download_objects() as $download_object) {
pts_file_io::unlink($test_install_directory . $download_object->get_filename());
}
}
} else {
pts_client::$display->test_install_error('No installation script found.');
$installed = true;
}
// Additional validation checks?
$custom_validated_output = pts_tests::call_test_script($test_install_request->test_profile, 'validate-install', PHP_EOL . 'Validating Installation...' . PHP_EOL, $test_install_directory, null, false);
if (!empty($custom_validated_output) && !pts_strings::string_bool($custom_validated_output)) {
$installed = false;
//.........这里部分代码省略.........
示例2: run_test
//.........这里部分代码省略.........
// The test ended too quickly, results are not valid
self::test_run_error($test_run_manager, $test_run_request, 'This test ended prematurely.');
return false;
}
}
if (!empty($max_length)) {
if ($max_length < $time_test_elapsed_actual) {
// The test took too much time, results are not valid
self::test_run_error($test_run_manager, $test_run_request, 'This test run was exhausted.');
return false;
}
}
if ($allow_cache_share && !is_file($cache_share_pt2so) && $cache_share instanceof pts_storage_object) {
$cache_share->save_to_file($cache_share_pt2so);
unset($cache_share);
}
if ($test_run_manager->get_results_identifier() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveInstallationLogs', 'FALSE')) {
if (is_file($test_run_request->test_profile->get_install_dir() . 'install.log')) {
$backup_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/installation-logs/' . $test_run_manager->get_results_identifier() . '/';
pts_file_io::mkdir($backup_log_dir, 0777, true);
copy($test_run_request->test_profile->get_install_dir() . 'install.log', $backup_log_dir . basename($test_identifier) . '.log');
}
}
// Fill in missing test details
if (empty($arguments_description)) {
$arguments_description = $test_run_request->test_profile->get_test_subtitle();
}
$file_var_checks = array(array('pts-results-scale', 'set_result_scale', null), array('pts-results-proportion', 'set_result_proportion', null), array('pts-results-quantifier', 'set_result_quantifier', null), array('pts-test-version', 'set_version', null), array('pts-test-description', null, 'set_used_arguments_description'), array('pts-footnote', null, null));
foreach ($file_var_checks as &$file_check) {
list($file, $set_function, $result_set_function) = $file_check;
if (is_file($test_directory . $file)) {
$file_contents = pts_file_io::file_get_contents($test_directory . $file);
unlink($test_directory . $file);
if (!empty($file_contents)) {
if ($set_function != null) {
call_user_func(array($test_run_request->test_profile, $set_function), $file_contents);
} else {
if ($result_set_function != null) {
if ($result_set_function == 'set_used_arguments_description') {
$arguments_description = $file_contents;
} else {
call_user_func(array($test_run_request, $result_set_function), $file_contents);
}
} else {
if ($file == 'pts-footnote') {
$test_run_request->test_profile->test_installation->set_install_footnote($file_contents);
}
}
}
}
}
}
if (empty($arguments_description)) {
$arguments_description = 'Phoronix Test Suite v' . PTS_VERSION;
}
foreach (pts_client::environmental_variables() as $key => $value) {
$arguments_description = str_replace('$' . $key, $value, $arguments_description);
if (!in_array($key, array('VIDEO_MEMORY', 'NUM_CPU_CORES', 'NUM_CPU_JOBS'))) {
$extra_arguments = str_replace('$' . $key, $value, $extra_arguments);
}
}
// Any device notes to add to PTS test notes area?
foreach (phodevi::read_device_notes($test_type) as $note) {
pts_test_notes_manager::add_note($note);
}
// As of PTS 4.4, this is removed and superceded effectively by reporting the notes to table
// Any special information (such as forced AA/AF levels for graphics) to add to the description string of the result?
/*
if(($special_string = phodevi::read_special_settings_string($test_type)) != null)
{
if(strpos($arguments_description, $special_string) === false)
{
if($arguments_description != null)
{
$arguments_description .= ' | ';
}
$arguments_description .= $special_string;
}
}
*/
// Result Calculation
$test_run_request->set_used_arguments_description($arguments_description);
$test_run_request->set_used_arguments($extra_arguments);
pts_test_result_parser::calculate_end_result($test_run_request, $active_result_buffer);
// Process results
pts_client::$display->test_run_end($test_run_request);
pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_post_run_message());
pts_module_manager::module_process('__post_test_run', $test_run_request);
$report_elapsed_time = $cache_share_present == false && $test_run_request->active->get_result() != 0;
pts_tests::update_test_install_xml($test_run_request->test_profile, $report_elapsed_time ? $time_test_elapsed : 0);
pts_storage_object::add_in_file(PTS_CORE_STORAGE, 'total_testing_time', $time_test_elapsed / 60);
if ($report_elapsed_time && pts_client::do_anonymous_usage_reporting() && $time_test_elapsed >= 60) {
// If anonymous usage reporting enabled, report test run-time to OpenBenchmarking.org
pts_openbenchmarking_client::upload_usage_data('test_complete', array($test_run_request, $time_test_elapsed));
}
// Remove lock
pts_client::release_lock($lock_file);
return $active_result_buffer;
}