aboutsummaryrefslogtreecommitdiff
path: root/kernel/test.c
diff options
context:
space:
mode:
authorMarvin Borner2020-08-30 18:56:05 +0200
committerMarvin Borner2020-08-30 18:56:05 +0200
commit30932492e9f8a98e1f98461c9d28547f23d82e7e (patch)
treeffc7acb099a81e09d73df2e4a8290d4a8dc8bfc2 /kernel/test.c
parentffa367193078ba32012494cfa7be50e6b3b18e2d (diff)
Even more tests
Diffstat (limited to 'kernel/test.c')
-rw-r--r--kernel/test.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/kernel/test.c b/kernel/test.c
index 93fcbb1..f1a49a6 100644
--- a/kernel/test.c
+++ b/kernel/test.c
@@ -1,30 +1,13 @@
// MIT License, Copyright (c) 2020 Marvin Borner
-#include <assert.h>
#include <boot.h>
#include <conv.h>
#include <cpu.h>
-#include <fs.h>
-#include <keyboard.h>
-#include <load.h>
#include <math.h>
#include <mem.h>
-#include <mouse.h>
#include <serial.h>
#include <str.h>
-#include <syscall.h>
-#include <timer.h>
-
-#define a_mag 0x55
-#define b_mag 0x42
-#define check(exp) \
- if (!(exp)) { \
- printf("\x1B[31m[FAIL]\x1B[0m %s:%d: %s: Test '%s'\n", __FILE__, __LINE__, \
- __func__, #exp); \
- } else { \
- printf("\x1B[32m[PASS]\x1B[0m %s:%d: %s: Test '%s'\n", __FILE__, __LINE__, \
- __func__, #exp); \
- }
+#include <test.h>
void test_all(struct vid_info *vid_info)
{
@@ -39,28 +22,25 @@ void test_all(struct vid_info *vid_info)
heap_init(0x00f00000);
u32 *a = malloc(a_mag);
u32 *b = malloc(b_mag);
- check(a[-1] == a_mag);
- check(a[a_mag] == b_mag);
- check(b[-1] == b_mag);
+ equals(a[-1], a_mag);
+ equals(a[a_mag], b_mag);
+ equals(b[-1], b_mag);
// Test math
- check(pow(2, 3) == 8);
- check(pow(0, 3) == 0);
- check(pow(0, 0) == 1);
+ equals(pow(2, 3), 8);
+ equals(pow(0, 3), 0);
+ equals(pow(0, 0), 1);
// Test conv
- check(atoi("42") == 42);
- check(strcmp(htoa(0x42), "42") == 0);
- check(htoi("42") == 0x42);
- check(strcmp(itoa(42), "42") == 0);
-
- boot_passed = vid_info;
-
- // Install drivers
- interrupts_install();
- timer_install();
- keyboard_install();
- mouse_install();
+ char buf[10] = { 0 };
+ strcpy(buf, "42");
+ equals(atoi(buf), 42);
+ equals_str(htoa(0x42), "42");
+ equals(htoi(buf), 0x42);
+ equals_str(itoa(42), "42");
+ equals_str(conv_base(42, buf, 0, 0), "");
+ equals_str(conv_base(42, buf, 2, 0), "101010");
+ /* equals_str(conv_base(424242, buf, 36, 0), "93ci"); // TODO: THIS */
idle();
}