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 --- .gitignore | 19 +++++--- Makefile | 37 ++++---------- bam.lua | 94 ++++++++++++++++++++++++++++++++++++ make_cdrom.sh | 22 ++++----- res/fonts/bam.lua | 19 ++++++++ res/keymaps/bam.lua | 12 +++++ 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 - 45 files changed, 322 insertions(+), 257 deletions(-) create mode 100644 bam.lua create mode 100644 res/fonts/bam.lua create mode 100644 res/keymaps/bam.lua 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 diff --git a/.gitignore b/.gitignore index 6c14d1a..0268822 100644 --- a/.gitignore +++ b/.gitignore @@ -3,14 +3,17 @@ tags -*.o -*.bin -*.lib -*.map -*.log - -*.bf -*.km +build/* +.bam/* + +# *.o +# *.bin +# *.lib +# *.map +# *.log +# +# *.bf +# *.km *.iso cdrom/ diff --git a/Makefile b/Makefile index 05b0372..47ed44a 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,24 @@ -DIRS = src/common/libkogata src/common/libc src/common/libalgo \ - src/kernel src/lib/libkogata \ - src/sysbin/init src/sysbin/giosrv src/sysbin/login src/sysbin/terminal src/sysbin/shell \ - res/fonts res/keymaps - all: - for dir in $(DIRS); do \ - $(MAKE) -C $$dir || exit 1; \ - done - -rebuild: - for dir in $(DIRS); do \ - $(MAKE) -C $$dir rebuild || exit 1; \ - done + bam clean: - for dir in $(DIRS); do \ - $(MAKE) -C $$dir clean; \ - done + bam -c -mrproper: - for dir in $(DIRS); do \ - $(MAKE) -C $$dir mrproper; \ - done +rebuild: clean all -run_tests: rebuild - src/tests/run_tests.sh +mrproper: clean -cdrom.iso: all make_cdrom.sh - ./make_cdrom.sh +run_tests: + bam + src/tests/run_tests.sh -run_qemu: cdrom.iso +run_qemu: all qemu-system-i386 -cdrom cdrom.iso -serial stdio -m 12 -run_qemu_debug: cdrom.iso +run_qemu_debug: all qemu-system-i386 -cdrom cdrom.iso -serial stdio -m 12 -s -S & \ (sleep 0.1; gdb src/kernel/kernel.bin -x gdb_cmd) -run_bochs_debug: cdrom.iso +run_bochs_debug: all bochs -f bochs_debug.cfg -q diff --git a/bam.lua b/bam.lua new file mode 100644 index 0000000..b0c6d54 --- /dev/null +++ b/bam.lua @@ -0,0 +1,94 @@ +-- +-- Redefine output function to put everything in build/ +-- + +function BuildOutput(settings, fname) + if fname:sub(1, 4) == "src/" then + fname = fname:sub(5) + end + local out = PathJoin("build", PathBase(fname) .. settings.config_ext) + return out +end + +-- +-- Define custom settings +-- + +host_settings = NewSettings() +host_settings.cc.Output = BuildOutput +host_settings.cc.extension = ".host.o" +host_settings.cc.includes:Add("src/lib/include/proto", + "src/common/include") + +common_settings = NewSettings() + +common_settings.compile.mappings['s'] = function(settings, input) + local output = BuildOutput(settings, input) .. settings.cc.extension + AddJob(output, "nasm " .. input, + "nasm -felf -g -o " .. output .. " " .. input) + AddDependency(output, input) + return output +end + +common_settings.cc.exe_c = "i586-elf-gcc" +common_settings.cc.exe_cxx = "i586-elf-g++" +common_settings.cc.Output = BuildOutput +common_settings.cc.includes:Add("src/common/include", ".") +common_settings.cc.flags:Add("-m32", + "-ffreestanding", + "-std=gnu99", + "-Wall", "-Wextra", "-Werror", + "-Wno-unused-parameter", + "-Wno-unused-function", + "-g", "-O0") + +common_settings.link.exe = "i586-elf-gcc" +common_settings.link.extension = ".bin" +common_settings.link.flags:Add("-ffreestanding", + "-nostdlib", + "-O0") +common_settings.link.libs:Add("gcc") +common_settings.link.Output = BuildOutput + +user_settings = TableDeepCopy(common_settings) +user_settings.cc.includes:Add('src/lib/include') + +-- +-- Require build scripts for all components +-- + +require 'src/common/libkogata/bam' +require 'src/common/libc/bam' +require 'src/common/libalgo/bam' + +require 'src/kernel/bam' + +require 'src/lib/libkogata/bam' + +require 'src/sysbin/bam' + +require 'res/fonts/bam' +require 'res/keymaps/bam' + +-- +-- Build script for CDROM.iso +-- + +cdrom = "build/cdrom.iso" + +AddJob(cdrom, "building ISO", "./make_cdrom.sh") +AddDependency(cdrom, kernel, sysbin, fonts, keymaps) + +DefaultTarget(cdrom) + +-- +-- Script for running tests +-- + +tests = {} + +require 'src/tests/slab_test/bam' +require 'src/tests/ktests/bam' +require 'src/tests/utests/bam' + +PseudoTarget("test", tests) diff --git a/make_cdrom.sh b/make_cdrom.sh index f803017..4e7feb6 100755 --- a/make_cdrom.sh +++ b/make_cdrom.sh @@ -8,24 +8,24 @@ fi # Copy system files to CDROM -cp src/kernel/kernel.bin cdrom/boot; strip cdrom/boot/kernel.bin -cp src/kernel/kernel.map cdrom/boot -cp src/sysbin/init/init.bin cdrom/boot; strip cdrom/boot/init.bin +cp build/kernel.bin cdrom/boot; strip cdrom/boot/kernel.bin +cp build/kernel.map cdrom/boot +cp build/init.bin cdrom/boot; strip cdrom/boot/init.bin mkdir -p cdrom/sys/bin -cp src/sysbin/giosrv/giosrv.bin cdrom/sys/bin -cp src/sysbin/login/login.bin cdrom/sys/bin -cp src/sysbin/terminal/terminal.bin cdrom/sys/bin -cp src/sysbin/shell/shell.bin cdrom/sys/bin +cp build//giosrv.bin cdrom/sys/bin +cp build/login.bin cdrom/sys/bin +cp build/terminal.bin cdrom/sys/bin +cp build/shell.bin cdrom/sys/bin for BIN in cdrom/sys/bin/*.bin; do strip $BIN; done mkdir -p cdrom/sys/fonts -cp res/fonts/*.bf cdrom/sys/fonts -cp res/fonts/pcvga.bf cdrom/sys/fonts/default.bf +cp build/res/fonts/*.bf cdrom/sys/fonts +cp build/res/fonts/pcvga.bf cdrom/sys/fonts/default.bf mkdir -p cdrom/sys/keymaps -cp res/keymaps/*.km cdrom/sys/keymaps -cp res/keymaps/fr.km cdrom/sys/keymaps/default.km +cp build/res/keymaps/*.km cdrom/sys/keymaps +cp build/res/keymaps/fr.km cdrom/sys/keymaps/default.km cp README.md cdrom diff --git a/res/fonts/bam.lua b/res/fonts/bam.lua new file mode 100644 index 0000000..1f99169 --- /dev/null +++ b/res/fonts/bam.lua @@ -0,0 +1,19 @@ +fonts = {} + +for _, file in pairs(Collect('res/fonts/*.s')) do + local out = PathJoin('build', PathBase(file) .. '.bf') + AddJob(out, "nasm font " .. out, "nasm -o " .. out .. " " .. file) + AddDependency(out, file) + table.insert(fonts, out) +end + +for _, file in pairs(Collect('res/fonts/*.c')) do + local obj = Compile(host_settings, file) + local tgt = PathJoin('build', PathBase(file) .. '_tmp') + local bin = Link(host_settings, tgt, obj) + + local out = PathJoin('build', PathBase(file) .. '.bf') + AddJob(out, "call font " .. bin, "./" .. bin .. " > " .. out) + AddDependency(out, bin) + table.insert(fonts, out) +end diff --git a/res/keymaps/bam.lua b/res/keymaps/bam.lua new file mode 100644 index 0000000..f078dd0 --- /dev/null +++ b/res/keymaps/bam.lua @@ -0,0 +1,12 @@ +keymaps = {} + +for _, file in pairs(Collect('res/keymaps/*.c')) do + local obj = Compile(host_settings, file) + local tgt = PathJoin('build', PathBase(file) .. '_tmp') + local bin = Link(host_settings, tgt, obj) + + local out = PathJoin('build', PathBase(file) .. '.km') + AddJob(out, "call font " .. bin, "./" .. bin .. " > " .. out) + AddDependency(out, bin) + table.insert(keymaps, out) +end 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