summaryrefslogtreecommitdiff
path: root/test-cli/test/tests
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-06 12:46:27 +0100
commit9f07a57d89a927aa9b172c1bf20c7ab563658c73 (patch)
tree3691cb8d09862db185a628c7bb07df6dd50a64bb /test-cli/test/tests
parent98d40cecc9818360984188755e455aa53933aab0 (diff)
downloadboard-9f07a57d89a927aa9b172c1bf20c7ab563658c73.zip
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.gz
board-9f07a57d89a927aa9b172c1bf20c7ab563658c73.tar.bz2
Fixed multiple errors.
Diffstat (limited to 'test-cli/test/tests')
-rw-r--r--test-cli/test/tests/qamp.py25
-rw-r--r--test-cli/test/tests/qaudio.py35
-rw-r--r--test-cli/test/tests/qbutton.py5
-rw-r--r--test-cli/test/tests/qduplex_ser.py4
-rw-r--r--test-cli/test/tests/qeeprom.py3
-rw-r--r--test-cli/test/tests/qethernet.py3
-rw-r--r--test-cli/test/tests/qflash.py3
-rw-r--r--test-cli/test/tests/qi2c.py3
-rw-r--r--test-cli/test/tests/qiperf.py53
-rw-r--r--test-cli/test/tests/qnand.py5
-rw-r--r--test-cli/test/tests/qram.py5
-rw-r--r--test-cli/test/tests/qrtc.py4
-rw-r--r--test-cli/test/tests/qscreen.py4
-rw-r--r--test-cli/test/tests/qserial.py4
-rw-r--r--test-cli/test/tests/qusb.py28
-rw-r--r--test-cli/test/tests/qwifi.py14
16 files changed, 88 insertions, 110 deletions
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: