summaryrefslogtreecommitdiff
path: root/test-cli
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli')
-rw-r--r--test-cli/.idea/workspace.xml54
-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
-rw-r--r--test-cli/test_main.py6
6 files changed, 81 insertions, 79 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml
index 887bf9b..edde041 100644
--- a/test-cli/.idea/workspace.xml
+++ b/test-cli/.idea/workspace.xml
@@ -2,39 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4991a6e0-1b9d-4824-9b6e-5ac031eb4816" name="Default Changelist" comment="">
- <change afterPath="$PROJECT_DIR$/test/enums/__init__.py" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/test/helpers/DiskHelpers.py" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/test/helpers/cmdline.py" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/test/helpers/usb.py" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/test/tasks/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/setup.xml" beforeDir="false" afterPath="$PROJECT_DIR$/setup.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/files/dtmf-13579.wav" beforeDir="false" afterPath="$PROJECT_DIR$/test/files/dtmf-13579.wav" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/files/test_pattern.png" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/test/flashers/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/enums/StationStates.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/flashers/flasheeprom.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tasks/flasheeprom.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/flashers/flashmemory.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tasks/flashmemory.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/int_registers.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/int_registers.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/psqldb.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/psqldb.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/setup_xml.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/setup_xml.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/syscmd.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/syscmd.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/testsrv_db.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/testsrv_db.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/runners/simple.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/runners/simple.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qamp.py" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qamper.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qamper.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qaudio.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qaudio.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qduplex_ser.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qduplex_ser.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qeeprom.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qeeprom.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qethernet.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qethernet.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qi2c.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qdmesg.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qnand.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qnand.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qram.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qram.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qrtc.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qrtc.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qscreen.py" beforeDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qserial.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qserial.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qtemplate.py" beforeDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/helpers/qrreader.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/qrreader.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qdmesg.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qdmesg.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test/tests/qusb.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qusb.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qwifi.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qwifi.py" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/tests/qusbdual.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qusbdual.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@@ -53,28 +25,31 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectId" id="1YfjUHHfmr4Muw0TDMT8ItsS6oU" />
- <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
+ <component name="ProjectLevelVcsManager" settingsEditedManually="true">
+ <ConfirmationsSetting value="2" id="Add" />
+ </component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
+ <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/test/tests" />
- <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
+ <property name="settings.editor.selected.configurable" value="configurable.group.appearance" />
</component>
<component name="RecentsManager">
- <key name="MoveFile.RECENT_KEYS">
- <recent name="$PROJECT_DIR$/test/scripts" />
- </key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/test/tests" />
<recent name="$PROJECT_DIR$/test/tasks" />
<recent name="$PROJECT_DIR$/test/helpers" />
</key>
+ <key name="MoveFile.RECENT_KEYS">
+ <recent name="$PROJECT_DIR$/test/scripts" />
+ </key>
</component>
<component name="RunManager">
<configuration name="test" type="PythonConfigurationType" factoryName="Python">
@@ -116,6 +91,9 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
+ <component name="VcsManagerConfiguration">
+ <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
+ </component>
<component name="WindowStateProjectService">
<state x="668" y="354" width="640" height="396" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1593588611185">
<screen x="67" y="27" width="1853" height="1053" />
@@ -125,6 +103,10 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="726" y="301" width="524" height="502" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/67.27.1853.1053/1920.0.1920.1080@67.27.1853.1053" timestamp="1593533225414" />
+ <state x="482" y="187" key="SettingsEditor" timestamp="1594023927905">
+ <screen x="67" y="27" width="1853" height="1053" />
+ </state>
+ <state x="482" y="187" key="SettingsEditor/67.27.1853.1053/1920.0.1920.1080@67.27.1853.1053" timestamp="1594023927905" />
<state x="607" y="223" width="762" height="658" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser" timestamp="1593071903123">
<screen x="67" y="27" width="1853" height="1053" />
</state>
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")
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 36d5fb1..a8eff91 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -174,7 +174,7 @@ def main():
runner1 = SimpleTestRunner(psdbObj)
testresult = runner1.run(suite1)
- #Execute manually tests
+ # Execute manually tests
for test in tests_manually_executed:
test.execute()
@@ -232,7 +232,7 @@ def main():
# get barcode using the scanner, only if autotest is disabled
autotest = psdbObj.get_setup_variable("AUTOTEST_" + globalVar.station)
- if autotest == "True":
+ if int(autotest) == 1:
psdbObj.set_factorycode(globalVar.g_uuid, "1234567890") # fake factory code
else:
qrreceived = False
@@ -268,7 +268,7 @@ def main():
# reset board if AUTOTEST is enabled
autotest = psdbObj.get_setup_variable("AUTOTEST_" + globalVar.station)
- if autotest == "True":
+ if int(autotest) == 1:
os.system('reboot')