aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ktests
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/ktests
parent27a6934ea3073c3eaf782cc7615ce4ed0dbf4a18 (diff)
downloadkogata-360da84db0d7165c84d160b518f39cd16006c758.tar.gz
kogata-360da84db0d7165c84d160b518f39cd16006c758.zip
Migrate to BAM build tool
Diffstat (limited to 'src/tests/ktests')
-rw-r--r--src/tests/ktests/bam.lua35
l---------src/tests/ktests/breakpoint/Makefile1
l---------src/tests/ktests/btree1/Makefile1
l---------src/tests/ktests/btree2/Makefile1
l---------src/tests/ktests/cmdline/Makefile1
l---------src/tests/ktests/hashtbl1/Makefile1
l---------src/tests/ktests/hashtbl2/Makefile1
l---------src/tests/ktests/kmalloc/Makefile1
l---------src/tests/ktests/region1/Makefile1
-rw-r--r--src/tests/ktests/rules.make17
-rwxr-xr-xsrc/tests/ktests/run_qemu_test.sh26
11 files changed, 55 insertions, 31 deletions
diff --git a/src/tests/ktests/bam.lua b/src/tests/ktests/bam.lua
new file mode 100644
index 0000000..b721a8b
--- /dev/null
+++ b/src/tests/ktests/bam.lua
@@ -0,0 +1,35 @@
+local obj_nokmain = {}
+for name in TableWalk(kernel_obj) do
+ if not name:find('kmain') then
+ table.insert(obj_nokmain, name)
+ end
+end
+
+for _, name in pairs({
+ "breakpoint",
+ "btree1", "btree2",
+ "cmdline",
+ "hashtbl1", "hashtbl2",
+ "kmalloc",
+ "region1"
+}) do
+ local map = "build/tests/ktest_" .. name .. ".map"
+
+ local test_config = TableDeepCopy(common_settings)
+ test_config.cc.includes:Add("src/kernel/include",
+ "src/tests/ktests/"..name)
+ test_config.cc.flags:Add('-DBUILD_KERNEL_TEST')
+ test_config.link.flags:Add("-T src/kernel/linker.ld",
+ "-Xlinker -Map=" .. map)
+ test_config.cc.extension = ".ktest_" .. name .. ".o"
+
+ local kmain = Compile(test_config, "src/kernel/core/kmain.c")
+ local bin = Link(test_config, "tests/ktest_"..name,
+ {obj_nokmain, kmain, common_libkogata, common_libc, common_libalgo})
+
+ local out = "build/tests/ktest_"..name..".log"
+ AddJob(out, "ktest " .. name, "./src/tests/ktests/run_qemu_test.sh " .. bin .. " " .. out .. " " .. map)
+ AddDependency(out, bin)
+ table.insert(tests, out)
+end
+
diff --git a/src/tests/ktests/breakpoint/Makefile b/src/tests/ktests/breakpoint/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/breakpoint/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/btree1/Makefile b/src/tests/ktests/btree1/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/btree1/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/btree2/Makefile b/src/tests/ktests/btree2/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/btree2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/cmdline/Makefile b/src/tests/ktests/cmdline/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/cmdline/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/hashtbl1/Makefile b/src/tests/ktests/hashtbl1/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/hashtbl1/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/hashtbl2/Makefile b/src/tests/ktests/hashtbl2/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/hashtbl2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/kmalloc/Makefile b/src/tests/ktests/kmalloc/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/kmalloc/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/region1/Makefile b/src/tests/ktests/region1/Makefile
deleted file mode 120000
index 4630a7c..0000000
--- a/src/tests/ktests/region1/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-../rules.make \ No newline at end of file
diff --git a/src/tests/ktests/rules.make b/src/tests/ktests/rules.make
deleted file mode 100644
index fac175d..0000000
--- a/src/tests/ktests/rules.make
+++ /dev/null
@@ -1,17 +0,0 @@
-LIB = ../../../kernel/kernel.lib
-
-OBJ = kmain.o sys.o
-
-CFLAGS = -I . -I ../../../common/include -I ../../../kernel/include -DBUILD_KERNEL_TEST
-LDFLAGS = -T ../../../kernel/linker.ld -Xlinker -Map=test_kernel.map
-
-OUT = test_kernel.bin
-
-include ../../../rules.make
-
-%.o: ../../../kernel/core/%.c test.c
- $(CC) -c $< -o $@ $(CFLAGS)
-
-run_test: rebuild
- ../run_qemu_test.sh
-
diff --git a/src/tests/ktests/run_qemu_test.sh b/src/tests/ktests/run_qemu_test.sh
index 5f7df83..92cf10a 100755
--- a/src/tests/ktests/run_qemu_test.sh
+++ b/src/tests/ktests/run_qemu_test.sh
@@ -1,12 +1,26 @@
#!/bin/bash
-(qemu-system-i386 -kernel test_kernel.bin -initrd ../../../kernel/kernel.map -serial stdio -m 16 -display none & echo $! >pid) \
- | tee >(grep -m 1 "TEST-" >result; kill -INT `cat pid`) \
+BINFILE=$1
+LOGFILE=$2
+MAPFILE=$3
-RESULT=`cat result`
+RESULTFILE=`mktemp`
+PIDFILE=`mktemp`
-rm result
-rm pid
+(timeout 10s qemu-system-i386 -kernel $BINFILE -initrd $MAPFILE -serial stdio -m 16 -display none 2>/dev/null \
+ & echo $! >$PIDFILE) \
+ | tee >(grep -m 1 "TEST-" >$RESULTFILE; kill -INT `cat $PIDFILE`) > $LOGFILE
-if [ $RESULT != '(TEST-OK)' ]; then exit 1; fi
+RESULT=`cat $RESULTFILE`
+
+rm $RESULTFILE
+rm $PIDFILE
+
+if [ "$RESULT" != '(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