diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oeqa/runtime/cases/thermald.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/oeqa/runtime/cases/thermald.py b/lib/oeqa/runtime/cases/thermald.py new file mode 100644 index 00000000..b0efecd8 --- /dev/null +++ b/lib/oeqa/runtime/cases/thermald.py | |||
@@ -0,0 +1,45 @@ | |||
1 | from oeqa.runtime.case import OERuntimeTestCase | ||
2 | from oeqa.core.decorator.depends import OETestDepends | ||
3 | from oeqa.runtime.decorator.package import OEHasPackage | ||
4 | import threading | ||
5 | import time | ||
6 | import re | ||
7 | |||
8 | class ThermaldTest(OERuntimeTestCase): | ||
9 | def get_thermal_zone_with_target_type(self, target_type): | ||
10 | i = 0 | ||
11 | while True: | ||
12 | status, output = self.target.run('cat /sys/class/thermal/thermal_zone%s/type' % i) | ||
13 | if status: | ||
14 | return -1 | ||
15 | if output == target_type: | ||
16 | return i | ||
17 | i = i + 1 | ||
18 | |||
19 | def run_thermald_emulation_to_exceed_setpoint_then_end_thermald_process(self, run_args): | ||
20 | time.sleep(2) | ||
21 | self.target.run('echo 106000 > /sys/class/thermal/thermal_zone%s/emul_temp' % run_args) | ||
22 | time.sleep(2) | ||
23 | __, output = self.target.run('pidof thermald') | ||
24 | self.target.run('kill -9 %s' % output) | ||
25 | |||
26 | def test_thermald_emulation_mode(self): | ||
27 | # Thermald test depend on thermal emulation, where CONFIG_THERMAL_EMULATION=y was required | ||
28 | # To enable thermal emulation, refer to https://github.com/intel/thermal_daemon/blob/master/test/readme_test.txt | ||
29 | (status, output) = self.target.run('gzip -dc /proc/config.gz | grep CONFIG_THERMAL_EMULATION=y') | ||
30 | self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output)) | ||
31 | |||
32 | @OEHasPackage(['thermald']) | ||
33 | @OETestDepends(['thermald.ThermaldTest.test_thermald_emulation_mode']) | ||
34 | def test_thermald_can_track_thermal_exceed_setpoint(self): | ||
35 | x86_thermal_zone_index = self.get_thermal_zone_with_target_type('x86_pkg_temp') | ||
36 | if x86_thermal_zone_index < 0: | ||
37 | self.skipTest('Could not get the thermal zone index for target type (%s)' % 'x86_pkg_temp') | ||
38 | td_thread = threading.Thread(target=self.run_thermald_emulation_to_exceed_setpoint_then_end_thermald_process, | ||
39 | args=(x86_thermal_zone_index,)) | ||
40 | td_thread.start() | ||
41 | status, output = self.target.run('thermald --no-daemon --loglevel=info') | ||
42 | regex_search = ".*thd_cdev_set_state.*106000" | ||
43 | regex_comp = re.compile(regex_search) | ||
44 | m = regex_comp.search(output) | ||
45 | self.assertTrue(m, msg='status and output: %s and %s' % (status, output)) | ||