thermald.py: fix 'thermald --no-daemon' taking forever issue

skip test if CONFIG_THERMAL_EMULATION is not set

Observed multiple issues:

(1) Randomly not picking pid of thermld daemon (not sure why)
(2) 'thermald --no-daemon --loglevle=info' taking forever

Increase sleep time to make sure pid is avaialble.
Added timeout for the command.

Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
Naveen Saini 2021-02-04 11:00:14 +08:00 committed by Anuj Mittal
parent 1cc1dc6e88
commit 0e8b3cd2c5

View File

@ -19,7 +19,7 @@ class ThermaldTest(OERuntimeTestCase):
def run_thermald_emulation_to_exceed_setpoint_then_end_thermald_process(self, run_args):
time.sleep(2)
self.target.run('echo 106000 > /sys/class/thermal/thermal_zone%s/emul_temp' % run_args)
time.sleep(2)
time.sleep(5)
__, output = self.target.run('pidof thermald')
self.target.run('kill -9 %s' % output)
@ -27,7 +27,8 @@ class ThermaldTest(OERuntimeTestCase):
# Thermald test depend on thermal emulation, where CONFIG_THERMAL_EMULATION=y was required
# To enable thermal emulation, refer to https://github.com/intel/thermal_daemon/blob/master/test/readme_test.txt
(status, output) = self.target.run('gzip -dc /proc/config.gz | grep CONFIG_THERMAL_EMULATION=y')
self.assertEqual(status, 0, msg='status and output: %s and %s' % (status, output))
if status:
self.skipTest("CONFIG_THERMAL_EMULATION is not set")
@OEHasPackage(['thermald'])
@OETestDepends(['thermald.ThermaldTest.test_thermald_emulation_mode'])
@ -38,7 +39,8 @@ class ThermaldTest(OERuntimeTestCase):
td_thread = threading.Thread(target=self.run_thermald_emulation_to_exceed_setpoint_then_end_thermald_process,
args=(x86_thermal_zone_index,))
td_thread.start()
status, output = self.target.run('thermald --no-daemon --loglevel=info')
td_thread.join()
status, output = self.target.run('timeout 3s thermald --no-daemon --loglevel=info')
regex_search = ".*thd_cdev_set_state.*106000"
regex_comp = re.compile(regex_search)
m = regex_comp.search(output)