aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/bam.lua37
-rw-r--r--src/common/bam.lua16
-rw-r--r--src/common/include/proto/fs.h6
-rw-r--r--src/kernel/bam.lua34
-rw-r--r--src/kernel/core/kmain.c8
-rw-r--r--src/kernel/user/syscall.c1
-rw-r--r--src/lib/bam.lua24
-rw-r--r--src/lib/libc/syscall.c7
-rw-r--r--src/sysbin/bam.lua39
-rw-r--r--src/tests/ktests/bam.lua61
-rwxr-xr-xsrc/tests/ktests/run_qemu_test.sh3
-rw-r--r--src/tests/slab_test/bam.lua19
-rw-r--r--src/tests/slab_test/slab_test.c2
-rw-r--r--src/tests/utests/bam.lua37
-rw-r--r--src/tests/utests/chan1/test.c18
-rw-r--r--src/tests/utests/chan2/test.c50
-rw-r--r--src/tests/utests/fs1/test.c18
-rw-r--r--src/tests/utests/fs2/test.c16
-rw-r--r--src/tests/utests/malloc/test.c8
-rwxr-xr-xsrc/tests/utests/run_qemu_test.sh5
-rw-r--r--src/tests/utests/subfs/test.c18
21 files changed, 229 insertions, 198 deletions
diff --git a/src/bin/bam.lua b/src/bin/bam.lua
index 76b7b2a..d529ece 100644
--- a/src/bin/bam.lua
+++ b/src/bin/bam.lua
@@ -1,23 +1,24 @@
-local function bin_settings(name)
- local s = TableDeepCopy(user_settings)
- s.link.flags:Add("-T src/lib/linker.ld",
- "-Xlinker -Map=build/bin/" .. name .. ".map")
- if name == 'lua' or name == 'luac' then
- s.cc.includes:Add("src/lib/lua")
+return function(s, lib)
+ local function bin_settings(name)
+ local s = TableDeepCopy(s.user_settings)
+ s.link.flags:Add("-T src/lib/linker.ld")
+ if name == 'lua' or name == 'luac' then
+ s.cc.includes:Add("src/lib/lua")
+ end
+ return s
end
- return s
-end
-local function bin_exe(name, deps)
- local s = bin_settings(name)
+ local function bin_exe(name, deps)
+ local s = bin_settings(name)
- local src = Collect('src/bin/' .. name .. '/*.c')
- local obj = Compile(s, src)
+ local src = Collect('src/bin/' .. name .. '/*.c')
+ local obj = Compile(s, src)
- return Link(s, 'bin/' .. name .. ".bin", {obj, deps})
-end
+ return Link(s, 'bin/' .. name .. ".bin", {obj, deps})
+ end
-bin = {
- bin_exe('lua', {liblua}),
- -- bin_exe('luac', {liblua}),
-}
+ return {
+ bin_exe('lua', {lib.liblua}),
+ -- bin_exe('luac', {liblua}),
+ }
+end
diff --git a/src/common/bam.lua b/src/common/bam.lua
index 6d4a29c..77b98c5 100644
--- a/src/common/bam.lua
+++ b/src/common/bam.lua
@@ -1,7 +1,11 @@
-local function lib(name)
- local source = Collect('src/common/' .. name .. '/*.c')
- return Compile(common_settings, source)
-end
+return function(s)
+ local function lib(name)
+ local source = Collect('src/common/' .. name .. '/*.c')
+ return Compile(s.common_settings, source)
+ end
-common_libc = lib('libc')
-common_libkogata = lib('libkogata')
+ return {
+ libc = lib('libc'),
+ libkogata = lib('libkogata')
+ }
+end
diff --git a/src/common/include/proto/fs.h b/src/common/include/proto/fs.h
index e70ff55..49091eb 100644
--- a/src/common/include/proto/fs.h
+++ b/src/common/include/proto/fs.h
@@ -50,9 +50,9 @@ typedef struct {
#define IOCTL_BLOCKDEV_GET_BLOCK_COUNT 41
-#define SEL_READ 0x01
-#define SEL_WRITE 0x02
-#define SEL_ERROR 0x04
+#define SEL_READ (0x01)
+#define SEL_WRITE (0x02)
+#define SEL_ERROR (0x04)
typedef struct {
fd_t fd;
diff --git a/src/kernel/bam.lua b/src/kernel/bam.lua
index 2dc724e..43328e6 100644
--- a/src/kernel/bam.lua
+++ b/src/kernel/bam.lua
@@ -1,19 +1,23 @@
-local kernel_settings = TableDeepCopy(common_settings)
+return function(s, common)
+ local kernel_settings = TableDeepCopy(s.common_settings)
-kernel_settings.cc.includes:Add("src/common/include/kogata",
- "src/kernel/include")
+ kernel_settings.cc.includes:Add("src/common/include/kogata",
+ "src/kernel/include")
-kernel_settings.link.flags:Add("-T src/kernel/linker.ld")
+ kernel_settings.link.flags:Add("-T src/kernel/linker.ld")
-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_libc, common_libkogata})
+ 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'),
+ }
+ obj = Compile(kernel_settings, kernel_source)
+ return {
+ obj = obj,
+ bin = Link(kernel_settings, "kernel", {obj, common.libc, common.libkogata})
+ }
+end
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index dd66805..8ce9f0a 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -69,8 +69,12 @@ void kmain(multiboot_info_t *mbd, int32_t mb_magic) {
// to allocate memory ; they just increment it of the allocated quantity
void* kernel_data_end = (void*)&k_end_addr;
- elf_shdr_t *elf_sections = (elf_shdr_t*)(mbd->elf_sec.addr + K_HIGHHALF_ADDR);
- ASSERT(sizeof(elf_shdr_t) == mbd->elf_sec.size);
+
+ elf_shdr_t *elf_sections = 0;
+ if (mbd->elf_sec.size != 0) {
+ elf_sections = (elf_shdr_t*)(mbd->elf_sec.addr + K_HIGHHALF_ADDR);
+ ASSERT(mbd->elf_sec.size == 0 || sizeof(elf_shdr_t) == mbd->elf_sec.size);
+ }
dbglog_setup();
diff --git a/src/kernel/user/syscall.c b/src/kernel/user/syscall.c
index 9497bf2..e89f62d 100644
--- a/src/kernel/user/syscall.c
+++ b/src/kernel/user/syscall.c
@@ -325,6 +325,7 @@ uint32_t select_sc(sc_args_t args) {
if (h) {
fds[i].got_flags = file_poll(h, &wait_objs[n_wait_objs]);
if (wait_objs[n_wait_objs]) n_wait_objs++;
+ dbg_printf("KERNEL fds[%d].got_flags = 0x%p (fd %d)\n", i, fds[i].got_flags,fds[i].fd);
if (fds[i].got_flags & fds[i].req_flags) ret = true;
}
}
diff --git a/src/lib/bam.lua b/src/lib/bam.lua
index 44edad2..b7bee20 100644
--- a/src/lib/bam.lua
+++ b/src/lib/bam.lua
@@ -1,11 +1,15 @@
-local function lib(name)
- local source = {Collect('src/lib/' .. name .. '/*.c'),
- Collect('src/lib/' .. name .. '/*.s')}
- return Compile(user_settings, source)
-end
-
-libc = {lib('libc'), common_libc, common_libkogata}
+return function(s, common)
+ local function lib(name)
+ local source = {Collect('src/lib/' .. name .. '/*.c'),
+ Collect('src/lib/' .. name .. '/*.s')}
+ return Compile(s.user_settings, source)
+ end
+
+ local libc = {lib('libc'), common.libc, common.libkogata}
-libkogata = {lib('libkogata'), libc}
-
-liblua = {lib('lua'), libc}
+ return {
+ libc = libc,
+ libkogata = {lib('libkogata'), libc},
+ liblua = {lib('lua'), libc}
+ }
+end
diff --git a/src/lib/libc/syscall.c b/src/lib/libc/syscall.c
index 83708da..32aba00 100644
--- a/src/lib/libc/syscall.c
+++ b/src/lib/libc/syscall.c
@@ -9,7 +9,8 @@ static inline uint32_t sc_docall(uint32_t a, uint32_t b, uint32_t c, uint32_t d,
uint32_t ret;
asm volatile("int $0x40"
:"=a"(ret)
- :"a"(a),"b"(b),"c"(c),"d"(d),"S"(ss),"D"(dd));
+ :"a"(a),"b"(b),"c"(c),"d"(d),"S"(ss),"D"(dd)
+ :"memory");
return ret;
}
@@ -108,7 +109,7 @@ fd_t sc_use_token(token_t *tok) {
}
bool sc_make_fs(const char* name, const char* driver, fd_t source, const char* options) {
- volatile sc_make_fs_args_t args = {
+ sc_make_fs_args_t args = {
.driver = driver,
.driver_strlen = strlen(driver),
.fs_name = name,
@@ -124,7 +125,7 @@ bool sc_fs_add_source(const char* fs, fd_t source, const char* options) {
return sc_docall(SC_FS_ADD_SRC, (uint32_t)fs, strlen(fs), source, (uint32_t)options, strlen(options));
}
bool sc_fs_subfs(const char* name, const char* orig_fs, const char* root, int ok_modes) {
- volatile sc_subfs_args_t args = {
+ sc_subfs_args_t args = {
.new_name = name,
.new_name_strlen = strlen(name),
.from_fs = orig_fs,
diff --git a/src/sysbin/bam.lua b/src/sysbin/bam.lua
index 8628bf1..9e13a8a 100644
--- a/src/sysbin/bam.lua
+++ b/src/sysbin/bam.lua
@@ -1,23 +1,24 @@
-local function sysbin_settings(name)
- local s = TableDeepCopy(user_settings)
- s.link.flags:Add("-T src/lib/linker.ld",
- "-Xlinker -Map=build/sysbin/" .. name .. ".map")
- return s
-end
+return function(s, lib)
+ local function sysbin_settings(name)
+ local s = TableDeepCopy(s.user_settings)
+ s.link.flags:Add("-T src/lib/linker.ld")
+ return s
+ end
-local function sysbin_exe(name, deps)
- local s = sysbin_settings(name)
+ local function sysbin_exe(name, deps)
+ local s = sysbin_settings(name)
- local src = Collect('src/sysbin/' .. name .. '/*.c')
- local obj = Compile(s, src)
+ local src = Collect('src/sysbin/' .. name .. '/*.c')
+ local obj = Compile(s, src)
- return Link(s, 'sysbin/' .. name .. ".bin", {obj, deps})
-end
+ return Link(s, 'sysbin/' .. name .. ".bin", {obj, deps})
+ end
-sysbin = {
- sysbin_exe('init', {libkogata}),
- sysbin_exe('giosrv', {libkogata}),
- sysbin_exe('login', {libkogata}),
- sysbin_exe('terminal', {libkogata}),
- sysbin_exe('shell', {libkogata}),
-}
+ return {
+ sysbin_exe('init', {lib.libkogata}),
+ sysbin_exe('giosrv', {lib.libkogata}),
+ sysbin_exe('login', {lib.libkogata}),
+ sysbin_exe('terminal', {lib.libkogata}),
+ sysbin_exe('shell', {lib.libkogata}),
+ }
+end
diff --git a/src/tests/ktests/bam.lua b/src/tests/ktests/bam.lua
index b721a8b..c1be337 100644
--- a/src/tests/ktests/bam.lua
+++ b/src/tests/ktests/bam.lua
@@ -1,35 +1,38 @@
-local obj_nokmain = {}
-for name in TableWalk(kernel_obj) do
- if not name:find('kmain') then
- table.insert(obj_nokmain, name)
+return function(s, common, kernel_obj)
+ local tests = {}
+
+ local obj_nokmain = {}
+ for name in TableWalk(kernel_obj) do
+ if not name:find('kmain') then
+ table.insert(obj_nokmain, name)
+ end
end
-end
-for _, name in pairs({
- "breakpoint",
- "btree1", "btree2",
- "cmdline",
- "hashtbl1", "hashtbl2",
- "kmalloc",
- "region1"
-}) do
- local map = "build/tests/ktest_" .. name .. ".map"
+ for _, name in pairs({
+ "breakpoint",
+ "btree1", "btree2",
+ "cmdline",
+ "hashtbl1", "hashtbl2",
+ "kmalloc",
+ "region1"
+ }) do
+ local test_config = TableDeepCopy(s.common_settings)
+ test_config.cc.includes:Add("src/kernel/include",
+ "src/common/include/kogata",
+ "src/tests/ktests/"..name)
+ test_config.cc.flags:Add('-DBUILD_KERNEL_TEST')
+ test_config.link.flags:Add("-T src/kernel/linker.ld")
+ test_config.cc.extension = ".ktest_" .. name .. ".o"
- 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 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 = bin .. ".log"
+ AddJob(out, "ktest " .. name, "./src/tests/ktests/run_qemu_test.sh " .. bin .. " " .. out)
+ AddDependency(out, bin)
+ table.insert(tests, out)
+ end
- 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)
+ return tests
end
-
diff --git a/src/tests/ktests/run_qemu_test.sh b/src/tests/ktests/run_qemu_test.sh
index 4249a96..bc86f12 100755
--- a/src/tests/ktests/run_qemu_test.sh
+++ b/src/tests/ktests/run_qemu_test.sh
@@ -2,12 +2,11 @@
BINFILE=$1
LOGFILE=$2
-MAPFILE=$3
RESULTFILE=`mktemp`
PIDFILE=`mktemp`
-(timeout 3s qemu-system-i386 -kernel $BINFILE -initrd $MAPFILE -serial stdio -m 16 -display none 2>/dev/null \
+(timeout 3s qemu-system-i386 -kernel $BINFILE -serial stdio -m 16 -display none 2>/dev/null \
& echo $! >$PIDFILE) \
| tee >(grep -m 1 "TEST-" >$RESULTFILE; kill -INT `cat $PIDFILE`) > $LOGFILE
diff --git a/src/tests/slab_test/bam.lua b/src/tests/slab_test/bam.lua
index 87c6666..cd5ad2d 100644
--- a/src/tests/slab_test/bam.lua
+++ b/src/tests/slab_test/bam.lua
@@ -1,11 +1,14 @@
-local source = {"src/common/libkogata/slab_alloc.c",
- "src/tests/slab_test/slab_test.c"}
-local obj = Compile(host_settings, source)
+return function(s)
+ local source = {"src/common/libkogata/slab_alloc.c",
+ "src/tests/slab_test/slab_test.c"}
+ local obj = Compile(s.host_settings, source)
-local bin = Link(host_settings, "build/tests/slab_test", obj)
+ local f = s.host_settings.cc.Output(s.host_settings, "tests/slab_test")
+ local bin = Link(s.host_settings, f, obj)
-local slab_test = "build/tests/slab_test.log"
-AddJob(slab_test, "slab_test", "./" .. bin .. " > " .. slab_test)
-AddDependency(slab_test, bin)
+ local slab_test = f .. ".log"
+ AddJob(slab_test, "slab_test", "./" .. bin .. " > " .. slab_test)
+ AddDependency(slab_test, bin)
-table.insert(tests, slab_test)
+ return slab_test
+end
diff --git a/src/tests/slab_test/slab_test.c b/src/tests/slab_test/slab_test.c
index 747c785..31af03d 100644
--- a/src/tests/slab_test/slab_test.c
+++ b/src/tests/slab_test/slab_test.c
@@ -1,4 +1,4 @@
-#include <slab_alloc.h>
+#include <kogata/slab_alloc.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/tests/utests/bam.lua b/src/tests/utests/bam.lua
index 6137399..abbce88 100644
--- a/src/tests/utests/bam.lua
+++ b/src/tests/utests/bam.lua
@@ -1,21 +1,24 @@
-for _, name in pairs({
- "chan1", "chan2",
- "fs1", "fs2",
- "malloc",
- "subfs"
-}) do
- local map = "build/tests/utest_" .. name .. ".map"
+return function(s, kernel, lib)
+ local tests = {}
- local config = TableDeepCopy(user_settings)
- config.link.flags:Add( '-Xlinker -Map=' .. map,
- '-T src/sysbin/linker.ld')
+ for _, name in pairs({
+ "chan1", "chan2",
+ "fs1", "fs2",
+ "malloc",
+ "subfs"
+ }) do
+ local config = TableDeepCopy(s.user_settings)
+ config.link.flags:Add('-T src/lib/linker.ld')
- local obj = Compile(config, 'src/tests/utests/' .. name .. '/test.c')
- local bin = Link(config, 'tests/utest_' .. name, {obj, libkogata})
+ local obj = Compile(config, 'src/tests/utests/' .. name .. '/test.c')
+ local bin = Link(config, 'tests/utest_' .. name, {obj, lib.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)
+ local out = bin .. ".log"
+ AddJob(out, "utest " .. name, "./src/tests/utests/run_qemu_test.sh " .. bin .. " " .. out .. " " .. kernel)
+ AddDependency(out, bin)
+ AddDependency(out, kernel)
+ table.insert(tests, out)
+ end
+
+ return tests
end
diff --git a/src/tests/utests/chan1/test.c b/src/tests/utests/chan1/test.c
index 1b89255..0c4e61a 100644
--- a/src/tests/utests/chan1/test.c
+++ b/src/tests/utests/chan1/test.c
@@ -1,26 +1,26 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
int main(int argc, char **argv) {
- fd_pair_t ch = make_channel(false);
+ fd_pair_t ch = sc_make_channel(false);
char* s = "Hello, world!";
- ASSERT(write(ch.a, 0, strlen(s), s) == strlen(s));
+ ASSERT(sc_write(ch.a, 0, strlen(s), s) == strlen(s));
char buf[128];
- ASSERT(read(ch.b, 0, 128, buf) == strlen(s));
+ ASSERT(sc_read(ch.b, 0, 128, buf) == strlen(s));
ASSERT(strncmp(s, buf, strlen(s)) == 0);
- close(ch.a);
+ sc_close(ch.a);
sel_fd_t sel = { .fd = ch.b, .req_flags = SEL_ERROR };
- ASSERT(select(&sel, 1, 0));
+ ASSERT(sc_select(&sel, 1, 0));
ASSERT(sel.got_flags & SEL_ERROR);
- close(ch.b);
+ sc_close(ch.b);
dbg_printf("(TEST-OK)\n");
diff --git a/src/tests/utests/chan2/test.c b/src/tests/utests/chan2/test.c
index a2f8b3f..c972e79 100644
--- a/src/tests/utests/chan2/test.c
+++ b/src/tests/utests/chan2/test.c
@@ -1,9 +1,9 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
volatile int step = 0; // volatile because thread-shared
@@ -15,6 +15,8 @@ const char* msg_d = "hello world";
void listen_thread(fd_t c1, fd_t c2) {
dbg_printf("listen_thread started\n");
+ dbg_printf("Got args: %d, %d\n", c1, c2);
+
sel_fd_t sel[2];
sel[0].fd = c1;
sel[1].fd = c2;
@@ -23,49 +25,49 @@ void listen_thread(fd_t c1, fd_t c2) {
char buf[128];
dbg_printf("Doing first select...\n");
- ASSERT(select(sel, 2, -1));
+ ASSERT(sc_select(sel, 2, -1));
dbg_printf("%x %x\n", sel[0].got_flags, sel[1].got_flags);
ASSERT(sel[0].got_flags & SEL_READ);
ASSERT(!(sel[1].got_flags & SEL_READ));
- ASSERT(read(c1, 0, strlen(msg_a), buf) == strlen(msg_a));
+ ASSERT(sc_read(c1, 0, strlen(msg_a), buf) == strlen(msg_a));
ASSERT(strncmp(buf, msg_a, strlen(msg_a)) == 0);
- ASSERT(write(c1, 0, strlen(msg_c), msg_c) == strlen(msg_c));
+ ASSERT(sc_write(c1, 0, strlen(msg_c), msg_c) == strlen(msg_c));
step = 1;
dbg_printf("Doing second select...\n");
- ASSERT(select(sel, 2, -1));
+ ASSERT(sc_select(sel, 2, -1));
dbg_printf("%x %x\n", sel[0].got_flags, sel[1].got_flags);
ASSERT(sel[1].got_flags & SEL_READ);
ASSERT(!(sel[0].got_flags & SEL_READ));
- ASSERT(read(c2, 0, strlen(msg_b), buf) == strlen(msg_b));
+ ASSERT(sc_read(c2, 0, strlen(msg_b), buf) == strlen(msg_b));
ASSERT(strncmp(buf, msg_b, strlen(msg_b)) == 0);
- ASSERT(write(c2, 0, strlen(msg_d), msg_d) == strlen(msg_d));
+ ASSERT(sc_write(c2, 0, strlen(msg_d), msg_d) == strlen(msg_d));
step = 2;
dbg_printf("Doing third select...\n");
- ASSERT(select(sel, 2, -1));
+ ASSERT(sc_select(sel, 2, -1));
dbg_printf("%x %x\n", sel[0].got_flags, sel[1].got_flags);
ASSERT(sel[0].got_flags & SEL_ERROR);
ASSERT(!(sel[1].got_flags & SEL_ERROR));
- close(c1);
+ sc_close(c1);
step = 3;
dbg_printf("Doing fourth select...\n");
- ASSERT(select(sel + 1, 1, -1));
+ ASSERT(sc_select(sel + 1, 1, -1));
dbg_printf("%x\n", sel[1].got_flags);
ASSERT(sel[1].got_flags & SEL_ERROR);
- close(c2);
+ sc_close(c2);
step = 4;
- exit_thread();
+ sc_exit_thread();
}
int main(int argc, char **argv) {
- fd_pair_t ch1 = make_channel(false);
+ fd_pair_t ch1 = sc_make_channel(false);
ASSERT(ch1.a != 0 && ch1.b != 0);
- fd_pair_t ch2 = make_channel(false);
+ fd_pair_t ch2 = sc_make_channel(false);
ASSERT(ch2.a != 0 && ch2.b != 0);
void* stack = malloc(0x1000);
@@ -77,42 +79,42 @@ int main(int argc, char **argv) {
*(--esp) = ch2.a;
*(--esp) = ch1.a;
*(--esp) = 0; // false return address
- dbg_printf("launching waiter thread\n");
- ASSERT(sys_new_thread(listen_thread, esp));
+ dbg_printf("launching waiter thread (args: %d, %d)\n", ch1.a, ch2.a);
+ ASSERT(sc_sys_new_thread(listen_thread, esp));
fd_t c1 = ch1.b, c2 = ch2.b;
// -- the test on the first channel
- ASSERT(write(c1, 0, strlen(msg_a), msg_a) == strlen(msg_a));
+ ASSERT(sc_write(c1, 0, strlen(msg_a), msg_a) == strlen(msg_a));
dbg_printf("wait for step1 signal\n");
while(step != 1);
dbg_printf("got step1 signal, proceeding\n");
- ASSERT(read(c1, 0, strlen(msg_c), buf) == strlen(msg_c));
+ ASSERT(sc_read(c1, 0, strlen(msg_c), buf) == strlen(msg_c));
ASSERT(strncmp(msg_c, buf, strlen(msg_c)) == 0);
// -- the test on the second channel
- ASSERT(write(c2, 0, strlen(msg_b), msg_b) == strlen(msg_b));
+ ASSERT(sc_write(c2, 0, strlen(msg_b), msg_b) == strlen(msg_b));
dbg_printf("wait for step2 signal\n");
while(step != 2);
dbg_printf("got step2 signal, proceeding\n");
- ASSERT(read(c2, 0, strlen(msg_d), buf) == strlen(msg_d));
+ ASSERT(sc_read(c2, 0, strlen(msg_d), buf) == strlen(msg_d));
ASSERT(strncmp(msg_d, buf, strlen(msg_d)) == 0);
// -- closing stuff
- close(c1);
+ sc_close(c1);
dbg_printf("waiting for step3 signal\n");
while(step != 3);
dbg_printf("got step3 signal, proceeding\n");
- close(c2);
+ sc_close(c2);
dbg_printf("waiting for step4 signal\n");
while(step != 4);
diff --git a/src/tests/utests/fs1/test.c b/src/tests/utests/fs1/test.c
index 79db13b..7356c14 100644
--- a/src/tests/utests/fs1/test.c
+++ b/src/tests/utests/fs1/test.c
@@ -1,37 +1,37 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
int main(int argc, char **argv) {
dbg_print("Hello, world! from user process.\n");
- fd_t f = open("io:/", FM_READDIR);
+ fd_t f = sc_open("io:/", FM_READDIR);
dbg_printf("openned /: %d\n", f);
ASSERT(f != 0);
dirent_t x;
size_t ent_no = 0;
- while (readdir(f, ent_no++, &x)) {
+ while (sc_readdir(f, ent_no++, &x)) {
dbg_printf("- '%s' %p %d\n", x.name, x.st.type, x.st.size);
if (x.st.type == FT_REGULAR) {
char buf[256];
strcpy(buf, "io:/");
strcpy(buf+4, x.name);
dbg_printf("trying to open %s...\n", buf);
- fd_t ff = open(buf, FM_READ);
+ fd_t ff = sc_open(buf, FM_READ);
ASSERT(ff != 0);
dbg_printf("ok, open as %d\n", ff);
char* cont = malloc(x.st.size + 1);
- ASSERT(read(ff, 0, x.st.size, cont) == x.st.size);
+ ASSERT(sc_read(ff, 0, x.st.size, cont) == x.st.size);
cont[x.st.size] = 0;
dbg_printf("> '%s'\n", cont);
- close(ff);
+ sc_close(ff);
}
}
- close(f);
+ sc_close(f);
dbg_printf("(TEST-OK)\n");
diff --git a/src/tests/utests/fs2/test.c b/src/tests/utests/fs2/test.c
index 0acf11d..1b72eb7 100644
--- a/src/tests/utests/fs2/test.c
+++ b/src/tests/utests/fs2/test.c
@@ -1,28 +1,28 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
int main(int argc, char **argv) {
dbg_print("Hello, world! from user process.\n");
- fd_t f = open("io:/mod", FM_READDIR);
+ fd_t f = sc_open("io:/mod", FM_READDIR);
dbg_printf("openned io:/mod as %d\n", f);
ASSERT(f != 0);
dirent_t x;
size_t ent_no = 0;
- while (ent_no < 2) {
- ASSERT (readdir(f, ent_no++, &x));
+ while (ent_no < 1) {
+ ASSERT (sc_readdir(f, ent_no++, &x));
ASSERT((!strcmp(x.name, "utest_fs2.bin")) || (!strcmp(x.name, "kernel.map")));
ASSERT(x.st.type == FT_REGULAR);
}
- ASSERT(!readdir(f, ent_no++, &x));
- close(f);
+ ASSERT(!sc_readdir(f, ent_no++, &x));
+ sc_close(f);
dbg_printf("(TEST-OK)\n");
diff --git a/src/tests/utests/malloc/test.c b/src/tests/utests/malloc/test.c
index fb2f3b9..9a937aa 100644
--- a/src/tests/utests/malloc/test.c
+++ b/src/tests/utests/malloc/test.c
@@ -1,10 +1,10 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
-#include <region_alloc.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
+#include <kogata/region_alloc.h>
int main(int argc, char **argv) {
dbg_print("(BEGIN-USER-TEST malloc-test)\n");
diff --git a/src/tests/utests/run_qemu_test.sh b/src/tests/utests/run_qemu_test.sh
index e806501..b9f3c36 100755
--- a/src/tests/utests/run_qemu_test.sh
+++ b/src/tests/utests/run_qemu_test.sh
@@ -2,12 +2,13 @@
BINFILE=$1
LOGFILE=$2
+KERNEL=$3
RESULTFILE=`mktemp`
PIDFILE=`mktemp`
-(timeout 3s qemu-system-i386 -kernel build/kernel.bin -append "init=io:/mod/`basename $BINFILE`" \
- -initrd "$BINFILE,build/kernel.map" -serial stdio -m 16 -display none 2>/dev/null \
+(timeout 3s qemu-system-i386 -kernel $KERNEL -append "init=io:/mod/`basename $BINFILE`" \
+ -initrd "$BINFILE" -serial stdio -m 16 -display none 2>/dev/null \
& echo $! >$PIDFILE) \
| tee >(grep -m 1 "TEST-" >$RESULTFILE; kill -INT `cat $PIDFILE`) >$LOGFILE
diff --git a/src/tests/utests/subfs/test.c b/src/tests/utests/subfs/test.c
index 52c1025..b237181 100644
--- a/src/tests/utests/subfs/test.c
+++ b/src/tests/utests/subfs/test.c
@@ -1,30 +1,30 @@
#include <string.h>
-#include <malloc.h>
+#include <kogata/malloc.h>
-#include <syscall.h>
-#include <debug.h>
+#include <kogata/syscall.h>
+#include <kogata/debug.h>
int main(int argc, char **argv) {
dbg_print("Hello, world! from user process.\n");
- ASSERT(fs_subfs("mod", "io", "/mod", FM_READ | FM_READDIR));
+ ASSERT(sc_fs_subfs("mod", "io", "/mod", FM_READ | FM_READDIR));
- fd_t f = open("mod:/", FM_READDIR);
+ fd_t f = sc_open("mod:/", FM_READDIR);
dbg_printf("openned mod:/ as %d\n", f);
ASSERT(f != 0);
dirent_t x;
size_t ent_no = 0;
- while (ent_no < 2) {
- ASSERT (readdir(f, ent_no++, &x));
+ while (ent_no < 1) {
+ ASSERT (sc_readdir(f, ent_no++, &x));
ASSERT((!strcmp(x.name, "utest_subfs.bin")) || (!strcmp(x.name, "kernel.map")));
ASSERT(x.st.type == FT_REGULAR);
}
- ASSERT(!readdir(f, ent_no++, &x));
- close(f);
+ ASSERT(!sc_readdir(f, ent_no++, &x));
+ sc_close(f);
dbg_printf("(TEST-OK)\n");