Advertisement
IvoB1n

ts

Dec 4th, 2020
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # use ./tests/test_script.sh /tests/add/add (-l for less information) to run script
  4.  
  5. dir_to_search=$1;
  6. less_flag=$2
  7.  
  8. search() {
  9. for file in "$1"/*; do
  10. if [ -f "$file" ]; then
  11. test "$file"
  12. elif [ -d "$file" ]; then
  13. echo " "
  14. echo " "
  15. echo " "
  16. echo "----$file----"
  17. echo " "
  18.  
  19. search "$file";
  20. fi
  21. done
  22. }
  23.  
  24. test() {
  25. if [ "$less_flag" = "-l" ]; then
  26. echo "$1"
  27. ./compiler < "$1" >/dev/null 2>/dev/null
  28. ret_val=$?
  29. line=$(head -n 1 $1)
  30. echo " "
  31. echo "return value: \e[0;36m $ret_val \e[0m \e[0;36m ///// \e[0m"
  32. echo "expected:\e[0;33m $line \e[0m \e[0;33m ///// \e[0m"
  33. echo " /"
  34. echo " /"
  35. elif [ "$less_flag" = "-v" ]; then
  36. echo "$1"
  37. rm valgrind.txt
  38. valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all ./compiler < "$1" >gen.code 2>valgrind.txt
  39. ret_val=$?
  40. line=$(head -n 1 $1)
  41. echo " "
  42. echo "return value: $ret_val"
  43. echo "expected $line "
  44. elif [ "$less_flag" = "-lv" ]; then
  45. echo "$1"
  46. valgrind ./compiler < "$1" >/dev/null # 2>/dev/null
  47. ret_val=$?
  48. line=$(head -n 1 $1)
  49. echo " "
  50. echo "return value: \e[0;36m $ret_val \e[0m \e[0;36m ///// \e[0m"
  51. echo "expected:\e[0;33m $line \e[0m \e[0;33m ///// \e[0m"
  52. echo " /"
  53. echo " /"
  54. elif [ "$less_flag" = "-gl" ]; then
  55. echo "$1"
  56. ./compiler < "$1" 2>/dev/null > output.out
  57. ret_val=$?
  58. # line=$(head -n 1 $1)
  59. # echo " "
  60. # echo "return value: \e[0;36m $ret_val \e[0m \e[0;36m ///// \e[0m"
  61. # echo "expected:\e[0;33m $line \e[0m \e[0;33m ///// \e[0m"
  62. # echo " /"
  63. # echo " /"
  64. elif [ "$less_flag" = "-g" ]; then
  65. echo "$1"
  66. ./compiler < "$1" #> output.out 2>/dev/null
  67. ret_val=$?
  68. line=$(head -n 1 $1)
  69. echo " "
  70. echo "return value: \e[0;36m $ret_val \e[0m \e[0;36m ///// \e[0m"
  71. echo "expected:\e[0;33m $line \e[0m \e[0;33m ///// \e[0m"
  72. echo " /"
  73. echo " /"
  74. elif [ "$less_flag" = "-go" ]; then
  75. rm gen.code
  76. ./compiler < "$1" >gen.code #2>/dev/null
  77. ret_valcom=$?
  78. echo " ~~~~~~~~~ "
  79. ./ic20int gen.code
  80. echo ""
  81. echo " ~~~~~~~~~ "
  82. ret_valint=$?
  83.  
  84. line=$(head -n 1 $1)
  85. echo "return value comp: $ret_valcom "
  86. echo "expected: $line "
  87. echo "return value inter: $ret_valint "
  88. echo "$1"
  89.  
  90. else
  91. echo "$1"
  92. ./compiler < "$1"
  93. ret_val=$?
  94. line=$(head -n 1 $1)
  95. echo " "
  96. echo "return value: \e[0;36m $ret_val \e[0m \e[0;36m ///// \e[0m"
  97. echo "expected:\e[0;33m $line \e[0m \e[0;33m ///// \e[0m"
  98. echo " /"
  99. echo " /"
  100. fi
  101. echo " "
  102. }
  103.  
  104. if [ $1 = "-h" ]; then
  105. echo "./tests/test_script.sh /tests/add/add (-l for less information)"
  106. elif [ -f $dir_to_search ]; then
  107. test $dir_to_search
  108. else
  109. search "$dir_to_search"
  110. fi
Advertisement
RAW Paste Data Copied
Advertisement