summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qusb.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-07-06 14:08:27 +0200
committerHector Fernandez <hector@iatec.biz>2020-07-06 14:08:27 +0200
commit0e8e3ecd4b9be71c41008b95950d089819622dff (patch)
tree6c73dd034d81eaf1b5381e6c665277903d369408 /test-cli/test/tests/qusb.py
parent5dcd213c28451ac210703dc5bf9bf538671a0682 (diff)
downloadboard-0e8e3ecd4b9be71c41008b95950d089819622dff.zip
board-0e8e3ecd4b9be71c41008b95950d089819622dff.tar.gz
board-0e8e3ecd4b9be71c41008b95950d089819622dff.tar.bz2
Corrected some errors in USB and USBDUAL tests.
Diffstat (limited to 'test-cli/test/tests/qusb.py')
-rw-r--r--test-cli/test/tests/qusb.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py
index df1248d..b5d152e 100644
--- a/test-cli/test/tests/qusb.py
+++ b/test-cli/test/tests/qusb.py
@@ -1,6 +1,7 @@
import sh
import unittest
from test.helpers.usb import USBDevices
+import os.path
class Qusb(unittest.TestCase):
@@ -33,41 +34,58 @@ class Qusb(unittest.TestCase):
# error = 1 means "no found"
pass
# mount the device
- sh.mkdir("-p", "/mnt/pendrive")
- p = sh.mount(device, "/mnt/pendrive")
+ sh.mkdir("-p", "/tmp/station/pendrive")
+ p = sh.mount(device, "/tmp/station/pendrive")
if p.exit_code != 0:
self.fail("failed: Unable to mount the USB memory device.")
# execute test
- for i in range(self.__repetitions):
+ for i in range(int(self.__repetitions)):
# copy files
try:
p = sh.cp("/var/lib/hwtest-files/usbdatatest.bin",
"/var/lib/hwtest-files/usbdatatest.bin.md5",
- "/mnt/pendrive")
+ "/tmp/station/pendrive")
except sh.ErrorReturnCode as e:
- sh.umount("/mnt/pendrive")
- sh.rmdir("/mnt/pendrive")
+ try:
+ sh.umount("/tmp/station/pendrive")
+ except sh.ErrorReturnCode:
+ pass
+ sh.rmdir("/tmp/station/pendrive")
self.fail("failed: Unable to copy files to the USB memory device.")
+ # check if the device is still mounted
+ if not os.path.ismount("/tmp/station/pendrive"):
+ sh.rm("/tmp/station/pendrive/*")
+ sh.rmdir("/tmp/station/pendrive")
+ self.fail("failed: USB device unmounted during/after copying files.")
# check MD5
try:
- p = sh.md5sum("/mnt/pendrive/usbdatatest.bin")
+ p = sh.md5sum("/tmp/station/pendrive/usbdatatest.bin")
except sh.ErrorReturnCode as e:
- sh.umount("/mnt/pendrive")
- sh.rmdir("/mnt/pendrive")
+ try:
+ sh.umount("/tmp/station/pendrive")
+ except sh.ErrorReturnCode:
+ pass
+ sh.rmdir("/tmp/station/pendrive")
self.fail("failed: Unable to calculate MD5 of the copied file.")
newmd5 = p.stdout.decode().split(" ")[0]
- with open('/mnt/pendrive/usbdatatest.bin.md5', 'r') as outfile:
- oldmd5 = outfile.read()
+ with open('/tmp/station/pendrive/usbdatatest.bin.md5', 'r') as outfile:
+ oldmd5 = outfile.read().rstrip("\n")
outfile.close()
if newmd5 != oldmd5:
- sh.umount("/mnt/pendrive")
- sh.rmdir("/mnt/pendrive")
+ try:
+ sh.umount("/tmp/station/pendrive")
+ except sh.ErrorReturnCode:
+ pass
+ sh.rmdir("/tmp/station/pendrive")
self.fail("failed: MD5 check failed.")
# delete copied files
- sh.rm("-f", "/mnt/pendrive/usbdatatest.bin", "/mnt/pendrive/usbdatatest.bin.md5")
+ sh.rm("-f", "/tmp/station/pendrive/usbdatatest.bin", "/tmp/station/pendrive/usbdatatest.bin.md5")
# Finish
- sh.umount("/mnt/pendrive")
- sh.rmdir("/mnt/pendrive")
+ try:
+ sh.umount("/tmp/station/pendrive")
+ except sh.ErrorReturnCode:
+ pass
+ sh.rmdir("/tmp/station/pendrive")
def getresults(self):
return self.__resultlist