My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

mftest 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. ISCONT='\\ *$'
  33. # List available tests and ask for selection
  34. if [[ $TESTENV == '-' ]]; then
  35. IND=0
  36. NAMES=()
  37. for FILE in $( ls -1 $TESTPATH/*-tests )
  38. do
  39. let IND++
  40. TNAME=${FILE/-tests/}
  41. TNAME=${TNAME/$TESTPATH\//}
  42. NAMES+=($TNAME)
  43. (( IND < 10 )) && echo -n " "
  44. echo " $IND) $TNAME"
  45. done
  46. echo
  47. for (( ; ; ))
  48. do
  49. read -p "Select a test to apply (1-$IND) : " NAMEIND
  50. [[ -z "$NAMEIND" ]] && { echo '(canceled)' ; exit 1 ; }
  51. [[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; echo ; break ; }
  52. echo "Invalid selection."
  53. done
  54. fi
  55. # Get the contents of the test file
  56. OUT=$( cat $TESTPATH/$TESTENV-tests 2>/dev/null ) || { echo "Can't find test '$TESTENV'." ; exit 1 ; }
  57. # Count up the number of tests
  58. # TODO: List test descriptions with numbers
  59. TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
  60. # Get the entered or interactive test index
  61. CHOICE=${2:-0}
  62. # User entered a number?
  63. (( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
  64. if [[ $CHOICE == 0 ]]; then
  65. # List test descriptions with numbers
  66. echo "Available '$TESTENV' tests:" ; echo "$OUT" | {
  67. IND=0
  68. SED=$(which gsed || which sed)
  69. while IFS= read -r LINE
  70. do
  71. if [[ $LINE =~ $ISEXEC ]]; then
  72. DESC=$( "$SED" -E 's/^.+"(.*)".*$/\1/g' <<<"$LINE" )
  73. (( ++IND < 10 )) && echo -n " "
  74. echo " $IND) $DESC"
  75. fi
  76. done
  77. }
  78. CHOICE=1
  79. if [[ $TESTCOUNT > 1 ]]; then
  80. for (( ; ; ))
  81. do
  82. read -p "Select a '$TESTENV' test (1-$TESTCOUNT) : " CHOICE
  83. [[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
  84. [[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
  85. echo ">>> Invalid test index '$CHOICE'."
  86. done
  87. fi
  88. fi
  89. # Finally, run the specified test lines
  90. echo "$OUT" | {
  91. IND=0
  92. GOTX=0
  93. CMD=""
  94. while IFS= read -r LINE
  95. do
  96. if [[ $LINE =~ $ISCMD || $GOTX == 1 ]]; then
  97. ((!IND)) && let IND++
  98. if [[ $LINE =~ $ISEXEC ]]; then
  99. ((IND++ > CHOICE)) && break
  100. else
  101. ((!HEADER)) && {
  102. HEADER=1
  103. echo -e "\n#\n# Test $TESTENV ($CHOICE) $DESC\n#"
  104. }
  105. ((IND == CHOICE)) && {
  106. GOTX=1
  107. [[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | sed -e 's/\\//g' )
  108. [[ $LINE =~ $ISCONT ]] || { echo $CMD ; eval "$CMD" ; CMD="" ; }
  109. }
  110. fi
  111. fi
  112. done
  113. }
  114. # Build the test too?
  115. echo ; read -p "Build $TESTENV test #$CHOICE (y/N) ? " BUILD_YES
  116. [[ $BUILD_YES == 'Y' || $BUILD_YES == 'Yes' ]] && platformio run --project-dir . -e $TESTENV