aboutsummaryrefslogtreecommitdiff
path: root/benchmarks/scripts/gen-benchmark
blob: 1a5d6577e9ef976475ccdecb91324d73ad582d63 (plain) (blame)
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
#!/bin/sh

NAME=
PROGS=
while getopts "n:p:" opt; do
	case "$opt" in
		n) NAME="$OPTARG";;
		p) PROGS="$PROGS $OPTARG";;
		*) echo "unrecognised options -$OPTARG" >&2; exit 1;
	esac
done

mkdir -p "build/$NAME" "reports/$NAME"

if [ -z "$NAME" ]; then
	echo "No name given for benchmark" >&2; exit 2;
fi

if [ -z "$PROGS" ]; then
	echo "No programs to add to initrd" >&2; exit 3;
fi

for p in $PROGS; do dep="build/${NAME}/${p}.d"; cat << ENDRULES >> benchmarks.mk
${NAME}_PROGS += build/${NAME}/${p}
${dep}:
-include ${dep}
build/${NAME}/${p}: $NAME/$p.c \$(COMMON)
	\$(COMPILE_BENCHMARK) $NAME/${p}.c \$(COMMON) -o build/${NAME}/${p}

ENDRULES
done

cat << ENDRULES >> benchmarks.mk
build/${NAME}/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)
	for p in \$(${NAME}_PROGS); do echo \$\$p; done \\
		| \$(GEN_INITRD) build/$NAME/initrd

BENCHMARKS += ${NAME}
.PHONY: ${NAME}
${NAME}: build/${NAME}/initrd
	timeout --foreground 30s \$(QEMU) build/${NAME}/initrd > reports/${NAME}/log

ENDRULES