from test.helpers.syscmd import SysCommand import unittest import time class Qrtc(unittest.TestCase): def __init__(self, testname, testfunc, rtc): super(Qrtc, self).__init__(testfunc) self.__rtc = rtc 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]) 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: self.fail("failed: RTC is not running") else: self.fail("failed: couldn't execute hwclock command 2nd time") else: self.fail("failed: couldn't execute hwclock command")