summaryrefslogtreecommitdiff
path: root/test-cli/test_main.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-10 17:37:16 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-11 10:15:20 +0100
commit41ffba6a76a80a7ef4553cb8856393dd209d172e (patch)
treef8ad8a10870ff4b489eb35f04eef643191a7a705 /test-cli/test_main.py
parentd38c92bfd7b6abe3a52b51b87b1a2949b857d9b4 (diff)
downloadboard-41ffba6a76a80a7ef4553cb8856393dd209d172e.zip
board-41ffba6a76a80a7ef4553cb8856393dd209d172e.tar.gz
board-41ffba6a76a80a7ef4553cb8856393dd209d172e.tar.bz2
First release of the test. All the tests work correctly for SOPA0000.
Diffstat (limited to 'test-cli/test_main.py')
-rw-r--r--test-cli/test_main.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index f8e3c1a..6e56214 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -24,7 +24,9 @@ import socket
from test.helpers.iseelogger import ISEE_Logger
import logging
import binascii
+from test.flashers.flasher import flash
+# global variables
psdbObj = TestSrv_Database()
xmlObj = None
loggerObj = None
@@ -116,6 +118,7 @@ def create_board():
def program_eeprom(eeprompath):
+ print("Start programming Eeprom...")
# check if eeprompath is correct
if os.path.isfile(eeprompath):
# create u-boot data struct
@@ -124,12 +127,13 @@ def program_eeprom(eeprompath):
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
- data += binascii.unhexlify((get_mac(globalVar.g_mid)).replace(':', '')) # mac0 --> 'f8:b1:56:ac:62:d7'
+ 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 an validate
+ # write into eeprom and read back
f = open(eeprompath, "r+b")
f.write(data)
f.seek(0)
@@ -137,13 +141,12 @@ def program_eeprom(eeprompath):
for i in range(57):
if data_rx[i] != data[i]:
print("Error while programming eeprom memory.")
- break
+ return 1
print("Eeprom programmed succesfully.")
-
-
-def flash_nvmemory(flashscript):
- if os.path.isfile(flashscript):
- print("a")
+ return 0
+ else:
+ print("eeprom memory not found.")
+ return 1
def create_boardvariables_list(uuid):
@@ -159,11 +162,12 @@ def main():
create_board()
# create and run tests according to the board type
runner = SimpleTestRunner(psdbObj)
- runner.run(create_testsuite())
- # execute aditional tasks
- varlist = create_boardvariables_list(globalVar.g_uuid)
- program_eeprom(varlist["eeprompath"])
- flash_nvmemory(varlist["flashscript"])
+ testresult = runner.run(create_testsuite())
+ # execute aditional tasks, only if the test was succesfull
+ if testresult.wasSuccessful():
+ varlist = create_boardvariables_list(globalVar.g_uuid)
+ program_eeprom(varlist["eeprompath"])
+ flash(globalVar.g_mid)
if __name__ == "__main__":