test.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. SIMD_FLAGS=""
  8. #SIMD_FLAGS="-msse2 -mssse3 -mavx2"
  9. chmod +x ${ROOT_PATH}/tools/build.sh;
  10. ${ROOT_PATH}/tools/build.sh "NONE" "NONE" "${ROOT_PATH}" "${TEMP_ROOT}" "NONE" "${MODE} ${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}_${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 ./test/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} ${SIMD_FLAGS} -c ${file} -o ${TEMP_DIR}/${base}_test.o;
  32. # Linking with frameworks
  33. echo "Linking ${name}";
  34. g++ ${TEMP_DIR}/*.o ${TEMP_DIR}/*.a -lm -pthread -o ${TEMP_DIR}/application;
  35. # Run the test case
  36. echo "Executing ${name}";
  37. ./${TEMP_DIR}/application;
  38. if [ $? -eq 0 ]
  39. then
  40. echo "Passed ${name}!";
  41. else
  42. echo "Failed ${name}!";
  43. break;
  44. fi
  45. done