-
Notifications
You must be signed in to change notification settings - Fork 13
/
run_test.sh
executable file
·59 lines (47 loc) · 1.4 KB
/
run_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#$1 -- directory where snort is installed
if [ $# -lt 1 ] ; then
printf "usage: run_test.sh <snort_install_dir>"
exit -1
fi
[ -d "$SNORT3_DAQ_DIR" ] && daq_dir="--daq-dir $SNORT3_DAQ_DIR"
# global args (add any needed here for your environment)
args="-H -U"
# setup environnement
export snorty_path=$1
export snort="$snorty_path/bin/snort $daq_dir $args"
export snort2lua="$snorty_path/bin/snort2lua"
export LUA_PATH=$snorty_path/include/snort/lua/\?.lua\;\;
export SNORT_LUA_PATH=$snorty_path/etc/snort/
export PATH=$PATH:$(pwd)/bin
if [ -d "${snorty_path}/lib64" ]; then
libs=${snorty_path}/lib64
else
libs=${snorty_path}/lib
fi
export PKG_CONFIG_PATH=$libs/pkgconfig:$PKG_CONFIG_PATH
export SNORT_DAQ_LIBS=$libs/snort/daq:$libs/snort/daq/extra
export SNORT_PLUGINS=$libs/snort/plugins
tests=$2
[ "$tests" ] || tests=`find . -name \*.bats`
# run tests for all .bats
for t in $tests ; do
printf "\n# $t:\n"
pushd . &>/dev/null
cd `dirname $t`
bats -t .
popd &> /dev/null
done | tee demo_result.log
# calculate stats
pass=$(grep "^ok" -c demo_result.log)
fail=$(grep "^not ok" -c demo_result.log)
skip=$(grep "ok [0-9] # skip" -c demo_result.log)
pass=$(($pass - $skip))
total=$(($pass + $fail + $skip))
printf "\n"
printf "Total = $total, Pass = $pass, Fail = $fail, Skip = $skip\n" | tee demo_summary.log
if [ $fail -ne 0 ]; then
exit 1;
else
exit 0;
fi