summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test-cli/setup.xml4
-rw-r--r--test-cli/test/helpers/cmdline.py28
-rw-r--r--test-cli/test_main.py131
3 files changed, 98 insertions, 65 deletions
diff --git a/test-cli/setup.xml b/test-cli/setup.xml
index c904b29..81f0919 100644
--- a/test-cli/setup.xml
+++ b/test-cli/setup.xml
@@ -1,9 +1,7 @@
<?xml version="1.0"?>
<data>
<setup>
- <test idline="1"/> <!-- Test line identify -->
- <board model="SOPA0000" variant="BW2Q-QXXX"/>
- <db dbname="testsrv" type="PgSQLConnection" host="192.168.50.2" port="5432" user="admin" password="Idkfa2009" /> <!-- database setup -->
+ <db dbname="testsrv" type="PgSQLConnection" host="192.168.60.3" port="5432" user="admin" password="Idkfa2009" /> <!-- database setup -->
</setup>
</data>
diff --git a/test-cli/test/helpers/cmdline.py b/test-cli/test/helpers/cmdline.py
new file mode 100644
index 0000000..fad81ac
--- /dev/null
+++ b/test-cli/test/helpers/cmdline.py
@@ -0,0 +1,28 @@
+
+class LinuxKernel:
+
+ __kernel_vars = {}
+
+ def __init__(self):
+ self.parse_kernel_cmdline()
+
+ def parse_kernel_cmdline(self):
+ cmdline = open('/proc/cmdline', 'rb').read().decode()
+ cmd_array = cmdline.split()
+ i = 0
+ for f in cmdline.split():
+ pos = f.find('=')
+ if pos == -1:
+ cmd_array[i - 1] = cmd_array[i - 1] + " " + f
+ cmd_array.remove(cmd_array[i])
+ else:
+ i += 1
+ self.__kernel_vars = {}
+ for f in cmd_array:
+ dat = f.split('=')
+ self.__kernel_vars[dat[0]] = dat[1]
+
+ def getkvar(self, vName, vdefault):
+ if vName in self.__kernel_vars:
+ return self.__kernel_vars[vName]
+ return vdefault
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index ea20cee..3345f53 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -26,6 +26,7 @@ from test.tasks.flasheeprom import flash_eeprom
from test.tasks.flashmemory import flash_memory
from test.helpers.qrreader import QRReader
from test.tasks.generatedmesg import generate_dmesg
+from test.helpers.cmdline import LinuxKernel
# global variables
psdbObj = TestSrv_Database()
@@ -61,8 +62,6 @@ def add_test_task(suite, testdefname, paramlist):
suite.addTest(Qrtc(testdefname, "execute", paramlist))
elif testdefname == "CONSUMPTION":
suite.addTest(Qamper(testdefname, "execute", paramlist))
- elif testdefname == "DMESG":
- suite.addTest(TestSysCommand(testdefname, "execute", paramlist))
elif testdefname == "ETHERNET":
suite.addTest(Qethernet(testdefname, "execute", paramlist))
elif testdefname == "NAND":
@@ -99,8 +98,12 @@ def create_testsuite():
def create_board():
- model_id = xmlObj.gettagKey('board', 'model')
- variant = xmlObj.gettagKey('board', 'variant')
+ cmd = LinuxKernel()
+ model_id = cmd.getkvar("bmodel", "none")
+ variant = cmd.getkvar("bvariant", "none")
+
+ if model_id == "none" or variant == "none":
+ return 1
# get model id
globalVar.g_mid = model_id + "-" + variant
@@ -115,6 +118,7 @@ def create_board():
get_mac(globalVar.g_mid))
print(globalVar.g_uuid)
psdbObj.bond_to_station(globalVar.g_uuid, globalVar.station)
+ return 0
def get_taskvars_list(uuid):
@@ -127,64 +131,67 @@ def get_taskvars_list(uuid):
def main():
# initialize the board
- create_board()
- # create a process
- globalVar.testid_ctl = psdbObj.open_test(globalVar.g_uuid)
- # create and run tests according to the board type
- runner = SimpleTestRunner(psdbObj)
- loggerObj.getlogger().info("Tests running")
- testresult = runner.run(create_testsuite())
- # save dmesg
- generate_dmesg(globalVar.testid_ctl, psdbObj)
-
- # execute aditional tasks, only if the test was succesfull
- 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
-
- # 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)
-
- # flash non-volatile memory
- resultmemory = 0
- if "flashimagepath" in varlist and len(varlist["flashimagepath"]) > 0:
- resultmemory = flash_memory(varlist["flashimagepath"])
- psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHMEMORY",
- "TASK_OK" if resultmemory == 0 else "TASK_FAIL",
- varlist["flashimagepath"])
-
- # update status with the result
- if resulteeprom == 0 and resultmemory == 0:
- alltasksok = True
- psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_OK")
- else:
- psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_FAIL")
-
- if alltasksok:
- # get barcode using the scanner
- loggerObj.getlogger().info("Waiting for barcode scanner")
- qrreceived = False
- while not qrreceived:
- qr = QRReader()
- if qr.openQR():
- # waits 5s to receive a valid code
- if qr.readQRasync(5):
- qrreceived = True
- factorycode = qr.getQRNumber()
- psdbObj.set_factorycode(globalVar.g_uuid, factorycode)
- qr.closeQR()
-
- loggerObj.getlogger().info("Python program finished")
+ res = create_board()
+ if res:
+ loggerObj.getlogger().info("Python program error")
+ else:
+ # create a process
+ globalVar.testid_ctl = psdbObj.open_test(globalVar.g_uuid)
+ # create and run tests according to the board type
+ runner = SimpleTestRunner(psdbObj)
+ loggerObj.getlogger().info("Tests running")
+ testresult = runner.run(create_testsuite())
+ # save dmesg
+ generate_dmesg(globalVar.testid_ctl, psdbObj)
+
+ # execute aditional tasks, only if the test was succesfull
+ 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
+
+ # 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)
+
+ # flash non-volatile memory
+ resultmemory = 0
+ if "flashimagepath" in varlist and len(varlist["flashimagepath"]) > 0:
+ resultmemory = flash_memory(varlist["flashimagepath"])
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHMEMORY",
+ "TASK_OK" if resultmemory == 0 else "TASK_FAIL",
+ varlist["flashimagepath"])
+
+ # update status with the result
+ if resulteeprom == 0 and resultmemory == 0:
+ alltasksok = True
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_OK")
+ else:
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_FAIL")
+
+ if alltasksok:
+ # get barcode using the scanner
+ loggerObj.getlogger().info("Waiting for barcode scanner")
+ qrreceived = False
+ while not qrreceived:
+ qr = QRReader()
+ if qr.openQR():
+ # waits 5s to receive a valid code
+ if qr.readQRasync(5):
+ qrreceived = True
+ factorycode = qr.getQRNumber()
+ psdbObj.set_factorycode(globalVar.g_uuid, factorycode)
+ qr.closeQR()
+
+ loggerObj.getlogger().info("Python program finished")
if __name__ == "__main__":