3
0

build.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # Make sure we're able to get the number of cores
  17. if [ $(uname) = 'Darwin' ]; then
  18. NUMCORES=$(sysctl -n hw.logicalcpu)
  19. else
  20. NUMCORES=$(nproc)
  21. fi
  22. if [ -f Makefile ]; then
  23. make -j$NUMCORES
  24. else
  25. echo "Error: 'cmake' did not finish successfully."
  26. exit
  27. fi
  28. if [ $? -eq 0 ]; then
  29. cp libpcapreader.so ../../../code/ID2TLib/
  30. else
  31. echo "Error: 'make' did not finish successfully."
  32. exit
  33. fi
  34. cd ../../../
  35. # Create the ID2T script
  36. cat >./id2t <<EOF
  37. #!/bin/sh
  38. # Find the executable
  39. if [ $(uname) = 'Darwin' ]; then
  40. alias readlink='greadlink'
  41. fi
  42. ID2T_DIR=\$(readlink -f \$0)
  43. SCRIPT_PATH=\${ID2T_DIR%/*}
  44. cd \$SCRIPT_PATH
  45. # Execute ID2T
  46. exec ./code/CLI.py "\$@"
  47. EOF
  48. # Create the test script
  49. cat >./run_tests <<EOF
  50. #!/bin/sh
  51. # Find the executable
  52. if [ $(uname) = 'Darwin' ]; then
  53. alias readlink='greadlink'
  54. fi
  55. ID2T_DIR=\$(readlink -f \$0)
  56. SCRIPT_PATH=\${ID2T_DIR%/*}
  57. cd \$SCRIPT_PATH/code
  58. # Execute tests
  59. set -e
  60. testpath="discover -s Test/"
  61. if [ -e "Test/test_\$1.py" ]; then
  62. testpath="Test/test_\$1.py"
  63. fi
  64. PYTHONWARNINGS="ignore" coverage3 run --source=. -m unittest \$testpath >/dev/null
  65. coverage3 html
  66. coverage3 report -m
  67. EOF
  68. # Create the test script
  69. cat >./test_efficiency <<EOF
  70. #!/bin/sh
  71. # Find the executable
  72. if [ $(uname) = 'Darwin' ]; then
  73. alias readlink='greadlink'
  74. fi
  75. ID2T_DIR=\$(readlink -f \$0)
  76. SCRIPT_PATH=\${ID2T_DIR%/*}
  77. cd \$SCRIPT_PATH/code
  78. # Execute tests
  79. set -e
  80. python3 -m unittest Test/efficiency_testing.py
  81. EOF
  82. chmod +x ./code/CLI.py
  83. chmod +x ./id2t
  84. chmod +x ./run_tests
  85. chmod +x ./test_efficiency
  86. echo -e "\n\nAll is set. ID2T is ready."
  87. echo -e "\nRun efficiency tests with the command './test_efficiency'"
  88. echo -e "Run unit tests with the command './run_tests'"
  89. echo -e "Run ID2T with the command './id2t'"