summaryrefslogtreecommitdiff
path: root/test-cli/test_main.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-13 12:17:51 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-19 21:31:03 +0100
commite74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283 (patch)
tree9532b642b798498ed46dea08623c08314c7c873f /test-cli/test_main.py
parent41ffba6a76a80a7ef4553cb8856393dd209d172e (diff)
downloadboard-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.zip
board-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.tar.gz
board-e74e0a36d9ad6a01c04500f3a24cb0ef5dd0b283.tar.bz2
Added final flashing tasks: eeprom and nand.
Diffstat (limited to 'test-cli/test_main.py')
-rw-r--r--test-cli/test_main.py77
1 files changed, 38 insertions, 39 deletions
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 6e56214..6681d4e 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -23,8 +23,8 @@ from test.helpers.globalVariables import globalVar
import socket
from test.helpers.iseelogger import ISEE_Logger
import logging
-import binascii
-from test.flashers.flasher import flash
+from test.flashers.flasheeprom import flash_eeprom
+from test.flashers.flashmemory import flash_memory
# global variables
psdbObj = TestSrv_Database()
@@ -80,8 +80,6 @@ def add_test_task(suite, testdefname, paramlist):
def create_testsuite():
# create an object TestSuite
suite = unittest.TestSuite()
- # get id of the full test for this board
- globalVar.testid_ctl = psdbObj.open_test(globalVar.g_uuid)
# get list of tests for this board
tests = psdbObj.get_tests_list(globalVar.g_uuid)
# loop in every test for this board
@@ -117,41 +115,9 @@ def create_board():
get_mac(globalVar.g_mid))
-def program_eeprom(eeprompath):
- print("Start programming Eeprom...")
- # check if eeprompath is correct
- if os.path.isfile(eeprompath):
- # create u-boot data struct
- data = bytearray()
- data += (2029785358).to_bytes(4, 'big') # magicid --> 0x78FC110E
- data += bytearray([0, 0, 0, 0]) # crc32 = 0
- data += bytearray(globalVar.g_uuid + "\0",
- 'ascii') # uuid --> 'c0846c8a-5fa5-11ea-8576-f8b156ac62d7' and \0 at the end
- mac0 = get_mac(globalVar.g_mid)
- data += binascii.unhexlify(mac0.replace(':', '')) # mac0 --> 'f8:b1:56:ac:62:d7'
- data += bytearray([0, 0, 0, 0, 0, 0]) # mac1 --> 0:0:0:0:0:0
- # calculate crc
- crc = (binascii.crc32(data, 0)).to_bytes(4, 'big')
- data[4:8] = crc
- # write into eeprom and read back
- f = open(eeprompath, "r+b")
- f.write(data)
- f.seek(0)
- data_rx = f.read(57)
- for i in range(57):
- if data_rx[i] != data[i]:
- print("Error while programming eeprom memory.")
- return 1
- print("Eeprom programmed succesfully.")
- return 0
- else:
- print("eeprom memory not found.")
- return 1
-
-
def create_boardvariables_list(uuid):
varlist = {}
- for row in psdbObj.get_board_variables(globalVar.g_uuid):
+ for row in psdbObj.get_board_variables(uuid):
varname, varvalue = row
varlist[varname] = varvalue
return varlist
@@ -160,14 +126,47 @@ def create_boardvariables_list(uuid):
def main():
# initialize the board
create_board()
+ # create a process
+ globalVar.testid_ctl = psdbObj.open_test(globalVar.g_uuid)
+ globalVar.taskid_ctl = psdbObj.create_process(globalVar.testid_ctl)
# create and run tests according to the board type
runner = SimpleTestRunner(psdbObj)
testresult = runner.run(create_testsuite())
# execute aditional tasks, only if the test was succesfull
if testresult.wasSuccessful():
+ # change status to "running tasks"
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_RUNNING")
+ # get extra variables
varlist = create_boardvariables_list(globalVar.g_uuid)
- program_eeprom(varlist["eeprompath"])
- flash(globalVar.g_mid)
+
+ resultmemory = 0
+ # flash eeprom
+ if "eeprompath" in varlist and len(varlist["eeprompath"]) > 0:
+ mac0 = psdbObj.get_board_macaddr(globalVar.g_uuid)
+ resulteeprom = flash_eeprom(varlist["eeprompath"], globalVar.g_uuid, mac0)
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHEEPROM",
+ "TASK_OK" if resulteeprom == 0 else "TASK_FAIL")
+ else:
+ resulteeprom = 0
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHEEPROM", "TASK_SKIP")
+
+ # flash non-volatile memory
+ 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")
+ else:
+ resultmemory = 0
+ psdbObj.create_task_result(globalVar.taskid_ctl, "FLASHMEMORY", "TASK_SKIP")
+
+ # update status with the result
+ if resulteeprom == 0 and resultmemory == 0:
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_OK")
+ else:
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_FAIL")
+ else:
+ # change status to "not done"
+ psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_NOT_DONE")
if __name__ == "__main__":