build.sh 2.0 KB

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