summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qusb.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests/qusb.py')
-rw-r--r--test-cli/test/tests/qusb.py26
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'))