@@ -46,10 +46,15 @@ validate_board() {
46
46
validate_vid_pid_consistency " $board_name " " $boards_file "
47
47
echo " "
48
48
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
+
49
55
# Add more validation rules here as needed
50
- # Rule 5: Future validation rules can be added here
51
56
echo " =========================================="
52
- print_success " 🎉 ALL VALIDATION RULES PASSED for board '$board_name '"
57
+ print_success " ALL VALIDATION RULES PASSED for board '$board_name '"
53
58
echo " =========================================="
54
59
}
55
60
@@ -392,13 +397,53 @@ validate_vid_pid_consistency() {
392
397
echo " ✓ VID and PID consistency check passed"
393
398
}
394
399
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
+ }
402
447
403
448
# Main execution
404
449
main () {
0 commit comments