diff options
Diffstat (limited to 'test-cli/test/tests')
-rw-r--r-- | test-cli/test/tests/qduplex_ser.py | 18 | ||||
-rw-r--r-- | test-cli/test/tests/qflash.py | 77 | ||||
-rw-r--r-- | test-cli/test/tests/qserial.py | 8 | ||||
-rw-r--r-- | test-cli/test/tests/qusb.py | 10 |
4 files changed, 26 insertions, 87 deletions
diff --git a/test-cli/test/tests/qduplex_ser.py b/test-cli/test/tests/qduplex_ser.py index 0666363..cb690cb 100644 --- a/test-cli/test/tests/qduplex_ser.py +++ b/test-cli/test/tests/qduplex_ser.py @@ -30,11 +30,7 @@ class Qduplex(unittest.TestCase): # open serial connection self.__serial1 = serial.Serial(self.__port1, self.__baudrate, timeout=1) - self.__serial1.flushInput() - self.__serial1.flushOutput() self.__serial2 = serial.Serial(self.__port2, self.__baudrate, timeout=1) - self.__serial2.flushInput() - self.__serial2.flushOutput() def __del__(self): self.__serial1.close() @@ -43,6 +39,12 @@ class Qduplex(unittest.TestCase): def execute(self): # generate a random uuid test_uuid = str(uuid.uuid4()).encode() + + # clean serial ports + self.__serial1.flushInput() + self.__serial1.flushOutput() + self.__serial2.flushInput() + self.__serial2.flushOutput() # send the uuid through serial port self.__serial1.write(test_uuid) time.sleep(0.05) # there might be a small delay @@ -52,7 +54,13 @@ class Qduplex(unittest.TestCase): if self.__serial2.readline() != test_uuid: self.fail("failed: port {} write/read mismatch".format(self.__port2)) - test_uuid = str(uuid.uuid4()).encode() + time.sleep(0.05) # there might be a small delay + + # clean serial ports + self.__serial1.flushInput() + self.__serial1.flushOutput() + self.__serial2.flushInput() + self.__serial2.flushOutput() # send the uuid through serial port self.__serial2.write(test_uuid) time.sleep(0.05) # there might be a small delay diff --git a/test-cli/test/tests/qflash.py b/test-cli/test/tests/qflash.py deleted file mode 100644 index 59ed13d..0000000 --- a/test-cli/test/tests/qflash.py +++ /dev/null @@ -1,77 +0,0 @@ -from test.helpers.syscmd import SysCommand -import unittest -from test.helpers.globalVariables import globalVar - - -class Qflasher(unittest.TestCase): - params = None - - def __init__(self, testname, testfunc, varlist): - self.params = varlist - super(Qflasher, self).__init__(testfunc) - self._testMethodDoc = testname - model=globalVar.g_mid - if model.find("IGEP0046") == 0: - self._flash_method = "mx6" - self._binlocation="/boot/" - elif model.find("IGEP0034") == 0: - self._flash_method = "nandti" - self._binlocation = "/boot/" - elif model.find("SOPA") == 0: - self._flash_method = "sopaflash" - elif model.find("OMAP3") == 0: - self._flash_method = "nandti" - self._binlocation = "/boot/" - elif model.find("OMAP5") == 0: - self._flash_method = "nandti" - self._binlocation = "/boot/" - - - def execute(self): - # CASE eMMC boards. - if(self._flash_method == "mx6"): - str_cmd= "dd if={}u-boot.imx of=/dev/mmcblk2 bs=512 seek=2 2>&1 >/dev/null".format(self._binlocation) - flash_command = SysCommand("flash_command", str_cmd) - if flash_command.execute() == 0: - str_cmd = "sync" - sync_command = SysCommand("sync_command", str_cmd) - if sync_command.execute() != 0: - self.fail("failed: could not sync") - else: - self.fail("failed: could not complete flash eMMC commands") - # CASE of nandflash boards - elif(self._flash_method == "nandti"): - str_cmd = "nandwrite -p -s 0x0 /dev/mtd0 {}u-boot.img 2>&1 >/dev/null; " \ - "nandwrite -p -s 0x20000 /dev/mtd0 {}u-boot.img 2>&1 >/dev/null; " \ - "nandwrite -p -s 0x40000 /dev/mtd0 {}u-boot.img 2>&1 >/dev/null; " \ - "nandwrite -p -s 0x60000 /dev/mtd0 {}u-boot.img 2>&1 >/dev/null; " \ - "".format(self._binlocation, self._binlocation, self._binlocation, self._binlocation,) - flash_MLO_command = SysCommand("flash_MLO_command", str_cmd) - if flash_MLO_command.execute() == 0: - str_cmd= "nandwrite -p /dev/mtd1 {}u-boot.img 2>&1 >/dev/null".format(self._binlocation) - flash_uBoot_command = SysCommand("flash_command", str_cmd) - if flash_uBoot_command.execute() == 0: - str_cmd = "sync" - sync_command = SysCommand("sync_command", str_cmd) - if sync_command.execute() != 0: - self.fail("failed: could not sync") - else: - self.fail("failed: could not complete flash u-boot commnds") - else: - self.fail("failed: could not complete flash MLO commnd") - - - # CASE of SOPA0000 BOARD. FULL FLASH (u-boot+kernel+rootfs) - elif (self._flash_method == "sopaflash"): - str_cmd = "nandtest /dev/mtd0 >/dev/null" - flash_command = SysCommand("flash_command", str_cmd) - if flash_command.execute() == 0: - str_cmd = "/usr/bin/igep-flash --skip-nandtest --image /opt/firmware/demo-ti-image-*-*.tar* >/dev/null 2>&1" - sync_command = SysCommand("sync_command", str_cmd) - if sync_command.execute() != 0: - self.fail("failed: could not complete flashing procces") - else: - self.fail("failed: could not complete nandtest mtd0") - - else: - self.fail("failed: could not find flash method") diff --git a/test-cli/test/tests/qserial.py b/test-cli/test/tests/qserial.py index 67e3af1..45c9d03 100644 --- a/test-cli/test/tests/qserial.py +++ b/test-cli/test/tests/qserial.py @@ -9,7 +9,7 @@ class Qserial(unittest.TestCase): __port = None __baudrate = None - #varlist: port, baudrate + # varlist: port, baudrate def __init__(self, testname, testfunc, varlist): self.params = varlist super(Qserial, self).__init__(testfunc) @@ -26,8 +26,6 @@ class Qserial(unittest.TestCase): # open serial connection self.__serial = serial.Serial(self.__port, self.__baudrate, timeout=1) - self.__serial.flushInput() - self.__serial.flushOutput() def __del__(self): self.__serial.close() @@ -35,6 +33,9 @@ class Qserial(unittest.TestCase): def execute(self): # generate a random uuid test_uuid = str(uuid.uuid4()).encode() + # clean serial port + self.__serial.flushInput() + self.__serial.flushOutput() # send the uuid through serial port self.__serial.write(test_uuid) time.sleep(0.05) # there might be a small delay @@ -44,4 +45,3 @@ class Qserial(unittest.TestCase): # check if what it was sent is equal to what has been received if self.__serial.readline() != test_uuid: self.fail("failed: port {} write/read mismatch".format(self.__port)) - diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py index 6a004f0..6c22c48 100644 --- a/test-cli/test/tests/qusb.py +++ b/test-cli/test/tests/qusb.py @@ -21,11 +21,19 @@ class Qusb(unittest.TestCase): device = q.group(0) # 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 + try: + p = sh.findmnt("-n", device) + if p.exit_code == 0: + sh.umount(device) + except sh.ErrorReturnCode_1: + # error = 1 means "no found" + pass # mount the device p = sh.mount(device, "/mnt/pendrive") if p.exit_code == 0: # copy files - p = sh.cp("/root/usbtest/usbdatatest.bin", "/root/usbtest/usbdatatest.md5", "/mnt/pendrive") + p = sh.cp("test/files/usbtest/usbdatatest.bin", "test/files/usbtest/usbdatatest.md5", "/mnt/pendrive") if p.exit_code == 0: # check md5 with changedir("/mnt/pendrive/"): |