diff options
Diffstat (limited to 'test-cli/test/tests/qusb.py')
-rw-r--r-- | test-cli/test/tests/qusb.py | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py index 316cef5..d952afc 100644 --- a/test-cli/test/tests/qusb.py +++ b/test-cli/test/tests/qusb.py @@ -7,11 +7,13 @@ from test.helpers.changedir import changedir class Qusb(unittest.TestCase): params = None + __resultlist = None # resultlist is a python list of python dictionaries def __init__(self, testname, testfunc, varlist): self.params = varlist super(Qusb, self).__init__(testfunc) self._testMethodDoc = testname + self.__resultlist = [] def execute(self): # Execute script usb.sh @@ -19,9 +21,19 @@ class Qusb(unittest.TestCase): 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} - q = re.search("/dev/sd\w\d", p.stdout.decode('ascii')) + match = re.search("/dev/sd\w\d", p.stdout.decode('ascii')) # get the first device which matches the pattern - device = q.group(0) + if match: + device = match.group(0) + else: + self.__resultlist.append( + { + "desc": "Test result", + "data": "FAILED: No pendrive found", + "type": "string" + } + ) + self.fail("failed: No pendrive 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 @@ -50,15 +62,43 @@ class Qusb(unittest.TestCase): sh.umount("/mnt/pendrive") # check result if q is None: - self.fail("failed: wrong md5 result.") + self.__resultlist.append( + { + "desc": "Test result", + "data": "FAILED: Wrong md5 result", + "type": "string" + } + ) + self.fail("failed: Wrong md5 result.") else: # umount sh.umount("/mnt/pendrive") - self.fail("failed: unable to copy files.") + self.__resultlist.append( + { + "desc": "Test result", + "data": "FAILED: Unable to copy files to the USB memory device", + "type": "string" + } + ) + self.fail("failed: Unable to copy files to the USB memory device.") else: - self.fail("failed: unable to mount the device.") + self.__resultlist.append( + { + "desc": "Test result", + "data": "FAILED: Unable to mount the USB memory device", + "type": "string" + } + ) + self.fail("failed: Unable to mount the USB memory device.") + + # Test successful + self.__resultlist.append( + { + "desc": "Test result", + "data": "OK", + "type": "string" + } + ) def getresults(self): - # resultlist is a python list of python dictionaries - resultlist = [] - return resultlist + return self.__resultlist |