feat(tfut): add support for hooks and run configs
With this patch, the pre_tfut_build hook can be implemented in the
TFUT run config files in order to perform custom actions, such as
setting build targets. This way, build targets can be specified in
the TFUT run config files, as it is currently done for TF-A, allowing
for more flexibility.
Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
Signed-off-by: Edward Potapov <edward.potapov@arm.com>
Change-Id: If8a4d0c63a885eee9ffdd8f2c5a68c6a3cff9cd4
diff --git a/script/build_package.sh b/script/build_package.sh
index eaa29a1..e7e1fe7 100755
--- a/script/build_package.sh
+++ b/script/build_package.sh
@@ -127,6 +127,15 @@
done
fi
+ if [ "$run_config_tfut_candidates" ]; then
+ for config_fragment in $run_config_tfut_candidates; do
+ (
+ source "$ci_root/run_config_tfut/$config_fragment"
+ call_func "$func" "$config_fragment"
+ )
+ done
+ fi
+
# Also source test config file
(
unset "$func"
@@ -779,8 +788,12 @@
fi
fi
- config=$(cat "$config_file" | grep -v "tests=")
- cmake_config=$(echo "$config" | sed -e 's/^/\-D/')
+ #TODO: extract vars from env to use them for cmake
+
+ test -f "$config_file"
+
+ config=$(cat "$config_file" | grep -v "tests=") \
+ && cmake_config=$(echo "$config" | sed -e 's/^/\-D/')
# Check if cmake is installed
if ! command -v cmake &> /dev/null
@@ -829,9 +842,9 @@
set_hook_var "spm_build_targets" "$targets"
}
-set_tfut_build_targets() {
- echo "Set build target to '${targets:?}'"
- set_hook_var "tfut_build_targets" "$targets"
+add_tfut_build_targets() {
+ echo "Add TFUT build targets '${targets:?}'"
+ append_hook_var "tfut_build_targets" "$targets "
}
set_spm_out_dir() {
@@ -1259,6 +1272,20 @@
fi
fi
+if [ "$run_config_tfut" ]; then
+ # Get candidates for run TFUT config
+ run_config_tfut_candidates="$("$ci_root/script/gen_run_config_candidates.py" \
+ "--unit-testing" "$run_config_tfut")"
+ if [ -z "$run_config_tfut_candidates" ]; then
+ die "No run TFUT config candidates!"
+ else
+ echo
+ echo "Chosen fragments:"
+ echo
+ echo "$run_config_tfut_candidates" | sed 's/^\|\n/\t/g'
+ fi
+fi
+
call_hook "test_setup"
echo
@@ -1549,6 +1576,9 @@
echo "Building Trusted Firmware UT ($mode) ..." |& log_separator
+ # Clean TFUT build targets
+ set_hook_var "tfut_build_targets" ""
+
# Call pre-build hook
call_hook pre_tfut_build
diff --git a/script/gen_run_config_candidates.py b/script/gen_run_config_candidates.py
index 5a52f99..e6c4e25 100755
--- a/script/gen_run_config_candidates.py
+++ b/script/gen_run_config_candidates.py
@@ -16,6 +16,8 @@
parser = argparse.ArgumentParser(description="Choose run configurations")
parser.add_argument("--print-only", "-p", action="store_true", default=False,
help="Print only; don't check for matching run configs.")
+parser.add_argument("--unit-testing", action="store_true", default=False,
+ help="Use to indicate if it is a unit testing config or not")
parser.add_argument("args", nargs=argparse.REMAINDER, help="Run configuration")
opts = parser.parse_args()
@@ -24,7 +26,10 @@
# Obtain path to run_config directory
script_root = os.path.dirname(os.path.abspath(sys.argv[0]))
-run_config_dir = os.path.join(script_root, os.pardir, "run_config")
+if (not opts.unit_testing):
+ run_config_dir = os.path.join(script_root, os.pardir, "run_config")
+else:
+ run_config_dir = os.path.join(script_root, os.pardir, "run_config_tfut")
arg = opts.args[0]
run_config = arg.split(":")[-1]