#!/bin/bash FULLBUILD=false NONINTERACTIVE=false while test $# -gt 0 do case "$1" in --non-interactive) NONINTERACTIVE=true ;; --full) FULLBUILD=true ;; esac shift done # Install required packages if [ ! ${NONINTERACTIVE} = true ]; then ./resources/install_dependencies.sh fi # Fullbuild or nonexistent venv if [ ${FULLBUILD} = true -o ! -d .venv ]; then rm -Rf .venv python3 -m venv .venv if [ $? != 0 ]; then echo "Error: Could not create the venv. Please make sure the 'venv' Python-module is installed." exit fi fi # Activate the venv source .venv/bin/activate # Install wheel first pip3 install wheel # Install python packages pip3 install -r resources/requirements.txt # Deactivate the venv deactivate # Create the Makefile using cmake, from a clean build directory cd code_boost/src/build/ if [ ${PWD##*/} = 'build' ]; then if [ ${FULLBUILD} = true ]; then # Only delete everything if we are in a folder called 'build'. rm -rf ./* fi else echo "Error: The 'build' directory was not found." exit fi which ninja &>/dev/null if [ $? != 0 ]; then cmake .. # Make sure we're able to get the number of cores if [ $(uname) = 'Darwin' ]; then NUMCORES=$(sysctl -n hw.logicalcpu) else NUMCORES=$(nproc) fi if [ -f Makefile ]; then make -j$NUMCORES else echo "Error: 'cmake' did not finish successfully." exit fi else cmake .. -G Ninja if [ -f build.ninja ]; then ninja else echo "Error: 'cmake' did not finish successfully." exit fi fi if [ $? -eq 0 ]; then cp libpcapreader.so ../../../code/ID2TLib/ cp libbotnetcomm.so ../../../code/ID2TLib/Botnet else echo "Error: 'make' did not finish successfully." exit fi cd ../../../ # Create the ID2T script cat >./id2t <./run_tests </dev/null cd code # Execute tests set -e PRINT_COV=true testpath="discover -s Test/" if [ -e "Test/test_\$1.py" ]; then testpath="Test/test_\$1.py" PRINT_COV=false fi PYTHONWARNINGS="ignore" python3 -m coverage run --source=. -m unittest \$testpath >/dev/null if \$PRINT_COV ; then python3 -m coverage html python3 -m coverage report -m fi deactivate EOF # Create the test script cat >./test_efficiency <.dat\" you can get a more detailed look." deactivate exit \$error EOF chmod +x ./code/CLI.py chmod +x ./id2t chmod +x ./run_tests chmod +x ./test_efficiency echo -e "\n\nAll is set. ID2T is ready." echo -e "\nRun efficiency tests with the command './test_efficiency'" echo -e "Run unit tests with the command './run_tests'" echo -e "Run ID2T with the command './id2t'"