diff options
author | Hector Fernandez <hector@iatec.biz> | 2020-06-25 14:42:42 +0200 |
---|---|---|
committer | Hector Fernandez <hector@iatec.biz> | 2020-06-25 14:42:42 +0200 |
commit | 9ac8a326412b04e4873b883c2f2a056ca0b22480 (patch) | |
tree | 2fe1e5fd870df9147c8eacb19980148d752be268 /test-cli/test/tests | |
parent | db3b1e45c47a1ef23c1ad67114a09cbec0976681 (diff) | |
download | board-9ac8a326412b04e4873b883c2f2a056ca0b22480.zip board-9ac8a326412b04e4873b883c2f2a056ca0b22480.tar.gz board-9ac8a326412b04e4873b883c2f2a056ca0b22480.tar.bz2 |
Modified USB test and the way it finds USB memory storages.
Diffstat (limited to 'test-cli/test/tests')
-rw-r--r-- | test-cli/test/tests/qusb.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py index d952afc..32d99ef 100644 --- a/test-cli/test/tests/qusb.py +++ b/test-cli/test/tests/qusb.py @@ -2,6 +2,7 @@ import sh import unittest import re import os +from test.helpers.usb import USBDevices from test.helpers.changedir import changedir @@ -16,24 +17,20 @@ class Qusb(unittest.TestCase): self.__resultlist = [] def execute(self): - # Execute script usb.sh - test_abspath = os.path.dirname(os.path.abspath(__file__)) - test_abspath = os.path.join(test_abspath, "..", "..") - p = sh.bash(os.path.join(test_abspath, 'test/scripts/usb.sh')) - # Search in the stdout a pattern "/dev/sd + {letter} + {number} - match = re.search("/dev/sd\w\d", p.stdout.decode('ascii')) - # get the first device which matches the pattern - if match: - device = match.group(0) + # get usb device + dev_obj = USBDevices(self.params["xml"]) + if dev_obj.getMassStorage(): + device = dev_obj.getMassStorage()['disk'] + "1" else: self.__resultlist.append( { "desc": "Test result", - "data": "FAILED: No pendrive found", + "data": "FAILED: No USB memory found", "type": "string" } ) - self.fail("failed: No pendrive found.") + self.fail("failed: No USB memory found.") + # create a new folder where the pendrive is going to be mounted sh.mkdir("-p", "/mnt/pendrive") # check if the device is mounted, and umount it @@ -48,11 +45,12 @@ class Qusb(unittest.TestCase): p = sh.mount(device, "/mnt/pendrive") if p.exit_code == 0: # copy files - p = sh.cp(os.path.join(test_abspath, "test/files/usbtest/usbdatatest.bin"), - os.path.join(test_abspath, "test/files/usbtest/usbdatatest.md5"), + test_abspath = os.path.dirname(os.path.abspath(__file__)) + "/../" + p = sh.cp(os.path.join(test_abspath, "files/usbtest/usbdatatest.bin"), + os.path.join(test_abspath, "files/usbtest/usbdatatest.md5"), "/mnt/pendrive") if p.exit_code == 0: - # check md5 + # check with changedir("/mnt/pendrive/"): p = sh.md5sum("-c", "usbdatatest.md5") q = re.search("OK", p.stdout.decode('ascii')) |