summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test-cli/setup.xml6
-rw-r--r--test-cli/test/helpers/plc.py26
-rw-r--r--test-cli/test/helpers/testsrv_db.py13
-rw-r--r--test-cli/test/tests/qamper.py2
-rw-r--r--test-cli/test/tests/qplc.py58
-rw-r--r--test-cli/test_main.py2
6 files changed, 84 insertions, 23 deletions
diff --git a/test-cli/setup.xml b/test-cli/setup.xml
index 5cdd65b..70c6feb 100644
--- a/test-cli/setup.xml
+++ b/test-cli/setup.xml
@@ -15,7 +15,11 @@
<qeth loops="1" interface="eth0" bwexpected="5.0" port="5000" serverip="192.168.60.3" duration="10" to="/mnt/station_ramdisk" eth_res_file="eth_test_{}.json" eth_st_file="eth_st_{}.json" retries="5" wait_retry="10"/>
<qeeprom i2c_address="0050" i2c_bus="0"/>
<qemmc device="mmcblk0" to="/mnt/station_ramdisk" emmc_res_file="emmc_status.txt"/>
- <qplc firmware="" firmware_md5="" factory_tool="/root/hwtest-files/apps/configlayer" gen_ip="0" gen_mac="1" mtd_device="/dev/mtd0" factory_password="betera" firmware_password="paterna"/>
+ <qplc firmwarepath="/root/hwtest-files/firmware" firmware="" firmware_md5=""
+ factory_tool="/root/hwtest-files/apps/configlayer" gen_ip="0" gen_mac="1"
+ mtd_device="/dev/mtd0" factory_password="betera" firmware_password="paterna"
+ plc_test_ip="192.168.60.91" skipflash="1"
+ />
</setup>
<usb>
<usbdev MANUFACTURER="Linux 4.9.81+ ohci_hcd" PRODUCT="OHCI Host Controller" CLASS="09" VENDOR="1d6b" PRODID="0001" ignore="1"/>
diff --git a/test-cli/test/helpers/plc.py b/test-cli/test/helpers/plc.py
index 3b00934..b1ec382 100644
--- a/test-cli/test/helpers/plc.py
+++ b/test-cli/test/helpers/plc.py
@@ -1,10 +1,10 @@
import sh
from sh import flashcp
-from sh import flash_erase
+from sh import flash_eraseall
from sh import ErrorReturnCode
from sh import Command
from test.helpers.gpio import gpio
-
+import time
class dcpPLC(object):
__nReset = None
@@ -33,10 +33,18 @@ class dcpPLC(object):
self.__nRest = gpio('75', 'out', '1')
self.__nRest = gpio('69', 'out', '1')
+ def setPLCReset(self):
+ self.__nRest = gpio('75', 'out', '0')
+ self.__nRest = gpio('69', 'out', '0')
+ time.sleep(0.25)
+ self.__nRest = gpio('69', 'out', '1')
+ self.__nRest = gpio('75', 'out', '1')
+
+
def SaveFirmware(self, firmare):
self.setSaveFirmwareMode()
try:
- flash_erase(self.__mtd_device)
+ flash_eraseall(self.__mtd_device)
flashcp(firmare, self.__mtd_device)
except ErrorReturnCode as Error:
return False, "plc flash firmware failed {} ".format(Error.exit_code)
@@ -44,11 +52,21 @@ class dcpPLC(object):
def set_plc (self, var, value, password):
try:
- self.__myConfigTool("-o", "SET", "-p", "{}".format(var), '{}'.format(value), "-w", "{}".format(password))
+ res = self.__myConfigTool("-o", "SET", "-p", "{}={}".format(var, value), "-w", "{}".format(password))
+ print(res)
except ErrorReturnCode as Error:
return False, "set var failed {} {}".format(var,Error.exit_code)
return True, ''
+ def set_plc2 (self, var1, value1,var2, value2, password):
+ try:
+ res = self.__myConfigTool("-o", "SET", "-p", "{}={}".format(var1, value1), "-p", "{}={}".format(var2, value2), "-w", "{}".format(password))
+ print(res)
+ except ErrorReturnCode as Error:
+ return False, "set var failed {}".format(Error.exit_code)
+ return True, ''
+
+
def get_plc (self, var, value, password):
try:
self.__myConfigTool("-o", "GET", "-p", "{}".format(var), '{}'.format(value), "-w", "{}".format(password))
diff --git a/test-cli/test/helpers/testsrv_db.py b/test-cli/test/helpers/testsrv_db.py
index c2b2276..556c246 100644
--- a/test-cli/test/helpers/testsrv_db.py
+++ b/test-cli/test/helpers/testsrv_db.py
@@ -132,6 +132,19 @@ class TestSrv_Database(object):
# print(r)
return None
+
+ def get_plc_macaddr(self, board_uuid):
+ sql = "SELECT * FROM isee.f_get_plcmac(\'{}\')".format(board_uuid)
+ # print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ return res, ''
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ print(r)
+ return None, r
+
+
def get_board_macaddr(self, board_uuid):
sql = "SELECT * FROM isee.f_get_board_macaddr('{}')".format(board_uuid)
# print('>>>' + sql)
diff --git a/test-cli/test/tests/qamper.py b/test-cli/test/tests/qamper.py
index df340eb..96b673c 100644
--- a/test-cli/test/tests/qamper.py
+++ b/test-cli/test/tests/qamper.py
@@ -39,7 +39,7 @@ class Qamper(unittest.TestCase):
)
def execute(self):
- if self.dummytest:
+ if self.dummytest == '1':
self.current = "0.0"
self.saveresultinfile(self.current)
return
diff --git a/test-cli/test/tests/qplc.py b/test-cli/test/tests/qplc.py
index 01258a9..a70ae3a 100644
--- a/test-cli/test/tests/qplc.py
+++ b/test-cli/test/tests/qplc.py
@@ -3,21 +3,26 @@ import unittest
import os.path
import os
import sh
+import stat
from test.helpers.md5 import md5_file
from test.helpers.plc import dcpPLC
+from test.helpers.iseelogger import logObj
class Qplc(unittest.TestCase):
params = None
__resultlist = None # resultlist is a python list of python dictionaries
__QPLCName = None
__plc = None
+ __board_uuid = None
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qplc, self).__init__(testfunc)
self._testMethodDoc = testname
self.__xmlObj = varlist["xml"]
+ self.__psdbObj = varlist["db"]
+ self.__board_uuid = varlist["boarduuid"]
self.__QPLCName = varlist.get('name', 'qplc')
self.__firmware = varlist.get('firmware', self.__xmlObj.getKeyVal(self.__QPLCName, "firmware", ""))
@@ -26,27 +31,32 @@ class Qplc(unittest.TestCase):
self.__gen_ip = varlist.get('gen_ip', self.__xmlObj.getKeyVal(self.__QPLCName, "gen_ip", "0"))
self.__gen_mac = varlist.get('gen_mac', self.__xmlObj.getKeyVal(self.__QPLCName, "gen_mac", "0"))
self.__mtd_device = varlist.get('mtd_device', self.__xmlObj.getKeyVal(self.__QPLCName, "mtd_device", "/dev/mtd0"))
+ self.__firmware_Path = varlist.get('firmwarepath', self.__xmlObj.getKeyVal(self.__QPLCName, "firmwarepath", "/root/hwtest-files/firmware"))
+ self.__plc_test_ip = varlist.get('plc_test_ip', self.__xmlObj.getKeyVal(self.__QPLCName, "plc_test_ip", "192.168.60.91"))
+ self.__skipflash = varlist.get('skipflash', self.__xmlObj.getKeyVal(self.__QPLCName, "skipflash", "0"))
self.__plc = dcpPLC(self.__factoryTool, self.__mtd_device)
-
+ self.__factory_password = varlist.get('factory_password', self.__xmlObj.getKeyVal(self.__QPLCName, "factory_password", "0"))
+ self.__firmware_password = varlist.get('firmware_password', self.__xmlObj.getKeyVal(self.__QPLCName, "firmware_password", "0"))
self.__resultlist = []
def checkfiles(self):
- if not os.path.isfile('{}/{}'.format(self.__filepath_from, self.__file_source)):
- return False, 'File test binary Not found {}/{}'.format(self.__filepath_from, self.__file_source)
- if not os.path.isfile('{}/{}'.format(self.__filepath_from, self.__file_md5)):
- return False, 'File test binary md5 Not found {}/{}'.format(self.__filepath_from, self.__file_md5)
- if self.__check_mounted != '':
- if not os.path.ismount('{}'.format(self.__check_mounted)):
- return False, 'Required mounted failed: {}'.format(self.__path_to)
- r, s = self.removefileIfExist('{}/{}'.format(self.__path_to, self.__file_source))
- if not r:
- return r, s
+ if not os.path.isfile(self.__factoryTool):
+ return False, 'Factory tool Not found {}/{}'.format(self.__factoryTool)
+ if not os.path.isfile('{}/{}'.format(self.__firmware_Path, self.__firmware)):
+ return False, 'Firmware Not found {}/{}'.format(self.__firmware_Path, self.__firmware)
+ if not os.path.isfile('{}/{}'.format(self.__firmware_Path, self.__firmware_md5)):
+ return False, 'Firmware md5 Not found {}/{}'.format(self.__firmware_Path, self.__firmware_md5)
+ try:
+ mode = os.stat(self.__mtd_device).st_mode;
+ if not stat.S_ISCHR(mode):
+ return False, 'No device {} found'.format(self.__mtd_device)
+ except:
+ return False, 'No device {} found'.format(self.__mtd_device)
return True, ''
def __flashMemory(self):
- self.__plc.setSaveFirmwareMode()
- r, v = self.__plc.SaveFirmware(self.__firmware)
+ r, v = self.__plc.SaveFirmware('{}/{}'.format(self.__firmware_Path, self.__firmware))
if not r:
self.fail(v)
@@ -56,12 +66,28 @@ class Qplc(unittest.TestCase):
if not v:
self.fail(m)
# do flash & verify
- self.__flashMemory()
+ if self.__skipflash == '0':
+ self.__flashMemory()
# do Plc boot
self.__plc.setBootMode()
# Wait plc goes UP
-
-
+ if self.__gen_mac:
+ res, v = self.__psdbObj.get_plc_macaddr(self.__board_uuid)
+ if res == None and v == 'MAC limit by uuid':
+ self.fail('MAC limit by uuid')
+ elif res == None:
+ self.fail('BUG: ?????')
+ logObj.getlogger().info("MAC {}".format(res[0]))
+ plcMAC = res[0][0]
+ self.__plc.set_plc2('SYSTEM.PRODUCTION.SECTOR0_UNLOCK_PASSWORD',
+ self.__factory_password,
+ 'SYSTEM.PRODUCTION.MAC_ADDR',
+ '{}'.format(plcMAC),
+ self.__firmware_password)
+ #self.__plc.set_plc('SYSTEM.PRODUCTION.SECTOR0_UNLOCK_PASSWORD', self.__factory_password, self.__firmware_password)
+ #plcMAC = res[0][0]
+ #self.__plc.set_plc('SYSTEM.PRODUCTION.MAC_ADDR', '{}'.format(plcMAC), self.__firmware_password)
+ self.__plc.setPLCReset()
def getresults(self):
return self.__resultlist
diff --git a/test-cli/test_main.py b/test-cli/test_main.py
index 3f52152..bce9de9 100644
--- a/test-cli/test_main.py
+++ b/test-cli/test_main.py
@@ -279,7 +279,7 @@ def getBarCode(fake):
psdbObj.set_factorycode(globalVar.g_uuid, str(random.randint(1, 1000001)))
return
qrreceived = False
- wait_count = psdbObj.get_setup_variable("QRWAIT_SEC", xmlObj.getKeyVal("test_main", "qr_wait_time", "120"))
+ wait_count = psdbObj.get_setup_variable("test_main", xmlObj.getKeyVal("test_main", "qr_wait_time", "120"))
while not qrreceived or int(wait_count) > 0:
qr = QRReader()
if qr.openQR():