From 34df86b37d6838b115e65e5f3a332344afeb86b8 Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Wed, 1 Jul 2020 10:45:34 +0200 Subject: Changes to adapt to new way to save results in DB. Created audio test. Added protections against unexpected status in DB. --- test-cli/test/tests/qdmesg.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test-cli/test/tests/qdmesg.py (limited to 'test-cli/test/tests/qdmesg.py') diff --git a/test-cli/test/tests/qdmesg.py b/test-cli/test/tests/qdmesg.py new file mode 100644 index 0000000..45dd4eb --- /dev/null +++ b/test-cli/test/tests/qdmesg.py @@ -0,0 +1,38 @@ +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("/tmp/station/dmesg.txt"): + print("dmesg remove") + os.remove("/tmp/station/dmesg.txt") + # generate file + p = sh.dmesg("--color=never", _out="/tmp/station/dmesg.txt") + print("Exit code: {}".format(p.exit_code)) + if p.exit_code == 0: + # save result + # with open('/tmp/station/dmesg.txt', 'w') as outfile: + # n = outfile.write(p.stdout.decode('ascii')) + # outfile.close() + + # save dmesg result in DB + self.pgObj.upload_result_file(self.params["testidctl"], self.params["testid"], "dmesg output", + "/tmp/station/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") -- cgit v1.1 From 0e8e3ecd4b9be71c41008b95950d089819622dff Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Mon, 6 Jul 2020 14:08:27 +0200 Subject: Corrected some errors in USB and USBDUAL tests. --- test-cli/test/tests/qdmesg.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test-cli/test/tests/qdmesg.py') diff --git a/test-cli/test/tests/qdmesg.py b/test-cli/test/tests/qdmesg.py index 45dd4eb..8117deb 100644 --- a/test-cli/test/tests/qdmesg.py +++ b/test-cli/test/tests/qdmesg.py @@ -2,6 +2,7 @@ import sh import os.path from os import path + class Qdmesg: params = None __resultlist = None # resultlist is a python list of python dictionaries @@ -17,11 +18,9 @@ class Qdmesg: self.pgObj.run_test(self.params["testidctl"], self.params["testid"]) # delete previous file if path.exists("/tmp/station/dmesg.txt"): - print("dmesg remove") os.remove("/tmp/station/dmesg.txt") # generate file p = sh.dmesg("--color=never", _out="/tmp/station/dmesg.txt") - print("Exit code: {}".format(p.exit_code)) if p.exit_code == 0: # save result # with open('/tmp/station/dmesg.txt', 'w') as outfile: -- cgit v1.1 From 1d51a80b57cc8c80c78d67c85290503997060e9e Mon Sep 17 00:00:00 2001 From: Hector Fernandez Date: Mon, 6 Jul 2020 17:22:17 +0200 Subject: Modified paths of ram and nfs temporary folders. --- test-cli/test/tests/qdmesg.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'test-cli/test/tests/qdmesg.py') diff --git a/test-cli/test/tests/qdmesg.py b/test-cli/test/tests/qdmesg.py index 8117deb..b35f1ff 100644 --- a/test-cli/test/tests/qdmesg.py +++ b/test-cli/test/tests/qdmesg.py @@ -17,19 +17,14 @@ class Qdmesg: print("running dmesg test") self.pgObj.run_test(self.params["testidctl"], self.params["testid"]) # delete previous file - if path.exists("/tmp/station/dmesg.txt"): - os.remove("/tmp/station/dmesg.txt") + if path.exists("/mnt/station_ramdisk/dmesg.txt"): + os.remove("/mnt/station_ramdisk/dmesg.txt") # generate file - p = sh.dmesg("--color=never", _out="/tmp/station/dmesg.txt") + p = sh.dmesg("--color=never", _out="/mnt/station_ramdisk/dmesg.txt") if p.exit_code == 0: - # save result - # with open('/tmp/station/dmesg.txt', 'w') as outfile: - # n = outfile.write(p.stdout.decode('ascii')) - # outfile.close() - # save dmesg result in DB self.pgObj.upload_result_file(self.params["testidctl"], self.params["testid"], "dmesg output", - "/tmp/station/dmesg.txt", "text/plain") + "/mnt/station_ramdisk/dmesg.txt", "text/plain") self.pgObj.finish_test(self.params["testidctl"], self.params["testid"], "TEST_COMPLETE", "") print("success dmesg test") else: -- cgit v1.1 From d46bce422fd03cd57d1ba336361da17d6efb48db Mon Sep 17 00:00:00 2001 From: Manel Caro Date: Fri, 31 Jul 2020 02:07:37 +0200 Subject: TEST restructure --- test-cli/test/tests/qdmesg.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'test-cli/test/tests/qdmesg.py') diff --git a/test-cli/test/tests/qdmesg.py b/test-cli/test/tests/qdmesg.py index b35f1ff..39a5047 100644 --- a/test-cli/test/tests/qdmesg.py +++ b/test-cli/test/tests/qdmesg.py @@ -1,4 +1,5 @@ import sh +import os import os.path from os import path @@ -9,24 +10,23 @@ class Qdmesg: def __init__(self, testname, testfunc, varlist): self.params = varlist - self._testMethodDoc = testname + self.__testMethodDoc = testname self.__resultlist = [] self.pgObj = varlist["db"] + self.__xmlObj = varlist["xml"] + self.__QdmesgName = varlist.get('name', 'qdmesg') + self.__syslog_dmesg_file = varlist.get('syslog_dmesg',self.__xmlObj.getKeyVal(self.__QdmesgName, "syslog_dmesg", + "/var/log/kern.log")) + + def getTestName(self): + return self.__testMethodDoc 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: + if not os.path.isfile('{}'.format(self.__syslog_dmesg_file)): self.pgObj.finish_test(self.params["testidctl"], self.params["testid"], "TEST_FAILED", "") - print("fail dmesg test") + return False + self.pgObj.upload_result_file(self.params["testidctl"], self.params["testid"], "{}".format(self.__syslog_dmesg_file), + "{}".format(self.__syslog_dmesg_file), "text/plain") + self.pgObj.finish_test(self.params["testidctl"], self.params["testid"], "TEST_COMPLETE", "") + return True -- cgit v1.1