summaryrefslogtreecommitdiff
path: root/test-cli/test_main.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-07-07 09:57:58 +0200
committerHector Fernandez <hector@iatec.biz>2020-07-07 09:57:58 +0200
commit43f688b414ea182cd9baf06ee83df072c3f563f5 (patch)
tree7195e69d9f6cf28f0627e7db0cbfacaf9c9e2698 /test-cli/test_main.py
parent47827e40f71696e04ad805296dedc44a03451db3 (diff)
downloadboard-43f688b414ea182cd9baf06ee83df072c3f563f5.zip
board-43f688b414ea182cd9baf06ee83df072c3f563f5.tar.gz
board-43f688b414ea182cd9baf06ee83df072c3f563f5.tar.bz2
Added full support for USBLOOP test. Reboot board always if autotest is enabled.
Diffstat (limited to 'test-cli/test_main.py')
-rw-r--r--test-cli/test_main.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index a8eff91..8f82398 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -11,6 +11,7 @@ from test.tests.qram import Qram
from test.tests.qusb import Qusb
from test.tests.qeeprom import Qeeprom
from test.tests.qserial import Qserial
+from test.tests.qusbdual import Qusbdual
from test.tests.qwifi import Qwifi
from test.tests.qrtc import Qrtc
from test.tests.qduplex_ser import Qduplex
@@ -44,6 +45,12 @@ def clear():
_ = call('clear' if os.name == 'posix' else 'cls')
+def reboot_if_autotest():
+ # reset board if AUTOTEST is enabled
+ autotest = psdbObj.get_setup_variable("AUTOTEST_" + globalVar.station)
+ if int(autotest) == 1:
+ os.system('reboot')
+
def create_paramslist(params):
paramlist = {}
for row in params:
@@ -86,8 +93,8 @@ def add_test(suite, testdefname, paramlist):
elif testdefname == "AUDIO":
suite.addTest(Qaudio(testdefname, "execute", paramlist))
return 0
- elif testdefname == "USBDUAL":
- suite.addTest(Qaudio(testdefname, "execute", paramlist))
+ elif testdefname == "USBLOOP":
+ suite.addTest(Qusbdual(testdefname, "execute", paramlist))
return 0
elif testdefname == "DMESG":
tests_manually_executed.append(Qdmesg(testdefname, "execute", paramlist))
@@ -127,6 +134,7 @@ def create_board():
if model_id == "none" or variant == "none":
print("Error: Cannot open DB connection")
loggerObj.getlogger().info("Station error: #Cannot get model and variant information#")
+ reboot_if_autotest()
exit(0)
# get model id
@@ -136,6 +144,7 @@ def create_board():
if "Station" not in globalVar.station:
print("Error: Wrong Station name")
loggerObj.getlogger().info("Station error: #Wrong station name#")
+ reboot_if_autotest()
exit(0)
processor_id = get_die_id(globalVar.g_mid)
@@ -165,6 +174,7 @@ def main():
# Abort
print(
"Error: Wrong previous station state before changing to TESTS_RUNNING state. STATION_ERROR state unexpected.")
+ reboot_if_autotest()
exit(0)
psdbObj.change_station_state(globalVar.station, StationStates.TESTS_RUNNING.name)
@@ -185,6 +195,7 @@ def main():
# Abort
print(
"Error: Wrong previous station state before changing to TESTS_OK state. STATION_ERROR state unexpected.")
+ reboot_if_autotest()
exit(0)
psdbObj.change_station_state(globalVar.station, StationStates.TESTS_OK.name)
# Change state to "EXTRATASKS_RUNNING"
@@ -192,6 +203,7 @@ def main():
# Abort
print(
"Error: Wrong previous station state before changing to EXTRATASKS_RUNNING state. STATION_ERROR state unexpected.")
+ reboot_if_autotest()
exit(0)
psdbObj.change_station_state(globalVar.station, StationStates.EXTRATASKS_RUNNING.name)
# create task control
@@ -227,6 +239,7 @@ def main():
# Abort
print(
"Error: Wrong previous station state before changing to WAITING_FOR_SCANNER state. STATION_ERROR state unexpected.")
+ reboot_if_autotest()
exit(0)
psdbObj.change_station_state(globalVar.station, StationStates.WAITING_FOR_SCANNER.name)
@@ -256,20 +269,18 @@ def main():
else:
psdbObj.update_taskctl_status(globalVar.taskid_ctl, "TASK_BOARD_FAIL")
loggerObj.getlogger().info("Station error: #Unable to complete extra tasks#")
-
else:
# Change state to "TESTS_FAILED"
if psdbObj.read_station_state(globalVar.station) == StationStates.STATION_ERROR.name:
# Abort
print(
"Error: Wrong previous station state before changing to TESTS_FAILED state. STATION_ERROR state unexpected.")
+ reboot_if_autotest()
exit(0)
psdbObj.change_station_state(globalVar.station, StationStates.TESTS_FAILED.name)
# reset board if AUTOTEST is enabled
- autotest = psdbObj.get_setup_variable("AUTOTEST_" + globalVar.station)
- if int(autotest) == 1:
- os.system('reboot')
+ reboot_if_autotest()
if __name__ == "__main__":
@@ -287,12 +298,14 @@ if __name__ == "__main__":
# Abort
print("Error: Cannot parse setup.xml file")
loggerObj.getlogger().info("Station error: #Cannot parse XML configuration file#")
+ reboot_if_autotest()
exit(0)
# Try to connect to the DB, according to setup.xml configuration
if not psdbObj.open(xmlObj):
print("Error: Cannot open DB connection")
loggerObj.getlogger().info("Station error: #Cannot open DB connection#")
+ reboot_if_autotest()
exit(0)
# get station name
@@ -311,6 +324,9 @@ if __name__ == "__main__":
# Change state to "TESTS_CHECKING_ENV"
psdbObj.change_station_state(globalVar.station, StationStates.TESTS_CHECKING_ENV.name)
+ # Wait before beginning
+ time.sleep(2)
+
# Look for a barcode scanner
qr = QRReader()
if qr.openQR():
@@ -319,6 +335,7 @@ if __name__ == "__main__":
# Abort
print("Error: Cannot find a barcode scanner.")
loggerObj.getlogger().info("Station error: #Cannot find a barcode scanner#")
+ reboot_if_autotest()
exit(0)
# Look for an amperimeter
@@ -327,12 +344,14 @@ if __name__ == "__main__":
# Abort
print("Error: Cannot open an amperimeter COM port.")
loggerObj.getlogger().info("Station error: #Cannot open an amperimeter COM port#")
+ reboot_if_autotest()
exit(0)
if not amp.hello():
if not amp.hello():
# Abort
print("Error: Cannot open find an amperimeter.")
loggerObj.getlogger().info("Station error: #Cannot open find an amperimeter#")
+ reboot_if_autotest()
exit(0)
# Execute main