Skip to content

Commit 9454c04

Browse files
committed
ci: Add rule for debug level menu
1 parent bf2d762 commit 9454c04

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed

.github/scripts/validate_board.sh

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ validate_board() {
4646
validate_vid_pid_consistency "$board_name" "$boards_file"
4747
echo ""
4848

49+
# Rule 5: Check for DebugLevel menu
50+
echo "Rule 5: DebugLevel Menu Validation"
51+
echo "=================================="
52+
validate_debug_level_menu "$board_name" "$boards_file"
53+
echo ""
54+
4955
# Add more validation rules here as needed
50-
# Rule 5: Future validation rules can be added here
5156
echo "=========================================="
52-
print_success "🎉 ALL VALIDATION RULES PASSED for board '$board_name'"
57+
print_success "ALL VALIDATION RULES PASSED for board '$board_name'"
5358
echo "=========================================="
5459
}
5560

@@ -392,13 +397,53 @@ validate_vid_pid_consistency() {
392397
echo " ✓ VID and PID consistency check passed"
393398
}
394399

395-
# Future validation rules can be added here
396-
# Example:
397-
# validate_custom_rule() {
398-
# local board_name="$1"
399-
# local boards_file="$2"
400-
# # Add custom validation logic here
401-
# }
400+
# Rule 5: Check for DebugLevel menu
401+
validate_debug_level_menu() {
402+
local board_name="$1"
403+
local boards_file="$2"
404+
405+
# Required DebugLevel menu options
406+
local required_debug_levels=("none" "error" "warn" "info" "debug" "verbose")
407+
local missing_levels=()
408+
409+
# Check if DebugLevel menu exists
410+
if ! grep -q "^$board_name.menu.DebugLevel\." "$boards_file"; then
411+
print_error "Missing DebugLevel menu for board '$board_name'"
412+
exit 1
413+
fi
414+
415+
# Check each required debug level
416+
for level in "${required_debug_levels[@]}"; do
417+
if ! grep -q "^$board_name.menu.DebugLevel.$level=" "$boards_file"; then
418+
missing_levels+=("$level")
419+
fi
420+
done
421+
422+
if [ ${#missing_levels[@]} -gt 0 ]; then
423+
print_error "Missing DebugLevel menu options for board '$board_name':"
424+
printf ' - %s\n' "${missing_levels[@]}"
425+
exit 1
426+
fi
427+
428+
# Check that each debug level has the correct build.code_debug value
429+
local code_debug_values=("0" "1" "2" "3" "4" "5")
430+
local debug_level_index=0
431+
432+
for level in "${required_debug_levels[@]}"; do
433+
local expected_value="${code_debug_values[$debug_level_index]}"
434+
local actual_value
435+
actual_value=$(grep "^$board_name.menu.DebugLevel.$level.build.code_debug=" "$boards_file" | cut -d'=' -f2)
436+
437+
if [ "$actual_value" != "$expected_value" ]; then
438+
print_error "Invalid code_debug value for DebugLevel '$level' in board '$board_name': expected '$expected_value', found '$actual_value'"
439+
exit 1
440+
fi
441+
442+
debug_level_index=$((debug_level_index + 1))
443+
done
444+
445+
echo " ✓ DebugLevel menu validation completed"
446+
}
402447

403448
# Main execution
404449
main() {

0 commit comments

Comments
 (0)