diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-03-09 12:39:50 +0100 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-03-09 12:39:50 +0100 |
commit | c685367cbd6abf1c6ae442df759e39b25a907d3b (patch) | |
tree | 37a942f44512c7b567447de41b1ff2c8496898be /test-cli/test/tests/qrtc.py | |
parent | a03055f657d2e970e45e7ea2a3e66857f821eabd (diff) | |
download | board-c685367cbd6abf1c6ae442df759e39b25a907d3b.zip board-c685367cbd6abf1c6ae442df759e39b25a907d3b.tar.gz board-c685367cbd6abf1c6ae442df759e39b25a907d3b.tar.bz2 |
Fixed several test procedures.
Diffstat (limited to 'test-cli/test/tests/qrtc.py')
-rw-r--r-- | test-cli/test/tests/qrtc.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/test-cli/test/tests/qrtc.py b/test-cli/test/tests/qrtc.py index 884a290..0be0f99 100644 --- a/test-cli/test/tests/qrtc.py +++ b/test-cli/test/tests/qrtc.py @@ -1,11 +1,12 @@ -from test.helpers.syscmd import SysCommand +import sh import unittest import time +import re class Qrtc(unittest.TestCase): params = None - __rtc = "/dev/rtc0" + __rtc = None def __init__(self, testname, testfunc, varlist): self.params = varlist @@ -17,16 +18,19 @@ class Qrtc(unittest.TestCase): self._testMethodDoc = testname def execute(self): - str_cmd = "hwclock -f {}".format(self.__rtc) - rtc_set = SysCommand("rtc_set", str_cmd) - if rtc_set.execute() == 0: - curr_hour = rtc_set.getOutput().decode('ascii').split(" ") - time1 = int((curr_hour[4].split(":"))[2]) + # get time from RTC peripheral + p = sh.hwclock("-f", self.__rtc) + if p.exit_code == 0: + time1 = re.search("([01]?[0-9]{1}|2[0-3]{1})[:][0-5]{1}[0-9]{1}[:][0-5]{1}[0-9]{1}", + p.stdout.decode('ascii')) time.sleep(1) - if rtc_set.execute() == 0: - curr_hour = rtc_set.getOutput().decode('ascii').split(" ") - time2 = int((curr_hour[4].split(":"))[2]) - if time1==time2: + # get time from RTC another time + p = sh.hwclock("-f", self.__rtc) + if p.exit_code == 0: + time2 = re.search("([01]?[0-9]{1}|2[0-3]{1})[:][0-5]{1}[0-9]{1}[:][0-5]{1}[0-9]{1}", + p.stdout.decode('ascii')) + # check if the seconds of both times are different + if time1 == time2: self.fail("failed: RTC is not running") else: self.fail("failed: couldn't execute hwclock command 2nd time") |