summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qrtc.py
blob: 1d02f7842d29465b3f20f926eca0f91275d1fe8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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")