summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-10 17:37:16 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-11 10:15:20 +0100
commit41ffba6a76a80a7ef4553cb8856393dd209d172e (patch)
treef8ad8a10870ff4b489eb35f04eef643191a7a705
parentd38c92bfd7b6abe3a52b51b87b1a2949b857d9b4 (diff)
downloadboard-41ffba6a76a80a7ef4553cb8856393dd209d172e.zip
board-41ffba6a76a80a7ef4553cb8856393dd209d172e.tar.gz
board-41ffba6a76a80a7ef4553cb8856393dd209d172e.tar.bz2
First release of the test. All the tests work correctly for SOPA0000.
-rw-r--r--test-cli/.idea/workspace.xml21
-rw-r--r--test-cli/setup.xml2
-rw-r--r--test-cli/test/files/test_ok.pngbin18150 -> 0 bytes
-rw-r--r--test-cli/test/files/usbtest/usbdatatest.binbin0 -> 33554431 bytes
-rw-r--r--test-cli/test/files/usbtest/usbdatatest.md51
-rw-r--r--test-cli/test/flashers/__init__.py (renamed from test-cli/test/suites/__init__.py)0
-rw-r--r--test-cli/test/flashers/flasher.py10
-rw-r--r--test-cli/test/flashers/flasher_sopa0000.py13
-rw-r--r--test-cli/test/helpers/int_registers.py3
-rw-r--r--test-cli/test/helpers/uboot_flasher.py0
-rw-r--r--test-cli/test/runners/simple.py1
-rw-r--r--test-cli/test/tests/qduplex_ser.py18
-rw-r--r--test-cli/test/tests/qflash.py77
-rw-r--r--test-cli/test/tests/qserial.py8
-rw-r--r--test-cli/test/tests/qusb.py10
-rw-r--r--test-cli/test_main.py30
16 files changed, 82 insertions, 112 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml
index c2653e0..6b65c5c 100644
--- a/test-cli/.idea/workspace.xml
+++ b/test-cli/.idea/workspace.xml
@@ -2,15 +2,18 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4991a6e0-1b9d-4824-9b6e-5ac031eb4816" name="Default Changelist" comment="">
- <change afterPath="$PROJECT_DIR$/test/scripts/__init__.py" afterDir="false" />
- <change afterPath="$PROJECT_DIR$/test/scripts/flasher_sopa0000" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/test/flashers/flasher_sopa0000.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/button_script.sh" beforeDir="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/helpers/usb.sh" beforeDir="false" afterPath="$PROJECT_DIR$/test/scripts/usb.sh" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/tests/qbutton.py" beforeDir="false" />
+ <change beforePath="$PROJECT_DIR$/setup.xml" beforeDir="false" afterPath="$PROJECT_DIR$/setup.xml" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/test/files/test_ok.png" beforeDir="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/uboot_flasher.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/flashers/flasher.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/suites/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/flashers/__init__.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/qflash.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/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_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_main.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@@ -95,10 +98,10 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="451" y="210" width="1084" height="713" key="#com.intellij.execution.impl.EditConfigurationsDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1583495767719" />
- <state x="663" y="357" width="650" height="390" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1583775329972">
+ <state x="663" y="357" width="650" height="390" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1583852674511">
<screen x="67" y="27" width="1853" height="1053" />
</state>
- <state x="663" y="357" width="650" height="390" key="#com.intellij.fileTypes.FileTypeChooser/67.27.1853.1053@67.27.1853.1053" timestamp="1583775329972" />
+ <state x="663" y="357" width="650" height="390" key="#com.intellij.fileTypes.FileTypeChooser/67.27.1853.1053@67.27.1853.1053" timestamp="1583852674511" />
<state x="726" y="301" width="524" height="502" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1583775384564">
<screen x="67" y="27" width="1853" height="1053" />
</state>
diff --git a/test-cli/setup.xml b/test-cli/setup.xml
index db9e7db..e17a1d5 100644
--- a/test-cli/setup.xml
+++ b/test-cli/setup.xml
@@ -3,7 +3,7 @@
<setup>
<test idline="1"/> <!-- Test line identify -->
<board model="SOPA0000" variant="BW2Q-QXXX"/>
- <db dbname="testsrv" type="PgSQLConnection" host="192.168.8.1" port="5432" user="admin" password="Idkfa2009" /> <!-- database setup -->
+ <db dbname="testsrv" type="PgSQLConnection" host="192.168.8.100" port="5432" user="admin" password="Idkfa2009" /> <!-- database setup -->
</setup>
</data>
diff --git a/test-cli/test/files/test_ok.png b/test-cli/test/files/test_ok.png
deleted file mode 100644
index 6ccc7b3..0000000
--- a/test-cli/test/files/test_ok.png
+++ /dev/null
Binary files differ
diff --git a/test-cli/test/files/usbtest/usbdatatest.bin b/test-cli/test/files/usbtest/usbdatatest.bin
new file mode 100644
index 0000000..423eec3
--- /dev/null
+++ b/test-cli/test/files/usbtest/usbdatatest.bin
Binary files differ
diff --git a/test-cli/test/files/usbtest/usbdatatest.md5 b/test-cli/test/files/usbtest/usbdatatest.md5
new file mode 100644
index 0000000..4358fb7
--- /dev/null
+++ b/test-cli/test/files/usbtest/usbdatatest.md5
@@ -0,0 +1 @@
+6ef9717ac968b592803d0026f662a85e usbdatatest.bin
diff --git a/test-cli/test/suites/__init__.py b/test-cli/test/flashers/__init__.py
index e69de29..e69de29 100644
--- a/test-cli/test/suites/__init__.py
+++ b/test-cli/test/flashers/__init__.py
diff --git a/test-cli/test/flashers/flasher.py b/test-cli/test/flashers/flasher.py
new file mode 100644
index 0000000..d962fca
--- /dev/null
+++ b/test-cli/test/flashers/flasher.py
@@ -0,0 +1,10 @@
+from test.flashers.flasher_sopa0000 import flash_sopa0000
+
+
+def flash(modelid):
+ result = None
+
+ if modelid.find("SOPA0000") == 0:
+ result = flash_sopa0000()
+
+ return result
diff --git a/test-cli/test/flashers/flasher_sopa0000.py b/test-cli/test/flashers/flasher_sopa0000.py
new file mode 100644
index 0000000..818be91
--- /dev/null
+++ b/test-cli/test/flashers/flasher_sopa0000.py
@@ -0,0 +1,13 @@
+from test.helpers.syscmd import SysCommand
+
+
+def flash_sopa0000():
+ print("Sart programming Nand memory...")
+ 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:
+ print("Flasher: Could not complete flashing task.")
+ return 1
+ else:
+ print("Flasher: NAND memory flashed succesfully.")
+ return 0
diff --git a/test-cli/test/helpers/int_registers.py b/test-cli/test/helpers/int_registers.py
index 030035d..22a3d9b 100644
--- a/test-cli/test/helpers/int_registers.py
+++ b/test-cli/test/helpers/int_registers.py
@@ -55,7 +55,6 @@ def get_mac(modelid):
# mac = mac + read(rg)
# #erase trailing zeros
# mac = mac[4::1]
- mac = sh.cat("/sys/class/net/eth0/address")
-
+ mac = sh.cat("/sys/class/net/eth0/address").strip()
return mac
diff --git a/test-cli/test/helpers/uboot_flasher.py b/test-cli/test/helpers/uboot_flasher.py
deleted file mode 100644
index e69de29..0000000
--- a/test-cli/test/helpers/uboot_flasher.py
+++ /dev/null
diff --git a/test-cli/test/runners/simple.py b/test-cli/test/runners/simple.py
index dd7c74d..f8b4dd4 100644
--- a/test-cli/test/runners/simple.py
+++ b/test-cli/test/runners/simple.py
@@ -65,6 +65,7 @@ class TextTestResult(unittest.TestResult):
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
test.longMessage = err[1]
+ print(err[1])
self.result = self.ERROR
def addFailure(self, test, err):
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/"):
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index f8e3c1a..6e56214 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -24,7 +24,9 @@ import socket
from test.helpers.iseelogger import ISEE_Logger
import logging
import binascii
+from test.flashers.flasher import flash
+# global variables
psdbObj = TestSrv_Database()
xmlObj = None
loggerObj = None
@@ -116,6 +118,7 @@ def create_board():
def program_eeprom(eeprompath):
+ print("Start programming Eeprom...")
# check if eeprompath is correct
if os.path.isfile(eeprompath):
# create u-boot data struct
@@ -124,12 +127,13 @@ def program_eeprom(eeprompath):
data += bytearray([0, 0, 0, 0]) # crc32 = 0
data += bytearray(globalVar.g_uuid + "\0",
'ascii') # uuid --> 'c0846c8a-5fa5-11ea-8576-f8b156ac62d7' and \0 at the end
- data += binascii.unhexlify((get_mac(globalVar.g_mid)).replace(':', '')) # mac0 --> 'f8:b1:56:ac:62:d7'
+ mac0 = get_mac(globalVar.g_mid)
+ data += binascii.unhexlify(mac0.replace(':', '')) # mac0 --> 'f8:b1:56:ac:62:d7'
data += bytearray([0, 0, 0, 0, 0, 0]) # mac1 --> 0:0:0:0:0:0
# calculate crc
crc = (binascii.crc32(data, 0)).to_bytes(4, 'big')
data[4:8] = crc
- # write into eeprom an validate
+ # write into eeprom and read back
f = open(eeprompath, "r+b")
f.write(data)
f.seek(0)
@@ -137,13 +141,12 @@ def program_eeprom(eeprompath):
for i in range(57):
if data_rx[i] != data[i]:
print("Error while programming eeprom memory.")
- break
+ return 1
print("Eeprom programmed succesfully.")
-
-
-def flash_nvmemory(flashscript):
- if os.path.isfile(flashscript):
- print("a")
+ return 0
+ else:
+ print("eeprom memory not found.")
+ return 1
def create_boardvariables_list(uuid):
@@ -159,11 +162,12 @@ def main():
create_board()
# create and run tests according to the board type
runner = SimpleTestRunner(psdbObj)
- runner.run(create_testsuite())
- # execute aditional tasks
- varlist = create_boardvariables_list(globalVar.g_uuid)
- program_eeprom(varlist["eeprompath"])
- flash_nvmemory(varlist["flashscript"])
+ testresult = runner.run(create_testsuite())
+ # execute aditional tasks, only if the test was succesfull
+ if testresult.wasSuccessful():
+ varlist = create_boardvariables_list(globalVar.g_uuid)
+ program_eeprom(varlist["eeprompath"])
+ flash(globalVar.g_mid)
if __name__ == "__main__":