diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-03-06 12:46:27 +0100 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-03-06 12:46:27 +0100 |
commit | 9f07a57d89a927aa9b172c1bf20c7ab563658c73 (patch) | |
tree | 3691cb8d09862db185a628c7bb07df6dd50a64bb /test-cli/test | |
parent | 98d40cecc9818360984188755e455aa53933aab0 (diff) | |
download | board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.zip board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.gz board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.bz2 |
Fixed multiple errors.
Diffstat (limited to 'test-cli/test')
-rw-r--r-- | test-cli/test/helpers/int_registers.py (renamed from test-cli/test/helpers/get_dieid.py) | 46 | ||||
-rw-r--r-- | test-cli/test/helpers/testsrv_db.py | 26 | ||||
-rw-r--r-- | test-cli/test/runners/simple.py | 39 | ||||
-rw-r--r-- | test-cli/test/tests/qamp.py | 25 | ||||
-rw-r--r-- | test-cli/test/tests/qaudio.py | 35 | ||||
-rw-r--r-- | test-cli/test/tests/qbutton.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qduplex_ser.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qeeprom.py | 3 | ||||
-rw-r--r-- | test-cli/test/tests/qethernet.py | 3 | ||||
-rw-r--r-- | test-cli/test/tests/qflash.py | 3 | ||||
-rw-r--r-- | test-cli/test/tests/qi2c.py | 3 | ||||
-rw-r--r-- | test-cli/test/tests/qiperf.py | 53 | ||||
-rw-r--r-- | test-cli/test/tests/qnand.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qram.py | 5 | ||||
-rw-r--r-- | test-cli/test/tests/qrtc.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qscreen.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qserial.py | 4 | ||||
-rw-r--r-- | test-cli/test/tests/qusb.py | 28 | ||||
-rw-r--r-- | test-cli/test/tests/qwifi.py | 14 |
19 files changed, 141 insertions, 168 deletions
diff --git a/test-cli/test/helpers/get_dieid.py b/test-cli/test/helpers/int_registers.py index 48e724e..cf2e35b 100644 --- a/test-cli/test/helpers/get_dieid.py +++ b/test-cli/test/helpers/int_registers.py @@ -21,24 +21,36 @@ def read(addr): os.close(fd) return "%08X" % retval[0] -def getRegisters(model): - if model.find("IGEP0046") == 0: + +def get_die_id(modelid): + dieid = "" + + # get registers + if modelid.find("IGEP0046") == 0: registers = [0x021BC420, 0x021BC410] - elif model.find("IGEP0034") == 0 or model.find("SOPA0000") == 0: + elif modelid.find("IGEP0034") == 0 or modelid.find("SOPA0000") == 0: + # registers: mac_id0_lo, mac_id0_hi, mac_id1_lo, mac_id1_hi registers = [0x44e10630, 0x44e10634, 0x44e10638, 0x44e1063C] - elif model.find("OMAP3") == 0: + elif modelid.find("OMAP3") == 0: registers = [0x4830A224, 0x4830A220, 0x4830A21C, 0x4830A218] - elif model.find("OMAP5") == 0: + elif modelid.find("OMAP5") == 0: registers = [0x4A002210, 0x4A00220C, 0x4A002208, 0x4A002200] - return registers - -def genDieid(modelid): - registers = getRegisters(modelid) - id = "" - for i in range(len(registers)): - id=id+(read(registers[i])) - return id - -#if __name__ == "__main__": - #registers = [0x021BC420, 0x021BC410] - #print(main(registers)) + else: + raise Exception('modelid not defined') + + for rg in registers: + dieid = dieid + read(rg) + return dieid + + +def get_mac(modelid): + mac = None + + if modelid.find("IGEP0034") == 0 or modelid.find("SOPA0000") == 0: + # registers: mac_id0_lo, mac_id0_hi + registers = [0x44e10630, 0x44e10634] + mac = "" + for rg in registers: + mac = mac + read(rg) + + return mac diff --git a/test-cli/test/helpers/testsrv_db.py b/test-cli/test/helpers/testsrv_db.py index b7b75b1..d937d3e 100644 --- a/test-cli/test/helpers/testsrv_db.py +++ b/test-cli/test/helpers/testsrv_db.py @@ -27,11 +27,13 @@ class TestSrv_Database(object): def create_board(self, processor_id, model_id, variant, station, bmac=None): '''create a new board''' if bmac is None: - sql = "SELECT isee.f_create_board('{}', '{}', '{}', NULL, '{}');".format(processor_id, model_id, variant, - station) + sql = "SELECT * FROM isee.f_create_board('{}', '{}', '{}', NULL, '{}');".format(processor_id, model_id, + variant, + station) else: - sql = "SELECT isee.f_create_board('{}', '{}', '{}', '{}', '{}');".format(processor_id, model_id, variant, - bmac, station) + sql = "SELECT * FROM isee.f_create_board('{}', '{}', '{}', '{}', '{}');".format(processor_id, model_id, + variant, + bmac, station) # print('>>>' + sql) try: res = self.__sqlObject.db_execute_query(sql) @@ -57,7 +59,7 @@ class TestSrv_Database(object): def get_test_params_list(self, testid): '''get the board test list''' - sql = "SELECT * FROM isee.f_get_test_params_list('{}')".format(testid) + sql = "SELECT * FROM isee.f_get_test_params_list({})".format(testid) # print('>>>' + sql) try: res = self.__sqlObject.db_execute_query(sql) @@ -75,7 +77,7 @@ class TestSrv_Database(object): try: res = self.__sqlObject.db_execute_query(sql) # print(res) - return res + return res[0][0] except Exception as err: r = find_between(str(err), '#', '#') # print(r) @@ -83,12 +85,10 @@ class TestSrv_Database(object): def run_test(self, testid_ctl, testid): '''get the board test list''' - sql = "SELECT * FROM isee.f_run_test('{}','{}')".format(testid_ctl, testid) + sql = "SELECT isee.f_run_test({},{})".format(testid_ctl, testid) # print('>>>' + sql) try: - res = self.__sqlObject.db_execute_query(sql) - # print(res) - return res + self.__sqlObject.db_execute_query(sql) except Exception as err: r = find_between(str(err), '#', '#') # print(r) @@ -96,12 +96,10 @@ class TestSrv_Database(object): def finish_test(self, testid_ctl, testid, newstatus): '''get the board test list''' - sql = "SELECT * FROM isee.f_finish_test('{}','{}','{}')".format(testid_ctl, testid, newstatus) + sql = "SELECT isee.f_finish_test({},{},'{}')".format(testid_ctl, testid, newstatus) # print('>>>' + sql) try: - res = self.__sqlObject.db_execute_query(sql) - # print(res) - return res + self.__sqlObject.db_execute_query(sql) except Exception as err: r = find_between(str(err), '#', '#') # print(r) diff --git a/test-cli/test/runners/simple.py b/test-cli/test/runners/simple.py index 084a5b8..dd7c74d 100644 --- a/test-cli/test/runners/simple.py +++ b/test-cli/test/runners/simple.py @@ -12,7 +12,6 @@ from test.helpers.globalVariables import globalVar from test.helpers.testsrv_db import TestSrv_Database - class SimpleTestRunner: """ A Test Runner that shows results in a simple human-readable format. @@ -33,15 +32,12 @@ class SimpleTestRunner: self.stream.write(message) def run(self, test): - """ Run the given test case or Test Suite. - - """ + """ Run the given test case or Test Suite. """ result = TextTestResult(self, self.__pgObj) test(result) - result.testsRun - # self.writeUpdate("---------------------------------------------\n") return result + class TextTestResult(unittest.TestResult): # Print in terminal with colors PASS = '\033[32mPASS\033[0m\n' @@ -60,14 +56,11 @@ class TextTestResult(unittest.TestResult): unittest.TestResult.startTest(self, test) self.runner.writeUpdate("%s : " % test.shortDescription()) # SEND TO DB THE UPDATE THAT WE RUN EACH TEST - self.__pgObj.update_set_test_row(globalVar.station, globalVar.testid_ctl, globalVar.g_uuid, test.shortDescription(), "RUNNING") - # psdb = TestSrv_Database() - # psdb.open("setup.xml") - # psdb.update_set_test_row(globalVar.station, globalVar.testid_ctl, globalVar.g_uuid, test.shortDescription(), "RUNNING") + self.__pgObj.run_test(test.params["testidctl"], test.params["testid"]) def addSuccess(self, test): unittest.TestResult.addSuccess(self, test) - self.result=self.PASS + self.result = self.PASS def addError(self, test, err): unittest.TestResult.addError(self, test, err) @@ -76,25 +69,17 @@ class TextTestResult(unittest.TestResult): def addFailure(self, test, err): unittest.TestResult.addFailure(self, test, err) - test.longMessage=err[1] + test.longMessage = err[1] self.result = self.FAIL def stopTest(self, test): unittest.TestResult.stopTest(self, test) # display: print test result self.runner.writeUpdate(self.result) - # DB: PREPARE THE DATA TO BE INSERTED - dbdata = {} - dbdata['uuid'] = globalVar.g_uuid - dbdata['name'] = test.shortDescription() - dbdata['result'] = self.result - dbdata['msg'] = str(test.longMessage) - #CONVERT FANCY FAIL AND PASS - if self.result==self.PASS: simple_result="TRUE" - if self.result == self.FAIL: simple_result = "FALSE" - elif self.result == self.ERROR: simple_result = "FALSE" - #SEND TO DB THE RESULT OF THE TEST - # psdb = TestSrv_Database() - # psdb.open("setup.xml") - self.__pgObj.add_test_to_batch(globalVar.g_uuid, test.shortDescription(), globalVar.testid_ctl, simple_result, globalVar.g_mid, test.longMessage) - # psdb.add_test_to_batch(globalVar.g_uuid, test.shortDescription(), globalVar.testid_ctl, simple_result, globalVar.g_mid, test.longMessage) + # SEND TO DB THE RESULT OF THE TEST + if self.result == self.PASS: + status = "TEST_COMPLETE" + else: + status = "TEST_FAILED" + self.__pgObj.finish_test(test.params["testidctl"], test.params["testid"], status) + diff --git a/test-cli/test/tests/qamp.py b/test-cli/test/tests/qamp.py index 3e38ce9..cf18fc5 100644 --- a/test-cli/test/tests/qamp.py +++ b/test-cli/test/tests/qamp.py @@ -3,10 +3,13 @@ import unittest import serial import time + class Qamp(unittest.TestCase): + params = None - #varlist: undercurrent, overcurrent + # varlist: undercurrent, overcurrent def __init__(self, testname, testfunc, varlist): + self.params = varlist self._current = 0.0 if "undercurrent" in varlist: self._undercurrent = varlist["undercurrent"] @@ -16,7 +19,7 @@ class Qamp(unittest.TestCase): self._overcurrent = varlist["overcurrent"] else: raise Exception('overcurrent param inside Qamp must be defined') - self._vshuntfactor=16384.0 + self._vshuntfactor = 16384.0 self._ser = serial.Serial() self._ser.port = '/dev/ttyUSB0' self._ser.baudrate = 115200 @@ -34,19 +37,19 @@ class Qamp(unittest.TestCase): def execute(self): # Open Serial port ttyUSB0 - error=0 + error = 0 try: self._ser.open() except: self.fail("failed: IMPOSSIBLE OPEN USB-SERIAL PORT ( {} )".format(self._ser.port)) - error=1 - if error==0: + error = 1 + if error == 0: # Clean input and output buffer of serial port self._ser.flushInput() self._ser.flushOutput() # Send command to read Voltage at Shunt resistor # Prepare cmd - cmd = ('at+in?\n\r') + cmd = 'at+in?\n\r' i = 0 # Write, 1 by 1 byte at a time to avoid hanging of serial receiver code of listener, emphasis being made at sleep of 50 ms. @@ -57,7 +60,7 @@ class Qamp(unittest.TestCase): # Read, 1 by 1 byte res = [] - while (self._ser.inWaiting() > 0): # if incoming bytes are waiting to be read from the serial input buffer + while self._ser.inWaiting() > 0: # if incoming bytes are waiting to be read from the serial input buffer res.append(self._ser.read(1).decode('ascii')) # read the bytes and convert from binary array to ASCII string = ''.join(res) @@ -65,12 +68,8 @@ class Qamp(unittest.TestCase): self._current = float(int(string, 0)) / self._vshuntfactor print(self._current) # In order to give a valid result it is importarnt to define an under current value - if (self._current > float(self._overcurrent)): + if self._current > float(self._overcurrent): self.fail("failed: OVERCURRENT DETECTED ( {} )".format(self._current)) - if (self._current < float(self._undercurrent)): + if self._current < float(self._undercurrent): self.fail("failed: UNDERCURRENT DETECTED ( {} )".format(self._current)) - - - - diff --git a/test-cli/test/tests/qaudio.py b/test-cli/test/tests/qaudio.py index fe57be2..ef4da67 100644 --- a/test-cli/test/tests/qaudio.py +++ b/test-cli/test/tests/qaudio.py @@ -1,38 +1,39 @@ from test.helpers.syscmd import SysCommand import unittest -#class name + + class Qaudio(unittest.TestCase): - # Initialize the variables + params = None - def __init__(self, testname, testfunc, dtmfFile): - # Doing this we will initialize the class and later on perform a particular method inside this class + def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qaudio, self).__init__(testfunc) self._testMethodDoc = testname - self._dtmfFile=dtmfFile - self.__sum=0 - self.__refSum = 25 # 1+3+5+7+9 + if "dtmfFile" in varlist: + self._dtmfFile = varlist["dtmfFile"] + else: + raise Exception('undercurrent param inside Qamp must be defined') + self.__sum = 0 + self.__refSum = 25 # 1+3+5+7+9 def execute(self): - str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" #.format(self.__dtmfFile) + str_cmd = "aplay test/files/dtmf-13579.wav & arecord -r 8000 -d 1 recorded.wav" # .format(self.__dtmfFile) audio_loop = SysCommand("command-name", str_cmd) - if audio_loop.execute() == -1:# BUG: Returns -1 but work + if audio_loop.execute() == -1: # BUG: Returns -1 but work lines = audio_loop.getOutput().splitlines() str_cmd = "multimon -t wav -a DTMF recorded.wav -q" dtmf_decoder = SysCommand("command-name", str_cmd) - a=dtmf_decoder.execute() - if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work + a = dtmf_decoder.execute() + if dtmf_decoder.execute() == -1: # BUG: Returns -1 but work self.__raw_out = dtmf_decoder.getOutput() if self.__raw_out == "": - return -1 + self.fail("failed: can not execute multimon command") lines = dtmf_decoder.getOutput().splitlines() for i in range(0, 5): - aux=[int(s) for s in lines[i].split() if s.isdigit()] - self.__sum=self.__sum+aux[0] + aux = [int(s) for s in lines[i].split() if s.isdigit()] + self.__sum = self.__sum + aux[0] self.failUnless(self.__sum == self.__refSum), "failed: incorrect dtmf code" + str(self.__sum) else: self.fail("failed: fail reading recorded file") - return -1 else: self.fail("failed: fail playing/recording file") - return -1 - return 0
\ No newline at end of file diff --git a/test-cli/test/tests/qbutton.py b/test-cli/test/tests/qbutton.py index 4718924..46ddde0 100644 --- a/test-cli/test/tests/qbutton.py +++ b/test-cli/test/tests/qbutton.py @@ -1,11 +1,14 @@ from test.helpers.syscmd import SysCommand import unittest -import uuid import time + class Qbutton(unittest.TestCase): + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist + super(Qbutton, self).__init__(testfunc) if "gpio" in varlist: self.__gpio = varlist["gpio"] else: diff --git a/test-cli/test/tests/qduplex_ser.py b/test-cli/test/tests/qduplex_ser.py index 837b4d0..46fb5db 100644 --- a/test-cli/test/tests/qduplex_ser.py +++ b/test-cli/test/tests/qduplex_ser.py @@ -1,12 +1,14 @@ -from test.helpers.syscmd import SysCommand import unittest import uuid import serial import time + class Qduplex(unittest.TestCase): + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qduplex, self).__init__(testfunc) if "port1" in varlist: self.__port1 = varlist["port1"] diff --git a/test-cli/test/tests/qeeprom.py b/test-cli/test/tests/qeeprom.py index acdc1f6..d2c55ef 100644 --- a/test-cli/test/tests/qeeprom.py +++ b/test-cli/test/tests/qeeprom.py @@ -3,12 +3,13 @@ import unittest class Qeeprom(unittest.TestCase): - + params = None __position = None __eeprompath = None # varlist: position, eeprompath def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qeeprom, self).__init__(testfunc) self._testMethodDoc = testname if "position" in varlist: diff --git a/test-cli/test/tests/qethernet.py b/test-cli/test/tests/qethernet.py index adee67f..1d4c9bc 100644 --- a/test-cli/test/tests/qethernet.py +++ b/test-cli/test/tests/qethernet.py @@ -9,8 +9,11 @@ class Qethernet(unittest.TestCase): __bind = None __bwexpected = None __port = None + params = None + #varlist content: serverip, bwexpected, port, (optional)bind def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qethernet, self).__init__(testfunc) if "serverip" in varlist: self.__serverip = varlist["serverip"] diff --git a/test-cli/test/tests/qflash.py b/test-cli/test/tests/qflash.py index 0c3fcb5..59ed13d 100644 --- a/test-cli/test/tests/qflash.py +++ b/test-cli/test/tests/qflash.py @@ -2,9 +2,12 @@ from test.helpers.syscmd import SysCommand import unittest from test.helpers.globalVariables import globalVar + class Qflasher(unittest.TestCase): + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qflasher, self).__init__(testfunc) self._testMethodDoc = testname model=globalVar.g_mid diff --git a/test-cli/test/tests/qi2c.py b/test-cli/test/tests/qi2c.py index 2f14424..71eb64e 100644 --- a/test-cli/test/tests/qi2c.py +++ b/test-cli/test/tests/qi2c.py @@ -1,9 +1,12 @@ from test.helpers.syscmd import SysCommand import unittest + class Qi2c(unittest.TestCase): + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qi2c, self).__init__(testfunc) if "busnum" in varlist: self.__busnum = varlist["busnum"] diff --git a/test-cli/test/tests/qiperf.py b/test-cli/test/tests/qiperf.py deleted file mode 100644 index 126b6ee..0000000 --- a/test-cli/test/tests/qiperf.py +++ /dev/null @@ -1,53 +0,0 @@ -from test.helpers.syscmd import SysCommand - - -class QIperf(object): - __sip = None - __raw_out = None - __MB_req = None - __MB_real = None - __BW_real = None - __dat_list = None - __bind = None - - def __init__(self, sip = None): - if sip is not None: - self.__sip = sip - self.__MB_req = '10' - - def execute(self, sip = None, bind = None): - if sip is not None: - self.__sip = sip - - if bind is None: - str_cmd = "iperf -c {} -x CMSV -n {}M".format(self.__sip, self.__MB_req) - else: - self.__bind = bind - str_cmd = "iperf -c {} -x CMSV -n {}M -B {}".format(self.__sip, self.__MB_req, self.__bind) - t = SysCommand("iperf", str_cmd) - if t.execute() == 0: - self.__raw_out = t.getOutput() - if self.__raw_out == "": - return -1 - lines = t.getOutput().splitlines() - dat = lines[1] - dat = dat.decode('ascii') - dat_list = dat.split( ) - for d in dat_list: - a = dat_list.pop(0) - if a == "sec": - break - self.__MB_real = dat_list[0] - self.__BW_real = dat_list[2] - self.__dat_list = dat_list - print(self.__MB_real) - print(self.__BW_real) - else: - return -1 - return 0 - - def get_Total_MB(self): - return self.__MB_real; - - def get_Total_BW(self): - return self.__MB_real; diff --git a/test-cli/test/tests/qnand.py b/test-cli/test/tests/qnand.py index 9f2cd47..5125c1c 100644 --- a/test-cli/test/tests/qnand.py +++ b/test-cli/test/tests/qnand.py @@ -1,14 +1,15 @@ import unittest import sh -class Qnand(unittest.TestCase): +class Qnand(unittest.TestCase): + params = None __device = "10M" # varlist: device def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qnand, self).__init__(testfunc) - if "device" in varlist: self.__device = varlist["device"] else: diff --git a/test-cli/test/tests/qram.py b/test-cli/test/tests/qram.py index ade7aeb..cc75b68 100644 --- a/test-cli/test/tests/qram.py +++ b/test-cli/test/tests/qram.py @@ -1,15 +1,16 @@ import unittest import sh -class Qram(unittest.TestCase): +class Qram(unittest.TestCase): + params = None __memsize = "10M" __loops = "1" # varlist: memsize, loops def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qram, self).__init__(testfunc) - if "memsize" in varlist: self.__memsize = varlist["memsize"] else: diff --git a/test-cli/test/tests/qrtc.py b/test-cli/test/tests/qrtc.py index 8e31572..884a290 100644 --- a/test-cli/test/tests/qrtc.py +++ b/test-cli/test/tests/qrtc.py @@ -2,11 +2,13 @@ from test.helpers.syscmd import SysCommand import unittest import time -class Qrtc(unittest.TestCase): +class Qrtc(unittest.TestCase): + params = None __rtc = "/dev/rtc0" def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qrtc, self).__init__(testfunc) if "rtc" in varlist: self.__rtc = varlist["rtc"] diff --git a/test-cli/test/tests/qscreen.py b/test-cli/test/tests/qscreen.py index 87e53b2..aaee628 100644 --- a/test-cli/test/tests/qscreen.py +++ b/test-cli/test/tests/qscreen.py @@ -1,12 +1,14 @@ from test.helpers.syscmd import SysCommand import unittest -import time from test.helpers.cv_display_test import pattern_detect + class Qscreen(unittest.TestCase): + params = None #varlist: display def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qscreen, self).__init__(testfunc) if "display" in varlist: self.__display = varlist["display"] diff --git a/test-cli/test/tests/qserial.py b/test-cli/test/tests/qserial.py index d3e2ee6..d798578 100644 --- a/test-cli/test/tests/qserial.py +++ b/test-cli/test/tests/qserial.py @@ -1,12 +1,14 @@ -from test.helpers.syscmd import SysCommand import unittest import uuid import serial import time + class Qserial(unittest.TestCase): + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qserial, self).__init__(testfunc) if "port" in varlist: self.__port = varlist["port"] diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py index 0390143..70265a5 100644 --- a/test-cli/test/tests/qusb.py +++ b/test-cli/test/tests/qusb.py @@ -1,9 +1,14 @@ from test.helpers.syscmd import SysCommand import unittest + class Qusb(unittest.TestCase): + __numPorts = None + __devLabel = None + params = None def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qusb, self).__init__(testfunc) if "numPorts" in varlist: self.__numPorts = varlist["numPorts"] @@ -14,27 +19,27 @@ class Qusb(unittest.TestCase): self.__devLabel = varlist["devLabel"] else: raise Exception('devLabel param inside Qusb must be defined') - if testname=="USBOTG": + if testname == "USBOTG": self.__usbFileName = "/this_is_an_usb_otg" self.__usbtext = "USBOTG" else: self.__usbFileName = "/this_is_an_usb_host" self.__usbtext = "USBHOST" - self.__numUsbFail=[] + self.__numUsbFail = [] def execute(self): - str_cmd= "lsblk -o LABEL" + str_cmd = "lsblk -o LABEL" lsblk_command = SysCommand("lsblk", str_cmd) if lsblk_command.execute() == 0: self.__raw_out = lsblk_command.getOutput() if self.__raw_out == "": return -1 lines = lsblk_command.getOutput().splitlines() - host_list=[] + host_list = [] for i in range(len(lines)): - if str(lines[i].decode('ascii'))==self.__devLabel: + if str(lines[i].decode('ascii')) == self.__devLabel: host_list.append(i) - if len(host_list)==int(self.__numPorts): + if len(host_list) == int(self.__numPorts): str_cmd = "lsblk -o MOUNTPOINT" lsblk_command = SysCommand("lsblk", str_cmd) if lsblk_command.execute() == 0: @@ -45,13 +50,14 @@ class Qusb(unittest.TestCase): else: lines = lsblk_command.getOutput().splitlines() for i in range(len(host_list)): - file_path=str(lines[host_list[i]].decode('ascii')) + self.__usbFileName + file_path = str(lines[host_list[i]].decode('ascii')) + self.__usbFileName usb_file = open(file_path, 'r') - read=usb_file.read() - if read.find(self.__usbtext)!=-1: + read = usb_file.read() + if read.find(self.__usbtext) != -1: print(file_path + " --> OK!") else: - self.fail("failed: could not read from usb {}".format(lines[host_list[i]].decode('ascii'))) + self.fail( + "failed: could not read from usb {}".format(lines[host_list[i]].decode('ascii'))) self.__numUsbFail.append(host_list[i]) usb_file.close() else: @@ -60,4 +66,4 @@ class Qusb(unittest.TestCase): else: self.fail("failed: reference and real usb host devices number mismatch") else: - self.fail("failed: couldn't execute lsblk command")
\ No newline at end of file + self.fail("failed: couldn't execute lsblk command") diff --git a/test-cli/test/tests/qwifi.py b/test-cli/test/tests/qwifi.py index 154dd52..2a5fa0c 100644 --- a/test-cli/test/tests/qwifi.py +++ b/test-cli/test/tests/qwifi.py @@ -9,14 +9,16 @@ class Qwifi(unittest.TestCase): __bind = None __OKBW = None __port = None + params = None - #varlist: sip, bind, OKBW, port + #varlist: serverip, bind, OKBW, port def __init__(self, testname, testfunc, varlist): + self.params = varlist super(Qwifi, self).__init__(testfunc) - if "sip" in varlist: - self.__sip = varlist["sip"] + if "serverip" in varlist: + self.__serverip = varlist["serverip"] else: - raise Exception('sip param inside Qwifi have been be defined') + raise Exception('serverip param inside Qwifi have been be defined') if "OKBW" in varlist: self.__OKBW = varlist["OKBW"] else: @@ -47,10 +49,10 @@ class Qwifi(unittest.TestCase): if result: # execute iperf command against the server if self.__bind is None: - p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", + p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port) else: - p = sh.iperf("-c", self.__sip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", + p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port, "-B", self.__bind) # check if it was executed succesfully if p.exit_code == 0: |