Continue HIL test refactoring WIP

feature/EBB_Regression_Tests
EmbeddedMan 2024-03-13 20:51:17 -05:00
rodzic f8aa40dca4
commit 2bbab85052
5 zmienionych plików z 117 dodań i 12 usunięć

Wyświetl plik

@ -0,0 +1,93 @@
# Test file to show each function working
from saleae import automation
import os
import os.path
from datetime import datetime
import sys
import csv
import time
from pyaxidraw import axidraw
from ebb_serial_utility import query
from ebb_serial_utility import EBB_version_less_than
from saleae_capture_one import capture_command
from analyze_digital_csv import analyze_digital_csv
from analyze_digital_csv import extract_debug_uart
from analyze_digital_csv import compare_debug_uart
def test_ISR_math_run(test_input_path : str):
all_tests_pass = False
# Create new test artifact directory
# Each test will create a directory within this directory with its artifacts
artifact_dir = os.path.join(os.getcwd(), f'../sample output/output-{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}')
input_filepath = os.path.join(os.getcwd(), test_input_path)
os.makedirs(artifact_dir, exist_ok = True)
# Connect to EBB
ad = axidraw.AxiDraw() # Initialize class
ad.interactive()
if not ad.connect(): # Open serial port to AxiDraw;
print("failed to connect")
quit()
the_port = ad.plot_status.port
if the_port is None:
print("failed to connect")
sys.exit() # end script
the_port.reset_input_buffer()
print("connected")
EBB_version = query(the_port, 'V\r')
last_command = ""
if EBB_version_less_than(EBB_version.decode("utf-8"), "3.0.0"):
print("EBB version required is 3.0.0 or above, but found :" + EBB_version)
return False
# Turn on the debug features we need in order to run our tests
response = str(query(the_port, "CU,250,1" + '\r'))
#print(last_command + " :: " + response.strip())
response = str(query(the_port, "CU,251,1" + '\r'))
#print(last_command + " :: " + response.strip())
response = str(query(the_port, "CU,257,1" + '\r'))
#print(last_command + " :: " + response.strip())
# Walk through each line of the tests from the test input file
# and execute them
#for data_line in test_input_file:
with open(input_filepath, "r", newline='') as test_input_file:
reader = csv.reader(test_input_file, quotechar='"', doublequote=True, skipinitialspace=True)
for param in reader:
if (len(param) >= 5):
if (param[0] != '0'):
print(param[2] + ": ", end='')
test_dir = os.path.join(artifact_dir, param[2])
#capture_command(param[1], test_dir, float(param[3]), param[4])
capture_command(param[1], test_dir, float(param[3]), the_port)
# Now perform the type of analysis appropriate for this test
# In this case, extract the debug UART data
# and then check to see if it matches what we have from the test input file
#check_debug_serial(analyzer_export_filepath, expected_params)
if compare_debug_uart(extract_debug_uart(test_dir), param[4]):
print("Pass")
else:
print("Fail")
all_tests_pass = False
ad.disconnect() # Close serial port to AxiDraw
test_input_file.close()
print("Complete")
return all_tests_pass
# For calling the main function from the command line
#test_ISR_math_run(sys.argv[1])

Wyświetl plik

@ -0,0 +1,24 @@
# Main EBB hardware in the loop test script
#
# Called without any parameters, this script will run all EBB hardware tests
# A single sub test can be run by naming that test as the first parameter
#
from test_ISR_math import test_ISR_math_run
all_tests_pass = True
# Test :
print("Run test: test_ISR_math_run()")
if test_ISR_math_run("..\\test input data\\test_inputs_simple.csv") == False:
all_tests_pass = False
# Done running all tests
if all_tests_pass == True:
print("All tests passed")
else:
print("Some or all tests failed")
print("Complete")

Wyświetl plik

Nie można renderować tego pliku, ponieważ ma nieprawidłową liczbę pól w wierszu 2.

Wyświetl plik

Nie można renderować tego pliku, ponieważ ma nieprawidłową liczbę pól w wierszu 2.

Wyświetl plik

@ -1,12 +0,0 @@
# Main EBB hardware in the loop test script
#
# Called without any parameters, this script will run all EBB hardware tests
# A single sub test can be run by naming that test as the first parameter
#
from scripts.test_test import test_test_run
print("Run test: test_test_run()")
test_test_run()
print("Complete")