#!/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