aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-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
-rwxr-xr-xsrc/tests/run_tests.sh13
-rw-r--r--src/tests/slab_test/bam.lua11
-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
22 files changed, 107 insertions, 80 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
diff --git a/src/tests/run_tests.sh b/src/tests/run_tests.sh
deleted file mode 100755
index 470959b..0000000
--- a/src/tests/run_tests.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-cd `dirname $0`
-
-for FILE in */Makefile */*/Makefile; do
- TEST=`dirname $FILE`
- echo -n "Running test $TEST ... "
- if make -C $TEST run_test > $TEST/test.log 2>&1; then
- echo -e "\033[0;32mOK\033[0m"
- else
- echo -e "\033[0;31mFAIL\033[0m"
- fi
-done
diff --git a/src/tests/slab_test/bam.lua b/src/tests/slab_test/bam.lua
new file mode 100644
index 0000000..87c6666
--- /dev/null
+++ b/src/tests/slab_test/bam.lua
@@ -0,0 +1,11 @@
+local source = {"src/common/libkogata/slab_alloc.c",
+ "src/tests/slab_test/slab_test.c"}
+local obj = Compile(host_settings, source)
+
+local bin = Link(host_settings, "build/tests/slab_test", obj)
+
+local slab_test = "build/tests/slab_test.log"
+AddJob(slab_test, "slab_test", "./" .. bin .. " > " .. slab_test)
+AddDependency(slab_test, bin)
+
+table.insert(tests, slab_test)
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