diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-07-07 17:27:33 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-07-07 17:27:33 +0200 |
commit | 907b96801230e04d02575a3732a73e452089637b (patch) | |
tree | 361ef65c4845ac34954cbdd6082dc38aefcda282 /test-cli | |
parent | a0b900477098a435b5e434512c491f6bf0365b80 (diff) | |
download | board-907b96801230e04d02575a3732a73e452089637b.zip board-907b96801230e04d02575a3732a73e452089637b.tar.gz board-907b96801230e04d02575a3732a73e452089637b.tar.bz2 |
After USBLOOP test, g_mass_storage must be stopped so the board can be rebooted correctly.
Diffstat (limited to 'test-cli')
-rw-r--r-- | test-cli/.idea/workspace.xml | 1 | ||||
-rw-r--r-- | test-cli/test/tests/qusbdual.py | 7 | ||||
-rw-r--r-- | test-cli/test_main.py | 30 |
3 files changed, 22 insertions, 16 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml index 66fc90e..1d513ac 100644 --- a/test-cli/.idea/workspace.xml +++ b/test-cli/.idea/workspace.xml @@ -3,6 +3,7 @@ <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/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" /> diff --git a/test-cli/test/tests/qusbdual.py b/test-cli/test/tests/qusbdual.py index fcbb9aa..05b22c3 100644 --- a/test-cli/test/tests/qusbdual.py +++ b/test-cli/test/tests/qusbdual.py @@ -32,12 +32,14 @@ class Qusbdual(unittest.TestCase): try: p = sh.grep(sh.lsblk("-So", "NAME,VENDOR"), "Linux") except sh.ErrorReturnCode: + sh.modprobe("-r", "g_mass_storage") self.fail("failed: could not find any mass storage gadget") device = p.stdout.decode().split(" ")[0] # mount the mass storage gadget sh.mkdir("-p", "/mnt/station_ramdisk/hdd_gadget") p = sh.mount("-o", "ro", "/dev/" + device, "/mnt/station_ramdisk/hdd_gadget") if p.exit_code != 0: + sh.modprobe("-r", "g_mass_storage") self.fail("failed: Unable to mount the mass storage gadget.") # execute test for i in range(int(self.__repetitions)): @@ -49,11 +51,13 @@ class Qusbdual(unittest.TestCase): except sh.ErrorReturnCode as e: sh.umount("/mnt/station_ramdisk/hdd_gadget") sh.rmdir("/mnt/station_ramdisk/hdd_gadget") + sh.modprobe("-r", "g_mass_storage") self.fail("failed: Unable to copy files through USB.") # check if the device is still mounted if not os.path.ismount("/mnt/station_ramdisk/hdd_gadget"): sh.rm("/mnt/station_ramdisk/hdd_gadget/*") sh.rmdir("/mnt/station_ramdisk/hdd_gadget") + sh.modprobe("-r", "g_mass_storage") self.fail("failed: USB device unmounted during/after copying files.") # Check md5 try: @@ -61,6 +65,7 @@ class Qusbdual(unittest.TestCase): except sh.ErrorReturnCode as e: sh.umount("/mnt/station_ramdisk/hdd_gadget") sh.rmdir("/mnt/station_ramdisk/hdd_gadget") + sh.modprobe("-r", "g_mass_storage") self.fail("failed: Unable to calculate MD5 of the copied file.") newmd5 = p.stdout.decode().split(" ")[0] with open('/mnt/station_ramdisk/hdd_gadget/usb-test.bin.md5', 'r') as outfile: @@ -69,12 +74,14 @@ class Qusbdual(unittest.TestCase): if newmd5 != oldmd5: sh.umount("/mnt/station_ramdisk/hdd_gadget") sh.rmdir("/mnt/station_ramdisk/hdd_gadget") + sh.modprobe("-r", "g_mass_storage") self.fail("failed: MD5 check failed.") # delete copied files sh.rm("-f", "/mnt/station_nfsdisk/usb-test.bin", "/mnt/station_nfsdisk/usb-test.bin.md5") # Finish sh.umount("/mnt/station_ramdisk/hdd_gadget") sh.rmdir("/mnt/station_ramdisk/hdd_gadget") + sh.modprobe("-r", "g_mass_storage") def getresults(self): return self.__resultlist diff --git a/test-cli/test_main.py b/test-cli/test_main.py index 80dfbe2..942df61 100644 --- a/test-cli/test_main.py +++ b/test-cli/test_main.py @@ -30,6 +30,7 @@ from test.helpers.cmdline import LinuxKernel from test.helpers.amper import Amper from test.enums.StationStates import StationStates import time +import sh # global variables psdbObj = TestSrv_Database() @@ -51,8 +52,7 @@ def execute_station_error(text): while True: currentstate = psdbObj.read_station_state(globalVar.station) if currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() time.sleep(1) @@ -62,12 +62,10 @@ def check_first_state(): while True: currentstate = psdbObj.read_station_state(globalVar.station) if currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() time.sleep(1) elif currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() else: starttime = time.time() while currentstate != StationStates.WAIT_TEST_START.name: @@ -81,25 +79,26 @@ def check_first_state(): while True: currentstate = psdbObj.read_station_state(globalVar.station) if currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() time.sleep(1) elif currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() + + +def reboot_board(): + sh.reboot() + exit(0) def set_next_state(newstate): statewritten = psdbObj.change_station_state(globalVar.station, newstate) if statewritten == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() elif statewritten == StationStates.STATION_ERROR.name: while True: currentstate = psdbObj.read_station_state(globalVar.station) if currentstate == StationStates.STATION_REBOOT.name: - os.system("reboot") - exit(1) + reboot_board() time.sleep(1) @@ -107,8 +106,7 @@ 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") - exit(0) + reboot_board() def create_paramslist(params): |