summaryrefslogtreecommitdiff
path: root/scripts/PYTHON_SOFTWARE/test/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/PYTHON_SOFTWARE/test/helpers')
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__init__.py0
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__init__.pycbin0 -> 122 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/__init__.cpython-35.pycbin0 -> 118 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/cv_display_test.cpython-35.pycbin0 -> 3246 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/get_dieid.cpython-35.pycbin0 -> 1496 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/globalVariables.cpython-35.pycbin0 -> 345 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/psqldb.cpython-35.pycbin0 -> 1939 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/setup_xml.cpython-35.pycbin0 -> 1481 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/syscmd.cpython-35.pycbin0 -> 3694 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/testsrv_db.cpython-35.pycbin0 -> 5230 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/button_script.sh4
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/cv_display_test.py147
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/get_dieid.py41
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.py8
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.pycbin0 -> 375 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/psqldb.py55
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/setup_xml.py40
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/syscmd.py108
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/syscmd.pycbin0 -> 3984 bytes
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/testsrv_db.py162
-rw-r--r--scripts/PYTHON_SOFTWARE/test/helpers/uboot_flasher.py0
21 files changed, 565 insertions, 0 deletions
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__init__.py b/scripts/PYTHON_SOFTWARE/test/helpers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__init__.py
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__init__.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__init__.pyc
new file mode 100644
index 0000000..7d1c907
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__init__.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/__init__.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000..5224618
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/__init__.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/cv_display_test.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/cv_display_test.cpython-35.pyc
new file mode 100644
index 0000000..5df3dbc
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/cv_display_test.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/get_dieid.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/get_dieid.cpython-35.pyc
new file mode 100644
index 0000000..d822bf3
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/get_dieid.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/globalVariables.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/globalVariables.cpython-35.pyc
new file mode 100644
index 0000000..75d4904
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/globalVariables.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/psqldb.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/psqldb.cpython-35.pyc
new file mode 100644
index 0000000..8f85c0c
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/psqldb.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/setup_xml.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/setup_xml.cpython-35.pyc
new file mode 100644
index 0000000..d1a3f94
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/setup_xml.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/syscmd.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/syscmd.cpython-35.pyc
new file mode 100644
index 0000000..77658c7
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/syscmd.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/testsrv_db.cpython-35.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/testsrv_db.cpython-35.pyc
new file mode 100644
index 0000000..2169783
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/__pycache__/testsrv_db.cpython-35.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/button_script.sh b/scripts/PYTHON_SOFTWARE/test/helpers/button_script.sh
new file mode 100644
index 0000000..6908f22
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/button_script.sh
@@ -0,0 +1,4 @@
+#!/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/scripts/PYTHON_SOFTWARE/test/helpers/cv_display_test.py b/scripts/PYTHON_SOFTWARE/test/helpers/cv_display_test.py
new file mode 100644
index 0000000..7321667
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/cv_display_test.py
@@ -0,0 +1,147 @@
+import cv2
+import numpy as np
+import subprocess
+
+
+
+
+def adjust_gamma(image, gamma=1.0):
+ invGamma = 1.0 / gamma
+ table = np.array([((i / 255.0) ** invGamma) * 255
+ for i in np.arange(0, 256)]).astype("uint8")
+ return cv2.LUT(image, table)
+
+def pattern_detect(cam_device=0):
+
+ # RETURN 0 only if the test is ok
+ msg="0"
+ # Capture the corresponding camera device [0,1]
+ #capture = cv2.VideoCapture(0)
+ camid = subprocess.check_output("ls /dev/v4l/by-id/usb-Creative_Technology*", stderr=subprocess.STDOUT, shell=True)
+ camid = camid.decode('ascii').rstrip()
+ capture = cv2.VideoCapture(camid)
+ try:
+ _, image = capture.read()
+ except:
+ msg="Camera error"
+ print(msg)
+ return msg
+
+ # If the USB cam is not connected the capture image doesn't not have size atribbute
+ if not hasattr(image, 'shape'):
+ msg = "USB camera connection error"
+ print(msg)
+ return msg
+ else:
+ size_img=image.shape
+ # Create little squares of each color section
+ # The size of the suare will be 1/6 of the total Y size on the y axis
+ # and 1/25 of the total X size on the x axis
+ y1 = int(size_img[0] / 2 - size_img[0] / 12)
+ y2 = int(size_img[0] / 2 + size_img[0] / 12)
+
+ # Square for RED COLOR
+ xr1 = int(size_img[1] / 6 - size_img[1] / 25)
+ xr2 = int(size_img[1] / 6 + size_img[1] / 25)
+ red_cal = image[y1:y2, xr1:xr2]
+ # Square for GREEN COLOR
+ xg1 = int(size_img[1] / 2 - size_img[1] / 25)
+ xg2 = int(size_img[1] / 2 + size_img[1] / 25)
+ green_cal = image[y1:y2, xg1:xg2]
+ # Square for BLUE COLOR
+ xb1 = int(5 * size_img[1] / 6 - size_img[1] / 25)
+ xb2 = int(5 * size_img[1] / 6 + size_img[1] / 25)
+ blue_cal = image[y1:y2, xb1:xb2]
+ # Get the average color in the box as repeting the np.average funtion
+ # Average color for red
+ avg_color_per_row = np.average(red_cal, axis=0)
+ avg_color_rawr = np.average(avg_color_per_row, axis=0)
+ # Average color for green
+ avg_color_per_row = np.average(green_cal, axis=0)
+ avg_color_rawg = np.average(avg_color_per_row, axis=0)
+ # Average color for blue
+ avg_color_per_row = np.average(blue_cal, axis=0)
+ avg_color_rawb = np.average(avg_color_per_row, axis=0)
+
+ # In cas of the illumintion is not correct, it is performed a gamma filter in order to
+ # correct this illumination problem
+ # After testing the gamma factor correction is computed with the green color
+ # gamma = gamma_factor / blue+red into green part
+ # gamma factor = 50-100
+ #gamma = (100 / (avg_color_rawg[0] + avg_color_rawg[2] + 1))
+ gamma=1
+ # Adjust the image acording to this gamma value
+ adjusted = adjust_gamma(image, gamma=gamma)
+# adjusted=image
+ cv2.imwrite( "/home/root/result_hdmi_img.jpg", adjusted);
+ # Calculate again the average color using the gamma adjusted image
+ # Crop the gamma adjusted image for wach color section
+ red_cal = adjusted[y1:y2, xr1:xr2]
+ green_cal = adjusted[y1:y2, xg1:xg2]
+ blue_cal = adjusted[y1:y2, xb1:xb2]
+ # Calculate the average for the red
+ avg_color_per_row = np.average(red_cal, axis=0)
+ avg_color_red = np.average(avg_color_per_row, axis=0)
+ # Calculate the average for the green
+ avg_color_per_row = np.average(green_cal, axis=0)
+ avg_color_green = np.average(avg_color_per_row, axis=0)
+ # Calculate the average for the blue
+ avg_color_per_row = np.average(blue_cal, axis=0)
+ avg_color_blue = np.average(avg_color_per_row, axis=0)
+ # In order to count colour use the hsv conversion
+ hsv = cv2.cvtColor(adjusted, cv2.COLOR_BGR2HSV)
+ # Create a mask for each color, definig the upper and lower bound of each color in hsv space
+ # Create the blue mask with the bounds
+ lower_blue = np.array([100, 50, 50])
+ upper_blue = np.array([130, 255, 255])
+ mask_b = cv2.inRange(hsv, lower_blue, upper_blue)
+ # Create the green mask with the bounds
+ lower_green = np.array([50, 50, 50])
+ upper_green = np.array([80, 255, 255])
+ mask_g = cv2.inRange(hsv, lower_green, upper_green)
+ # Create the red mask with the bounds. In this case we use a composed mask, sum of two different
+ # group of bounds
+ # First red mask
+ lower_red = np.array([0, 50, 50])
+ upper_red = np.array([10, 255, 255])
+ mask0 = cv2.inRange(hsv, lower_red, upper_red)
+ # Second red mask
+ lower_red = np.array([170, 50, 50])
+ upper_red = np.array([180, 255, 255])
+ mask1 = cv2.inRange(hsv, lower_red, upper_red)
+ # compose both masks
+ mask_r = mask0 + mask1
+ # mask_r = cv2.inRange(hsv, lower_red, upper_red)
+ # Perform a morphological open to expand
+# kernel = np.ones((5, 5), np.uint8)
+# closing_r = cv2.morphologyEx(mask_r, cv2.MORPH_OPEN, kernel)
+# closing_b = cv2.morphologyEx(mask_b, cv2.MORPH_OPEN, kernel)
+# closing_g = cv2.morphologyEx(mask_g, cv2.MORPH_OPEN, kernel)
+ # Count the number of pixels that are not of the corresponding color (black)
+# count_r = cv2.countNonZero(closing_r)
+# count_b = cv2.countNonZero(closing_b)
+# count_g = cv2.countNonZero(closing_g)
+ #-----------
+ count_r = cv2.countNonZero(mask_r)
+ count_b = cv2.countNonZero(mask_b)
+ count_g = cv2.countNonZero(mask_g)
+ #-------
+ if (count_r < 5):
+ msg = "RED COUNT FAIL"
+ return msg
+ if (count_g < 5):
+ msg = "GREEN COUNT FAIL"
+ return msg
+ if (count_b < 5):
+ msg = "BLUE COUNT FAIL"
+ return msg
+ if (avg_color_red[2] < 150 or avg_color_rawr[2] < 200):
+ msg = "AVG RED COUNT FAIL"
+ return msg
+ if (avg_color_green[1] < 200 or avg_color_rawg[1] < 200):
+ msg = "AVG GREEN COUNT FAIL"
+ return msg
+ if (avg_color_blue[0] < 200 or avg_color_rawb[0] < 200):
+ msg = "AVG BLUE COUNT FAIL"
+ return msg
+ return msg
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/get_dieid.py b/scripts/PYTHON_SOFTWARE/test/helpers/get_dieid.py
new file mode 100644
index 0000000..029ddb5
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/get_dieid.py
@@ -0,0 +1,41 @@
+import mmap
+import os
+import struct
+MAP_MASK = mmap.PAGESIZE - 1
+WORD = 4
+def read(addr):
+ """ Read from any location in memory
+ Returns the readed value in hexadecimal format
+ Keyword arguments:
+ - addr: The memory address to be readed.
+ """
+ fd = os.open("/dev/mem", os.O_RDWR | os.O_SYNC)
+ # Map one page
+ mm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE | mmap.PROT_READ, offset=addr & ~MAP_MASK)
+ mm.seek(addr & MAP_MASK)
+ retval = struct.unpack('I', mm.read(WORD))
+ mm.close()
+ os.close(fd)
+ return "%08X" % retval[0]
+
+def getRegisters(model):
+ if model.find("IGEP0046") == 0:
+ registers = [0x021BC420, 0x021BC410]
+ elif model.find("IGEP0034") == 0 or model.find("SOPA0000") == 0:
+ registers = [0x44e10630, 0x44e10634, 0x44e10638, 0x44e1063C]
+ elif model.find("OMAP3") == 0:
+ registers = [0x4830A224, 0x4830A220, 0x4830A21C, 0x4830A218]
+ elif model.find("OMAP5") == 0:
+ registers = [0x4A002210, 0x4A00220C, 0x4A002208, 0x4A002200]
+ return registers
+
+def genDieid(modelid):
+ registers=getRegisters(modelid)
+ id=""
+ for i in range(len(registers)):
+ id=id+(read(registers[i]))
+ return id
+
+#if __name__ == "__main__":
+ #registers = [0x021BC420, 0x021BC410]
+ #print(main(registers))
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.py b/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.py
new file mode 100644
index 0000000..6b89f4d
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.py
@@ -0,0 +1,8 @@
+def globalVar():
+ guuid = ""
+ procid = ""
+ mid = ""
+ testid_ctl = ""
+ g_mid = ""
+ outdata = "NONE"
+ station = ""
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.pyc
new file mode 100644
index 0000000..3450022
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/globalVariables.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/psqldb.py b/scripts/PYTHON_SOFTWARE/test/helpers/psqldb.py
new file mode 100644
index 0000000..af08579
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/psqldb.py
@@ -0,0 +1,55 @@
+import psycopg2
+
+class PgSQLConnection(object):
+ """aaaaaaa"""
+
+ __conection_object = None
+ __db_config = {'dbname': 'testsrv', 'host': '192.168.2.171',
+ 'password': 'Idkfa2009', 'port': 5432, 'user': 'admin'}
+
+ def __init__ (self, connect_str = None):
+ self.__conection_object = None
+ if connect_str is not None:
+ self.__db_config = connect_str
+ else:
+ self.__db_config = {'dbname': 'testsrv', 'host': '192.168.2.171',
+ 'password': 'Idkfa2009', 'port': 5432, 'user': 'admin'}
+
+ def db_connect (self, connect_str = None):
+ result = False
+ try:
+ if connect_str == None:
+ self.__conection_object = psycopg2.connect(**self.__db_config)
+ else:
+ __db_config = connect_str;
+ self.__conection_object = psycopg2.connect(**self.__db_config)
+ self.__conection_object.autocommit = True
+ result = True
+ except Exception as error:
+ print(error)
+ return result
+
+ def db_execute_query(self, query):
+ cur = self.__conection_object.cursor()
+ cur.execute(query)
+ data = cur.fetchall()
+ cur.close()
+ return data
+
+ def commit(self):
+ self.__conection_object.commit()
+
+
+ def db_close(self):
+ if self.__conection_object is not None:
+ self.__conection_object.close()
+ del self.__conection_object
+ self.__conection_object = None
+
+
+ def __del__(self):
+ if self.__conection_object is not None:
+ self.__conection_object.close()
+ #print("disconnected")
+
+
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/setup_xml.py b/scripts/PYTHON_SOFTWARE/test/helpers/setup_xml.py
new file mode 100644
index 0000000..3fd9fd5
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/setup_xml.py
@@ -0,0 +1,40 @@
+import xml.etree.ElementTree as XMLParser
+
+class XMLSetup (object):
+ """aaaaa"""
+ __tree = None # Parser
+ __dbType = None # database connection required: PgSQLConnection
+ __dbConnectionRaw = None # Connection string in raw
+ __dbConnectionStr = None # Connection string to use in sql object connection
+
+ def __init__(self, filename):
+ """aaaaa"""
+ self.__tree = XMLParser.parse(filename)
+
+ def __del__(self):
+ """aaaaa"""
+ pass
+
+ def getdbConnectionStr (self):
+ """aaaaa"""
+ if self.__dbConnectionRaw is not None:
+ return self.__dbConnectionRaw
+
+ for element in self.__tree.iter('db'):
+ self.__dbConnectionRaw = element.attrib
+ self.__dbType = self.__dbConnectionRaw['type']
+ if self.__dbType == "PgSQLConnection":
+ self.__dbConnectionStr = self.getPostgresConnectionStr()
+ return self.__dbConnectionStr
+
+ return None
+
+ def getPostgresConnectionStr (self):
+ """aaaaa"""
+ str = self.__dbConnectionRaw
+ del str['type']
+ return str
+
+ def getMysqlConnectionStr (self):
+ """aaaaa"""
+ pass \ No newline at end of file
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.py b/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.py
new file mode 100644
index 0000000..b579e39
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.py
@@ -0,0 +1,108 @@
+import unittest
+import subprocess
+from test.helpers.globalVariables import globalVar
+
+
+class TestSysCommand(unittest.TestCase):
+ __str_cmd = None
+ __testname = None
+ __outfilename = None
+ __outdata = None
+ __outtofile = False
+
+ def __init__(self, testname, testfunc, str_cmd, outtofile = False):
+ """ init """
+ super(TestSysCommand, self).__init__(testfunc)
+ self.__str_cmd = str_cmd
+ self.__testname = testname
+ self.__outtofile = outtofile
+ self._testMethodDoc = testname
+ if self.__outtofile is True:
+ self.__outfilename = '/tmp/{}.txt'.format(testname)
+
+ def getName(self):
+ return self.__testname
+
+ def execute(self):
+ res = -1
+ try:
+ completed = subprocess.run(
+ self.__str_cmd,
+ check=True,
+ shell=True,
+ stdout=subprocess.PIPE,
+ )
+ self.assertTrue(completed.returncode is 0)
+ if completed.returncode is 0:
+ if self.__outtofile is True:
+ f = open(self.__outfilename, 'wb')
+ f.write(completed.stdout)
+ f.close()
+ res = 0
+ else:
+ res = -3
+ outdata = completed.stdout
+ self.longMessage=str(outdata).replace("'","")
+ self.assertTrue(True)
+ except subprocess.CalledProcessError as err:
+ self.assertTrue(False)
+ res = -1
+ except Exception as t:
+ res = -2
+ return res
+
+ def remove_file(self):
+ pass
+
+class SysCommand(object):
+ __str_cmd = None
+ __cmdname = None
+ __outdata = None
+ __errdata = None
+
+ def __init__(self, cmdname, str_cmd):
+ """ init """
+ self.__str_cmd = str_cmd
+ self.__cmdname = cmdname
+
+ def getName(self):
+ return self.__testname
+
+ def execute(self):
+ res = -1
+ try:
+ self.__outdata = None
+ self.__errdata = None
+ completed = subprocess.run(
+ self.__str_cmd,
+ check=True,
+ shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE
+ )
+ self.__outdata = completed.stdout
+ if completed.returncode is 0:
+ res = 0
+ if completed.stderr.decode('ascii') != "":
+ res = -1
+ self.__errdata = completed.stderr
+ except subprocess.CalledProcessError as err:
+ res = -2
+ except Exception as t:
+ res = -3
+ return res
+
+ def getOutput(self):
+ return self.__outdata
+
+ def getOutErr(self):
+ return self.__errdata
+
+ def getOutputlines(self):
+ return self.__outdata.splitlines()
+
+ def save_file(self, fname):
+ f = open(fname, 'wb')
+ f.write(self.__outdata)
+ f.close()
+
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.pyc b/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.pyc
new file mode 100644
index 0000000..1332c75
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/syscmd.pyc
Binary files differ
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/testsrv_db.py b/scripts/PYTHON_SOFTWARE/test/helpers/testsrv_db.py
new file mode 100644
index 0000000..bac6ed8
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/testsrv_db.py
@@ -0,0 +1,162 @@
+from test.helpers.psqldb import PgSQLConnection
+from test.helpers.setup_xml import XMLSetup
+
+def find_between( s, first, last ):
+ try:
+ start = s.index( first ) + len( first )
+ end = s.index( last, start )
+ return s[start:end]
+ except ValueError:
+ return ""
+
+
+class TestSrv_Database(object):
+ ''' TestSrv Database Helper '''
+
+ __sqlObject = None
+ __xml_setup = None
+
+ def __init__(self):
+ pass
+
+ def open (self, filename):
+ '''Open database connection'''
+ self.__xml_setup = XMLSetup(filename)
+ self.__sqlObject = PgSQLConnection()
+ return self.__sqlObject.db_connect(self.__xml_setup.getdbConnectionStr())
+
+ def create_board(self, processor_id, model_id, variant, bmac = None):
+ '''create a new board'''
+ if bmac is None:
+ sql = "SELECT isee.create_board('{}', '{}', '{}', NULL);".format(processor_id, model_id, variant)
+ else:
+ sql = "SELECT isee.create_board('{}', '{}', '{}', '{}');".format(processor_id, model_id, variant, bmac)
+ #print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ #print(res)
+ return res[0][0];
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ #print(r)
+ return None
+
+ def create_model(self, modid, variant, descr, tgid):
+ '''create new model'''
+ sql = "SELECT isee.create_model('{}', '{}', '{}', '{}')".format(modid, variant, descr, tgid)
+ #print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ #print(res)
+ return res[0][0];
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ #print(r)
+ return None
+
+ def create_test_definition(self, testname, testdesc, testfunc):
+ '''Create a new definition and return definition id on fail (testname already exist) return -1'''
+ sql = "SELECT isee.define_test('{}', '{}', '{}')".format(testname, testdesc, testfunc)
+ #print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ #print(res)
+ return res[0][0];
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ #print(r)
+ return None
+
+ def add_testdef_to_group(self, testgroupid, testname, testparam):
+ '''Assign definition to group test return true on success or false if it fails'''
+ sql = "SELECT isee.add_test_to_group('{}', '{}', '{}')".format(testgroupid, testname, testparam)
+ #print('>>>' + sql)
+ try:
+ res = self.__sqlObject.db_execute_query(sql)
+ #print(res)
+ return res[0][0];
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ #print(r)
+ return None
+
+ def getboard_test_list(self, board_uuid):
+ '''get the board test list'''
+ sql = "SELECT isee.gettestlist('{}')".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
+
+ def getboard_comp_test_list(self, board_uuid):
+ '''get the board test list'''
+ sql = "SELECT isee.gettestcompletelist('{}')".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
+
+ def open_testbatch(self, board_uuid):
+ '''get the board test list'''
+ sql = "SELECT isee.open_testbatch('{}')".format(board_uuid)
+ #print('>>>' + sql)
+ try:
+ res = str(self.__sqlObject.db_execute_query(sql)[0])
+ res = res.replace('(', '')
+ res = res.replace(')', '')
+ res = res.replace(',', '')
+ #print(res)
+ return res;
+ except Exception as err:
+ r = find_between(str(err), '#', '#')
+ #print(r)
+ return None
+
+ def add_test_to_batch(self, board_uuid, testid, testid_ctl, result, groupid, data):
+ '''get the board test list'''
+ sql = "SELECT isee.add_test_to_batch_c('{}','{}','{}','{}','{}','{}')".format(board_uuid, testid, testid_ctl, result, groupid, data)
+ #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
+
+ def close_testbatch(self, board_uuid, testid_ctl):
+ '''get the board test list'''
+ sql = "SELECT isee.close_testbatch('{}','{}')".format(board_uuid, testid_ctl)
+ #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
+
+ def update_set_test_row(self, nstation, testid_ctl, board_uuid, ctest, cstatus):
+ '''get the board test list'''
+ sql = "SELECT isee.update_set_test_row('{}','{}','{}','{}','{}')".format(nstation, testid_ctl ,board_uuid, ctest, cstatus)
+ #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 \ No newline at end of file
diff --git a/scripts/PYTHON_SOFTWARE/test/helpers/uboot_flasher.py b/scripts/PYTHON_SOFTWARE/test/helpers/uboot_flasher.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/PYTHON_SOFTWARE/test/helpers/uboot_flasher.py