build.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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" coverage run --source=. -m unittest \$testpath >/dev/null
  59. coverage html
  60. coverage report -m
  61. EOF
  62. # Create the efficiency 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. python -m unittest Test/efficiency_testing.py
  75. EOF
  76. # Create the memory usage test script
  77. cat >./test_memory <<EOF
  78. #!/bin/sh
  79. # Find the executable
  80. if [ $(uname) = 'Darwin' ]; then
  81. alias readlink='greadlink'
  82. fi
  83. ID2T_DIR=\$(readlink -f \$0)
  84. SCRIPT_PATH=\${ID2T_DIR%/*}
  85. cd \$SCRIPT_PATH/code
  86. # Execute tests
  87. set -e
  88. python -m unittest Test/memory_testing.py
  89. EOF
  90. chmod +x ./code/CLI.py
  91. chmod +x ./id2t
  92. chmod +x ./run_tests
  93. chmod +x ./test_efficiency
  94. chmod +x ./test_memory
  95. echo -e "\n\nAll is set. ID2T is ready."
  96. echo -e "\nRun efficiency tests with the command './test_efficiency'"
  97. echo -e "Run memory usage tests with the command './test_memory'"
  98. echo -e "Run unit tests with the command './run_tests'"
  99. echo -e "Run ID2T with the command './id2t'"