summaryrefslogtreecommitdiff
path: root/test-cli/test
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test')
-rw-r--r--test-cli/test/helpers/qrreader.py40
-rw-r--r--test-cli/test/tests/qdmesg.py3
-rw-r--r--test-cli/test/tests/qusb.py50
-rw-r--r--test-cli/test/tests/qusbdual.py7
4 files changed, 60 insertions, 40 deletions
diff --git a/test-cli/test/helpers/qrreader.py b/test-cli/test/helpers/qrreader.py
index 908c9db..744db54 100644
--- a/test-cli/test/helpers/qrreader.py
+++ b/test-cli/test/helpers/qrreader.py
@@ -13,18 +13,17 @@ qrdevice_list = [
"SM SM-2D PRODUCT HID KBW"
]
-
-qrkey_list = { 'KEY_0':'0',
- 'KEY_1':'1',
- 'KEY_2':'2',
- 'KEY_3':'3',
- 'KEY_4':'4',
- 'KEY_5':'5',
- 'KEY_6':'6',
- 'KEY_7':'7',
- 'KEY_8':'8',
- 'KEY_9':'9'
- }
+qrkey_list = {'KEY_0': '0',
+ 'KEY_1': '1',
+ 'KEY_2': '2',
+ 'KEY_3': '3',
+ 'KEY_4': '4',
+ 'KEY_5': '5',
+ 'KEY_6': '6',
+ 'KEY_7': '7',
+ 'KEY_8': '8',
+ 'KEY_9': '9'
+ }
class QRReader:
@@ -41,13 +40,13 @@ class QRReader:
for device in devices:
if device.name in qrdevice_list:
self.__myReader['NAME'] = device.name
- #print(self.__myReader['NAME'])
+ # print(self.__myReader['NAME'])
self.__myReader['PATH'] = device.path
- #print(self.__myReader['PATH'])
+ # print(self.__myReader['PATH'])
self.__myReader['PHYS'] = device.phys
- #print(self.__myReader['PHYS'])
+ # print(self.__myReader['PHYS'])
- def IsQR (self):
+ def IsQR(self):
return 'NAME' in self.__myReader
def getQRNumber(self):
@@ -84,7 +83,7 @@ class QRReader:
return True
return False
- def wait_event (self, timeout):
+ def wait_event(self, timeout):
selector.register(self.__dev, selectors.EVENT_READ)
while True:
events = selector.select(timeout);
@@ -114,8 +113,7 @@ class QRReader:
return r
return False
-
-#qr = QRReader()
-#if qr.openQR():
+# qr = QRReader()
+# if qr.openQR():
# print(qr.readQRasync(2))
-#qr.closeQR()
+# qr.closeQR()
diff --git a/test-cli/test/tests/qdmesg.py b/test-cli/test/tests/qdmesg.py
index 45dd4eb..8117deb 100644
--- a/test-cli/test/tests/qdmesg.py
+++ b/test-cli/test/tests/qdmesg.py
@@ -2,6 +2,7 @@ import sh
import os.path
from os import path
+
class Qdmesg:
params = None
__resultlist = None # resultlist is a python list of python dictionaries
@@ -17,11 +18,9 @@ class Qdmesg:
self.pgObj.run_test(self.params["testidctl"], self.params["testid"])
# delete previous file
if path.exists("/tmp/station/dmesg.txt"):
- print("dmesg remove")
os.remove("/tmp/station/dmesg.txt")
# generate file
p = sh.dmesg("--color=never", _out="/tmp/station/dmesg.txt")
- print("Exit code: {}".format(p.exit_code))
if p.exit_code == 0:
# save result
# with open('/tmp/station/dmesg.txt', 'w') as outfile:
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
diff --git a/test-cli/test/tests/qusbdual.py b/test-cli/test/tests/qusbdual.py
index bb295b8..ad95b84 100644
--- a/test-cli/test/tests/qusbdual.py
+++ b/test-cli/test/tests/qusbdual.py
@@ -37,7 +37,7 @@ class Qusbdual(unittest.TestCase):
if p.exit_code != 0:
self.fail("failed: Unable to mount the mass storage gadget.")
# execute test
- for i in range(self.__repetitions):
+ for i in range(int(self.__repetitions)):
# copy files
try:
p = sh.cp("/tmp/station/hdd_gadget/usb-test.bin", "/tmp/station/hdd_gadget/usb-test.bin.md5",
@@ -46,6 +46,11 @@ class Qusbdual(unittest.TestCase):
sh.umount("/tmp/station/hdd_gadget")
sh.rmdir("/tmp/station/hdd_gadget")
self.fail("failed: Unable to copy files through USB.")
+ # check if the device is still mounted
+ if not os.path.ismount("/tmp/station/hdd_gadget"):
+ sh.rm("/tmp/station/hdd_gadget/*")
+ sh.rmdir("/tmp/station/hdd_gadget")
+ self.fail("failed: USB device unmounted during/after copying files.")
# Check md5
try:
p = sh.md5sum("/tmp/stationnfs/usb-test.bin")