diff options
author | dzwdz | 2022-08-05 15:06:48 +0200 |
---|---|---|
committer | dzwdz | 2022-08-05 15:06:48 +0200 |
commit | f6b139d55e7fa9ec5498eeadfdf3fdd5d0a927f4 (patch) | |
tree | e19ce224e1431ee7c54fc7f4785303e4e6999024 /src/kernel | |
parent | 27124aab29d54ba9f228dee18a48e903e222812a (diff) |
move the mount_resolve test to userland, remove the kernel selftests
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/main.c | 4 | ||||
-rw-r--r-- | src/kernel/tests/base.h | 21 | ||||
-rw-r--r-- | src/kernel/tests/main.c | 14 | ||||
-rw-r--r-- | src/kernel/tests/tests.h | 4 | ||||
-rw-r--r-- | src/kernel/tests/vfs.c | 49 |
5 files changed, 0 insertions, 92 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c index 75d9a29..03ff177 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -2,14 +2,10 @@ #include <kernel/main.h> #include <kernel/mem/alloc.h> #include <kernel/proc.h> -#include <kernel/tests/tests.h> #include <kernel/util.h> #include <stdint.h> void kmain(struct kmain_info info) { - kprintf("tests...\n"); - tests_all(); - kprintf("loading init...\n"); process_seed(&info); diff --git a/src/kernel/tests/base.h b/src/kernel/tests/base.h deleted file mode 100644 index ec314c5..0000000 --- a/src/kernel/tests/base.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include <kernel/arch/generic.h> -#include <kernel/util.h> -#include <stdbool.h> - -extern bool _did_tests_fail; - -// tests MUST be used -#pragma GCC diagnostic error "-Wunused-function" - -#define TEST(name) \ - static void __test_##name(void) - -#define TEST_RUN(name) \ - __test_##name(); - -#define TEST_COND(cond) \ - if (!(cond)) { \ - _did_tests_fail = true; \ - kprintf("test failed at " __FILE__ ":" NUM2STR(__LINE__) " "); \ - } diff --git a/src/kernel/tests/main.c b/src/kernel/tests/main.c deleted file mode 100644 index 8a6921a..0000000 --- a/src/kernel/tests/main.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <kernel/panic.h> -#include <kernel/tests/base.h> -#include <kernel/tests/tests.h> - -bool _did_tests_fail; - -void tests_all(void) { - _did_tests_fail = false; - - tests_vfs(); - - if (_did_tests_fail) - panic_invalid_state(); -} diff --git a/src/kernel/tests/tests.h b/src/kernel/tests/tests.h deleted file mode 100644 index 0f8693a..0000000 --- a/src/kernel/tests/tests.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void tests_all(void); -void tests_vfs(void); diff --git a/src/kernel/tests/vfs.c b/src/kernel/tests/vfs.c deleted file mode 100644 index 9f7c6da..0000000 --- a/src/kernel/tests/vfs.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <kernel/mem/alloc.h> -#include <kernel/tests/base.h> -#include <kernel/tests/tests.h> -#include <kernel/vfs/mount.h> -#include <shared/mem.h> - -TEST(vfs_mount_resolve) { - struct vfs_mount *mount = NULL; - -#define ADD_MOUNT(path) do { \ - struct vfs_mount *mount2 = kmalloc(sizeof *mount2); \ - mount2->prefix = path; \ - mount2->prefix_len = sizeof(path) - 1; \ - mount2->prev = mount; \ - mount = mount2; \ - } while (0) - - ADD_MOUNT(""); // root mount - ADD_MOUNT("/dir/shadowed"); - ADD_MOUNT("/dir"); - -#undef ADD_MOUNT - -#define TEST_WRAPPER(path, expected) do { \ - struct vfs_mount *mount2 = vfs_mount_resolve(mount, path, sizeof(path) - 1); \ - TEST_COND((mount2->prefix_len == sizeof(expected) - 1) \ - && (0 == memcmp(mount2->prefix, expected, mount2->prefix_len))); \ - } while (0) - - TEST_WRAPPER("/", ""); - TEST_WRAPPER("/test", ""); - TEST_WRAPPER("/dir", "/dir"); - TEST_WRAPPER("/dirry", ""); - TEST_WRAPPER("/dir/", "/dir"); - TEST_WRAPPER("/dir/shadowed", "/dir"); - TEST_WRAPPER("/dir/shadowed/", "/dir"); - -#undef TEST_WRAPPER - - while (mount != NULL) { - struct vfs_mount *tmp = mount; - mount = mount->prev; - kfree(tmp); - } -} - -void tests_vfs(void) { - TEST_RUN(vfs_mount_resolve); -} |