summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qdmesg.py
blob: b35f1ff2f2a2766800209ace914a46e2379ecccb (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
29
30
31
32
import sh
import os.path
from os import path


class Qdmesg:
    params = None
    __resultlist = None  # resultlist is a python list of python dictionaries

    def __init__(self, testname, testfunc, varlist):
        self.params = varlist
        self._testMethodDoc = testname
        self.__resultlist = []
        self.pgObj = varlist["db"]

    def execute(self):
        print("running dmesg test")
        self.pgObj.run_test(self.params["testidctl"], self.params["testid"])
        # delete previous file
        if path.exists("/mnt/station_ramdisk/dmesg.txt"):
            os.remove("/mnt/station_ramdisk/dmesg.txt")
        # generate file
        p = sh.dmesg("--color=never", _out="/mnt/station_ramdisk/dmesg.txt")
        if p.exit_code == 0:
            # save dmesg result in DB
            self.pgObj.upload_result_file(self.params["testidctl"], self.params["testid"], "dmesg output",
                                          "/mnt/station_ramdisk/dmesg.txt", "text/plain")
            self.pgObj.finish_test(self.params["testidctl"], self.params["testid"], "TEST_COMPLETE", "")
            print("success dmesg test")
        else:
            self.pgObj.finish_test(self.params["testidctl"], self.params["testid"], "TEST_FAILED", "")
            print("fail dmesg test")