summaryrefslogtreecommitdiff
path: root/test-cli/test/helpers
diff options
context:
space:
mode:
authorManel Caro <mcaro@iseebcn.com>2019-03-09 21:38:10 +0100
committerManel Caro <mcaro@iseebcn.com>2019-03-10 11:25:47 +0100
commit7edd6c5f599533e67bdf494df13cab06d5995209 (patch)
treeed36d7f424d7535eff2bf5d089847dc1fe3a31be /test-cli/test/helpers
parente4366bb1f2dc3a43a1289f6f76967f1005278954 (diff)
downloadboard-7edd6c5f599533e67bdf494df13cab06d5995209.zip
board-7edd6c5f599533e67bdf494df13cab06d5995209.tar.gz
board-7edd6c5f599533e67bdf494df13cab06d5995209.tar.bz2
Modify some Execution Tests and EEprom Support
- Change Board Model to IGEP0000 - Change Audio Test - Change qbutton Test - Change qScreen Test - Added EEprom Support
Diffstat (limited to 'test-cli/test/helpers')
-rw-r--r--test-cli/test/helpers/__pycache__/__init__.cpython-35.pycbin118 -> 118 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/cv_display_test.cpython-35.pycbin3246 -> 3161 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/finisher.cpython-35.pycbin0 -> 4475 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/get_dieid.cpython-35.pycbin1496 -> 1535 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/globalVariables.cpython-35.pycbin345 -> 375 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/psqldb.cpython-35.pycbin1939 -> 1882 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/setup_xml.cpython-35.pycbin1481 -> 1481 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/syscmd.cpython-35.pycbin3694 -> 3683 bytes
-rw-r--r--test-cli/test/helpers/__pycache__/testsrv_db.cpython-35.pycbin5230 -> 6077 bytes
-rw-r--r--test-cli/test/helpers/cv_display_test.py10
-rw-r--r--test-cli/test/helpers/finisher.py151
-rw-r--r--test-cli/test/helpers/get_dieid.py2
-rw-r--r--test-cli/test/helpers/globalVariables.py2
-rw-r--r--test-cli/test/helpers/psqldb.py20
-rw-r--r--test-cli/test/helpers/testsrv_db.py16
15 files changed, 185 insertions, 16 deletions
diff --git a/test-cli/test/helpers/__pycache__/__init__.cpython-35.pyc b/test-cli/test/helpers/__pycache__/__init__.cpython-35.pyc
index 5224618..5a46842 100644
--- a/test-cli/test/helpers/__pycache__/__init__.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/__init__.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/cv_display_test.cpython-35.pyc b/test-cli/test/helpers/__pycache__/cv_display_test.cpython-35.pyc
index 5df3dbc..05de7f2 100644
--- a/test-cli/test/helpers/__pycache__/cv_display_test.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/cv_display_test.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/finisher.cpython-35.pyc b/test-cli/test/helpers/__pycache__/finisher.cpython-35.pyc
new file mode 100644
index 0000000..d647dd1
--- /dev/null
+++ b/test-cli/test/helpers/__pycache__/finisher.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/get_dieid.cpython-35.pyc b/test-cli/test/helpers/__pycache__/get_dieid.cpython-35.pyc
index d822bf3..23caec4 100644
--- a/test-cli/test/helpers/__pycache__/get_dieid.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/get_dieid.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/globalVariables.cpython-35.pyc b/test-cli/test/helpers/__pycache__/globalVariables.cpython-35.pyc
index 75d4904..7ac8396 100644
--- a/test-cli/test/helpers/__pycache__/globalVariables.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/globalVariables.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/psqldb.cpython-35.pyc b/test-cli/test/helpers/__pycache__/psqldb.cpython-35.pyc
index 8f85c0c..bdba2f1 100644
--- a/test-cli/test/helpers/__pycache__/psqldb.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/psqldb.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/setup_xml.cpython-35.pyc b/test-cli/test/helpers/__pycache__/setup_xml.cpython-35.pyc
index d1a3f94..58ec6f6 100644
--- a/test-cli/test/helpers/__pycache__/setup_xml.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/setup_xml.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/syscmd.cpython-35.pyc b/test-cli/test/helpers/__pycache__/syscmd.cpython-35.pyc
index 77658c7..fbb7322 100644
--- a/test-cli/test/helpers/__pycache__/syscmd.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/syscmd.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/__pycache__/testsrv_db.cpython-35.pyc b/test-cli/test/helpers/__pycache__/testsrv_db.cpython-35.pyc
index 2169783..b216640 100644
--- a/test-cli/test/helpers/__pycache__/testsrv_db.cpython-35.pyc
+++ b/test-cli/test/helpers/__pycache__/testsrv_db.cpython-35.pyc
Binary files differ
diff --git a/test-cli/test/helpers/cv_display_test.py b/test-cli/test/helpers/cv_display_test.py
index 7321667..b54a698 100644
--- a/test-cli/test/helpers/cv_display_test.py
+++ b/test-cli/test/helpers/cv_display_test.py
@@ -1,7 +1,5 @@
import cv2
import numpy as np
-import subprocess
-
@@ -17,9 +15,7 @@ def pattern_detect(cam_device=0):
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)
+ capture = cv2.VideoCapture("/dev/v4l/by-id/usb-Creative_Technology_Ltd._Live__Cam_Sync_HD_VF0770-video-index0")
try:
_, image = capture.read()
except:
@@ -145,3 +141,7 @@ def pattern_detect(cam_device=0):
msg = "AVG BLUE COUNT FAIL"
return msg
return msg
+
+
+
+
diff --git a/test-cli/test/helpers/finisher.py b/test-cli/test/helpers/finisher.py
new file mode 100644
index 0000000..73142d9
--- /dev/null
+++ b/test-cli/test/helpers/finisher.py
@@ -0,0 +1,151 @@
+from test.helpers.syscmd import SysCommand
+from test.helpers.globalVariables import globalVar
+import binascii
+import uuid
+import subprocess
+from PIL import Image, ImageDraw, ImageFont
+import qrcode
+import PIL
+
+class Finisher(object):
+ __muhb = None
+ __final_to_burn_to_eeprom = None
+ __qr_image = None
+
+ def __init__(self, muhb = None):
+ self.__muhb = muhb
+ self.__final_to_burn_to_eeprom = bytearray()
+ self.__qr_image = None
+ pass
+
+ def eeprom_burn(self):
+ ## Create binary file
+ str_cmd2 = "find /sys/ -iname 'eeprom'"
+ eeprom_location = SysCommand("eeprom_location", str_cmd2)
+ if eeprom_location.execute() == 0:
+ raw_out = eeprom_location.getOutput()
+ if raw_out == "":
+ self.fail("Unable to get EEPROM location. IS EEPROM CONNECTED?")
+ eeprom = raw_out.decode('ascii')
+ eeprom = eeprom.strip('\n')
+ ## push binary data to eeprom like if working with files
+ file2 = open(eeprom, "w+b")
+ file2.write(self.__final_to_burn_to_eeprom)
+ else:
+ self.fail("failed: could not complete find eeprom command")
+
+ def generate_qr_stamp(self):
+ # Generate QR to put in a stamp
+ qr = qrcode.QRCode(
+ version=1,
+ error_correction=qrcode.constants.ERROR_CORRECT_L,
+ box_size=10,
+ border=4,
+ )
+ # Use board_uuid to generate the QR code
+ qr.add_data(globalVar.g_uuid)
+ qr.make(fit=True)
+ # Save QR as image stamp.png
+ img = qr.make_image()
+ # Store QR as a class atrib
+ self.__qr_image = img
+ img.save('/home/root/stamp.png')
+
+ def print_stamp(self):
+ # Print stamp by sending a cmd to the printer
+ str_cmd3 = "lpr -o scaling=4 stamp.png".format(self.__display)
+ printstamp = SysCommand("printstamp", str_cmd3)
+ if printstamp.execute() != 0:
+ self.fail("failed: could not print stamp")
+
+ def generate_screen(self):
+ # Generate green image with board uuid and QR maybe pasted on top of green image
+ # Define image size
+ W = 1250
+ H = 703
+ # Create blank rectangle to write on
+ image = Image.new('RGB', (W, H), (46, 204, 113, 0))
+ draw = ImageDraw.Draw(image)
+ message = "TEST OK\n\n" + "Board UUID: "+ globalVar.g_uuid
+ font = ImageFont.truetype('/usr/share/fonts/truetype/dejavuu/DejaVuSans.ttf', 40)
+ # Calculate the width and height of the text to be drawn, given font size
+ w, h = draw.textsize(message, font=font)
+ # Write the text to the image, where (x,y) is the top left corner of the text
+ draw.text(((W-w)/2,(H-h)/2), message, align='center', font=font)
+ #draw.image(self.__qr_image)
+ image.save('/home/root/test/files/test_ok.png')
+
+ def show_result_screen(self):
+ # If test OK show test_OK.png located in /home/root, If test fail show test_fail.png, located in /home/root/test/files/test_KO.png
+ if globalVar.fstatus:
+ str_cmd4 = "fbi -T 1 --noverbose -d /dev/{} test/files/test_ok.png".format('fb0')
+ else:
+ str_cmd4 = "fbi -T 1 --noverbose -d /dev/{} test/files/test_ko.png".format('fb0')
+
+ display_image = SysCommand("display_image", str_cmd4)
+ #print(display_image.execute())
+ if display_image.execute() != -1:
+ self.fail("failed: could not display the image")
+
+
+ def end_ok(self):
+ # Burn retrieved igep eeprom struct
+ new = self.__muhb[0][0]
+
+ # Convert from string to hex
+ hnew = new.encode()
+ # Magic_id and default crc32 0x6d, 0x6a, 0x6d, 0xe4 with endianess changed so that u-boot loads it correctly
+ # IF magic ever changes this magic_id should be changed. At the end always magic_id of test and u-boot should
+ # be the same
+ magic_id = bytes([0xe4, 0x6d, 0x6a, 0x6d])
+ default_igep_crc32 = bytes([0x00, 0x00, 0x00, 0x00])
+
+ # Create bytearray
+ to_calculate = bytearray()
+ # Build the final hex binary for crc32 operation
+ to_calculate.extend(magic_id)
+ to_calculate.extend(default_igep_crc32)
+ to_calculate.extend(hnew)
+
+ # Calculate crc32!
+ new_crc32 = binascii.crc32(to_calculate)
+ hnew_crc32 = new_crc32.to_bytes(4, byteorder="little")
+
+ # Recreate final eeprom struct in bytearray
+ self.__final_to_burn_to_eeprom = bytearray()
+ self.__final_to_burn_to_eeprom.extend(magic_id)
+ self.__final_to_burn_to_eeprom.extend(hnew_crc32)
+ self.__final_to_burn_to_eeprom.extend(hnew)
+ self.eeprom_burn()
+
+ # Generate QR stamp
+ self.generate_qr_stamp()
+ # Send print stamp command
+ #self.print_stamp()
+ # Generate green image with board uuid and QR maybe pasted on top of green image
+ self.generate_screen()
+ # Show test_ok.png image in screen
+ self.show_result_screen()
+
+ def end_fail(self):
+ # Burn igep eeprom bug struct
+ hnew = self.__muhb.encode()
+ default_fail = bytes([0xD0, 0xBA, 0xD0, 0xBA])
+ self.__final_burn_to_eeprom = bytearray()
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(hnew)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.__final_to_burn_to_eeprom.extend(default_fail)
+ self.eeprom_burn()
+ # Show test_ko.png image in screen
+ self.show_result_screen() \ No newline at end of file
diff --git a/test-cli/test/helpers/get_dieid.py b/test-cli/test/helpers/get_dieid.py
index 029ddb5..b20f143 100644
--- a/test-cli/test/helpers/get_dieid.py
+++ b/test-cli/test/helpers/get_dieid.py
@@ -21,6 +21,8 @@ def read(addr):
def getRegisters(model):
if model.find("IGEP0046") == 0:
registers = [0x021BC420, 0x021BC410]
+ elif model.find("IGEP0000") == 0:
+ registers = [0x021BC420, 0x021BC410]
elif model.find("IGEP0034") == 0 or model.find("SOPA0000") == 0:
registers = [0x44e10630, 0x44e10634, 0x44e10638, 0x44e1063C]
elif model.find("OMAP3") == 0:
diff --git a/test-cli/test/helpers/globalVariables.py b/test-cli/test/helpers/globalVariables.py
index 6b89f4d..c4d8358 100644
--- a/test-cli/test/helpers/globalVariables.py
+++ b/test-cli/test/helpers/globalVariables.py
@@ -6,3 +6,5 @@ def globalVar():
g_mid = ""
outdata = "NONE"
station = ""
+ fstatus = ""
+ gdisplay = None \ No newline at end of file
diff --git a/test-cli/test/helpers/psqldb.py b/test-cli/test/helpers/psqldb.py
index af08579..26dd03d 100644
--- a/test-cli/test/helpers/psqldb.py
+++ b/test-cli/test/helpers/psqldb.py
@@ -7,21 +7,21 @@ class PgSQLConnection(object):
__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):
+ def __init__ (self):
+# 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):
result = False
try:
if connect_str == None:
self.__conection_object = psycopg2.connect(**self.__db_config)
else:
- __db_config = connect_str;
+ self.__db_config = connect_str;
self.__conection_object = psycopg2.connect(**self.__db_config)
self.__conection_object.autocommit = True
result = True
diff --git a/test-cli/test/helpers/testsrv_db.py b/test-cli/test/helpers/testsrv_db.py
index bac6ed8..94181f9 100644
--- a/test-cli/test/helpers/testsrv_db.py
+++ b/test-cli/test/helpers/testsrv_db.py
@@ -159,4 +159,18 @@ class TestSrv_Database(object):
except Exception as err:
r = find_between(str(err), '#', '#')
#print(r)
- return None \ No newline at end of file
+ return None
+
+ def getboard_eeprom(self, board_uuid):
+ '''get the board eeprom struct '''
+ sql = "SELECT isee.getboard_eeprom('{}')".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
+ \ No newline at end of file