aboutsummaryrefslogtreecommitdiff
path: root/tests/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scripts')
-rwxr-xr-xtests/scripts/gen-prog32
-rwxr-xr-xtests/scripts/gen-simple25
-rw-r--r--tests/scripts/makefile8
3 files changed, 27 insertions, 38 deletions
diff --git a/tests/scripts/gen-prog b/tests/scripts/gen-prog
deleted file mode 100755
index 6e99f37..0000000
--- a/tests/scripts/gen-prog
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-NAME=
-PROG=
-while getopts "n:p:" opt; do
- case "$opt" in
- n) NAME="$OPTARG";;
- p) PROG="$OPTARG";;
- *) echo "unrecognised options -$OPTARG" >&2; exit 1;
- esac
-done
-
-shift $((OPTIND - 1))
-
-# create all subdirectories
-mkdir -p $(echo "${@}" | tr ' ' '\n' | sed "s|[^/]*$||;s|^|build/$NAME|" | uniq)
-
-for s in ${@}
-do
- obj="build/${NAME}/${s%.*}.o"
- dep="${obj}.d"
-
- echo "${NAME}_OBJS += ${obj}" >> tests.mk
- echo "${dep}:" >> tests.mk
- echo "-include ${dep}" >> tests.mk
- echo "${obj}: $NAME/${s} \$(COMMON)" >> tests.mk
- echo " \$(COMPILE_TEST) -c $NAME/${s} -o ${obj}" >> tests.mk
-done
-
-echo "build/${NAME}/$PROG: \$(${NAME}_OBJS) \$(COMMON)" >> tests.mk
-echo " \$(COMPILE_TEST) \$(${NAME}_OBJS) \$(COMMON) \
- -o build/${NAME}/$PROG" >> tests.mk
diff --git a/tests/scripts/gen-simple b/tests/scripts/gen-simple
index a942fb3..fe2d7a4 100755
--- a/tests/scripts/gen-simple
+++ b/tests/scripts/gen-simple
@@ -10,6 +10,8 @@ while getopts "n:p:" opt; do
esac
done
+mkdir -p "build/$NAME"
+
if [ -z "$NAME" ]; then
echo "No name given for tests" >&2; exit 2;
fi
@@ -18,13 +20,28 @@ if [ -z "$PROGS" ]; then
echo "No programs to add to initrd" >&2; exit 3;
fi
-echo "build/$NAME/initrd: build/$NAME/init \$(COMMON) \$(KMI)" >> tests.mk
-echo " echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk
+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) \
- build/$NAME/initrd > reports/$NAME/log" >> 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
diff --git a/tests/scripts/makefile b/tests/scripts/makefile
index ed2b2b4..63150b1 100644
--- a/tests/scripts/makefile
+++ b/tests/scripts/makefile
@@ -15,7 +15,8 @@ OBFLAGS := -ffreestanding -nostdlib -std=c17 -g -O2
INCLUDEFLAGS := -I ../include -I.
WARNFLAGS := -Wall -Wextra
DEPFLAGS = -MT $@ -MMD -MP -MF $@.d
-COMPILE_TEST = $(COMPILER) $(WARNFLAGS) $(INCLUDEFLAGS) $(DEPFLAGS) $(OBFLAGS) $(ARCH_FLAGS)
+COMPILE_TEST = $(COMPILER) $(WARNFLAGS) $(INCLUDEFLAGS) \
+ $(DEPFLAGS) $(OBFLAGS) $(ARCH_FLAGS)
GEN_INITRD := cpio -H newc -o >
QEMU := qemu-system-$(ARCH) -machine virt -kernel ../kmi.bin \
@@ -27,11 +28,14 @@ QEMU := qemu-system-$(ARCH) -machine virt -kernel ../kmi.bin \
-initrd
KMI := ../kmi.bin
-COMMON := build/printf.o
+COMMON := build/printf.o build/string.o
build/printf.o: common/printf.c $(KMI)
$(COMPILE_TEST) -c common/printf.c -o build/printf.o
+build/string.o: common/string.c $(KMI)
+ $(COMPILE_TEST) -c common/string.c -o build/string.o
+
include tests.mk
.PHONY: check