From 360da84db0d7165c84d160b518f39cd16006c758 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 13 Jul 2016 22:31:46 +0200 Subject: Migrate to BAM build tool --- src/common/libalgo/Makefile | 11 ----------- src/common/libalgo/bam.lua | 3 +++ src/common/libc/Makefile | 11 ----------- src/common/libc/bam.lua | 3 +++ src/common/libkogata/Makefile | 11 ----------- src/common/libkogata/bam.lua | 3 +++ src/kernel/Makefile | 23 ----------------------- src/kernel/bam.lua | 20 ++++++++++++++++++++ src/lib/libkogata/Makefile | 13 ------------- src/lib/libkogata/bam.lua | 4 ++++ src/sysbin/bam.lua | 23 +++++++++++++++++++++++ src/sysbin/giosrv/Makefile | 12 ------------ src/sysbin/init/Makefile | 12 ------------ src/sysbin/init/main.c | 4 ++-- src/sysbin/login/Makefile | 12 ------------ src/sysbin/shell/Makefile | 12 ------------ src/sysbin/terminal/Makefile | 12 ------------ src/tests/ktests/bam.lua | 35 +++++++++++++++++++++++++++++++++++ src/tests/ktests/breakpoint/Makefile | 1 - src/tests/ktests/btree1/Makefile | 1 - src/tests/ktests/btree2/Makefile | 1 - src/tests/ktests/cmdline/Makefile | 1 - src/tests/ktests/hashtbl1/Makefile | 1 - src/tests/ktests/hashtbl2/Makefile | 1 - src/tests/ktests/kmalloc/Makefile | 1 - src/tests/ktests/region1/Makefile | 1 - src/tests/ktests/rules.make | 17 ----------------- src/tests/ktests/run_qemu_test.sh | 26 ++++++++++++++++++++------ src/tests/run_tests.sh | 13 ------------- src/tests/slab_test/bam.lua | 11 +++++++++++ src/tests/utests/bam.lua | 21 +++++++++++++++++++++ src/tests/utests/chan1/Makefile | 1 - src/tests/utests/chan2/Makefile | 1 - src/tests/utests/fs1/Makefile | 1 - src/tests/utests/fs2/Makefile | 1 - src/tests/utests/malloc/Makefile | 1 - src/tests/utests/rules.make | 14 -------------- src/tests/utests/run_qemu_test.sh | 36 ++++++++++++++++++++---------------- src/tests/utests/subfs/Makefile | 1 - 39 files changed, 165 insertions(+), 211 deletions(-) delete mode 100644 src/common/libalgo/Makefile create mode 100644 src/common/libalgo/bam.lua delete mode 100644 src/common/libc/Makefile create mode 100644 src/common/libc/bam.lua delete mode 100644 src/common/libkogata/Makefile create mode 100644 src/common/libkogata/bam.lua delete mode 100644 src/kernel/Makefile create mode 100644 src/kernel/bam.lua delete mode 100644 src/lib/libkogata/Makefile create mode 100644 src/lib/libkogata/bam.lua create mode 100644 src/sysbin/bam.lua delete mode 100644 src/sysbin/giosrv/Makefile delete mode 100644 src/sysbin/init/Makefile delete mode 100644 src/sysbin/login/Makefile delete mode 100644 src/sysbin/shell/Makefile delete mode 100644 src/sysbin/terminal/Makefile create mode 100644 src/tests/ktests/bam.lua delete mode 120000 src/tests/ktests/breakpoint/Makefile delete mode 120000 src/tests/ktests/btree1/Makefile delete mode 120000 src/tests/ktests/btree2/Makefile delete mode 120000 src/tests/ktests/cmdline/Makefile delete mode 120000 src/tests/ktests/hashtbl1/Makefile delete mode 120000 src/tests/ktests/hashtbl2/Makefile delete mode 120000 src/tests/ktests/kmalloc/Makefile delete mode 120000 src/tests/ktests/region1/Makefile delete mode 100644 src/tests/ktests/rules.make delete mode 100755 src/tests/run_tests.sh create mode 100644 src/tests/slab_test/bam.lua create mode 100644 src/tests/utests/bam.lua delete mode 120000 src/tests/utests/chan1/Makefile delete mode 120000 src/tests/utests/chan2/Makefile delete mode 120000 src/tests/utests/fs1/Makefile delete mode 120000 src/tests/utests/fs2/Makefile delete mode 120000 src/tests/utests/malloc/Makefile delete mode 100644 src/tests/utests/rules.make delete mode 120000 src/tests/utests/subfs/Makefile (limited to 'src') diff --git a/src/common/libalgo/Makefile b/src/common/libalgo/Makefile deleted file mode 100644 index fe6dbc6..0000000 --- a/src/common/libalgo/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -OBJ = keyval.o hashtbl.o btree.o - -LIB = - -CFLAGS = -I ../include - -LDFLAGS = - -OUT = libalgo.lib - -include ../../rules.make diff --git a/src/common/libalgo/bam.lua b/src/common/libalgo/bam.lua new file mode 100644 index 0000000..3b164a8 --- /dev/null +++ b/src/common/libalgo/bam.lua @@ -0,0 +1,3 @@ +local source = Collect('src/common/libalgo/*.c') + +common_libalgo = Compile(common_settings, source) diff --git a/src/common/libc/Makefile b/src/common/libc/Makefile deleted file mode 100644 index 54fa9f1..0000000 --- a/src/common/libc/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -OBJ = string.o printf.o - -LIB = - -CFLAGS = -I ../include - -LDFLAGS = - -OUT = libc.lib - -include ../../rules.make diff --git a/src/common/libc/bam.lua b/src/common/libc/bam.lua new file mode 100644 index 0000000..cee2ec4 --- /dev/null +++ b/src/common/libc/bam.lua @@ -0,0 +1,3 @@ +local source = Collect('src/common/libc/*.c') + +common_libc = Compile(common_settings, source) diff --git a/src/common/libkogata/Makefile b/src/common/libkogata/Makefile deleted file mode 100644 index 1c1113b..0000000 --- a/src/common/libkogata/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -OBJ = slab_alloc.o region_alloc.o mutex.o - -LIB = - -CFLAGS = -I ../include - -LDFLAGS = - -OUT = libkogata.lib - -include ../../rules.make diff --git a/src/common/libkogata/bam.lua b/src/common/libkogata/bam.lua new file mode 100644 index 0000000..30cf9eb --- /dev/null +++ b/src/common/libkogata/bam.lua @@ -0,0 +1,3 @@ +local source = Collect('src/common/libkogata/*.c') + +common_libkogata = Compile(common_settings, source) diff --git a/src/kernel/Makefile b/src/kernel/Makefile deleted file mode 100644 index 1082b29..0000000 --- a/src/kernel/Makefile +++ /dev/null @@ -1,23 +0,0 @@ - -OBJ = core/loader.o core/dbglog.o \ - core/gdt.o core/idt.o core/interrupt.o core/context_switch.o core/thread.o \ - core/frame.o core/paging.o core/freemem.o core/region.o core/kmalloc.o \ - core/worker.o core/prng.o \ - user/vfs.o user/nullfs.o user/process.o user/elf.o user/syscall.o user/ipc.o user/pager.o \ - dev/pci.o dev/pciide.o dev/v86.o dev/v86asm.o dev/vesa.o dev/pckbd.o \ - fs/iso9660.o - -LIB = ../common/libc/libc.lib ../common/libkogata/libkogata.lib ../common/libalgo/libalgo.lib - -CFLAGS = -I ./include -I ../common/include -DPRNG_INIT_ENTROPY=1$(shell date +%N) - -LDFLAGS = -T linker.ld -Xlinker -Map=kernel.map - -OUT = kernel.lib - -include ../rules.make - -kernel.bin: kernel.lib core/kmain.o core/sys.o - $(LD) $(LDFLAGS) -o $@ $^ - -all: $(OUT) kernel.bin diff --git a/src/kernel/bam.lua b/src/kernel/bam.lua new file mode 100644 index 0000000..1588315 --- /dev/null +++ b/src/kernel/bam.lua @@ -0,0 +1,20 @@ +local kernel_settings = TableDeepCopy(common_settings) + +kernel_settings.cc.includes:Add("src/kernel/include") + +kernel_settings.link.flags:Add("-T src/kernel/linker.ld", + "-Xlinker -Map=build/kernel.map") + +kernel_source = { + Collect('src/kernel/core/*.s'), + Collect('src/kernel/dev/*.s'), + Collect('src/kernel/core/*.c'), + Collect('src/kernel/dev/*.c'), + Collect('src/kernel/fs/*.c'), + Collect('src/kernel/user/*.c'), +} +kernel_obj = Compile(kernel_settings, kernel_source) + +kernel = Link(kernel_settings, "kernel", {kernel_obj, common_libkogata, + common_libc, common_libalgo}) + diff --git a/src/lib/libkogata/Makefile b/src/lib/libkogata/Makefile deleted file mode 100644 index 7a1a2ee..0000000 --- a/src/lib/libkogata/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -OBJ = start.o malloc.o debug.o syscall.o \ - mainloop.o gip.o draw.o keyboard.o \ - stdio.o unistd.o - -LIB = ../../common/libkogata/libkogata.lib ../../common/libalgo/libalgo.lib ../../common/libc/libc.lib - -CFLAGS = -I ../include -I ../../common/include - -LDFLAGS = - -OUT = libkogata.lib - -include ../../rules.make diff --git a/src/lib/libkogata/bam.lua b/src/lib/libkogata/bam.lua new file mode 100644 index 0000000..1e69e5d --- /dev/null +++ b/src/lib/libkogata/bam.lua @@ -0,0 +1,4 @@ +local source = Collect('src/lib/libkogata/*.c') +local obj = Compile(user_settings, source) + +libkogata = {obj, common_libc, common_libalgo, common_libkogata} diff --git a/src/sysbin/bam.lua b/src/sysbin/bam.lua new file mode 100644 index 0000000..819bc43 --- /dev/null +++ b/src/sysbin/bam.lua @@ -0,0 +1,23 @@ +local function sysbin_settings(name) + local s = TableDeepCopy(user_settings) + s.link.flags:Add("-T src/sysbin/linker.ld", + "-Xlinker -Map=build/" .. name .. ".map") + return s +end + +local function sysbin_exe(name) + local s = sysbin_settings(name) + + local src = Collect('src/sysbin/' .. name .. '/*.c') + local obj = Compile(s, src) + + return Link(s, name .. ".bin", {obj, libkogata}) +end + +sysbin = { + sysbin_exe('init'), + sysbin_exe('giosrv'), + sysbin_exe('login'), + sysbin_exe('terminal'), + sysbin_exe('shell'), +} diff --git a/src/sysbin/giosrv/Makefile b/src/sysbin/giosrv/Makefile deleted file mode 100644 index 9adc05a..0000000 --- a/src/sysbin/giosrv/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -OBJ = main.o - -LIB = ../../lib/libkogata/libkogata.lib - -CFLAGS = -I ./include -I ../../common/include -I ../../lib/include - -LDFLAGS = -T ../linker.ld -Xlinker -Map=giosrv.map - -OUT = giosrv.bin - -include ../../rules.make diff --git a/src/sysbin/init/Makefile b/src/sysbin/init/Makefile deleted file mode 100644 index e56d4c0..0000000 --- a/src/sysbin/init/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -OBJ = main.o - -LIB = ../../lib/libkogata/libkogata.lib - -CFLAGS = -I ./include -I ../../common/include -I ../../lib/include - -LDFLAGS = -T ../linker.ld -Xlinker -Map=init.map - -OUT = init.bin - -include ../../rules.make diff --git a/src/sysbin/init/main.c b/src/sysbin/init/main.c index f1cb77a..36ca884 100644 --- a/src/sysbin/init/main.c +++ b/src/sysbin/init/main.c @@ -156,7 +156,7 @@ int main(int argc, char **argv) { btree_t *cmdline = read_cmdline(); if (cmdline == 0) PANIC("[init] Could not parse cmdline"); - // Later : setup config: and read config file + // setup config: if (btree_find(cmdline, "config") == 0) { PANIC("[init] No config=xxx option specified on command line"); } else { @@ -170,7 +170,7 @@ int main(int argc, char **argv) { if (!ok) PANIC("[init] Could not setup config:"); } - // Setup sys: partition + // Setup sys: setup_sys(); // Setup GIP channel for communication between giosrv and login diff --git a/src/sysbin/login/Makefile b/src/sysbin/login/Makefile deleted file mode 100644 index 1232fa8..0000000 --- a/src/sysbin/login/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -OBJ = main.o - -LIB = ../../lib/libkogata/libkogata.lib - -CFLAGS = -I ./include -I ../../common/include -I ../../lib/include - -LDFLAGS = -T ../linker.ld -Xlinker -Map=login.map - -OUT = login.bin - -include ../../rules.make diff --git a/src/sysbin/shell/Makefile b/src/sysbin/shell/Makefile deleted file mode 100644 index 80d1009..0000000 --- a/src/sysbin/shell/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -OBJ = main.o - -LIB = ../../lib/libkogata/libkogata.lib - -CFLAGS = -I ./include -I ../../common/include -I ../../lib/include - -LDFLAGS = -T ../linker.ld -Xlinker -Map=shell.map - -OUT = shell.bin - -include ../../rules.make diff --git a/src/sysbin/terminal/Makefile b/src/sysbin/terminal/Makefile deleted file mode 100644 index cdbf2fe..0000000 --- a/src/sysbin/terminal/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -OBJ = main.o - -LIB = ../../lib/libkogata/libkogata.lib - -CFLAGS = -I ./include -I ../../common/include -I ../../lib/include - -LDFLAGS = -T ../linker.ld -Xlinker -Map=terminal.map - -OUT = terminal.bin - -include ../../rules.make 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 -- cgit v1.2.3