summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-05-31 21:34:25 +0800
committerGerrit <chrome-bot@google.com>2012-06-25 07:15:50 -0700
commit7ae80c05522afb393eac816e5e4e9f3993e1b1ed (patch)
tree1c070402690ce658908ec659beab63c6f72cb4e1 /test
parent80c635ecabdd398c20441cfd4dadb00c7eb76720 (diff)
downloadchrome-ec-7ae80c05522afb393eac816e5e4e9f3993e1b1ed.tar.gz
Thermal engine unit test
This test checks for the functionality of thermal engine. BUG=chrome-os-partner:10241 TEST=Test passed Disable thermal engine overheating warning and test failed Change-Id: Ideb0ff9ee4bd1617b11c56dfa2578a3f406381ff Reviewed-on: https://gerrit.chromium.org/gerrit/25370 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/build.mk8
-rw-r--r--test/thermal.py100
-rw-r--r--test/thermal.tasklist22
3 files changed, 129 insertions, 1 deletions
diff --git a/test/build.mk b/test/build.mk
index 5966f41579..2ad8df6c4f 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -6,7 +6,7 @@
# on-board test binaries build
#
-test-list=hello pingpong timer_calib timer_dos timer_jump mutex
+test-list=hello pingpong timer_calib timer_dos timer_jump mutex thermal
#disable: powerdemo
pingpong-y=pingpong.o
@@ -14,3 +14,9 @@ powerdemo-y=powerdemo.o
timer_calib-y=timer_calib.o
timer_dos-y=timer_dos.o
mutex-y=mutex.o
+
+# Mock modules for 'thermal'
+chip-mock-thermal-lpc.o=mock_lpc.o
+chip-mock-thermal-pwm.o=mock_pwm.o
+common-mock-thermal-x86_power.o=mock_x86_power.o
+common-mock-thermal-temp_sensor.o=mock_temp_sensor.o
diff --git a/test/thermal.py b/test/thermal.py
new file mode 100644
index 0000000000..30090b6b74
--- /dev/null
+++ b/test/thermal.py
@@ -0,0 +1,100 @@
+# Copyright (c) 2012 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.
+#
+# Thermal engine unit test
+#
+
+CPU = 0
+BOARD = 1
+CASE = 2
+
+def getWarningConfig(helper, sensor_type):
+ ret = dict()
+ helper.ec_command("thermalconf %d" % sensor_type)
+ ret['warning'] = int(helper.wait_output(
+ "Warning:\s*(?P<t>\d+) K", use_re=True)["t"])
+ ret['cpudown'] = int(helper.wait_output(
+ "CPU Down:\s*(?P<t>\d+) K", use_re=True)["t"])
+ ret['powerdown'] = int(helper.wait_output(
+ "Power Down:\s*(?P<t>\d+) K", use_re=True)["t"])
+ return ret
+
+def getFanConfig(helper, sensor_type):
+ ret = list()
+ helper.ec_command("thermalfan %d" % sensor_type)
+ while True:
+ try:
+ match = helper.wait_output("(?P<t>\d+)\s*K:\s*(?P<r>-?\d+)\s",
+ use_re=True, timeout=1)
+ ret.append((int(match["t"]), int(match["r"])))
+ except:
+ break
+ return ret
+
+
+def test(helper):
+ helper.wait_output("Inits done")
+
+ # Get thermal engine configuration
+ config = [getWarningConfig(helper, sensor_type)
+ for sensor_type in xrange(3)]
+ fan_config = [getFanConfig(helper, sensor_type)
+ for sensor_type in xrange(3)]
+
+ # Set initial temperature values
+ helper.ec_command("setcputemp %d" % max(fan_config[CPU][0][0]-1, 0))
+ helper.ec_command("setboardtemp %d" % max(fan_config[BOARD][0][0]-1, 0))
+ helper.ec_command("setcasetemp %d" % max(fan_config[CASE][0][0]-1, 0))
+
+ # Increase CPU temperature to first fan step
+ # Check if fan comes up
+ helper.ec_command("setcputemp %d" % fan_config[CPU][0][0])
+ helper.wait_output("Fan RPM: %d" % fan_config[CPU][0][1], timeout=11)
+
+ # Increase CPU temperature to second fan step
+ helper.ec_command("setcputemp %d" % fan_config[CPU][1][0])
+ helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1], timeout=11)
+
+ # Lower CPU temperature to 1 degree below second fan step
+ # Check fan speed doesn't change
+ helper.ec_command("setcputemp %d" % (fan_config[CPU][1][0]-1))
+ for i in xrange(12):
+ helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1], timeout=2)
+
+ # Set CPU temperature to a high value for only one second
+ # Check fan speed doesn't change
+ helper.ec_command("setcputemp 400")
+ helper.wait_output("Fan RPM: %d" % fan_config[CPU][1][1])
+ helper.ec_command("setcputemp %d" % fan_config[CPU][1][0])
+
+ # Set case temperature to first fan step
+ # Check fan is set to second step
+ helper.ec_command("setcasetemp %d" % fan_config[CASE][0][0])
+ for i in xrange(12):
+ helper.wait_output("Fan RPM: %d" % fan_config[CASE][1][1], timeout=2)
+
+ # Set case temperature to third fan step
+ # Check fan is set to third step
+ helper.ec_command("setcasetemp %d" % fan_config[CASE][2][0])
+ helper.wait_output("Fan RPM: %d" % fan_config[CASE][2][1], timeout=11)
+
+ # Set CPU temperature to trigger warning and throttle CPU
+ helper.ec_command("setcputemp %d" % config[CPU]['warning'])
+ helper.wait_output("Throttle CPU.", timeout=11)
+ helper.wait_output("Host event: 200", timeout=2)
+
+ # Lower CPU temperature and check CPU is not throttled
+ helper.ec_command("setcputemp %d" % (config[CPU]['warning']-5))
+ helper.wait_output("No longer throttle CPU.", timeout=2)
+
+ # Set CPU temperature to trigger CPU shutdown
+ helper.ec_command("setcputemp %d" % config[CPU]['cpudown'])
+ helper.wait_output("CPU overheated", timeout=11)
+
+ # Set CPU temperature to trigger force shutdown
+ helper.ec_command("setcputemp %d" % config[CPU]['powerdown'])
+ helper.wait_output("Force shutdown", timeout=11)
+
+ # Pass!
+ return True
diff --git a/test/thermal.tasklist b/test/thermal.tasklist
new file mode 100644
index 0000000000..87f1d0d302
--- /dev/null
+++ b/test/thermal.tasklist
@@ -0,0 +1,22 @@
+/* Copyright (c) 2012 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.
+ */
+
+/**
+ * List of enabled tasks in the priority order
+ *
+ * The first one has the lowest priority.
+ *
+ * For each task, use the macro TASK(n, r, d) where :
+ * 'n' in the name of the task
+ * 'r' in the main routine of the task
+ * 'd' in an opaque parameter passed to the routine at startup
+ */
+#define CONFIG_TASK_LIST \
+ TASK(WATCHDOG, watchdog_task, NULL) \
+ TASK(TEMPSENSOR, temp_sensor_task, NULL) \
+ TASK(THERMAL, thermal_task, NULL) \
+ TASK(PWM, pwm_task, NULL) \
+ TASK(X86POWER, x86_power_task, NULL) \
+ TASK(CONSOLE, console_task, NULL)