aboutsummaryrefslogtreecommitdiff
path: root/tests/scripts/gen-simple
blob: b6688b6ab4e313f5dae2853d543ae2c507c9a2c3 (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
44
45
46
47
48
#!/bin/sh

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

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

if [ -z "$NAME" ]; then
	echo "No name given for tests" >&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 >> tests.mk

${NAME}_PROGS += build/${NAME}/${p}
${dep}:
-include ${dep}

build/${NAME}/${p}: $NAME/$p.c \$(COMMON)
	\$(COMPILE_TEST) $NAME/${p}.c \$(COMMON) -o build/${NAME}/${p}

ENDRULES
done

cat << ENDRULES >> tests.mk

build/$NAME/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)
	for p in \$(${NAME}_PROGS); do echo \$\$p; done \\
		| \$(GEN_INITRD) build/$NAME/initrd

reports/$NAME/log: build/$NAME/initrd
	timeout --foreground 30s \$(QEMU) build/$NAME/initrd > reports/$NAME/log

TESTS += $NAME
.PHONY: $NAME
$NAME: reports/$NAME/log

ENDRULES