summaryrefslogtreecommitdiff
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
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.
-rw-r--r--test-cli/.idea/workspace.xml5
-rw-r--r--test-cli/test/tests/qusbdual.py10
-rw-r--r--test-cli/test_main.py31
3 files changed, 34 insertions, 12 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml
index 3d15030..1d513ac 100644
--- a/test-cli/.idea/workspace.xml
+++ b/test-cli/.idea/workspace.xml
@@ -3,9 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="4991a6e0-1b9d-4824-9b6e-5ac031eb4816" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qaudio.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qaudio.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qethernet.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qethernet.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qwifi.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qwifi.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qusbdual.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qusbdual.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
diff --git a/test-cli/test/tests/qusbdual.py b/test-cli/test/tests/qusbdual.py
index 054d7f4..fcbb9aa 100644
--- a/test-cli/test/tests/qusbdual.py
+++ b/test-cli/test/tests/qusbdual.py
@@ -1,6 +1,7 @@
import sh
import unittest
import os.path
+import time
class Qusbdual(unittest.TestCase):
@@ -25,10 +26,12 @@ class Qusbdual(unittest.TestCase):
p = sh.modprobe("g_mass_storage", "file=/var/lib/hwtest-files/mass-otg-test.img")
if p.exit_code != 0:
self.fail("failed: Unable to create a mass storage gadget.")
+ # wait to detect the new device
+ time.sleep(3)
# find the mass storage device
try:
p = sh.grep(sh.lsblk("-So", "NAME,VENDOR"), "Linux")
- except sh.ErrorReturnCode as e:
+ except sh.ErrorReturnCode:
self.fail("failed: could not find any mass storage gadget")
device = p.stdout.decode().split(" ")[0]
# mount the mass storage gadget
@@ -40,8 +43,9 @@ class Qusbdual(unittest.TestCase):
for i in range(int(self.__repetitions)):
# copy files
try:
- p = sh.cp("/mnt/station_ramdisk/hdd_gadget/usb-test.bin", "/mnt/station_ramdisk/hdd_gadget/usb-test.bin.md5",
- "/tmp/stationnfs")
+ p = sh.cp("/mnt/station_ramdisk/hdd_gadget/usb-test.bin",
+ "/mnt/station_ramdisk/hdd_gadget/usb-test.bin.md5",
+ "/mnt/station_nfsdisk/")
except sh.ErrorReturnCode as e:
sh.umount("/mnt/station_ramdisk/hdd_gadget")
sh.rmdir("/mnt/station_ramdisk/hdd_gadget")
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