diff options
| -rwxr-xr-x | benchmarks/scripts/gen-benchmark | 38 | ||||
| -rwxr-xr-x | scripts/gen-deps | 31 | ||||
| -rwxr-xr-x | tests/scripts/gen-simple | 48 | ||||
| -rwxr-xr-x | tests/scripts/gen-tests | 31 | ||||
| -rw-r--r-- | tests/scripts/makefile | 13 |
5 files changed, 77 insertions, 84 deletions
diff --git a/benchmarks/scripts/gen-benchmark b/benchmarks/scripts/gen-benchmark index 6545d11..1a5d657 100755 --- a/benchmarks/scripts/gen-benchmark +++ b/benchmarks/scripts/gen-benchmark @@ -10,7 +10,7 @@ while getopts "n:p:" opt; do esac done -mkdir -p "build/$NAME" +mkdir -p "build/$NAME" "reports/$NAME" if [ -z "$NAME" ]; then echo "No name given for benchmark" >&2; exit 2; @@ -20,26 +20,24 @@ 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" +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} - echo "${NAME}_PROGS += build/${NAME}/${p}" >> benchmarks.mk - echo "${dep}:" >> benchmarks.mk - echo "-include ${dep}" >> benchmarks.mk - echo "build/${NAME}/${p}: $NAME/$p.c \$(COMMON)" >> benchmarks.mk - echo " \$(COMPILE_BENCHMARK) $NAME/${p}.c \$(COMMON) \\" >> benchmarks.mk - echo " -o build/${NAME}/${p}" >> benchmarks.mk +ENDRULES done -echo "build/${NAME}/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)" >> benchmarks.mk -echo " for p in \$(${NAME}_PROGS); do \\" >> benchmarks.mk -echo " echo \$\$p; \\" >> benchmarks.mk -echo " done | \$(GEN_INITRD) build/$NAME/initrd" >> benchmarks.mk +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 -echo "BENCHMARKS += ${NAME}" >> benchmarks.mk -echo ".PHONY: ${NAME}" >> benchmarks.mk -echo "${NAME}: build/${NAME}/initrd" >> benchmarks.mk -echo " mkdir -p reports/${NAME}" >> benchmarks.mk -echo " timeout --foreground 30s \ - \$(QEMU) build/${NAME}/initrd > reports/${NAME}/log" >> benchmarks.mk +BENCHMARKS += ${NAME} +.PHONY: ${NAME} +${NAME}: build/${NAME}/initrd + timeout --foreground 30s \$(QEMU) build/${NAME}/initrd > reports/${NAME}/log + +ENDRULES diff --git a/scripts/gen-deps b/scripts/gen-deps index f45707c..d2288be 100755 --- a/scripts/gen-deps +++ b/scripts/gen-deps @@ -20,18 +20,23 @@ shift $((OPTIND - 1)) # create all subdirectories mkdir -p $(echo "${@}" | tr ' ' '\n' | sed "s|[^/]*$||;s|^|${BUILD}/|" | uniq) -for s in ${@} -do - obj="${BUILD}/${s%.*}.o" - lint="${obj}.l" - dep="${obj}.d" +for s in ${@}; do +obj="${BUILD}/${s%.*}.o" +lint="${obj}.l" +dep="${obj}.d" - echo "${PREFIX}OBJS += ${obj}" >> deps.mk - echo "${PREFIX}LINTS += ${lint}" >> deps.mk - echo "${dep}:" >> deps.mk - echo "-include ${dep}" >> deps.mk - echo "${obj}: ${s}" >> deps.mk - echo " \$(${COMPILE}) -c ${s} -o ${obj}" >> deps.mk - echo "${lint}: ${s}" >> deps.mk - echo " \$(${LINT}) -c ${s} -o /dev/null" >> deps.mk +cat << ENDRULES >> deps.mk + +${PREFIX}OBJS += ${obj} +${PREFIX}LINTS += ${lint} +${dep}: +-include ${dep} + +${obj}: ${s} + \$(${COMPILE}) -c ${s} -o ${obj} + +${lint}: ${s} + \$(${LINT}) -c ${s} -o /dev/null + +ENDRULES done diff --git a/tests/scripts/gen-simple b/tests/scripts/gen-simple index fe2d7a4..b6688b6 100755 --- a/tests/scripts/gen-simple +++ b/tests/scripts/gen-simple @@ -10,7 +10,7 @@ while getopts "n:p:" opt; do esac done -mkdir -p "build/$NAME" +mkdir -p "build/$NAME" "reports/$NAME" if [ -z "$NAME" ]; then echo "No name given for tests" >&2; exit 2; @@ -20,35 +20,29 @@ 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" +for p in $PROGS; do dep="build/${NAME}/${p}.d"; cat << ENDRULES >> tests.mk - 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 +${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 -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 +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 -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 +reports/$NAME/log: build/$NAME/initrd + timeout --foreground 30s \$(QEMU) build/$NAME/initrd > reports/$NAME/log -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 +TESTS += $NAME +.PHONY: $NAME +$NAME: reports/$NAME/log -echo "$NAME: reports/$NAME/OK" >> tests.mk +ENDRULES diff --git a/tests/scripts/gen-tests b/tests/scripts/gen-tests index 3be204d..57dba8f 100755 --- a/tests/scripts/gen-tests +++ b/tests/scripts/gen-tests @@ -3,27 +3,22 @@ mkdir -p $(for d in "${@}"; do echo $d; done | sed "s|^|build/|") mkdir -p $(for d in "${@}"; do echo $d; done | sed "s|^|reports/|") -for NAME in "${@}"; do - echo "build/$NAME/init.d:" >> tests.mk - echo "-include build/$NAME/init.d" >> tests.mk +for NAME in "${@}"; do cat << ENDRULES >> tests.mk +build/$NAME/init.d: +-include build/$NAME/init.d - echo "build/$NAME/init: $NAME/init.c \$(COMMON) \$(KMI)" >> tests.mk - echo " \$(COMPILE_TEST) $NAME/init.c \$(COMMON) -o build/$NAME/init" >> tests.mk +build/$NAME/init: $NAME/init.c \$(COMMON) \$(KMI) + \$(COMPILE_TEST) $NAME/init.c \$(COMMON) -o build/$NAME/init - echo "build/$NAME/initrd: build/$NAME/init" >> tests.mk - echo " echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk +build/$NAME/initrd: build/$NAME/init + echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd - echo "reports/$NAME/log: build/$NAME/initrd" >> tests.mk - echo " timeout --foreground 30s \$(QEMU) \ - build/$NAME/initrd > reports/$NAME/log" >> tests.mk +reports/$NAME/log: build/$NAME/initrd + timeout --foreground 30s \$(QEMU) build/$NAME/initrd > reports/$NAME/log - echo "reports/$NAME/OK: reports/$NAME/log" >> tests.mk - echo " grep 'BUG|ERROR' reports/$NAME/log \\" >> tests.mk - echo " && echo 'NOTOK' > reports/$NAME/log \\" >> tests.mk - echo " || tail -n1 reports/$NAME/log | tr -d '\\\\r' \\" >> tests.mk - echo " > reports/$NAME/OK" >> tests.mk +TESTS += $NAME +.PHONY: $NAME +$NAME: reports/$NAME/log - echo "TESTS += $NAME" >> tests.mk - echo ".PHONY: $NAME" >> tests.mk - echo "$NAME: reports/$NAME/OK" >> tests.mk +ENDRULES done diff --git a/tests/scripts/makefile b/tests/scripts/makefile index 63150b1..2161427 100644 --- a/tests/scripts/makefile +++ b/tests/scripts/makefile @@ -40,11 +40,12 @@ include tests.mk .PHONY: check check: $(TESTS) - @cd reports; for d in * ; do \ - if [ ! -f "$$d/OK" ]; then \ - echo "BROKEN: $$d" ; \ - elif [ "$$(tail -n1 $$d/OK)" != "OK" ]; then \ - echo "FAIL: $$d" ; \ - fi \ + @cd reports; for d in * ; do \ + if [ ! -f "$$d/log" ]; then \ + echo "BROKEN: $$d" ; \ + elif grep 'BUG|ERR' $$d/log \ + || [ "$$(tail -n1 $$d/log | tr -d '\r')" != "OK" ]; then \ + echo "FAIL: $$d" ; \ + fi \ done @echo "Done." |
