summaryrefslogtreecommitdiff
path: root/test-cli
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-04-16 17:09:19 +0200
committerHector Fernandez <hector@iatec.biz>2020-04-16 17:09:19 +0200
commit6a680137694233008005415e22cf889b85baa292 (patch)
treeb0b1c68dab8a76383e18c4d16f231f6171524ea2 /test-cli
parent9f613e33f27f772682ab7d7bd2261a9c4bd014c5 (diff)
downloadboard-6a680137694233008005415e22cf889b85baa292.zip
board-6a680137694233008005415e22cf889b85baa292.tar.gz
board-6a680137694233008005415e22cf889b85baa292.tar.bz2
First release
Diffstat (limited to 'test-cli')
-rw-r--r--test-cli/.idea/workspace.xml4
-rw-r--r--test-cli/test/tests/qethernet.py9
-rw-r--r--test-cli/test/tests/qusb.py9
-rw-r--r--test-cli/test/tests/qwifi.py17
-rw-r--r--test-cli/test_main.py35
5 files changed, 40 insertions, 34 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml
index 611fce4..d36015c 100644
--- a/test-cli/.idea/workspace.xml
+++ b/test-cli/.idea/workspace.xml
@@ -3,7 +3,9 @@
<component name="ChangeListManager">
<list default="true" id="4991a6e0-1b9d-4824-9b6e-5ac031eb4816" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/qrreader.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/qrreader.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qethernet.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qethernet.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qusb.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qusb.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qwifi.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qwifi.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
diff --git a/test-cli/test/tests/qethernet.py b/test-cli/test/tests/qethernet.py
index 027931c..2246029 100644
--- a/test-cli/test/tests/qethernet.py
+++ b/test-cli/test/tests/qethernet.py
@@ -6,12 +6,11 @@ import re
class Qethernet(unittest.TestCase):
__serverip = None
__numbytestx = None
- __bind = None
__bwexpected = None
__port = None
params = None
- #varlist content: serverip, bwexpected, port, (optional)bind
+ # varlist content: serverip, bwexpected, port
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qethernet, self).__init__(testfunc)
@@ -32,7 +31,11 @@ class Qethernet(unittest.TestCase):
def execute(self):
# execute iperf command against the server
- p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port)
+ try:
+ p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p", self.__port,
+ _timeout=20)
+ except sh.TimeoutException:
+ self.fail("failed: iperf timeout reached")
# check if it was executed succesfully
if p.exit_code == 0:
diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py
index 6c22c48..4c177d9 100644
--- a/test-cli/test/tests/qusb.py
+++ b/test-cli/test/tests/qusb.py
@@ -1,6 +1,7 @@
import sh
import unittest
import re
+import os
from test.helpers.changedir import changedir
@@ -14,7 +15,9 @@ class Qusb(unittest.TestCase):
def execute(self):
# Execute script usb.sh
- p = sh.bash('test/scripts/usb.sh')
+ test_abspath = os.path.dirname(os.path.abspath(__file__))
+ test_abspath = os.path.join(test_abspath, "..", "..")
+ p = sh.bash(os.path.join(test_abspath, 'test/scripts/usb.sh'))
# Search in the stdout a pattern "/dev/sd + {letter} + {number}
q = re.search("/dev/sd\w\d", p.stdout.decode('ascii'))
# get the first device which matches the pattern
@@ -33,7 +36,9 @@ class Qusb(unittest.TestCase):
p = sh.mount(device, "/mnt/pendrive")
if p.exit_code == 0:
# copy files
- p = sh.cp("test/files/usbtest/usbdatatest.bin", "test/files/usbtest/usbdatatest.md5", "/mnt/pendrive")
+ p = sh.cp(os.path.join(test_abspath, "test/files/usbtest/usbdatatest.bin"),
+ os.path.join(test_abspath, "test/files/usbtest/usbdatatest.md5"),
+ "/mnt/pendrive")
if p.exit_code == 0:
# check md5
with changedir("/mnt/pendrive/"):
diff --git a/test-cli/test/tests/qwifi.py b/test-cli/test/tests/qwifi.py
index b0b8d6b..684cb34 100644
--- a/test-cli/test/tests/qwifi.py
+++ b/test-cli/test/tests/qwifi.py
@@ -6,12 +6,11 @@ import re
class Qwifi(unittest.TestCase):
__serverip = None
__numbytestx = None
- __bind = None
__bwexpected = None
__port = None
params = None
- # varlist content: serverip, bwexpected, port, (optional)bind
+ # varlist content: serverip, bwexpected, port
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qwifi, self).__init__(testfunc)
@@ -27,10 +26,6 @@ class Qwifi(unittest.TestCase):
self.__port = varlist["port"]
else:
raise Exception('port param inside Qwifi must be defined')
- if "bind" in varlist:
- self.__bind = varlist["bind"]
- else:
- self.__bind = None
self.__numbytestx = "10M"
self._testMethodDoc = testname
@@ -50,12 +45,12 @@ class Qwifi(unittest.TestCase):
p.stdout.decode('ascii'))
if result:
# execute iperf command against the server
- if self.__bind is None:
- p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p",
- self.__port)
- else:
+ try:
p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p",
- self.__port, "-B", self.__bind)
+ self.__port, _timeout=20)
+ except sh.TimeoutException:
+ self.fail("failed: iperf timeout reached")
+
# check if it was executed succesfully
if p.exit_code == 0:
if p.stdout == "":
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 8798cb3..23250ca 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -31,6 +31,7 @@ from test.helpers.qrreader import QRReader
psdbObj = TestSrv_Database()
xmlObj = None
loggerObj = None
+test_abspath = None
# define clear function
@@ -136,34 +137,32 @@ def main():
loggerObj.getlogger().info("Tests running")
testresult = runner.run(create_testsuite())
# execute aditional tasks, only if the test was succesfull
- # if testresult.wasSuccessful():
- if True:
+ if testresult.wasSuccessful():
loggerObj.getlogger().info("Extra tasks running")
# create task control
globalVar.taskid_ctl = psdbObj.open_task(globalVar.g_uuid)
# get extra variables
varlist = get_taskvars_list(globalVar.g_uuid)
- alltasksok = False;
+ alltasksok = False
# flash eeprom
- # resulteeprom = 0
- # if "eeprompath" in varlist and len(varlist["eeprompath"]) > 0:
- # mac0 = psdbObj.get_board_macaddr(globalVar.g_uuid)
- # resulteeprom, eepromdata = flash_eeprom(varlist["eeprompath"], globalVar.g_uuid, mac0)
- # psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHEEPROM",
- # "TASK_OK" if resulteeprom == 0 else "TASK_FAIL", eepromdata)
+ resulteeprom = 0
+ if "eeprompath" in varlist and len(varlist["eeprompath"]) > 0:
+ mac0 = psdbObj.get_board_macaddr(globalVar.g_uuid)
+ resulteeprom, eepromdata = flash_eeprom(varlist["eeprompath"], globalVar.g_uuid, mac0)
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHEEPROM",
+ "TASK_OK" if resulteeprom == 0 else "TASK_FAIL", eepromdata)
# flash non-volatile memory
- # resultmemory = 0
- # if "image" in varlist and len(varlist["image"]) > 0:
- # resultmemory = flash_memory(varlist["image"])
- # psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHMEMORY",
- # "TASK_OK" if resultmemory == 0 else "TASK_FAIL", varlist["image"])
+ resultmemory = 0
+ if "image" in varlist and len(varlist["image"]) > 0:
+ resultmemory = flash_memory(varlist["image"])
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHMEMORY",
+ "TASK_OK" if resultmemory == 0 else "TASK_FAIL", varlist["image"])
# update status with the result
- # if resulteeprom == 0 and resultmemory == 0:
- if True:
+ if resulteeprom == 0 and resultmemory == 0:
alltasksok = True
psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_OK")
else:
@@ -189,6 +188,8 @@ def main():
if __name__ == "__main__":
# Clear the shell screen
clear()
+ test_abspath = os.path.dirname(os.path.abspath(__file__))
+ print(test_abspath)
# create logger
loggerObj = ISEE_Logger(logging.INFO)
@@ -196,7 +197,7 @@ if __name__ == "__main__":
# Try to parse the setup.xml file
try:
- xmlObj = XMLSetup("setup.xml")
+ xmlObj = XMLSetup(os.path.join(test_abspath, "setup.xml"))
except:
print("Error: Cannot parse setup.xml file")
exit(1)