flowtop: show proper title of what's tracked
[netsniff-ng-old.git] / test / dissector_fuzz.sh
blob87d8b8b00b9c68fe2795311ec72837921ba8d144
1 #!/usr/bin/env bash
3 # Note: build and _install_ the toolkit first!
5 set -u
7 if [ ${BASH_VERSINFO} -lt 3 ] ; then
8 echo 'Error: Your bash need to be version 3 or newer. Exiting.'
9 exit 1 # operators like =~ produce errors silently in old bash versions, so exit here
12 archive='ftp://wireshark.org/automated/captures/'
13 show_output='' # empty string evaluates to false
14 run_through='' # empty string evaluates to false
15 count_cores=0
16 count_files=0
17 netsniff_ng_opts=''
19 if [ $# -gt 0 ] ; then
20 if [ "$1" = '-h' -o "$1" = '--help' -o "$1" = '--usage' ] ; then
21 echo 'Usage: dissector_fuzz [-s (show netsniff-ng output, default: no)] [-r (keep running on errors, default: no)] [netsniff-ng long-args]'
22 exit 0
25 for opt in $@ ; do
26 if [ "${opt}" = '-s' ] ; then
27 show_output='true'
28 elif [ "${opt}" = '-r' ] ; then
29 run_through='true'
30 else
31 netsniff_ng_opts="${netsniff_ng_opts} ${opt}";
33 done
36 mkdir -p fuzzing
37 cd fuzzing
38 wget -r -Nc -np -nd -A.pcap "$archive" |& grep -E "%|^--"
39 ulimit -c unlimited
40 rm -f core
41 for file in *.pcap
43 echo "Testing file $file ..."
44 if [ $show_output ]; then
45 netsniff-ng --in "$file" "${netsniff_ng_opts}"
46 else
47 netsniff-ng --in "$file" "${netsniff_ng_opts}" > /dev/null
49 if [ -e core ]; then
50 echo "Fuck, core dumped on $file!"
51 let count_cores=count_cores+1
52 if [ $run_through ]; then
53 rm core
54 else
55 exit
58 done
60 if which cowsay > /dev/null ; then
61 echo_cmd='cowsay'
62 else
63 echo_cmd='echo'
66 ${echo_cmd} 'Your fuckup Score'
67 echo " * tested pcaps: $count_files"
68 echo " * core dumps: $count_cores"