diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-06-17 09:44:56 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-06-17 09:44:56 +0200 |
commit | 09b3bb38fc7305c9b47c29bc90ebc9c636827307 (patch) | |
tree | a793c8f232031183960178d2a18fcde4baf3348f /test-cli/test/tests | |
parent | 0dd2613b88d937e71b274d68924088b1bad65de4 (diff) | |
download | board-09b3bb38fc7305c9b47c29bc90ebc9c636827307.zip board-09b3bb38fc7305c9b47c29bc90ebc9c636827307.tar.gz board-09b3bb38fc7305c9b47c29bc90ebc9c636827307.tar.bz2 |
SOPA0000: Added support for saving results (strings or files) in the DB. It also saves a final DMESG file.
Diffstat (limited to 'test-cli/test/tests')
-rw-r--r-- | test-cli/test/tests/qamper.py | 23 | ||||
-rw-r--r-- | test-cli/test/tests/qduplex_ser.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qeeprom.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qethernet.py | 38 | ||||
-rw-r--r-- | test-cli/test/tests/qi2c.py | 14 | ||||
-rw-r--r-- | test-cli/test/tests/qnand.py | 17 | ||||
-rw-r--r-- | test-cli/test/tests/qram.py | 8 | ||||
-rw-r--r-- | test-cli/test/tests/qrtc.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qserial.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qusb.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qwifi.py | 34 |
11 files changed, 121 insertions, 36 deletions
diff --git a/test-cli/test/tests/qamper.py b/test-cli/test/tests/qamper.py index c611fdb..51aa469 100644 --- a/test-cli/test/tests/qamper.py +++ b/test-cli/test/tests/qamper.py @@ -4,6 +4,7 @@ from test.helpers.amper import Amper class Qamper(unittest.TestCase): params = None + __current = None # varlist: undercurrent, overcurrent def __init__(self, testname, testfunc, varlist): @@ -33,12 +34,22 @@ class Qamper(unittest.TestCase): self.fail("failed: can not communicate") return # get current value (in Amperes) - result = amp.getCurrent() + self.__current = amp.getCurrent() # close serial connection amp.close() - # # In order to give a valid result it is importarnt to define an under current value - if result > float(self._overcurrent): - self.fail("failed: Overcurrent detected ( {} )".format(result)) + # Check current range + if float(self.__current) > float(self._overcurrent): + self.fail("failed: Overcurrent detected ( {} )".format(self.__current)) + if float(self.__current) < float(self._undercurrent): + self.fail("failed: Undercurrent detected ( {} )".format(self.__current)) - if result < float(self._undercurrent): - self.fail("failed: Undercurrent detected ( {} )".format(result)) + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [ + { + "desc": "current (Ampers)", + "data": self.__current, + "type": "string" + } + ] + return resultlist diff --git a/test-cli/test/tests/qduplex_ser.py b/test-cli/test/tests/qduplex_ser.py index cb690cb..c7231c2 100644 --- a/test-cli/test/tests/qduplex_ser.py +++ b/test-cli/test/tests/qduplex_ser.py @@ -69,3 +69,8 @@ class Qduplex(unittest.TestCase): else: if self.__serial1.readline() != test_uuid: self.fail("failed: port {} write/read mismatch".format(self.__port1)) + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qeeprom.py b/test-cli/test/tests/qeeprom.py index 1921bf7..a65ca97 100644 --- a/test-cli/test/tests/qeeprom.py +++ b/test-cli/test/tests/qeeprom.py @@ -39,3 +39,7 @@ class Qeeprom(unittest.TestCase): else: self.fail("failed: Unable to write on the EEPROM device.") + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qethernet.py b/test-cli/test/tests/qethernet.py index 2246029..da085d8 100644 --- a/test-cli/test/tests/qethernet.py +++ b/test-cli/test/tests/qethernet.py @@ -1,6 +1,7 @@ import unittest import sh import re +import json class Qethernet(unittest.TestCase): @@ -9,11 +10,16 @@ class Qethernet(unittest.TestCase): __bwexpected = None __port = None params = None + __bwreal = None # varlist content: serverip, bwexpected, port def __init__(self, testname, testfunc, varlist): + # save the parameters list self.params = varlist + # configure the function to be executed when the test runs. "testfunc" is a name of a method inside this + # class, that in this situation, it can only be "execute". super(Qethernet, self).__init__(testfunc) + # validate and get the parameters if "serverip" in varlist: self.__serverip = varlist["serverip"] else: @@ -32,8 +38,8 @@ class Qethernet(unittest.TestCase): def execute(self): # execute iperf command against the server try: - p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port, - _timeout=20) + p = sh.iperf3("-c", self.__serverip, "-n", self.__numbytestx, "-f", "m", "-p", self.__port, "-J", + _timeout=20) except sh.TimeoutException: self.fail("failed: iperf timeout reached") @@ -42,17 +48,25 @@ class Qethernet(unittest.TestCase): if p.stdout == "": self.fail("failed: error executing iperf command") # analyze output string - # split by lines - lines = p.stdout.splitlines() - # get first line - dat = lines[1].decode('ascii') - # search for the BW value - a = re.search("\d+(\.\d)? Mbits/sec", dat) - b = a.group().split() - bwreal = b[0] + data = json.loads(p.stdout.decode('ascii')) + self.__bwreal = float(data['end']['sum_received']['bits_per_second'])/1024/1024 + # save result file + with open('/tmp/ethernet-iperf.json', 'w') as outfile: + json.dump(data, outfile) # check if BW is in the expected range - self.failUnless(float(bwreal) > float(self.__bwexpected) * 0.9, - "failed: speed is lower than spected. Speed(MB/s)" + str(bwreal)) + self.failUnless(self.__bwreal > float(self.__bwexpected) * 0.9, + "failed: speed is lower than spected. Speed(Mbits/s)" + str(self.__bwreal)) else: self.fail("failed: could not complete iperf command") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [ + { + "desc": "iperf3 output", + "data": "/tmp/ethernet-iperf.json", + "type": "file" + } + ] + return resultlist diff --git a/test-cli/test/tests/qi2c.py b/test-cli/test/tests/qi2c.py index c59975e..ad7ddf0 100644 --- a/test-cli/test/tests/qi2c.py +++ b/test-cli/test/tests/qi2c.py @@ -16,7 +16,7 @@ class Qi2c(unittest.TestCase): self.__register = varlist["register"].split("/") else: raise Exception('register param inside Qi2c must be defined') - self.__devices=[] + self.__devices = [] self._testMethodDoc = testname def execute(self): @@ -26,13 +26,19 @@ class Qi2c(unittest.TestCase): self.__raw_out = i2c_command.getOutput() if self.__raw_out == "": return -1 - lines=self.__raw_out.decode('ascii').splitlines() + lines = self.__raw_out.decode('ascii').splitlines() for i in range(len(lines)): if lines[i].count('UU'): if lines[i].find("UU"): - self.__devices.append("0x{}{}".format((i - 1), hex(int((lines[i].find("UU") - 4) / 3)).split('x')[-1])) + self.__devices.append( + "0x{}{}".format((i - 1), hex(int((lines[i].find("UU") - 4) / 3)).split('x')[-1])) for i in range(len(self.__register)): - if not(self.__register[i] in self.__devices): + if not (self.__register[i] in self.__devices): self.fail("failed: device {} not found in bus i2c-{}".format(self.__register[i], self.__busnum)) else: self.fail("failed: could not complete i2cdedtect command") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qnand.py b/test-cli/test/tests/qnand.py index 10a68f2..7ff7cb2 100644 --- a/test-cli/test/tests/qnand.py +++ b/test-cli/test/tests/qnand.py @@ -18,6 +18,21 @@ class Qnand(unittest.TestCase): def execute(self): try: - sh.nandtest("-m", self.__device, _out="/dev/null") + p = sh.nandtest("-m", self.__device) + # save result + with open('/tmp/nand-nandtest.txt', 'w') as outfile: + n = outfile.write(p.stdout.decode('ascii')) + except sh.ErrorReturnCode as e: self.fail("failed: could not complete nandtest command") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [ + { + "desc": "nandtest output", + "data": "/tmp/nand-nandtest.txt", + "type": "file" + } + ] + return resultlist diff --git a/test-cli/test/tests/qram.py b/test-cli/test/tests/qram.py index 5a7734a..561e980 100644 --- a/test-cli/test/tests/qram.py +++ b/test-cli/test/tests/qram.py @@ -23,6 +23,12 @@ class Qram(unittest.TestCase): def execute(self): try: - sh.memtester(self.__memsize, "1", _out="/dev/null") + p = sh.memtester(self.__memsize, "1", _out="/dev/null") + except sh.ErrorReturnCode as e: self.fail("failed: could not complete memtester command") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qrtc.py b/test-cli/test/tests/qrtc.py index 0be0f99..715bcb7 100644 --- a/test-cli/test/tests/qrtc.py +++ b/test-cli/test/tests/qrtc.py @@ -37,3 +37,7 @@ class Qrtc(unittest.TestCase): else: self.fail("failed: couldn't execute hwclock command") + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qserial.py b/test-cli/test/tests/qserial.py index 45c9d03..0cb5563 100644 --- a/test-cli/test/tests/qserial.py +++ b/test-cli/test/tests/qserial.py @@ -45,3 +45,8 @@ class Qserial(unittest.TestCase): # check if what it was sent is equal to what has been received if self.__serial.readline() != test_uuid: self.fail("failed: port {} write/read mismatch".format(self.__port)) + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py index 4c177d9..316cef5 100644 --- a/test-cli/test/tests/qusb.py +++ b/test-cli/test/tests/qusb.py @@ -57,3 +57,8 @@ class Qusb(unittest.TestCase): self.fail("failed: unable to copy files.") else: self.fail("failed: unable to mount the device.") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [] + return resultlist diff --git a/test-cli/test/tests/qwifi.py b/test-cli/test/tests/qwifi.py index 684cb34..0944dd7 100644 --- a/test-cli/test/tests/qwifi.py +++ b/test-cli/test/tests/qwifi.py @@ -1,6 +1,7 @@ import unittest import sh import re +import json class Qwifi(unittest.TestCase): @@ -9,6 +10,7 @@ class Qwifi(unittest.TestCase): __bwexpected = None __port = None params = None + __bwreal = None # varlist content: serverip, bwexpected, port def __init__(self, testname, testfunc, varlist): @@ -46,8 +48,8 @@ class Qwifi(unittest.TestCase): if result: # execute iperf command against the server try: - p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", - self.__port, _timeout=20) + p = sh.iperf3("-c", self.__serverip, "-n", self.__numbytestx, "-f", "m", "-p", self.__port, + "-J", _timeout=20) except sh.TimeoutException: self.fail("failed: iperf timeout reached") @@ -56,18 +58,15 @@ class Qwifi(unittest.TestCase): if p.stdout == "": self.fail("failed: error executing iperf command") # analyze output string - # split by lines - lines = p.stdout.splitlines() - # get first line - dat = lines[1].decode('ascii') - # search for the BW value - a = re.search("\d+(\.\d)? Mbits/sec", dat) - b = a.group().split() - bwreal = b[0] + data = json.loads(p.stdout.decode('ascii')) + self.__bwreal = float(data['end']['sum_received']['bits_per_second']) / 1024 / 1024 + # save result file + with open('/tmp/wifi-iperf.json', 'w') as outfile: + json.dump(data, outfile) # check if BW is in the expected range - self.failUnless(float(bwreal) > float(self.__bwexpected) * 0.9, - "failed: speed is lower than spected. Speed(MB/s)" + str(bwreal)) + self.failUnless(self.__bwreal > float(self.__bwexpected) * 0.9, + "failed: speed is lower than spected. Speed(Mbits/s)" + str(self.__bwreal)) else: self.fail("failed: could not complete iperf command") else: @@ -78,3 +77,14 @@ class Qwifi(unittest.TestCase): self.fail("failed: wifi module is not connected to the router.") else: self.fail("failed: couldn't execute iw command") + + def getresults(self): + # resultlist is a python list of python dictionaries + resultlist = [ + { + "desc": "iperf3 output", + "data": "/tmp/wifi-iperf.json", + "type": "file" + } + ] + return resultlist |