test.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. ROOT_PATH=.
  3. TEMP_ROOT=${ROOT_PATH}/../../temporary
  4. CPP_VERSION=-std=c++14
  5. MODE=-DDEBUG
  6. O_LEVEL=-O2
  7. chmod +x ${ROOT_PATH}/tools/buildAndRun.sh;
  8. ${ROOT_PATH}/tools/buildAndRun.sh "NONE" "NONE" "${ROOT_PATH}" "${TEMP_ROOT}" "NONE" "${MODE}" "${CPP_VERSION}" "${O_LEVEL}";
  9. if [ $? -ne 0 ]
  10. then
  11. exit 1
  12. fi
  13. # Get the specific temporary sub-folder for the compilation settings
  14. TEMP_SUB="${MODE}_${CPP_VERSION}_${O_LEVEL}"
  15. TEMP_SUB=$(echo $TEMP_SUB | tr "+" "p")
  16. TEMP_SUB=$(echo $TEMP_SUB | tr -d " =-")
  17. TEMP_DIR=${TEMP_ROOT}/${TEMP_SUB}
  18. for file in ./test/tests/*.cpp; do
  19. [ -e $file ] || continue
  20. # Get name without path
  21. name=${file##*/};
  22. # Get name without extension nor path
  23. base=${name%.cpp};
  24. # Remove previous test case
  25. rm -f ${TEMP_DIR}/*_test.o;
  26. rm -f ${TEMP_DIR}/application;
  27. # Compile test case that defines main
  28. echo "Compiling ${name}";
  29. g++ ${CPP_VERSION} ${MODE} -c ${file} -o ${TEMP_DIR}/${base}_test.o;
  30. # Linking with frameworks
  31. echo "Linking ${name}";
  32. g++ ${TEMP_DIR}/*.o ${TEMP_DIR}/*.a -lm -pthread -o ${TEMP_DIR}/application;
  33. # Run the test case
  34. echo "Executing ${name}";
  35. ./${TEMP_DIR}/application;
  36. if [ $? -eq 0 ]
  37. then
  38. echo "Passed ${name}!";
  39. else
  40. echo "Failed ${name}!";
  41. break;
  42. fi
  43. done