aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utests
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2016-07-13 22:31:46 +0200
committerAlex Auvolat <alex@adnab.me>2016-07-13 22:31:46 +0200
commit360da84db0d7165c84d160b518f39cd16006c758 (patch)
treea6fea5da753ec4ac5a37237cefda52801f9647ac /src/tests/utests
parent27a6934ea3073c3eaf782cc7615ce4ed0dbf4a18 (diff)
downloadkogata-360da84db0d7165c84d160b518f39cd16006c758.tar.gz
kogata-360da84db0d7165c84d160b518f39cd16006c758.zip
Migrate to BAM build tool
Diffstat (limited to 'src/tests/utests')
-rw-r--r--src/tests/utests/bam.lua21
l---------src/tests/utests/chan1/Makefile1
l---------src/tests/utests/chan2/Makefile1
l---------src/tests/utests/fs1/Makefile1
l---------src/tests/utests/fs2/Makefile1
l---------src/tests/utests/malloc/Makefile1
-rw-r--r--src/tests/utests/rules.make14
-rwxr-xr-xsrc/tests/utests/run_qemu_test.sh36
l---------src/tests/utests/subfs/Makefile1
9 files changed, 41 insertions, 36 deletions
diff --git a/src/tests/utests/bam.lua b/src/tests/utests/bam.lua
new file mode 100644
index 0000000..6137399
--- /dev/null
+++ b/src/tests/utests/bam.lua
@@ -0,0 +1,21 @@
+for _, name in pairs({
+ "chan1", "chan2",
+ "fs1", "fs2",
+ "malloc",
+ "subfs"
+}) do
+ local map = "build/tests/utest_" .. name .. ".map"
+
+ local config = TableDeepCopy(user_settings)
+ config.link.flags:Add( '-Xlinker -Map=' .. map,
+ '-T src/sysbin/linker.ld')
+
+ local obj = Compile(config, 'src/tests/utests/' .. name .. '/test.c')
+ local bin = Link(config, 'tests/utest_' .. name, {obj, libkogata})
+
+ local out = "build/tests/utest_"..name..".log"
+ AddJob(out, "utest " .. name, "./src/tests/utests/run_qemu_test.sh " .. bin .. " " .. out .. " " .. map)
+ AddDependency(out, bin)
+ AddDependency(out, kernel)
+ table.insert(tests, out)
+end
diff --git a/src/tests/utests/chan1/Makefile b/src/tests/utests/chan1/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/chan1/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/utests/chan2/Makefile b/src/tests/utests/chan2/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/chan2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/utests/fs1/Makefile b/src/tests/utests/fs1/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/fs1/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/utests/fs2/Makefile b/src/tests/utests/fs2/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/fs2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/utests/malloc/Makefile b/src/tests/utests/malloc/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/malloc/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/utests/rules.make b/src/tests/utests/rules.make
deleted file mode 100644
index ec48e87..0000000
--- a/src/tests/utests/rules.make
+++ /dev/null
@@ -1,14 +0,0 @@
-LIB = ../../../lib/libkogata/libkogata.lib
-
-OBJ = test.o
-
-CFLAGS = -I . -I ../../../common/include -I ../../../lib/include -DBUILD_USER_TEST
-LDFLAGS = -T ../../../sysbin/linker.ld -Xlinker -Map=init.map
-
-OUT = init.bin
-
-include ../../../rules.make
-
-run_test: rebuild
- ../run_qemu_test.sh
-
diff --git a/src/tests/utests/run_qemu_test.sh b/src/tests/utests/run_qemu_test.sh
index c168e8c..eb535ac 100755
--- a/src/tests/utests/run_qemu_test.sh
+++ b/src/tests/utests/run_qemu_test.sh
@@ -1,23 +1,27 @@
#!/bin/bash
-if [ "$1" = "watchdog" ]; then
- sleep 3 &
- PID=$!
- echo $PID > pid2
- wait $PID
- if [ $? -eq 0 ]; then echo "(TEST-FAIL)"; fi
- exit 0
-fi
+BINFILE=$1
+LOGFILE=$2
+MAPFILE=$3
+
+RESULTFILE=`mktemp`
+PIDFILE=`mktemp`
-(qemu-system-i386 -kernel ../../../kernel/kernel.bin -append 'init=io:/mod/init.bin' -initrd 'init.bin,../../../kernel/kernel.map' -serial stdio -m 16 -display none & echo $! >pid &
- $0 watchdog) \
- | tee >(grep -m 1 "TEST-" >result; kill -INT `cat pid`; kill -TERM `cat pid2`) \
+(timeout 10s qemu-system-i386 -kernel build/kernel.bin -append "init=io:/mod/`basename $BINFILE`" \
+ -initrd "$BINFILE,$MAPFILE" -serial stdio -m 16 -display none 2>/dev/null \
+ & echo $! >$PIDFILE) \
+ | tee >(grep -m 1 "TEST-" >$RESULTFILE; kill -INT `cat $PIDFILE`) >$LOGFILE
-RESULT=`cat result`
+RESULT=`cat $RESULTFILE`
-rm result
-rm pid
-rm pid2
+rm $RESULTFILE
+rm $PIDFILE
-if [ $RESULT != '(TEST-OK)' ]; then exit 1; fi
+if [ "$RESULT" != '[1] (TEST-OK)' ]; then
+ echo -e "\033[0;31m$BINFILE $RESULT\033[0m"
+ cp $LOGFILE $LOGFILE.err
+ exit 1;
+else
+ echo -e "\033[0;32m$BINFILE $RESULT\033[0m"
+fi
diff --git a/src/tests/utests/subfs/Makefile b/src/tests/utests/subfs/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/utests/subfs/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file