本文整理汇总了PHP中pts_file_io::file_get_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_file_io::file_get_contents方法的具体用法?PHP pts_file_io::file_get_contents怎么用?PHP pts_file_io::file_get_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_file_io
的用法示例。
在下文中一共展示了pts_file_io::file_get_contents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read_sensor
public static function read_sensor()
{
// Reads the system's temperature
$temp_c = -1;
if (phodevi::is_linux()) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp3_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp2_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp1_input', 'POSITIVE_NUMERIC');
}
if ($raw_temp != -1) {
if ($raw_temp > 1000) {
$raw_temp = $raw_temp / 1000;
}
$temp_c = pts_math::set_precision($raw_temp, 2);
}
if ($temp_c == -1) {
$acpi = phodevi_linux_parser::read_acpi(array('/thermal_zone/THM1/temperature', '/thermal_zone/TZ00/temperature', '/thermal_zone/TZ01/temperature'), 'temperature');
if (($end = strpos($acpi, ' ')) > 0) {
$temp_c = substr($acpi, 0, $end);
}
}
if ($temp_c == -1) {
$sensors = phodevi_linux_parser::read_sensors(array('Sys Temp', 'Board Temp'));
if ($sensors != false && is_numeric($sensors)) {
$temp_c = $sensors;
}
}
if ($temp_c == -1 && is_file('/sys/class/thermal/thermal_zone0/temp')) {
$temp_c = pts_file_io::file_get_contents('/sys/class/thermal/thermal_zone0/temp');
if ($temp_c > 1000) {
$temp_c = pts_math::set_precision($temp_c / 1000, 1);
}
}
} else {
if (phodevi::is_bsd()) {
$acpi = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz1.temp0', 'hw.acpi.thermal.tz1.temperature'));
if (($end = strpos($acpi, ' degC')) > 0 || ($end = strpos($acpi, 'C')) > 0) {
$acpi = substr($acpi, 0, $end);
if (is_numeric($acpi)) {
$temp_c = $acpi;
}
}
}
}
return $temp_c;
}
示例2: get_supported_devices
public static function get_supported_devices()
{
if (phodevi::is_linux()) {
$blockdev_dir = '/sys/block/';
$glob_regex = '{[shvm]d*,nvme*,mmcblk*}';
$disk_array = pts_file_io::glob($blockdev_dir . $glob_regex, GLOB_BRACE);
$supported = array();
foreach ($disk_array as $check_disk) {
$stat_path = $check_disk . '/stat';
if (is_file($stat_path) && pts_file_io::file_get_contents($stat_path) != null) {
array_push($supported, basename($check_disk));
}
}
return $supported;
}
return NULL;
}
示例3: read_sensor
public static function read_sensor()
{
$iowait = -1;
if (phodevi::is_linux() && is_file('/proc/stat')) {
$start_stat = pts_file_io::file_get_contents('/proc/stat');
sleep(1);
$end_stat = pts_file_io::file_get_contents('/proc/stat');
$start_stat = explode(' ', substr($start_stat, 0, strpos($start_stat, "\n")));
$end_stat = explode(' ', substr($end_stat, 0, strpos($end_stat, "\n")));
for ($i = 2, $diff_cpu_total = 0; $i < 9; $i++) {
$diff_cpu_total += $end_stat[$i] - $start_stat[$i];
}
$diff_iowait = $end_stat[6] - $start_stat[6];
$iowait = pts_math::set_precision(1000 * $diff_iowait / $diff_cpu_total / 10, 2);
}
return $iowait;
}
示例4: get_supported_devices
public static function get_supported_devices()
{
if (phodevi::is_linux()) {
$disk_list = shell_exec("ls -1 /sys/class/block | grep '^[shv]d[a-z]\$'");
// TODO make this native PHP
$disk_array = explode("\n", $disk_list);
$supported = array();
foreach ($disk_array as $check_disk) {
$stat_path = '/sys/class/block/' . $check_disk . '/stat';
if (is_file($stat_path) && pts_file_io::file_get_contents($stat_path) != null) {
array_push($supported, $check_disk);
}
}
return $supported;
}
return NULL;
}
示例5: audio_processor_string
public static function audio_processor_string()
{
$audio = null;
if (phodevi::is_macosx()) {
// TODO: implement
} else {
if (phodevi::is_bsd()) {
foreach (array('dev.hdac.0.%desc') as $dev) {
$dev = phodevi_bsd_parser::read_sysctl($dev);
if (!empty($dev)) {
$audio = $dev;
}
}
} else {
if (phodevi::is_windows()) {
// TODO: implement
} else {
if (phodevi::is_linux()) {
foreach (pts_file_io::glob('/sys/class/sound/card*/hwC0D*/vendor_name') as $vendor_name) {
$card_dir = dirname($vendor_name) . '/';
if (!is_readable($card_dir . 'chip_name')) {
continue;
}
$vendor_name = pts_file_io::file_get_contents($vendor_name);
$chip_name = pts_file_io::file_get_contents($card_dir . 'chip_name');
$audio = $vendor_name . ' ' . $chip_name;
if (strpos($chip_name, 'HDMI') !== false || strpos($chip_name, 'DP') !== false) {
// If HDMI is in the audio string, likely the GPU-provided audio, so try to find the mainboard otherwise
$audio = null;
} else {
break;
}
}
if ($audio == null) {
$audio = phodevi_linux_parser::read_pci('Multimedia audio controller');
}
if ($audio == null) {
$audio = phodevi_linux_parser::read_pci('Audio device');
}
}
}
}
}
return $audio;
}
示例6: read_sensor
public static function read_sensor()
{
// speed in MB/s
$speed = -1;
if (phodevi::is_linux()) {
static $sys_disk = null;
if ($sys_disk == null) {
foreach (pts_file_io::glob('/sys/class/block/sd*/stat') as $check_disk) {
if (pts_file_io::file_get_contents($check_disk) != null) {
$sys_disk = $check_disk;
break;
}
}
}
$speed = phodevi_linux_parser::read_sys_disk_speed($sys_disk, 'READ');
}
return $speed;
}
示例7: read_sensor
public static function read_sensor()
{
// Determine the current processor frequency
$cpu_core = 0;
// TODO: for now just monitoring the first core
$info = 0;
if (phodevi::is_linux()) {
// First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current
if (is_file('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_cur_freq')) {
$info = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_cur_freq');
$info = intval($info) / 1000;
} else {
if (is_file('/proc/cpuinfo')) {
$cpu_speeds = phodevi_linux_parser::read_cpuinfo('cpu MHz');
if (isset($cpu_speeds[0])) {
$cpu_core = isset($cpu_speeds[$cpu_core]) ? $cpu_core : 0;
$info = intval($cpu_speeds[$cpu_core]);
}
}
}
} else {
if (phodevi::is_solaris()) {
$info = shell_exec('psrinfo -v | grep MHz');
$info = substr($info, strrpos($info, 'at') + 3);
$info = trim(substr($info, 0, strpos($info, 'MHz')));
} else {
if (phodevi::is_bsd()) {
$info = phodevi_bsd_parser::read_sysctl('dev.cpu.0.freq');
} else {
if (phodevi::is_macosx()) {
$info = phodevi_osx_parser::read_osx_system_profiler('SPHardwareDataType', 'ProcessorSpeed');
if (($cut_point = strpos($info, ' ')) > 0) {
$info = substr($info, 0, $cut_point);
$info = str_replace(',', '.', $info);
}
if ($info < 100) {
$info *= 1000;
}
}
}
}
}
return pts_math::set_precision($info, 2);
}
示例8: read_sensor
public static function read_sensor()
{
// Report graphics processor temperature
$temp_c = -1;
if (phodevi::is_nvidia_graphics()) {
$temp_c = phodevi_parser::read_nvidia_extension('GPUCoreTemp');
} else {
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$temp_c = phodevi_linux_parser::read_ati_overdrive('Temperature');
} else {
foreach (array_merge(array('/sys/class/drm/card0/device/temp1_input'), pts_file_io::glob('/sys/class/drm/card0/device/hwmon/hwmon*/temp1_input')) as $temp_input) {
// This works for at least Nouveau driver with Linux 2.6.37 era DRM
if (is_readable($temp_input) == false) {
continue;
}
$temp_input = pts_file_io::file_get_contents($temp_input);
if (is_numeric($temp_input)) {
if ($temp_input > 1000) {
$temp_input /= 1000;
}
$temp_c = $temp_input;
break;
}
}
if ($temp_c == -1 && is_readable('/sys/kernel/debug/dri/0/i915_emon_status')) {
// Intel thermal
$i915_emon_status = file_get_contents('/sys/kernel/debug/dri/0/i915_emon_status');
$temp = strpos($i915_emon_status, 'GMCH temp: ');
if ($temp !== false) {
$temp = substr($i915_emon_status, $temp + 11);
$temp = substr($temp, 0, strpos($temp, PHP_EOL));
if (is_numeric($temp) && $temp > 0) {
$temp_c = $temp;
}
}
}
}
}
if ($temp_c > 1000 || $temp_c < 9) {
// Invalid data
return -1;
}
return $temp_c;
}
示例9: cpu_freq_linux
private function cpu_freq_linux()
{
$frequency = -1;
// First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current frequency.
if (is_file('/sys/devices/system/cpu/' . $this->cpu_to_monitor . '/cpufreq/scaling_cur_freq')) {
$frequency = pts_file_io::file_get_contents('/sys/devices/system/cpu/' . $this->cpu_to_monitor . '/cpufreq/scaling_cur_freq');
$frequency = intval($frequency) / 1000;
} else {
if (is_file('/proc/cpuinfo')) {
$cpu_speeds = phodevi_linux_parser::read_cpuinfo('cpu MHz');
$cpu_number = intval(substr($this->cpu_to_monitor, 3));
//cut 'cpu' from the beginning
if (!isset($cpu_speeds[$cpu_number])) {
return -1;
}
$frequency = intval($cpu_speeds[$cpu_number]);
}
}
return $frequency;
}
示例10: sys_temp_linux
private function sys_temp_linux()
{
$temp_c = -1;
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp3_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp2_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp1_input', 'POSITIVE_NUMERIC');
}
if ($raw_temp != -1) {
if ($raw_temp > 1000) {
$raw_temp = $raw_temp / 1000;
}
$temp_c = pts_math::set_precision($raw_temp, 2);
}
if ($temp_c == -1) {
$acpi = phodevi_linux_parser::read_acpi(array('/thermal_zone/THM1/temperature', '/thermal_zone/TZ00/temperature', '/thermal_zone/TZ01/temperature'), 'temperature');
if (($end = strpos($acpi, ' ')) > 0) {
$temp_c = substr($acpi, 0, $end);
}
}
if ($temp_c == -1) {
$sensors = phodevi_linux_parser::read_sensors(array('Sys Temp', 'Board Temp'));
if ($sensors != false && is_numeric($sensors)) {
$temp_c = $sensors;
}
}
if ($temp_c == -1 && is_file('/sys/class/thermal/thermal_zone0/temp')) {
$temp_c = pts_file_io::file_get_contents('/sys/class/thermal/thermal_zone0/temp');
if ($temp_c > 1000) {
$temp_c = pts_math::set_precision($temp_c / 1000, 1);
}
}
return $temp_c;
}
示例11: parse_equal_delimited_file
public static function parse_equal_delimited_file($file, $key)
{
$return_value = false;
foreach (explode("\n", pts_file_io::file_get_contents($file)) as $build_line) {
list($descriptor, $value) = pts_strings::trim_explode('=', $build_line);
if ($descriptor == $key) {
$return_value = $value;
break;
}
}
return $return_value;
}
示例12: 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;
}
示例13: cpu_default_frequency
public static function cpu_default_frequency($cpu_core = 0)
{
// Find out the processor frequency
$info = null;
// First, the ideal way, with modern CPUs using CnQ or EIST and cpuinfo reporting the current
if (is_file('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq')) {
$info = pts_file_io::file_get_contents('/sys/devices/system/cpu/cpu' . $cpu_core . '/cpufreq/scaling_max_freq');
$info = intval($info) / 1000000;
if ($info > 9) {
// For some reason on Linux 3.10 the scaling_max_freq is reported as 25GHz...
$info = null;
}
}
if ($info == null && isset(phodevi::$vfs->cpuinfo)) {
$cpu_mhz = self::read_cpuinfo_line('cpu MHz');
$info = $cpu_mhz / 1000;
if (empty($info)) {
$cpu_mhz = self::read_cpuinfo_line('clock');
$info = $cpu_mhz / 1000;
}
} else {
if ($info == null && phodevi::is_bsd()) {
$info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq_levels'));
if ($info != null) {
// Popping the top speed off of dev.cpu.0.freq_levels should be the default/highest supported frequency
$info = pts_arrays::first_element(explode(' ', str_replace('/', ' ', $info)));
if (!is_numeric($info)) {
$info = null;
}
}
if ($info == null) {
$info = phodevi_bsd_parser::read_sysctl(array('hw.acpi.cpu.px_global', 'machdep.est.frequency.target', 'hw.cpuspeed'));
}
if ($info == null) {
// dev.cpu.0.freq seems to be the real/current frequency, affected by power management, etc so only use as last fallback
$info = phodevi_bsd_parser::read_sysctl(array('dev.cpu.0.freq'));
}
if (is_numeric($info)) {
$info = $info / 1000;
} else {
$info = null;
}
} else {
if ($info == null && phodevi::is_windows()) {
$info = phodevi_windows_parser::read_cpuz('Processor 1', 'Stock frequency');
if ($info != null) {
if (($e = strpos($info, ' MHz')) !== false) {
$info = substr($info, 0, $e);
}
$info = $info / 1000;
}
} else {
if ($info == null) {
$info = phodevi::read_sensor(array('cpu', 'freq'));
if ($info > 1000) {
// Convert from MHz to GHz
$info = $info / 1000;
}
}
}
}
}
return pts_math::set_precision($info, 2);
}
示例14: render_page_process
public static function render_page_process($PATH)
{
echo phoromatic_webui_header_logged_in();
$main = '<h1>Settings</h1>
<h2>User Settings</h2>
<p>User settings are specific to your particular account, in cases where there are multiple individuals/accounts managing the same test systems and data.</p>
';
$stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_user_settings WHERE AccountID = :account_id AND UserID = :user_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':user_id', $_SESSION['UserID']);
$result = $stmt->execute();
$row = $result->fetchArray();
$user_settings = array('Email' => array('NotifyOnResultUploads' => 'Send notification when test results are uploaded to Phoromatic.', 'NotifyOnWarnings' => 'Send notification when any warnings are generated on a test system.', 'NotifyOnNewSystems' => 'Send notification when new test systems are added.', 'NotifyOnHungSystems' => 'Send notification when system(s) appear hung.'));
$main .= '<form name="system_form" id="system_form" action="?settings" method="post">';
foreach ($user_settings as $section => $section_settings) {
$main .= '<h3>' . $section . '</h3><p>';
foreach ($section_settings as $key => $setting) {
if (isset($_POST['user_settings_update'])) {
if (isset($_POST[$key]) && $_POST[$key] == 'yes') {
$row[$key] = 1;
} else {
$row[$key] = 0;
}
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_user_settings SET ' . $key . ' = :val WHERE AccountID = :account_id AND UserID = :user_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':user_id', $_SESSION['UserID']);
$stmt->bindValue(':val', $row[$key]);
$stmt->execute();
//echo phoromatic_server::$db->lastErrorMsg();
}
$main .= '<input type="checkbox" name="' . $key . '" ' . (isset($row[$key]) && $row[$key] == 1 ? 'checked="checked" ' : '') . 'value="yes" /> ' . $setting . '<br />';
}
$main .= '</p>';
}
$main .= '<p><input type="hidden" value="1" name="user_settings_update" /><input type="submit" value="Save User Settings" /></p>';
$main .= '</form>';
if (!PHOROMATIC_USER_IS_VIEWER) {
$main .= '<hr />
<h2>Account Settings</h2>
<p>Account settings are system-wide, in cases where there are multiple individuals/accounts managing the same test systems and data.</p>';
$stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_account_settings WHERE AccountID = :account_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$result = $stmt->execute();
$row = $result->fetchArray();
$account_settings = array('Global Settings' => array('ArchiveResultsLocally' => 'Archive test results on local test systems after the results have been uploaded.', 'UploadSystemLogs' => 'Upload system logs when uploading test results.', 'RunInstallCommand' => 'For all test schedules, always run the install command for test(s) prior to running them on the system.', 'ForceInstallTests' => 'For all test schedules, force the test installation/re-installation of tests each time prior to running the test.', 'SystemSensorMonitoring' => 'Enable the system sensor monitoring while tests are taking place.', 'UploadResultsToOpenBenchmarking' => 'For all test schedules, also upload test results to OpenBenchmarking.org.', 'PowerOffWhenDone' => 'Power off system(s) when scheduled tests are completed for the day.', 'PreSeedTestInstalls' => 'Attempt to pre-install commonly used tests on client systems while idling.', 'NetworkPowerUpWhenNeeded' => 'Use network Wake-On-LAN to power on systems when needed.', 'LetOtherGroupsViewResults' => 'Let other accounts/groups on this Phoromatic Server view (read-only) this account\'s results.', 'LetPublicViewResults' => 'Allow public/unauthenticated visitors to access these test results from the public viewer page.', 'PowerOnSystemDaily' => 'Attempt to power-on systems daily (unless there\'s a daily test schedule / trigger on the system) to maintain the DHCP lease on the network, update any software/hardware information, etc. When the daily update is done, the system will power off unless there\'s a test to run and the power-off setting above is enabled. This option is namely useful for systems that otherwise may be idling/powered-off for long periods of time between tests.', 'AutoApproveNewSystems' => 'Enabling this option will make new test systems immediately available for this account rather than the default behavior of first needing an administrator to approve/deny the system via the Phoromatic Server web interface. With this option enabled, the systems are automatically approved by default but can be later disabled/removed via the Phoromatic web interface.'));
$main .= '<form name="system_form" id="system_form" action="?settings" method="post">';
$settings_updated = false;
foreach ($account_settings as $section => $section_settings) {
$main .= '<h3>' . $section . '</h3><p>';
foreach ($section_settings as $key => $setting) {
if (isset($_POST['account_settings_update'])) {
if (isset($_POST[$key]) && $_POST[$key] == 'yes') {
$row[$key] = 1;
} else {
$row[$key] = 0;
}
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_account_settings SET ' . $key . ' = :val WHERE AccountID = :account_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':val', $row[$key]);
$stmt->execute();
if ($settings_updated == false) {
phoromatic_add_activity_stream_event('settings', null, 'modified');
$settings_updated = true;
}
//echo phoromatic_server::$db->lastErrorMsg();
}
$main .= '<input type="checkbox" name="' . $key . '" ' . (isset($row[$key]) && $row[$key] === 1 ? 'checked="checked" ' : '') . 'value="yes" /> ' . $setting . '<br />';
}
$main .= '</p>';
}
$main .= '<p><input type="hidden" value="1" name="account_settings_update" /><input type="submit" value="Save Account Settings" /></p>';
$main .= '</form>';
}
$main .= '<hr />
<h2>Cache Settings</h2>
<p>Proceed to the <a href="?caches">download cache page</a> for information about the Phoromatic Server\'s download caches.</p>';
$main .= '<hr />
<h2>User Password</h2>
<p>Proceed to the <a href="?password">password page</a> if you wish to update your account\'s password.</p>';
if (!PHOROMATIC_USER_IS_VIEWER) {
$main .= '<hr />
<h2>Build A Suite</h2>
<p><a href="?build_suite">Create a custom test suite</a>.</p>';
$update_script_path = phoromatic_server::phoromatic_account_path($_SESSION['AccountID']) . 'client-update-script.sh';
if (isset($_POST['client_update_script'])) {
file_put_contents($update_script_path, str_replace("\r\n", PHP_EOL, $_POST['client_update_script']));
}
if (!is_file($update_script_path)) {
$script_contents = pts_file_io::file_get_contents(PTS_CORE_STATIC_PATH . 'sample-pts-client-update-script.sh');
} else {
$script_contents = pts_file_io::file_get_contents($update_script_path);
}
$main .= '<form name="update_client_script_form" id="update_client_script_form" action="?settings" method="post">
<hr /><h2>Auto-Updating Clients</h2><p>If desired, you can paste a script in the below field if you wish to have Phoronix Test Suite / Phoromatic clients attempt to auto-update themselves. Any commands copied below are automatically executed by the client upon completing a test / beginning a new idle process / prior to attempting a system shutdown. If your script determines the client is to be updated, it should <em>reboot</em> the system afterwards to ensure no issues in the upgrade of the Phoronix Test Suite installation. A reference/example script is provided by default. This update script feature does not attempt to update the Phoromatic Server software.</p>
<p><textarea style="width: 80%; height: 400px;" name="client_update_script" id="client_update_script">' . $script_contents . '</textarea></p>
<p><input type="submit" value="Save Client Auto-Update Script" /></p>
</form>';
}
echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
echo phoromatic_webui_footer();
//.........这里部分代码省略.........
示例15: 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) {
//.........这里部分代码省略.........