Use build profiles instead of providing sdkconfig.defaults manually
ESP-IDF provides a more efficient way of handling and combining multi-configurations for a project than the way currently used: Build profiles. So I switched to this method instead of providing the sdkconfig.defaults.* files manually. This reduced the number of sdkconfig.defaults.* files as well as the configuration parameters defined in them. Refs #1085
This commit is contained in:
@@ -11,12 +11,12 @@ fi
|
||||
|
||||
# ==== 2. Valid Modes and Defaults ====
|
||||
valid_test_tags=("core" "tilt" "listener" "all" "relay_chn" "nvs" "run_limit" "batch")
|
||||
valid_test_profiles=("run_limit" "tilt" "nvs" "nvs_custom" "multi" "full_single" "full_multi")
|
||||
arg_tag="all" # Default to 'all' if no tag specified
|
||||
arg_profile="full_multi" # Default to 'full_multi' if no profile specified
|
||||
arg_clean=false
|
||||
arg_log=false
|
||||
arg_dry_run=false
|
||||
arg_sdkconfig_file=""
|
||||
flag_file=false
|
||||
|
||||
print_help() {
|
||||
echo "Usage: $0 -t <tags> [OPTIONS]"
|
||||
@@ -28,6 +28,10 @@ print_help() {
|
||||
echo ""
|
||||
echo " If no tag is specified, it defaults to 'all'."
|
||||
echo ""
|
||||
echo " -p, --profile [run_limit|tilt|nvs|nvs_custom|multi|full_single|full_multi] Specify which test tag to run."
|
||||
echo ""
|
||||
echo " If no profile is specified, it defaults to 'full_multi'."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -f, --file <path> Specify a custom sdkconfig file to use for the build."
|
||||
echo " Defaults to 'sdkconfig.defaults' if not provided."
|
||||
@@ -54,9 +58,8 @@ while [[ $# -gt 0 ]]; do
|
||||
arg_tag="$2"
|
||||
shift 2
|
||||
;;
|
||||
--file|-f)
|
||||
arg_sdkconfig_file="$2"
|
||||
flag_file=true
|
||||
--profile|-p)
|
||||
arg_profile="$2"
|
||||
shift 2
|
||||
;;
|
||||
--clean|-c)
|
||||
@@ -86,6 +89,11 @@ if [[ ! " ${valid_test_tags[*]} " =~ " $arg_tag " ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ! " ${valid_test_profiles[*]} " =~ " $arg_profile " ]]; then
|
||||
echo "❌ Invalid profile: '$arg_profile'"
|
||||
usage
|
||||
fi
|
||||
|
||||
# ==== 5. Resolve Paths and Switch to Working Directory ====
|
||||
script_dir=$(dirname "$(readlink -f "$0")")
|
||||
project_root=$(dirname "$script_dir")
|
||||
@@ -98,21 +106,9 @@ if [[ -z "$test_apps_dir" || ! -d "$test_apps_dir" ]]; then
|
||||
echo " Please ensure the script is in a 'scripts' directory and 'test_apps' is a sibling."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Found 'test_apps' at: $test_apps_dir"
|
||||
|
||||
if $flag_file; then
|
||||
if [[ -z "$arg_sdkconfig_file" || ! -f "$arg_sdkconfig_file" ]]; then
|
||||
echo "❌ Invalid or missing file: '$arg_sdkconfig_file'"
|
||||
usage
|
||||
fi
|
||||
# Resolve to an absolute path to work correctly after changing directory
|
||||
arg_sdkconfig_file=$(readlink -f "$arg_sdkconfig_file")
|
||||
else
|
||||
echo "⚠️ No SDK configuration file provided. Using default sdkconfig."
|
||||
arg_sdkconfig_file="$test_apps_dir/sdkconfig.defaults"
|
||||
fi
|
||||
|
||||
echo "🧪 Test mode: $arg_tag"
|
||||
echo "🧪 Test mode: $arg_tag | Profile: $arg_profile"
|
||||
echo "🧹 Clean: $arg_clean | 📄 Log: $arg_log"
|
||||
|
||||
echo "📂 Changing to working directory: $test_apps_dir"
|
||||
@@ -129,15 +125,14 @@ fi
|
||||
# In some locales, we can get errors like: "Error: unknown opcode or format name 'wsr.IBREAKA1'"
|
||||
# The 'LC_ALL=C' env variable is set to ensure consistent locale settings.
|
||||
LC_ALL=C \
|
||||
SDKCONFIG_DEFAULTS="$arg_sdkconfig_file" \
|
||||
RELAY_CHN_UNITY_TEST_GROUP_TAG="$arg_tag" \
|
||||
idf.py reconfigure build
|
||||
idf.py @profiles/"${arg_profile}" reconfigure build
|
||||
|
||||
echo "🚀 Running test with QEMU..."
|
||||
|
||||
if $arg_log; then
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
LOGFILE="test_log_${arg_tag}_$TIMESTAMP.txt"
|
||||
LOGFILE="test_log_${arg_profile}_${arg_tag}_$TIMESTAMP.txt"
|
||||
if $arg_dry_run; then
|
||||
echo "🔍 Dry run mode: Logging to $LOGFILE but not executing." | tee "$LOGFILE"
|
||||
echo "Command: idf.py qemu" | tee "$LOGFILE"
|
||||
|
||||
@@ -18,13 +18,16 @@ echo "🔍 Searching for 'test_apps' directory in '$project_root'..."
|
||||
test_apps_dir=$(find "$project_root" -type d -name "test_apps" | head -n 1)
|
||||
echo "test_apps dir: ${test_apps_dir}"
|
||||
|
||||
# Execute tests for all configs
|
||||
mapfile -t sdkcfg_files < <(find "$test_apps_dir" -maxdepth 1 -type f -name "sdkconfig.defaults*")
|
||||
# Execute tests for all profiles
|
||||
mapfile -t profiles < <(find "${test_apps_dir}/profiles" -maxdepth 1 -type f)
|
||||
|
||||
for sdkcfg_file in "${sdkcfg_files[@]}"; do
|
||||
echo "🔧 Running tests with config: $sdkcfg_file"
|
||||
"${script_dir}"/run_tests.sh -c -f "$sdkcfg_file" -t "$arg_tag" || {
|
||||
echo "❌ Tests failed with config: $sdkcfg_file"
|
||||
for profile in "${profiles[@]}"; do
|
||||
# Get only the name of the profile file
|
||||
profile=$(basename "${profile}")
|
||||
|
||||
echo "🔧 Running tests with profile: $profile"
|
||||
"${script_dir}"/run_tests.sh -c -p "$profile" -t "$arg_tag" || {
|
||||
echo "❌ Tests failed with profile: $profile"
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
Reference in New Issue
Block a user