My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/usr/bin/env bash
  2. #
  3. # mftest [name] [index]
  4. #
  5. # Set configuration options based on a test
  6. # By default it will do megaatmega2560
  7. # Use 'mftest -' to pick from the list.
  8. #
  9. MFINFO=$(mfinfo) || exit 1
  10. [[ -d Marlin/src ]] || { echo "Please 'cd' up to repo root." ; exit 1 ; }
  11. TESTPATH=buildroot/share/tests
  12. shopt -s extglob nocasematch
  13. # Get test
  14. TESTENV=${1:-'-'}
  15. # Allow shorthand for test name
  16. case $TESTENV in
  17. due) TESTENV='DUE' ;;
  18. esp) TESTENV='esp32' ;;
  19. lin*) TESTENV='linux_native' ;;
  20. lpc?(8)) TESTENV='LPC1768' ;;
  21. lpc9) TESTENV='LPC1769' ;;
  22. mega) TESTENV='megaatmega2560' ;;
  23. stm) TESTENV='STM32F1' ;;
  24. t35) TESTENV='teensy35' ;;
  25. teensy) TESTENV='teensy35' ;;
  26. -) ;;
  27. esac
  28. # Matching patterns
  29. ISNUM='^[0-9]+$'
  30. ISCMD='^(restore|opt|exec|use|pins|env)_'
  31. ISEXEC='^exec_'
  32. # List available tests and ask for selection
  33. if [[ $TESTENV == '-' ]]; then
  34. IND=0
  35. NAMES=()
  36. for FILE in $( ls -1 $TESTPATH/*-tests )
  37. do
  38. let IND++
  39. TNAME=${FILE/-tests/}
  40. TNAME=${TNAME/$TESTPATH\//}
  41. NAMES+=($TNAME)
  42. (( IND < 10 )) && echo -n " "
  43. echo " $IND) $TNAME"
  44. done
  45. echo
  46. for (( ; ; ))
  47. do
  48. read -p "Select a test to apply (1-$IND) : " NAMEIND
  49. [[ -z "$NAMEIND" ]] && { echo '(canceled)' ; exit 1 ; }
  50. [[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; echo ; break ; }
  51. echo "Invalid selection."
  52. done
  53. fi
  54. # Get the contents of the test file
  55. OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$TESTENV'." ; exit 1 ; }
  56. # Count up the number of tests
  57. # TODO: List test descriptions with numbers
  58. TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
  59. # Get the entered or interactive test index
  60. CHOICE=${2:-0}
  61. # User entered a number?
  62. (( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
  63. if [[ $CHOICE == 0 ]]; then
  64. # List test descriptions with numbers
  65. echo "Available '$TESTENV' tests:" ; echo "$OUT" | {
  66. IND=0
  67. SED=$(which gsed || which sed)
  68. while IFS= read -r LINE
  69. do
  70. if [[ $LINE =~ $ISEXEC ]]; then
  71. DESC=$( "$SED" -E 's/^.+"(.*)".*$/\1/g' <<<"$LINE" )
  72. (( ++IND < 10 )) && echo -n " "
  73. echo " $IND) $DESC"
  74. fi
  75. done
  76. }
  77. CHOICE=1
  78. if [[ $TESTCOUNT > 1 ]]; then
  79. for (( ; ; ))
  80. do
  81. read -p "Select a '$TESTENV' test (1-$TESTCOUNT) : " CHOICE
  82. [[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
  83. [[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
  84. echo ">>> Invalid test index '$CHOICE'."
  85. done
  86. fi
  87. fi
  88. # Finally, run the specified test lines
  89. echo "$OUT" | {
  90. IND=0
  91. while IFS= read -r LINE
  92. do
  93. if [[ $LINE =~ $ISCMD ]]; then
  94. ((!IND)) && let IND++
  95. if [[ $LINE =~ $ISEXEC ]]; then
  96. ((IND++ > CHOICE)) && break
  97. else
  98. ((!HEADER)) && {
  99. HEADER=1
  100. echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
  101. }
  102. ((IND == CHOICE)) && { echo "$LINE" ; eval "$LINE" ; }
  103. fi
  104. fi
  105. done
  106. }
  107. # Build the test too?
  108. echo ; read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
  109. [[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && platformio run --project-dir . -e $TESTENV