From 181cae23a2d02c2037e8a7793be93efa7a3f255a Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Wed, 6 Mar 2024 16:08:36 +0000 Subject: [PATCH 1/4] feat(remove-dts): Remove all dts references in the framework Signed-off-by: Miguel Silva --- framework/test_framework.py | 58 ------------------------------------- 1 file changed, 58 deletions(-) diff --git a/framework/test_framework.py b/framework/test_framework.py index bbe52b7..e1f87ba 100644 --- a/framework/test_framework.py +++ b/framework/test_framework.py @@ -11,7 +11,6 @@ import subprocess import psutil import constants as cons -from pydevicetree import Devicetree import connection test_config = { @@ -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") @@ -60,24 +55,6 @@ def parse_args(): input_args = parser.parse_args() return input_args -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] - - 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 - def run_command_in_terminal(command): """ Run a command in a new Terminal window. @@ -230,23 +207,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) @@ -259,27 +219,9 @@ def move_results_to_output(): 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 += "\"" - print(BUILD_CMD) res = os.system(BUILD_CMD) if res==0: From 74fa25e42b5473dcff35728cd625256e1c7093b2 Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Wed, 6 Mar 2024 16:09:57 +0000 Subject: [PATCH 2/4] feat: Add input arguments for platform and nix recipe Signed-off-by: Miguel Silva --- framework/test_framework.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/framework/test_framework.py b/framework/test_framework.py index e1f87ba..fda2d41 100644 --- a/framework/test_framework.py +++ b/framework/test_framework.py @@ -52,6 +52,14 @@ def parse_args(): "2 - logs all test results and the final report", default=0) + parser.add_argument("-recipe", "--recipe", + help="Path to the .nix recipe file", + default="../../recipes/single-baremetal/default.nix") + + parser.add_argument("-platform", "--platform", + help="Used define the target platform", + default=" ") + input_args = parser.parse_args() return input_args From 255feebc307a7fa14db492946531d346dd97bd5f Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Wed, 6 Mar 2024 16:11:45 +0000 Subject: [PATCH 3/4] feat: Add checks to verify if the arguments were provided Signed-off-by: Miguel Silva --- framework/test_framework.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/framework/test_framework.py b/framework/test_framework.py index fda2d41..17a42d6 100644 --- a/framework/test_framework.py +++ b/framework/test_framework.py @@ -226,6 +226,22 @@ def move_results_to_output(): os.system(RUN_CMD) print(cons.BLUE_TEXT + "Running nix build..." + cons.RESET_COLOR) + + 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 ../../' + test_config['nix_file'] BUILD_CMD += " --argstr platform " + test_config['platform'] BUILD_CMD += " --argstr log_level " + str(args.log_level) From 826fa2113ef80af318a8c8b72697f88be0a28fce Mon Sep 17 00:00:00 2001 From: Miguel Silva Date: Wed, 6 Mar 2024 16:12:50 +0000 Subject: [PATCH 4/4] ref: Use platform and recipe variables from the command line Signed-off-by: Miguel Silva --- framework/test_framework.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/test_framework.py b/framework/test_framework.py index 17a42d6..7ec2057 100644 --- a/framework/test_framework.py +++ b/framework/test_framework.py @@ -242,8 +242,8 @@ def move_results_to_output(): recipe = args.recipe print("Recipe .nix file: " + recipe) - BUILD_CMD = 'nix-build ../../' + test_config['nix_file'] - BUILD_CMD += " --argstr platform " + test_config['platform'] + BUILD_CMD = 'nix-build ' + recipe + BUILD_CMD += " --argstr platform " + platfrm BUILD_CMD += " --argstr log_level " + str(args.log_level) print(BUILD_CMD) @@ -262,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)