summaryrefslogtreecommitdiff
path: root/test-cli/test_main.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-09 19:16:08 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-09 19:16:08 +0100
commitd38c92bfd7b6abe3a52b51b87b1a2949b857d9b4 (patch)
treec1ee6a472e8acb779f016471e11e32ed64fc4355 /test-cli/test_main.py
parentc685367cbd6abf1c6ae442df759e39b25a907d3b (diff)
downloadboard-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.zip
board-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.tar.gz
board-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.tar.bz2
Created function to flash the eeprom memory.
Diffstat (limited to 'test-cli/test_main.py')
-rw-r--r--test-cli/test_main.py62
1 files changed, 46 insertions, 16 deletions
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 0e863dc..f8e3c1a 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -1,15 +1,11 @@
from test.helpers.int_registers import get_die_id
from test.helpers.int_registers import get_mac
from subprocess import call
-import xml.etree.ElementTree as XMLParser
-import errno
-import sys
import os
import unittest
from test.helpers.testsrv_db import TestSrv_Database
from test.helpers.setup_xml import XMLSetup
from test.runners.simple import SimpleTestRunner
-from test.tests.qbutton import Qbutton
from test.helpers.syscmd import TestSysCommand
from test.tests.qethernet import Qethernet
from test.tests.qaudio import Qaudio
@@ -18,17 +14,16 @@ from test.tests.qusb import Qusb
from test.tests.qi2c import Qi2c
from test.tests.qeeprom import Qeeprom
from test.tests.qserial import Qserial
-from test.tests.qscreen import Qscreen
from test.tests.qwifi import Qwifi
from test.tests.qrtc import Qrtc
from test.tests.qduplex_ser import Qduplex
from test.tests.qamper import Qamper
-from test.tests.qflash import Qflasher
from test.tests.qnand import Qnand
from test.helpers.globalVariables import globalVar
import socket
from test.helpers.iseelogger import ISEE_Logger
import logging
+import binascii
psdbObj = TestSrv_Database()
xmlObj = None
@@ -50,8 +45,6 @@ def create_paramslist(params):
def add_test_task(suite, testdefname, paramlist):
- testfunc = None
-
if testdefname == "AUDIO":
suite.addTest(Qaudio(testdefname, "execute", paramlist))
elif testdefname == "RAM":
@@ -62,18 +55,10 @@ def add_test_task(suite, testdefname, paramlist):
suite.addTest(Qeeprom(testdefname, "execute", paramlist))
elif testdefname == "SERIAL":
suite.addTest(Qserial(testdefname, "execute", paramlist))
- # elif testdefname == "HDMI":
- # suite.addTest(Qhdmi(testdefname, "execute", paramlist))
- # elif testdefname == "SCREEN":
- # suite.addTest(Qscreen(testdefname, "execute", paramlist))
- elif testdefname == "BUTTON":
- suite.addTest(Qbutton(testdefname, "execute", paramlist))
elif testdefname == "RTC":
suite.addTest(Qrtc(testdefname, "execute", paramlist))
elif testdefname == "CONSUMPTION":
suite.addTest(Qamper(testdefname, "execute", paramlist))
- # elif testdefname == "SATA":
- # suite.addTest(Qsata(testdefname, "execute", paramlist))
elif testdefname == "DMESG":
suite.addTest(TestSysCommand(testdefname, "execute", paramlist))
elif testdefname == "ETHERNET":
@@ -130,10 +115,55 @@ def create_board():
get_mac(globalVar.g_mid))
+def program_eeprom(eeprompath):
+ # 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
+ data += binascii.unhexlify((get_mac(globalVar.g_mid)).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
+ 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.")
+ break
+ print("Eeprom programmed succesfully.")
+
+
+def flash_nvmemory(flashscript):
+ if os.path.isfile(flashscript):
+ print("a")
+
+
+def create_boardvariables_list(uuid):
+ varlist = {}
+ for row in psdbObj.get_board_variables(globalVar.g_uuid):
+ varname, varvalue = row
+ varlist[varname] = varvalue
+ return varlist
+
+
def main():
+ # initialize the board
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"])
if __name__ == "__main__":