diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-06-19 13:15:56 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-06-19 13:15:56 +0200 |
commit | 278b5729a44837e37fe13611518c1babc8de00df (patch) | |
tree | 2e6a0350aa9edc5e05e886d32051f263f50f4040 /test-cli/test_main.py | |
parent | 736ddcfe6dc3b5edbab6773f1c6687f6597fa7a3 (diff) | |
download | board-278b5729a44837e37fe13611518c1babc8de00df.zip board-278b5729a44837e37fe13611518c1babc8de00df.tar.gz board-278b5729a44837e37fe13611518c1babc8de00df.tar.bz2 |
Model and variant type are obtained from kernel cmdline instead of setup.xml. Python checks if they exist and can generate an error message to the DB if they are missing.
Diffstat (limited to 'test-cli/test_main.py')
-rw-r--r-- | test-cli/test_main.py | 131 |
1 files changed, 69 insertions, 62 deletions
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__": |