test.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. ROOT_PATH=..
  3. TEMP_ROOT=${ROOT_PATH}/../../temporary
  4. CPP_VERSION=-std=c++14
  5. MODE="-DDEBUG"
  6. DEBUGGER="-g"
  7. SIMD="-march=native"
  8. O_LEVEL=-O2
  9. chmod +x ${ROOT_PATH}/tools/buildScripts/build.sh;
  10. ${ROOT_PATH}/tools/buildScripts/build.sh "NONE" "NONE" "${ROOT_PATH}" "${TEMP_ROOT}" "NONE" "${MODE} ${DEBUGGER} ${SIMD} ${CPP_VERSION} ${O_LEVEL}";
  11. if [ $? -ne 0 ]
  12. then
  13. exit 1
  14. fi
  15. # Get the specific temporary sub-folder for the compilation settings
  16. TEMP_SUB="${MODE}_${DEBUGGER}_${SIMD}_${CPP_VERSION}_${O_LEVEL}"
  17. TEMP_SUB=$(echo $TEMP_SUB | tr "+" "p")
  18. TEMP_SUB=$(echo $TEMP_SUB | tr -d " =-")
  19. TEMP_DIR=${TEMP_ROOT}/${TEMP_SUB}
  20. # Build empty backends to prevent getting linker errors
  21. g++ ${CPP_VERSION} ${MODE} ${DEBUGGER} ${SIMD} -c ${ROOT_PATH}/windowManagers/NoWindow.cpp -o ${TEMP_DIR}/NoWindow.o;
  22. if [ $? -ne 0 ]
  23. then
  24. exit 1
  25. fi
  26. g++ ${CPP_VERSION} ${MODE} ${DEBUGGER} ${SIMD} -c ${ROOT_PATH}/soundManagers/NoSound.cpp -o ${TEMP_DIR}/NoSound.o;
  27. if [ $? -ne 0 ]
  28. then
  29. exit 1
  30. fi
  31. for file in ./tests/*.cpp; do
  32. [ -e $file ] || continue
  33. # Get name without path
  34. name=${file##*/};
  35. # Get name without extension nor path
  36. base=${name%.cpp};
  37. # Remove previous test case
  38. rm -f ${TEMP_DIR}/*_test.o;
  39. rm -f ${TEMP_DIR}/application;
  40. # Compile test case that defines main
  41. echo "Compiling ${name}";
  42. g++ ${CPP_VERSION} ${MODE} ${DEBUGGER} ${SIMD} -c ${file} -o ${TEMP_DIR}/${base}_test.o;
  43. if [ $? -ne 0 ]
  44. then
  45. exit 1
  46. fi
  47. # Linking with frameworks
  48. echo "Linking ${name}";
  49. g++ ${TEMP_DIR}/*.o ${TEMP_DIR}/*.a -lm -pthread -o ${TEMP_DIR}/application;
  50. if [ $? -ne 0 ]
  51. then
  52. exit 1
  53. fi
  54. # Run the test case
  55. echo "Executing ${name}";
  56. ./${TEMP_DIR}/application --path ./tests;
  57. if [ $? -eq 0 ]
  58. then
  59. echo "Passed ${name}!";
  60. else
  61. echo "Failed ${name}!";
  62. # Re-run with a memory debugger.
  63. gdb -ex "run" -ex "bt" -ex "quit" --args ./${TEMP_DIR}/application --path ./tests;
  64. exit 1
  65. fi
  66. done