test.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. for file in ./tests/*.cpp; do
  21. [ -e $file ] || continue
  22. # Get name without path
  23. name=${file##*/};
  24. # Get name without extension nor path
  25. base=${name%.cpp};
  26. # Remove previous test case
  27. rm -f ${TEMP_DIR}/*_test.o;
  28. rm -f ${TEMP_DIR}/application;
  29. # Compile test case that defines main
  30. echo "Compiling ${name}";
  31. g++ ${CPP_VERSION} ${MODE} ${DEBUGGER} ${SIMD} -c ${file} -o ${TEMP_DIR}/${base}_test.o;
  32. if [ $? -ne 0 ]
  33. then
  34. exit 1
  35. fi
  36. # Linking with frameworks
  37. echo "Linking ${name}";
  38. g++ ${TEMP_DIR}/*.o ${TEMP_DIR}/*.a -lm -pthread -o ${TEMP_DIR}/application;
  39. if [ $? -ne 0 ]
  40. then
  41. exit 1
  42. fi
  43. # Run the test case
  44. echo "Executing ${name}";
  45. ./${TEMP_DIR}/application --path ./tests;
  46. if [ $? -eq 0 ]
  47. then
  48. echo "Passed ${name}!";
  49. else
  50. echo "Failed ${name}!";
  51. # Re-run with a memory debugger.
  52. gdb -ex "run" -ex "bt" -ex "quit" --args ./${TEMP_DIR}/application --path ./tests;
  53. exit 1
  54. fi
  55. done