aboutsummaryrefslogtreecommitdiff
path: root/scripts/chaos_dumps.sh
blob: d853e83f5ec43d823c244c8fc4dd8c119f47e1f6 (plain)
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
#!/bin/bash

CRASHCNT=0
GOODCRASHES=0
PROG=build/dnsd

make chaos

ulimit -S -c unlimited $PROG
mkdir -p dumps

while true; do
	$PROG -p 5333 -z tests/zone.file > /dev/null &
	PID=$!

	for i in $(seq 50); do
		dig -p 5333 test.example.com @localhost > /dev/null &
	done

	sleep 5

	if ! kill -s 15 $PID ; then
		CRASHCNT=$(( CRASHCNT + 1 ))

		echo -n "Crash #$CRASHCNT"

		if ! coredumpctl -o dumps/$CRASHCNT.core dump COREDUMP_PID=$PID "COREDUMP_EXE=$(realpath $PROG)" > /dev/null 2>&1; then
			GOODCRASHES=$(( GOODCRASHES + 1 ))
			echo " Good crash #$GOODCRASHES"
		fi
	fi
done