Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(remove dts): Remove the the use of DTS files #26

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 27 additions & 61 deletions framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import subprocess
import psutil
import constants as cons
from pydevicetree import Devicetree
import connection

test_config = {
Expand All @@ -27,10 +26,6 @@ def parse_args():
"""
parser = argparse.ArgumentParser(description="Bao Testing Framework")

parser.add_argument("-dts_path", "--dts_path",
help="Path to .dts configuration file",
default="../../configs/config.dts")

parser.add_argument("-bao_test_src_path", "--bao_test_src_path",
help="Path to bao-test /src dir",
default="../src")
Expand All @@ -57,26 +52,16 @@ def parse_args():
"2 - logs all test results and the final report",
default=0)

input_args = parser.parse_args()
return input_args
parser.add_argument("-recipe", "--recipe",
help="Path to the .nix recipe file",
default="../../recipes/single-baremetal/default.nix")

def parse_dts_file(file_path):
"""
Parse a DTS (Device Tree Source) file and extract relevant information.

Args:
file_path (str): The path to the DTS configuration file.
"""
tree = Devicetree.parseFile(file_path)
test_config['platform'] = \
tree.children[0].properties[0].values[0]
parser.add_argument("-platform", "--platform",
help="Used define the target platform",
default=" ")

test_config['nix_file'] = \
tree.children[0].children[0].children[0].properties[0].values[0]
test_config['suites'] = \
tree.children[0].children[0].children[0].properties[1].values
test_config['tests'] = \
tree.children[0].children[0].children[0].properties[2].values
input_args = parser.parse_args()
return input_args

def run_command_in_terminal(command):
"""
Expand Down Expand Up @@ -230,23 +215,6 @@ def move_results_to_output():
cons.RESET_COLOR)
sys.exit(-1)

print(cons.BLUE_TEXT +
"Reading config.dts..." +
cons.RESET_COLOR)

dts_path = args.dts_path
print("config.dts file: " + dts_path)

if args.dts_path is None:
print(cons.RED_TEXT +
"Error: Please provide the --dts_path argument." +
cons.RESET_COLOR)
else:
dts_path = args.dts_path

parse_dts_file(dts_path)
print(cons.GREEN_TEXT + "config.dts successfully read!" + cons.RESET_COLOR)

print(cons.BLUE_TEXT +
"Creating tests source file..." +
cons.RESET_COLOR)
Expand All @@ -258,27 +226,25 @@ def move_results_to_output():
os.system(RUN_CMD)

print(cons.BLUE_TEXT + "Running nix build..." + cons.RESET_COLOR)
BUILD_CMD = 'nix-build ../../' + test_config['nix_file']
LIST_SUITES = test_config['suites']
LIST_TESTS = test_config['tests']
BUILD_CMD += " --argstr platform " + test_config['platform']
BUILD_CMD += " --argstr log_level " + str(args.log_level)

if LIST_SUITES:
BUILD_CMD += " --argstr list_suites \""
for index, suit in enumerate(LIST_SUITES):
BUILD_CMD += suit
if index < len(LIST_SUITES) - 1:
BUILD_CMD += r"\ "
BUILD_CMD += "\""

if LIST_TESTS:
BUILD_CMD += " --argstr list_tests \""
for index, test in enumerate(LIST_TESTS):
BUILD_CMD += test
if index < len(LIST_TESTS) - 1:
BUILD_CMD += r"\ "
BUILD_CMD += "\""
if args.platform is None:
print(cons.RED_TEXT +
"Error: Please provide a --platform." +
cons.RESET_COLOR)
else:
platfrm = args.platform

if args.recipe is None:
print(cons.RED_TEXT +
"Error: Please provide the --recipe argument." +
cons.RESET_COLOR)
else:
recipe = args.recipe
print("Recipe .nix file: " + recipe)

BUILD_CMD = 'nix-build ' + recipe
BUILD_CMD += " --argstr platform " + platfrm
BUILD_CMD += " --argstr log_level " + str(args.log_level)

print(BUILD_CMD)
res = os.system(BUILD_CMD)
Expand All @@ -296,4 +262,4 @@ def move_results_to_output():
move_results_to_output()

print(cons.BLUE_TEXT + "Launching QEMU..." + cons.RESET_COLOR)
deploy_test(test_config['platform'])
deploy_test(platfrm)
Loading