build.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # Install required packages
  3. if [ "$1" != '--non-interactive' ]; then
  4. ./resources/install_dependencies.sh
  5. fi
  6. # Create the Makefile using cmake, from a clean build directory
  7. cd code_boost/src/build/
  8. if [ ${PWD##*/} = 'build' ]; then
  9. # Only delete everything if we are in a folder called 'build'.
  10. rm -rf ./*
  11. else
  12. echo "Error: The 'build' directory was not found."
  13. exit
  14. fi
  15. cmake ..
  16. if [ -f Makefile ]; then
  17. make
  18. else
  19. echo "Error: 'cmake' did not finish successfully."
  20. exit
  21. fi
  22. if [ $? -eq 0 ]; then
  23. cp libpcapreader.so ../../../code/ID2TLib/
  24. else
  25. echo "Error: 'make' did not finish successfully."
  26. exit
  27. fi
  28. cd ../../../
  29. # Create the ID2T script
  30. cat >./id2t <<EOF
  31. #!/bin/sh
  32. # Find the executable
  33. if [ $(uname) = 'Darwin' ]; then
  34. alias readlink='greadlink'
  35. fi
  36. ID2T_DIR=\$(readlink -f \$0)
  37. SCRIPT_PATH=\${ID2T_DIR%/*}
  38. cd \$SCRIPT_PATH
  39. # Execute ID2T
  40. exec ./code/CLI.py "\$@"
  41. EOF
  42. # Create the test script
  43. cat >./run_tests <<EOF
  44. #!/bin/sh
  45. # Find the executable
  46. if [ $(uname) = 'Darwin' ]; then
  47. alias readlink='greadlink'
  48. fi
  49. ID2T_DIR=\$(readlink -f \$0)
  50. SCRIPT_PATH=\${ID2T_DIR%/*}
  51. cd \$SCRIPT_PATH/code
  52. # Execute tests
  53. set -e
  54. testpath="discover -s Test/"
  55. if [ -e "Test/test_\$1.py" ]; then
  56. testpath="Test/test_\$1.py"
  57. fi
  58. PYTHONWARNINGS="ignore" coverage3 run --source=. -m unittest \$testpath >/dev/null
  59. coverage3 html
  60. coverage3 report -m
  61. EOF
  62. # Create the test script
  63. cat >./test_efficiency <<EOF
  64. #!/bin/sh
  65. # Find the executable
  66. if [ $(uname) = 'Darwin' ]; then
  67. alias readlink='greadlink'
  68. fi
  69. ID2T_DIR=\$(readlink -f \$0)
  70. SCRIPT_PATH=\${ID2T_DIR%/*}
  71. cd \$SCRIPT_PATH/code
  72. # Execute tests
  73. set -e
  74. python3 -m unittest Test/efficiency_testing.py
  75. EOF
  76. chmod +x ./code/CLI.py
  77. chmod +x ./id2t
  78. chmod +x ./run_tests
  79. chmod +x ./test_efficiency
  80. echo -e "\n\nAll is set. ID2T is ready."
  81. echo -e "\nRun efficiency tests with the command './test_efficiency'"
  82. echo -e "Run unit tests with the command './run_tests'"
  83. echo -e "Run ID2T with the command './id2t'"