summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qplc.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests/qplc.py')
-rw-r--r--test-cli/test/tests/qplc.py58
1 files changed, 42 insertions, 16 deletions
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