summaryrefslogtreecommitdiff
path: root/test-cli
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-03-09 19:16:08 +0100
committerHector Fernandez <hector@iatec.biz>2020-03-09 19:16:08 +0100
commitd38c92bfd7b6abe3a52b51b87b1a2949b857d9b4 (patch)
treec1ee6a472e8acb779f016471e11e32ed64fc4355 /test-cli
parentc685367cbd6abf1c6ae442df759e39b25a907d3b (diff)
downloadboard-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.zip
board-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.tar.gz
board-d38c92bfd7b6abe3a52b51b87b1a2949b857d9b4.tar.bz2
Created function to flash the eeprom memory.
Diffstat (limited to 'test-cli')
-rw-r--r--test-cli/.idea/workspace.xml32
-rw-r--r--test-cli/test/helpers/button_script.sh4
-rw-r--r--test-cli/test/helpers/testsrv_db.py13
-rw-r--r--test-cli/test/scripts/__init__.py0
-rwxr-xr-xtest-cli/test/scripts/usb.sh (renamed from test-cli/test/helpers/usb.sh)0
-rw-r--r--test-cli/test/tests/qbutton.py64
-rw-r--r--test-cli/test/tests/qusb.py2
-rw-r--r--test-cli/test/tests/qwifi.py19
-rw-r--r--test-cli/test_main.py62
9 files changed, 91 insertions, 105 deletions
diff --git a/test-cli/.idea/workspace.xml b/test-cli/.idea/workspace.xml
index 872ab45..c2653e0 100644
--- a/test-cli/.idea/workspace.xml
+++ b/test-cli/.idea/workspace.xml
@@ -2,17 +2,16 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4991a6e0-1b9d-4824-9b6e-5ac031eb4816" name="Default Changelist" comment="">
- <change afterPath="$PROJECT_DIR$/test/helpers/changedir.py" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/test/scripts/__init__.py" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/test/scripts/flasher_sopa0000" 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/amper.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/amper.py" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/test/helpers/usb.sh" beforeDir="false" afterPath="$PROJECT_DIR$/test/helpers/usb.sh" afterDir="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/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/qi2c.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qi2c.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/qserial.py" beforeDir="false" afterPath="$PROJECT_DIR$/test/tests/qserial.py" 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$/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" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -44,6 +43,9 @@
<property name="settings.editor.selected.configurable" value="Errors" />
</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" />
</key>
@@ -93,6 +95,14 @@
<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">
+ <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="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>
+ <state x="726" y="301" width="524" height="502" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/67.27.1853.1053@67.27.1853.1053" timestamp="1583775384564" />
<state width="717" height="568" key="DebuggerActiveHint" timestamp="1583488899608">
<screen x="67" y="27" width="1853" height="1053" />
</state>
@@ -157,9 +167,9 @@
<screen x="67" y="27" width="1853" height="1053" />
</state>
<state x="543" y="240" width="890" height="624" key="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory$2/67.27.1853.1053@67.27.1853.1053" timestamp="1583753593705" />
- <state x="641" y="119" width="704" height="867" key="find.popup" timestamp="1583427991724">
+ <state x="641" y="119" width="704" height="867" key="find.popup" timestamp="1583760766969">
<screen x="67" y="27" width="1853" height="1053" />
</state>
- <state x="641" y="119" width="704" height="867" key="find.popup/67.27.1853.1053@67.27.1853.1053" timestamp="1583427991724" />
+ <state x="641" y="119" width="704" height="867" key="find.popup/67.27.1853.1053@67.27.1853.1053" timestamp="1583760766969" />
</component>
</project> \ No newline at end of file
diff --git a/test-cli/test/helpers/button_script.sh b/test-cli/test/helpers/button_script.sh
deleted file mode 100644
index 6908f22..0000000
--- a/test-cli/test/helpers/button_script.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-i2cset -f -y 1 0x2d 0x40 0x31
-i2cset -f -y 1 0x2d 0x50 0xff
-i2cget -f -y 1 0x2d 0x50
diff --git a/test-cli/test/helpers/testsrv_db.py b/test-cli/test/helpers/testsrv_db.py
index d937d3e..9fb61fd 100644
--- a/test-cli/test/helpers/testsrv_db.py
+++ b/test-cli/test/helpers/testsrv_db.py
@@ -104,3 +104,16 @@ class TestSrv_Database(object):
r = find_between(str(err), '#', '#')
# print(r)
return None
+
+ def get_board_variables(self, board_uuid):
+ sql = "SELECT * FROM isee.f_get_boardvariables('{}')".format(board_uuid)
+ # print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ # print(res)
+ return res
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ # print(r)
+ return None
+
diff --git a/test-cli/test/scripts/__init__.py b/test-cli/test/scripts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test-cli/test/scripts/__init__.py
diff --git a/test-cli/test/helpers/usb.sh b/test-cli/test/scripts/usb.sh
index 52ea4b2..52ea4b2 100755
--- a/test-cli/test/helpers/usb.sh
+++ b/test-cli/test/scripts/usb.sh
diff --git a/test-cli/test/tests/qbutton.py b/test-cli/test/tests/qbutton.py
deleted file mode 100644
index 46ddde0..0000000
--- a/test-cli/test/tests/qbutton.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from test.helpers.syscmd import SysCommand
-import unittest
-import time
-
-
-class Qbutton(unittest.TestCase):
- params = None
-
- def __init__(self, testname, testfunc, varlist):
- self.params = varlist
- super(Qbutton, self).__init__(testfunc)
- if "gpio" in varlist:
- self.__gpio = varlist["gpio"]
- else:
- raise Exception('gpio param inside Qbutton must be defined')
- if self.__gpio == "SOPA":
- super(Qbutton, self).__init__("buttonSopa")
- else:
- super(Qbutton, self).__init__("buttonGpio")
- self._testMethodDoc = testname
-
- def buttonGpio(self):
- print("normal-button-test-using-gpio")
- self.fail("failed: GPIO BUTTON FAIL")
-
- def buttonSopa(self):
- str_cmd = "i2cset -f -y 1 0x2d 0x40 0x31"
- disable_pmic = SysCommand("disable_pmic", str_cmd)
- disable_pmic.execute()
- # BUG: REPEAT THIS EXECUTION TWICE BECAUSE FIRST TIME IT RETURNS AN ERROR
- led_on="echo 1 > /sys/class/leds/red\:usbhost/brightness"
- ledon = SysCommand("led_on", led_on)
- ledon.execute()
- time.sleep(0.1)
- disable_pmic.execute()
- if disable_pmic.execute() == 0:
- str_cmd = "i2cset -f -y 1 0x2d 0x50 0xff"
- reset_button = SysCommand("reset_button", str_cmd)
- if reset_button.execute() == 0:
- str_cmd = "i2cget -f -y 1 0x2d 0x50"
- get_button_val = SysCommand("get_button_val", str_cmd)
- print("\n\t --> PRESS button for 1 sec (TIMEOUT: 10s) \n")
- timeout = 0
- while timeout < 7200:
- if get_button_val.execute() == 0:
- get_button_val.execute()
- button_value = get_button_val.getOutput()
- button_value=button_value.decode('ascii').split("x")
- if int(button_value[1]) == 4:
- timeout = 7200
- led_off="echo 0 > /sys/class/leds/red\:usbhost/brightness"
- ledoff = SysCommand("led_off", led_off)
- ledoff.execute()
- time.sleep(0.5)
- timeout = timeout + 1
- if timeout==7200 and int(button_value[1]) == 0:
- self.fail("failed: timeout exceeded")
- else:
- timeout = 7200
- self.fail("failed: not button input")
- else:
- self.fail("failed: could not complete i2c reset button state")
- else:
- self.fail("failed: could not complete i2c disable PMIC")
diff --git a/test-cli/test/tests/qusb.py b/test-cli/test/tests/qusb.py
index 7ecf31e..6a004f0 100644
--- a/test-cli/test/tests/qusb.py
+++ b/test-cli/test/tests/qusb.py
@@ -14,7 +14,7 @@ class Qusb(unittest.TestCase):
def execute(self):
# Execute script usb.sh
- p = sh.bash('test/helpers/usb.sh')
+ p = sh.bash('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'))
# get the first device which matches the pattern
diff --git a/test-cli/test/tests/qwifi.py b/test-cli/test/tests/qwifi.py
index 2a5fa0c..8daf069 100644
--- a/test-cli/test/tests/qwifi.py
+++ b/test-cli/test/tests/qwifi.py
@@ -4,14 +4,14 @@ import re
class Qwifi(unittest.TestCase):
- __sip = None
+ __serverip = None
__numbytestx = None
__bind = None
- __OKBW = None
+ __bwexpected = None
__port = None
params = None
- #varlist: serverip, bind, OKBW, port
+ # varlist content: serverip, bwexpected, port, (optional)bind
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qwifi, self).__init__(testfunc)
@@ -19,8 +19,8 @@ class Qwifi(unittest.TestCase):
self.__serverip = varlist["serverip"]
else:
raise Exception('serverip param inside Qwifi have been be defined')
- if "OKBW" in varlist:
- self.__OKBW = varlist["OKBW"]
+ if "bwexpected" in varlist:
+ self.__bwexpected = varlist["bwexpected"]
else:
raise Exception('OKBW param inside Qwifi must be defined')
if "port" in varlist:
@@ -41,11 +41,12 @@ class Qwifi(unittest.TestCase):
# get the first line of the output stream
out1 = p.stdout.decode('ascii').splitlines()[0]
if out1 != "Not connected.":
- #check if the board has ip in the wlan0 interface
+ # check if the board has ip in the wlan0 interface
p = sh.ifconfig("wlan0")
if p.exit_code == 0:
- result = re.search("inet addr:(?!127\.0{1,3}\.0{1,3}\.0{0,2}1$)((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
- p.stdout)
+ result = re.search(
+ 'inet addr:(?!127\.0{1,3}\.0{1,3}\.0{0,2}1$)((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',
+ p.stdout.decode('ascii'))
if result:
# execute iperf command against the server
if self.__bind is None:
@@ -69,7 +70,7 @@ class Qwifi(unittest.TestCase):
bwreal = b[0]
# check if BW is in the expected range
- self.failUnless(float(bwreal) > float(self.__OKBW) * 0.9,
+ self.failUnless(float(bwreal) > float(self.__bwexpected) * 0.9,
"failed: speed is lower than spected. Speed(MB/s)" + str(bwreal))
else:
self.fail("failed: could not complete iperf command")
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 0e863dc..f8e3c1a 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -1,15 +1,11 @@
from test.helpers.int_registers import get_die_id
from test.helpers.int_registers import get_mac
from subprocess import call
-import xml.etree.ElementTree as XMLParser
-import errno
-import sys
import os
import unittest
from test.helpers.testsrv_db import TestSrv_Database
from test.helpers.setup_xml import XMLSetup
from test.runners.simple import SimpleTestRunner
-from test.tests.qbutton import Qbutton
from test.helpers.syscmd import TestSysCommand
from test.tests.qethernet import Qethernet
from test.tests.qaudio import Qaudio
@@ -18,17 +14,16 @@ from test.tests.qusb import Qusb
from test.tests.qi2c import Qi2c
from test.tests.qeeprom import Qeeprom
from test.tests.qserial import Qserial
-from test.tests.qscreen import Qscreen
from test.tests.qwifi import Qwifi
from test.tests.qrtc import Qrtc
from test.tests.qduplex_ser import Qduplex
from test.tests.qamper import Qamper
-from test.tests.qflash import Qflasher
from test.tests.qnand import Qnand
from test.helpers.globalVariables import globalVar
import socket
from test.helpers.iseelogger import ISEE_Logger
import logging
+import binascii
psdbObj = TestSrv_Database()
xmlObj = None
@@ -50,8 +45,6 @@ def create_paramslist(params):
def add_test_task(suite, testdefname, paramlist):
- testfunc = None
-
if testdefname == "AUDIO":
suite.addTest(Qaudio(testdefname, "execute", paramlist))
elif testdefname == "RAM":
@@ -62,18 +55,10 @@ def add_test_task(suite, testdefname, paramlist):
suite.addTest(Qeeprom(testdefname, "execute", paramlist))
elif testdefname == "SERIAL":
suite.addTest(Qserial(testdefname, "execute", paramlist))
- # elif testdefname == "HDMI":
- # suite.addTest(Qhdmi(testdefname, "execute", paramlist))
- # elif testdefname == "SCREEN":
- # suite.addTest(Qscreen(testdefname, "execute", paramlist))
- elif testdefname == "BUTTON":
- suite.addTest(Qbutton(testdefname, "execute", paramlist))
elif testdefname == "RTC":
suite.addTest(Qrtc(testdefname, "execute", paramlist))
elif testdefname == "CONSUMPTION":
suite.addTest(Qamper(testdefname, "execute", paramlist))
- # elif testdefname == "SATA":
- # suite.addTest(Qsata(testdefname, "execute", paramlist))
elif testdefname == "DMESG":
suite.addTest(TestSysCommand(testdefname, "execute", paramlist))
elif testdefname == "ETHERNET":
@@ -130,10 +115,55 @@ def create_board():
get_mac(globalVar.g_mid))
+def program_eeprom(eeprompath):
+ # check if eeprompath is correct
+ if os.path.isfile(eeprompath):
+ # create u-boot data struct
+ data = bytearray()
+ data += (2029785358).to_bytes(4, 'big') # magicid --> 0x78FC110E
+ 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'
+ 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
+ f = open(eeprompath, "r+b")
+ f.write(data)
+ f.seek(0)
+ data_rx = f.read(57)
+ for i in range(57):
+ if data_rx[i] != data[i]:
+ print("Error while programming eeprom memory.")
+ break
+ print("Eeprom programmed succesfully.")
+
+
+def flash_nvmemory(flashscript):
+ if os.path.isfile(flashscript):
+ print("a")
+
+
+def create_boardvariables_list(uuid):
+ varlist = {}
+ for row in psdbObj.get_board_variables(globalVar.g_uuid):
+ varname, varvalue = row
+ varlist[varname] = varvalue
+ return varlist
+
+
def main():
+ # initialize the board
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"])
if __name__ == "__main__":