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.

mftest 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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, allowing shorthand
  14. TESTENV=${1:-"mega"}
  15. case $TESTENV in
  16. due) TESTENV='DUE' ;;
  17. esp) TESTENV='esp32' ;;
  18. lin*) TESTENV='linux_native' ;;
  19. lpc?(8)) TESTENV='LPC1768' ;;
  20. lpc9) TESTENV='LPC1769' ;;
  21. mega) TESTENV='megaatmega2560' ;;
  22. stm) TESTENV='STM32F1' ;;
  23. t35) TESTENV='teensy35' ;;
  24. teensy) TESTENV='teensy35' ;;
  25. esac
  26. # Matching patterns
  27. ISNUM='^[0-9]+$'
  28. ISCMD='^(restore|opt|exec|use|pins|env)_'
  29. ISEXEC='^exec_'
  30. # List available tests and ask for selection
  31. if [[ $1 == '-' ]]; then
  32. IND=0
  33. NAMES=()
  34. for FILE in $( ls -1 $TESTPATH/*-tests )
  35. do
  36. let IND++
  37. TNAME=${FILE/-tests/}
  38. TNAME=${TNAME/$TESTPATH\//}
  39. NAMES+=($TNAME)
  40. echo " $IND) $TNAME"
  41. done
  42. echo
  43. for (( ; ; ))
  44. do
  45. read -p "Select a test to apply (1-$IND) : " NAMEIND
  46. [[ -z "$NAMEIND" ]] && { echo "Quitting." ; exit 1 ; }
  47. [[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; break ; }
  48. echo "Invalid selection."
  49. done
  50. fi
  51. # Get the contents of the test file
  52. OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$TESTENV'." ; exit 1 ; }
  53. # Count up the number of tests
  54. # TODO: List test descriptions with numbers
  55. TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
  56. # Get the entered or interactive test index
  57. CHOICE=${2:-0}
  58. if [[ $TESTCOUNT > 1 && ( $CHOICE == 0 || $1 == '-' ) ]]; then
  59. for (( ; ; ))
  60. do
  61. read -p "Test '$TESTENV' index (1-$TESTCOUNT) : " CHOICE
  62. [[ -z "$CHOICE" ]] && CHOICE=1
  63. [[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
  64. echo "Invalid test index '$CHOICE'."
  65. done
  66. else
  67. # Confirm a manually-entered test index
  68. ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) || { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
  69. fi
  70. # Finally, run the specified test lines
  71. echo "$OUT" | {
  72. IND=0
  73. while IFS= read -r LINE
  74. do
  75. if [[ $LINE =~ $ISCMD ]]; then
  76. ((!IND)) && let IND++
  77. if [[ $LINE =~ $ISEXEC ]]; then
  78. ((IND++ > CHOICE)) && break
  79. else
  80. ((!HEADER)) && {
  81. HEADER=1
  82. echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
  83. }
  84. ((IND == CHOICE)) && { echo "$LINE" ; eval "$LINE" ; }
  85. fi
  86. fi
  87. done
  88. }
  89. # Build the test too?
  90. echo ; read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
  91. [[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && platformio run --project-dir . -e $TESTENV