blob: fe2d7a4170f4f03376523d04f4eeebef3f16e126 (
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
49
50
51
52
53
54
|
#!/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"
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"
echo "${NAME}_PROGS += build/${NAME}/${p}" >> tests.mk
echo "${dep}:" >> tests.mk
echo "-include ${dep}" >> tests.mk
echo "build/${NAME}/${p}: $NAME/$p.c \$(COMMON)" >> tests.mk
echo " \$(COMPILE_TEST) $NAME/${p}.c \$(COMMON) \\" >> tests.mk
echo " -o build/${NAME}/${p}" >> tests.mk
done
echo "build/$NAME/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)" >> tests.mk
echo " for p in \$(${NAME}_PROGS); do \\" >> tests.mk
echo " echo \$\$p; \\" >> tests.mk
echo " done | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk
echo "reports/$NAME/log: build/$NAME/initrd" >> tests.mk
echo " mkdir -p reports/$NAME" >> tests.mk
echo " rm -f reports/$NAME/*" >> tests.mk
echo " timeout --foreground 30s \$(QEMU) \\" >> tests.mk
echo " build/$NAME/initrd > reports/$NAME/log" >> tests.mk
echo "TESTS += $NAME" >> tests.mk
echo ".PHONY: $NAME" >> tests.mk
echo "reports/$NAME/OK: reports/$NAME/log" >> tests.mk
echo " grep 'BUG' reports/$NAME/log \\" >> tests.mk
echo " && echo 'BUG' > reports/$NAME/log \\" >> tests.mk
echo " || tail -n1 reports/$NAME/log | tr -d '\\\\r' \\" >> tests.mk
echo " > reports/$NAME/OK" >> tests.mk
echo "$NAME: reports/$NAME/OK" >> tests.mk
|