summaryrefslogtreecommitdiff
path: root/scripts/PYTHON_SOFTWARE/test_main.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
committerManel Caro <mcaro@iseebcn.com>2019-03-09 21:25:56 +0100
commit9332c933fc05f42882640c9a4e35fab09854af84 (patch)
tree2b9b00b5a411b27f9705603c0d93b8925afd4677 /scripts/PYTHON_SOFTWARE/test_main.py
downloadboard-9332c933fc05f42882640c9a4e35fab09854af84.zip
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.gz
board-9332c933fc05f42882640c9a4e35fab09854af84.tar.bz2
Board: Client Test Suite Initial Commit
Diffstat (limited to 'scripts/PYTHON_SOFTWARE/test_main.py')
-rw-r--r--scripts/PYTHON_SOFTWARE/test_main.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/scripts/PYTHON_SOFTWARE/test_main.py b/scripts/PYTHON_SOFTWARE/test_main.py
new file mode 100644
index 0000000..6a8ed7e
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test_main.py
@@ -0,0 +1,101 @@
+from test.helpers.get_dieid import genDieid
+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.runners.simple import SimpleTestRunner
+from test.tests.qbutton import Qbutton
+from test.helpers.syscmd import TestSysCommand
+from test.helpers.syscmd import SysCommand
+from test.tests.qiperf import QIperf
+from test.tests.qethernet import Qethernet
+from test.tests.qaudio import Qaudio
+from test.tests.qram import Qram
+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.qamp import Qamp
+from test.tests.qflash import Qflasher
+from test.helpers.globalVariables import globalVar
+
+# define clear function
+def clear():
+ # check and make call for specific operating system
+ _ = call('clear' if os.name =='posix' else 'cls')
+
+
+def create_board():
+ psdb = TestSrv_Database()
+ psdb.open("setup.xml")
+ tree = XMLParser.parse('setup.xml')
+ root = tree.getroot()
+ suite = unittest.TestSuite()
+ for element in root.iter('board'):
+ # print(str(element.tag) + str(element.attrib))
+ model_id = element.attrib['model']
+ variant = element.attrib['variant']
+ nstation = element.attrib['station']
+ globalVar.g_mid=model_id + "-" + variant
+ globalVar.station=nstation
+ processor_id=genDieid(globalVar.g_mid)
+ print(globalVar.g_mid)
+ print(processor_id)
+ globalVar.g_uuid = psdb.create_board(processor_id, model_id, variant, bmac = None)
+
+def testsuite():
+ psdb=TestSrv_Database()
+ psdb.open("setup.xml")
+ suite = unittest.TestSuite()
+ tests=psdb.getboard_comp_test_list(globalVar.g_uuid)
+ for i in range(len(tests)):
+ #newstr = oldstr.replace("M", "")
+ variables=str(tests[i][0]).split(",")
+ testname=variables[0].replace('(', '')
+ testdes=variables[1]
+ testfunc=variables[2]
+ if len(tests)>2:
+ testparam=variables[3].replace(')', '')
+ testparam = testparam.replace('"', '')
+ testparam = testparam.replace(';', "','")
+ if testparam == "":
+ command = "suite.addTest({}('{}','execute'))".format(testfunc, testname)
+ else:
+ command="suite.addTest({}('{}','execute','{}'))".format(testfunc,testname,testparam)
+ else:
+ print(testname)
+ command = "suite.addTest({}('{}','execute'))".format(testfunc, testname)
+ exec(command)
+ globalVar.testid_ctl=psdb.open_testbatch(globalVar.g_uuid)
+ return suite
+
+
+def finish_test():
+ psdb = TestSrv_Database()
+ psdb.open("setup.xml")
+ psdb.close_testbatch(globalVar.g_uuid, globalVar.testid_ctl)
+
+def main():
+ #addtesttomodel()
+ #addtestdef()
+ create_board()
+ #globalVar.g_uuid = "1f59c654-0cc6-11e8-8d51-e644f56b8edd"
+ try:
+ os.remove("test_results.dat")
+ except:
+ pass
+ runner = SimpleTestRunner()
+ runner.run(testsuite())
+ finish_test()
+
+
+if __name__ == "__main__":
+ clear()
+ main()