Revert "Start monitoring temperature during tests."
This reverts commit 3b4712cc3f0a77cfa7851fb73fb03fcb0c4e6318.
BUG=chromium:361453
Change-Id: Ic00ca69a285cf38c041a26a0380f38c9a715f466
Reviewed-on: https://chromium-review.googlesource.com/194181
Reviewed-by: Ilja Friedel <ihf@chromium.org>
Commit-Queue: Ilja Friedel <ihf@chromium.org>
Tested-by: Ilja Friedel <ihf@chromium.org>
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index d734e90..9f0a9f2 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -471,7 +471,7 @@
cpu_usage_end = get_cpu_usage()
fraction_active_time = \
compute_active_cpu_time(cpu_usage_start, cpu_usage_end)
- logging.info('After waiting %.1fs CPU utilization is %.3f.',
+ logging.info('After waiting %.1fs CPU utilization is %f.',
time_passed, fraction_active_time)
if time_passed > timeout:
logging.warning('CPU did not become idle.')
@@ -482,7 +482,7 @@
return True
return False
- logging.info('Wait for idle CPU took %.1fs (utilization = %.3f).',
+ logging.info('Wait for idle CPU took %fs (utilization = %f).',
time_passed, fraction_active_time)
return True
@@ -498,319 +498,14 @@
logging.info(output)
-def wait_for_cool_machine():
- # TODO(ihf): Implement this. The concept of a cool machine is very
- # architecture specific. We either need a good heuristic or a table of
- # board specific temperatures.
- time.sleep(1.0)
+def wait_for_cool_cpu():
+ # TODO(ihf): Implement this.
return True
-# System paths for machine performance state.
-_CPUINFO = '/proc/cpuinfo'
-_CPUINFO_MAX_FREQ_FMT = '/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq'
-_CPUINFO_MIN_FREQ_FMT = '/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_min_freq'
-_KERNEL_MAX = '/sys/devices/system/cpu/kernel_max'
-_LSB_RELEASE = '/etc/lsb-release'
-_MEMINFO = '/proc/meminfo'
-_SCALING_GOVERNOR_FMT = '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor'
-_TEMP_CRIT_FMT = '/sys/class/hwmon/hwmon0/temp%d_crit'
-_TEMP_INPUT_FMT = '/sys/class/hwmon/hwmon0/temp%d_input'
-# Same temperatures for daisy_spring.
-_TEMP_CRIT_VIRT = '/sys/devices/virtual/hwmon/hwmon1/temp1_crit'
-_TEMP_INPUT_VIRT = '/sys/devices/virtual/hwmon/hwmon1/temp1_input'
-_TEMP_SENSOR_RE = 'Reading temperature...([0-9]*)'
+def wait_for_cool_idle_perf_machine():
+ # Wait for 60 seconds for the CPU usage to fall under 10%.
+ if not wait_for_idle_cpu(60, 0.1):
+ return False
+ return wait_for_cool_cpu()
-
-def _get_line_from_file(path, line):
- """
- line can be an integer or
- line can be a string that matches the beginning of the line
- """
- f = open(path)
- if (isinstance(line, int)):
- l = f.readline()
- for _ in range(0, line):
- l = f.readline()
- return l
- else:
- for l in f:
- if l.startswith(line):
- return l
- return None
-
-
-def _get_match_from_file(path, line, prefix, postfix):
- """
- Matches line in path and returns string between first prefix and postfix.
- """
- match = _get_line_from_file(path, line)
- # Strip everything from front of line including prefix.
- if prefix:
- match = re.split(prefix, match)[1]
- # Strip everything from back of string including first occurence of postfix.
- if postfix:
- match = re.split(postfix, match)[0]
- return match
-
-
-def _get_float_from_file(path, line, prefix, postfix):
- match = _get_match_from_file(path, line, prefix, postfix)
- return float(match)
-
-
-def _get_int_from_file(path, line, prefix, postfix):
- match = _get_match_from_file(path, line, prefix, postfix)
- return int(match)
-
-
-def _get_hex_from_file(path, line, prefix, postfix):
- match = _get_match_from_file(path, line, prefix, postfix)
- return int(match, 16)
-
-
-def get_temperature_critical():
- """
- Returns temperature at which we will see some throttling in the system.
- """
- min_temperature = 1000.0
- cpus = _get_number_cpus()
- for cpu in range(1, cpus + 1):
- path = _TEMP_CRIT_FMT % cpu
- #TODO(ihf): Figure out a more consistent way to obtain temperatures.
- if 'spring' in get_board():
- path = _TEMP_CRIT_VIRT
- temperature = _get_float_from_file(path, 0, None, None) * 0.001
- min_temperature = min(temperature, min_temperature)
- # Sanity check for real world values.
- assert ((min_temperature > 60.0) and
- (min_temperature < 150.0)), 'Unreasonable temperature.'
- return min_temperature
-
-
-def get_temperature_input_max():
- """
- Returns the maximum currently observed temperature.
- """
- max_temperature = -1000.0
- cpus = _get_number_cpus()
- for cpu in range(1, cpus + 1):
- path = _TEMP_INPUT_FMT % cpu
- #TODO(ihf): Figure out a more consistent way to obtain temperatures.
- if 'spring' in get_board():
- path = _TEMP_INPUT_VIRT
- temperature = _get_float_from_file(path, 0, None, None) * 0.001
- max_temperature = max(temperature, max_temperature)
- # Sanity check for real world values.
- assert ((max_temperature > 10.0) and
- (max_temperature < 150.0)), 'Unreasonable temperature.'
- return max_temperature
-
-
-def get_ec_temperatures():
- """
- Uses ectool to return a list of all sensor temperatures in Celsius.
- """
- temperatures = []
- # TODO(ihf): On my spring ectool temps all returns 200K for all sensors.
- if 'spring' in get_board():
- return temperatures
- try:
- full_cmd = 'ectool temps all'
- lines = utils.system_output(full_cmd).splitlines()
- for line in lines:
- temperature = int(line.split(': ')[1]) - 273
- temperatures.append(temperature)
- except Exception:
- logging.warn('Unable to read temperature sensors using ectool.')
- for temperature in temperatures:
- # Sanity check for real world values.
- assert ((temperature > 10.0) and
- (temperature < 150.0)), 'Unreasonable temperature.'
- return temperatures
-
-
-def get_cpu_cache_size():
- """
- Returns the last level CPU cache size in kBytes.
- """
- cache_size = _get_int_from_file(_CPUINFO, 'cache size', ': ', ' KB')
- # Sanity check.
- assert cache_size >= 64, 'Unreasonably small cache.'
- return cache_size
-
-
-def get_cpu_model_frequency():
- """
- Returns the model frequency from the CPU model name on Intel only. This
- might be redundant with get_cpu_max_frequency. Unit is Hz.
- """
- frequency = _get_float_from_file(_CPUINFO, 'model name', ' @ ', 'GHz')
- return 1.e9 * frequency
-
-
-def get_cpu_max_frequency():
- """
- Returns the largest of the max CPU core frequencies. The unit is Hz.
- """
- max_frequency = -1
- cpus = _get_number_cpus()
- for cpu in range(1, cpus + 1):
- path = _CPUINFO_MAX_FREQ_FMT % (cpu + 1)
- # Convert from kHz to Hz.
- frequency = 1000 * _get_float_from_file(path, 0, None, None)
- max_frequency = max(frequency, max_frequency)
- # Sanity check.
- assert max_frequency > 1e8, 'Unreasonably low CPU frequency.'
- return max_frequency
-
-
-def get_cpu_min_frequency():
- """
- Returns the smallest of the minimum CPU core frequencies.
- """
- min_frequency = 1e20
- cpus = _get_number_cpus()
- for cpu in range(1, cpus + 1):
- path = _CPUINFO_MIN_FREQ_FMT % cpu
- frequency = _get_float_from_file(path, 0, None, None)
- min_frequency = min(frequency, min_frequency)
- # Sanity check.
- assert min_frequency > 1e8, 'Unreasonably low CPU frequency.'
- return min_frequency
-
-
-def get_cpu_model():
- """
- Returns the CPU model.
- Only works on Intel.
- """
- cpu_model = _get_int_from_file(_CPUINFO, 'model\t', ': ', None)
- return cpu_model
-
-
-def get_cpu_family():
- """
- Returns the CPU family.
- Only works on Intel.
- """
- cpu_family = _get_int_from_file(_CPUINFO, 'cpu family\t', ': ', None)
- return cpu_family
-
-
-def get_board():
- """
- Get the ChromeOS release board name from /etc/lsb-release.
- """
- f = open('/etc/lsb-release')
- try:
- return re.search('BOARD=(.*)', f.read()).group(1)
- finally:
- f.close()
-
-
-def get_board_with_frequency_and_memory():
- """
- Returns a board name modified with CPU frequency and memory size to
- differentiate between different board variants. For instance
- link -> link_1.8GHz_4GB.
- """
- board_name = get_board()
- # Rounded to nearest GB and GHz.
- memory = int(round(get_mem_total()/1024.0))
- # Convert frequency to GHz with 1 digit accuracy after the decimal point.
- frequency = int(round(get_cpu_max_frequency() * 1e-8)) * 0.1
- board = "%s_%1.1fGHz_%dGB" % (board_name, frequency, memory)
- return board
-
-
-def get_mem_total():
- """
- Returns the total memory available in the system in MBytes.
- """
- mem_total = _get_float_from_file(_MEMINFO, 'MemTotal:', 'MemTotal:', ' kB')
- # Sanity check, all Chromebooks have at least 1GB of memory.
- assert mem_total > 1024*1024, 'Unreasonable amount of memory.'
- return mem_total / 1024
-
-
-def get_mem_free():
- """
- Returns the currently free memory in the system in MBytes.
- """
- mem_free = _get_float_from_file(_MEMINFO, 'MemFree:', 'MemFree:', ' kB')
- return mem_free / 1024
-
-
-def get_kernel_max():
- """
- Returns content of kernel_max.
- """
- kernel_max = _get_int_from_file(_KERNEL_MAX, 0, None, None)
- # Sanity check.
- assert ((kernel_max > 0) and (kernel_max < 257)), 'Unreasonable kernel_max.'
- return kernel_max
-
-
-def _get_number_cpus():
- """
- Returns the number of CPUs available.
- """
- # TODO(ihf): apparently get_kernel_max() + 1 is not right here due to
- # hyperthreading. We only need this right now to get sensible
- # temperature and frequency baselines. But to make the functions
- # more useful this needs to be fixed.
- return 1
-
-
-def set_high_performance_mode():
- """
- Sets the kernel governor mode to the highest setting.
- Returns previous governor state.
- """
- original_governors = get_scaling_governor_states()
- set_scaling_governors('performance')
- return original_governors
-
-
-def set_scaling_governors(value):
- """
- Sets all scaling governor to string value.
- Sample values: 'performance', 'interactive', 'ondemand', 'powersave'.
- """
- paths = _get_scaling_governor_paths()
- for path in paths:
- cmd = 'sudo echo %s > %s' % (value, path)
- logging.info('Writing scaling governor mode \'%s\' -> %s', value, path)
- utils.system(cmd)
-
-
-def _get_scaling_governor_paths():
- """
- Returns a list of paths to the governors.
- """
- cmd = 'ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'
- paths = utils.system_output(cmd).splitlines()
- logging.info(paths)
- return paths
-
-
-def get_scaling_governor_states():
- """
- Returns a list of (performance governor path, current state) tuples.
- """
- paths = _get_scaling_governor_paths()
- path_value_list = []
- for path in paths:
- value = _get_line_from_file(path, 0)
- path_value_list.append((path, value))
- return path_value_list
-
-
-def restore_scaling_governor_states(path_value_list):
- """
- Restores governor states. Inverse operation to get_scaling_governor_states.
- """
- for (path, value) in path_value_list:
- cmd = 'sudo echo %s > %s' % (value, path)
- utils.system(cmd)
diff --git a/client/common_lib/base_utils.py b/client/common_lib/base_utils.py
index 7d0cda1..c6b87e2 100644
--- a/client/common_lib/base_utils.py
+++ b/client/common_lib/base_utils.py
@@ -1043,7 +1043,7 @@
bg_job.command)
if nuke_subprocess(bg_job.sp) is None:
# If process could not be SIGKILL'd, log kernel stack.
- logging.warn(read_file('/proc/' + bg_job.sp.pid + '/stack'))
+ logging.warn(utils.read_file('/proc/' + bg_job.sp.pid + '/stack'))
bg_job.result.exit_status = bg_job.sp.poll()
bg_job.result.duration = time.time() - start_time
@@ -1470,6 +1470,12 @@
return get_arch()
+def get_board():
+ """
+ Get the board name from /etc/lsb-release.
+ """
+ return re.search('BOARD=(.*)', read_file('/etc/lsb-release')).group(1)
+
def get_num_logical_cpus_per_socket(run_function=run):
"""
diff --git a/client/cros/perf.py b/client/cros/perf.py
deleted file mode 100644
index 8b15d90..0000000
--- a/client/cros/perf.py
+++ /dev/null
@@ -1,138 +0,0 @@
-# Copyright 2014 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging, threading, time
-
-from autotest_lib.client.bin import utils
-from autotest_lib.client.cros import service_stopper
-
-
-# List of thermal throttling services that should be disabled.
-# - temp_metrics for link.
-# - thermal for daisy, snow, pit etc.
-# TODO(ihf): cpu_quiet on nyan isn't a service. We still need to disable it
-# on nyan. See crbug.com/357457.
-_THERMAL_SERVICES = ['temp_metrics', 'thermal']
-
-
-class PerfControl(object):
- """
- Provides methods for setting the performance mode of a device.
-
- In particular it verifies the machine is idle and cold and tries to set
- it into a consistent, high performance state during initialization.
-
- Furthermore it monitors the state of the machine (in particular
- temperature) and verifies that nothing bad happened along the way.
-
- Example usage:
-
- with PerfControl() as pc:
- if not pc.verify_is_valid():
- raise error.TestError(pc.get_error_reason())
- # Do all performance testing.
- ...
- if not pc.verify_is_valid():
- raise error.TestError(pc.get_error_reason())
- """
- def __init__(self):
- # Keep a copy of the current state for cleanup.
- self._temperature_init = self._get_current_temperature_max()
- self._temperature_critical = utils.get_temperature_critical()
- self._original_governors = utils.set_high_performance_mode()
- self._error_reason = None
- if not utils.wait_for_idle_cpu(60.0, 0.1):
- self._error_reason = 'Could not get idle CPU.'
- return
- if not utils.wait_for_cool_machine():
- self._error_reason = 'Could not get cold machine.'
- return
- self._temperature_cold = self._get_current_temperature_max()
- self._temperature_max = self._temperature_cold
- threading.Thread(target=self._monitor_performance_state).start()
- # Should be last just in case we had a runaway process.
- self._service_stopper = None
- self._stop_thermal_throttling()
-
-
- def __enter__(self):
- return self
-
-
- def __exit__(self, _type, value, traceback):
- # First thing restart thermal management.
- self._restore_thermal_throttling()
- utils.restore_scaling_governor_states(self._original_governors)
-
-
- def get_error_reason(self):
- """
- Returns an error reason string if we encountered problems to pass
- on to harness/wmatrix.
- """
- return self._error_reason
-
-
- def verify_is_valid(self):
- """
- For now we declare performance results as valid if
- - we did not have an error before.
- - the monitoring thread never saw temperatures too close to critical.
-
- TODO(ihf): search log files for thermal throttling messages like in
- src/build/android/pylib/perf/thermal_throttle.py
- """
- if self._error_reason:
- return False
- temperature_bad = (1.0/3.0 * self._temperature_cold +
- 2.0/3.0 * self._temperature_critical)
- logging.info("Max observed temperature = %.1f'C (bad limit = %.1f'C)",
- self._temperature_max, temperature_bad)
- if (self._temperature_max > temperature_bad):
- _error_reason = 'Machine got hot during testing.'
- return False
- return True
-
-
- def _monitor_performance_state(self):
- """
- Checks machine temperature once per second.
- TODO(ihf): make this more intelligent with regards to governor,
- CPU, GPU and maybe zram as needed.
- """
- while True:
- time.sleep(1)
- current_temperature = self._get_current_temperature_max()
- self._temperature_max = max(self._temperature_max,
- current_temperature)
- # TODO(ihf): Remove this spew once PerfControl is stable.
- logging.info('PerfControl CPU temperature = %.1f',
- current_temperature)
-
- def _get_current_temperature_max(self):
- """
- Returns the highest reported board temperature (all sensors) in Celsius.
- """
- temperature = utils.get_temperature_input_max()
- ec_temperatures = utils.get_ec_temperatures()
- if ec_temperatures:
- temperature = max(max(ec_temperatures), temperature)
- return temperature
-
-
- def _stop_thermal_throttling(self):
- """
- If exist on the platform/machine it stops the different thermal
- throttling scripts from running.
- Warning: this risks abnormal behavior if machine runs in high load.
- """
- self._service_stopper = service_stopper.ServiceStopper(
- _THERMAL_SERVICES)
-
-
- def _restore_thermal_throttling(self):
- """
- Restores the original thermal throttling state.
- """
- self._service_stopper.restore_services()
diff --git a/client/deps/glbench/src/testbase.cc b/client/deps/glbench/src/testbase.cc
index ad6e74f..b3ac876 100644
--- a/client/deps/glbench/src/testbase.cc
+++ b/client/deps/glbench/src/testbase.cc
@@ -34,25 +34,19 @@
// Target minimum iteration duration of 1s. This means the final/longest
// iteration is between 1s and 2s and the machine is active for 2s to 4s.
-// Notice as of March 2014 the BVT suite has a hard limit per job of 20 minutes.
#define MIN_ITERATION_DURATION_US 1000000
// Benchmark some draw commands, by running it many times. We want to measure
// the marginal cost, so we try more and more iterations until we reach the
// minimum specified iteration time.
double Bench(TestBase* test) {
- // Try to wait a bit to let machine cool down for next test. We allow for a
- // bit of hysteresis as it might take too long to do a perfect job, which is
- // probably not required. But these parameters could be tuned.
- double initial_temperature = GetInitialMachineTemperature();
- double temperature = 0;
- // Try to cool to initial + 5'C but don't wait longer than 30s.
- double wait = WaitForCoolMachine(initial_temperature + 5.0, 30.0,
- &temperature);
- printf("Bench: Cooled down to %.1f'C (initial=%.1f'C) after waiting %.1fs.\n",
- temperature, initial_temperature, wait);
- if (temperature > initial_temperature + 10.0)
- printf("Warning: Machine did not cool down enough for next test!");
+ // Conservatively let machine cool down. Our goal is to sleep at least three
+ // times as much (on average) as being active to dissipate heat.
+ // TODO(ihf): Investigate if it is necessary to idle even more in the future.
+ // In particular cooling down until reaching a temperature threshold.
+ const int cool_time = static_cast<int>((10*MIN_ITERATION_DURATION_US)/1.e6);
+ // TODO(ihf): Remove this sleep if we have better ways to handle burst/power.
+ sleep(cool_time);
// Do two iterations because initial timings can vary wildly.
TimeTest(test, 2);
@@ -127,11 +121,10 @@
if (length > 45)
printf("# Warning: adjust string formatting to length = %d\n",
length);
- // Results are marked using a leading '@RESULT: ' to allow parsing.
if (value == 0.0)
- printf("@RESULT: %-45s= 0 []\n", testname);
+ printf("%-45s= 0 []\n", testname);
else
- printf("@RESULT: %-45s= %10.2f [%s]\n", testname,
+ printf("%-45s= %10.2f [%s]\n", testname,
coefficient * (inverse ? 1.0 / value : value),
name_png);
} else {
diff --git a/client/deps/glbench/src/utils.cc b/client/deps/glbench/src/utils.cc
index ce1c9e9..fff468f 100644
--- a/client/deps/glbench/src/utils.cc
+++ b/client/deps/glbench/src/utils.cc
@@ -21,7 +21,6 @@
"#endif\n";
FilePath *g_base_path = new FilePath();
-double g_initial_temperature = GetMachineTemperature();
// Sets the base path for MmapFile to `dirname($argv0)`/$relative.
void SetBasePathFromArgv0(const char* argv0, const char* relative) {
@@ -57,92 +56,6 @@
return mmap_ptr;
}
-bool read_int_from_file(FilePath filename, int *value) {
- FILE *fd = fopen(filename.value().c_str(), "r");
- if (!fd) {
- printf("Error: could not open file for reading. (%s)\n",
- filename.value().c_str());
- return false;
- }
- int count = fscanf(fd, "%d", value);
- if (count != 1) {
- printf("Error: could not read integer from file. (%s)\n",
- filename.value().c_str());
- if(count != 1)
- return false;
- }
- fclose(fd);
- return true;
-}
-
-// Returns temperature at which CPU gets throttled.
-// TODO(ihf): update this based on the outcome of crbug.com/356422.
-double get_temperature_critical() {
- FilePath filename = FilePath("/sys/class/hwmon/hwmon0/temp1_crit");
- int temperature_mCelsius = 0;
- if (!read_int_from_file(filename, &temperature_mCelsius)) {
- // spring is special :-(.
- filename = FilePath("/sys/devices/virtual/hwmon/hwmon1/temp1_crit");
- if (!read_int_from_file(filename, &temperature_mCelsius))
- return -1000.0;
- }
- double temperature_Celsius = 0.001 * temperature_mCelsius;
- // Simple sanity check for reasonable critical temperatures.
- assert(temperature_Celsius >= 60.0);
- assert(temperature_Celsius <= 150.0);
- return temperature_Celsius;
-}
-
-// Returns currently measured temperature.
-// TODO(ihf): update this based on the outcome of crbug.com/356422.
-double get_temperature_input() {
- FilePath filename = FilePath("/sys/class/hwmon/hwmon0/temp1_input");
- int temperature_mCelsius = 0;
- if (!read_int_from_file(filename, &temperature_mCelsius)) {
- // spring is special :-(.
- filename = FilePath("/sys/devices/virtual/hwmon/hwmon1/temp1_input");
- if (!read_int_from_file(filename, &temperature_mCelsius))
- return -1000.0;
- }
- double temperature_Celsius = 0.001 * temperature_mCelsius;
- // Simple sanity check for reasonable temperatures.
- assert(temperature_Celsius >= 10.0);
- assert(temperature_Celsius <= 150.0);
- return temperature_Celsius;
-}
-
-const double GetInitialMachineTemperature() {
- return g_initial_temperature;
-}
-
-// TODO(ihf): update this based on the outcome of crbug.com/356422.
-// In particular we should probably just have a system script that we can call
-// and read the output from.
-double GetMachineTemperature() {
- double max_temperature = get_temperature_input();
- return max_temperature;
-}
-
-// Waits up to timeout seconds to reach cold_temperature in Celsius.
-double WaitForCoolMachine(double cold_temperature, double timeout,
- double *temperature) {
- // Integer times are in micro-seconds.
- uint64_t time_start = GetUTime();
- uint64_t time_now = time_start;
- uint64_t time_end = time_now + 1e6 * timeout;
- *temperature = GetMachineTemperature();
- while (time_now < time_end) {
- if (*temperature < cold_temperature)
- break;
- sleep(1.0);
- time_now = GetUTime();
- *temperature = GetMachineTemperature();
- }
- double wait_time = 1.0e-6 * (time_now - time_start);
- assert(wait_time >= 0);
- assert(wait_time < timeout + 5.0);
- return wait_time;
-}
namespace glbench {
diff --git a/client/deps/glbench/src/utils.h b/client/deps/glbench/src/utils.h
index 17e6c4c..13afe17 100644
--- a/client/deps/glbench/src/utils.h
+++ b/client/deps/glbench/src/utils.h
@@ -17,16 +17,6 @@
void *MmapFile(const char *name, size_t *length);
const FilePath& GetBasePath();
-// Returns temperature of system before testing started. It is used as a
-// reference for keeping the machine cool.
-const double GetInitialMachineTemperature();
-// For thermal monitoring of system.
-double GetMachineTemperature();
-// Wait for machine to cool with temperature in Celsius and timeout in seconds.
-// Returns the time spent waiting and sets the last observed temperature.
-double WaitForCoolMachine(double cold_temperature, double timeout,
- double *temperature);
-
namespace glbench {
GLuint SetupTexture(GLsizei size_log2);
diff --git a/client/site_tests/graphics_GLBench/graphics_GLBench.py b/client/site_tests/graphics_GLBench/graphics_GLBench.py
index fdad7b1..7a06c92 100644
--- a/client/site_tests/graphics_GLBench/graphics_GLBench.py
+++ b/client/site_tests/graphics_GLBench/graphics_GLBench.py
@@ -2,15 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import httplib
import logging
import os
+import time
import pprint
import urllib2
+import httplib
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
-from autotest_lib.client.cros import perf
from autotest_lib.client.cros import service_stopper
# to run this test manually on a test target
@@ -127,13 +127,22 @@
self._services.restore_services()
def report_temperature(self, keyname):
- temperature = utils.get_temperature_input_max()
+ try:
+ f = open('/sys/class/hwmon/hwmon0/temp1_input')
+ temperature = float(f.readline()) * 0.001
+ except Exception:
+ temperature = - 1000.0
logging.info('%s = %f degree Celsius', keyname, temperature)
self.output_perf_value(description=keyname, value=temperature,
units='Celsius', higher_is_better=False)
- def report_temperature_critical(self, keyname):
- temperature = utils.get_temperature_critical()
+ def report_temperature_critical(self):
+ keyname = 'temperature_critical'
+ try:
+ f = open('/sys/class/hwmon/hwmon0/temp1_crit')
+ temperature = float(f.readline()) * 0.001
+ except Exception:
+ temperature = - 1000.0
logging.info('%s = %f degree Celsius', keyname, temperature)
self.output_perf_value(description=keyname, value=temperature,
units='Celsius', higher_is_better=False)
@@ -154,7 +163,6 @@
raise error.TestFail('Unknown test unit in ' + testname)
def run_once(self, options='', raise_error_on_checksum=True):
- logging.info(utils.get_board_with_frequency_and_memory())
dep = 'glbench'
dep_dir = os.path.join(self.autodir, 'deps', dep)
self.job.install_pkg(dep, 'dep', dep_dir)
@@ -181,22 +189,20 @@
kill_cmd = '. /sbin/killers; term_process "^X$"'
cmd = 'X :1 vt1 & sleep 1; chvt 1 && DISPLAY=:1 %s; %s' % (cmd, kill_cmd)
- self.report_temperature_critical('temperature_critical')
+ if not utils.wait_for_cool_idle_perf_machine():
+ raise error.TestFail('Could not get cool/idle machine for test.')
+
+ # TODO(ihf): Remove this sleep once this test is guaranteed to run on a
+ # cold machine.
+ self.report_temperature_critical()
self.report_temperature('temperature_1_start')
- summary = None
- # Wrap the test run inside of a PerfControl instance to make machine
- # behavior more consistent.
- with perf.PerfControl() as pc:
- if not pc.verify_is_valid():
- raise error.TestError(pc.get_error_reason())
- self.report_temperature('temperature_2_before_test')
+ logging.info('Sleeping machine for one minute to physically cool down.')
+ time.sleep(60)
+ self.report_temperature('temperature_2_before_test')
- # Run the test. If it gets the CPU too hot pc should notice.
- summary = utils.system_output(cmd, retain_output=True)
- if not pc.verify_is_valid():
- raise error.TestError(pc.get_error_reason())
+ summary = utils.system_output(cmd, retain_output=True)
- # Write a copy of stdout to help debug failures.
+ # write a copy of stdout to help debug failures
results_path = os.path.join(self.outputdir, 'summary.txt')
f = open(results_path, 'w+')
f.write('# ---------------------------------------------------\n')
@@ -236,14 +242,15 @@
keyvals = {}
failed_tests = {}
for line in results:
- if not line.strip().startswith('@RESULT: '):
+ if line.strip().startswith('#'):
continue
- keyval, remainder = line[9:].split('[')
+ keyval, remainder = line.split('[')
key, val = keyval.split('=')
testname = key.strip()
testrating = float(val)
imagefile = remainder.split(']')[0]
unit, higher = self.get_unit_from_test(testname)
+ logging.info('%s %s %d', testname, unit, higher)
self.output_perf_value(description=testname, value=testrating,
units=unit, higher_is_better=higher)
diff --git a/client/site_tests/graphics_GLMark2/graphics_GLMark2.py b/client/site_tests/graphics_GLMark2/graphics_GLMark2.py
index fabb895..959c6c8 100644
--- a/client/site_tests/graphics_GLMark2/graphics_GLMark2.py
+++ b/client/site_tests/graphics_GLMark2/graphics_GLMark2.py
@@ -79,12 +79,8 @@
from cros.factory.test import ui
ui.start_reposition_thread('^glmark')
- # TODO(ihf): Switch this test to use perf.PerfControl like
- # graphics_GLBench once it is stable. crbug.com/344766.
- if not utils.wait_for_idle_cpu(60.0, 0.1):
- raise error.TestFail('Could not get idle CPU.')
- if not utils.wait_for_cool_machine():
- raise error.TestFail('Could not get cold machine.')
+ if not utils.wait_for_cool_idle_perf_machine():
+ raise error.TestFail('Could not get cool/idle machine for test.')
result = utils.run(cmd)
logging.info(result)