mirror of
https://github.com/tailix/kernel.git
synced 2024-11-20 11:16:10 -05:00
Add testing
This commit is contained in:
parent
4ac835fdcc
commit
88c55d2b23
12 changed files with 52 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
*.o
|
||||
*.bin
|
||||
|
||||
/config.mk
|
||||
|
||||
|
|
10
Makefile
10
Makefile
|
@ -2,8 +2,8 @@ include config.mk
|
|||
|
||||
run: run-iso
|
||||
|
||||
all: all-kernel all-iso all-libk
|
||||
clean: clean-kernel clean-iso clean-libk
|
||||
all: all-kernel all-iso all-libk all-test
|
||||
clean: clean-kernel clean-iso clean-libk clean-test
|
||||
|
||||
all-kernel: all-libk
|
||||
make all -C arch I=$(shell pwd)/include LIBK=$(shell pwd)/libk/libk.a
|
||||
|
@ -25,3 +25,9 @@ all-libk:
|
|||
|
||||
clean-libk:
|
||||
make clean -C libk
|
||||
|
||||
test-libk: all-libk
|
||||
make run -C test/libk I=$(shell pwd)/include LIBK=$(shell pwd)/libk/libk.a
|
||||
|
||||
clean-test:
|
||||
make clean -C test/libk
|
||||
|
|
|
@ -31,7 +31,7 @@ void console_initialize() {
|
|||
|
||||
void console_print(const char *const s)
|
||||
{
|
||||
console_write(s, strlen(s));
|
||||
console_write(s, kstrlen(s));
|
||||
}
|
||||
|
||||
void console_putc(const char c) {
|
||||
|
|
|
@ -37,7 +37,7 @@ void kprintf(const char *format, ...)
|
|||
case 'd':
|
||||
case 'u':
|
||||
case 'x':
|
||||
itoa (buf, c, *((int *) arg++));
|
||||
kitoa (buf, c, *((int *) arg++));
|
||||
p = buf;
|
||||
goto string;
|
||||
break;
|
||||
|
|
|
@ -65,11 +65,11 @@ void paging_initialize()
|
|||
|
||||
nframes = mem_end_page / 0x1000;
|
||||
frames = (unsigned int*)kmalloc(INDEX_FROM_BIT(nframes));
|
||||
memset(frames, 0, INDEX_FROM_BIT(nframes));
|
||||
kmemset(frames, 0, INDEX_FROM_BIT(nframes));
|
||||
|
||||
// Let's make a page directory.
|
||||
kernel_dir = (struct page_dir*)kmalloc_a(sizeof(struct page_dir));
|
||||
memset(kernel_dir, 0, sizeof(struct page_dir));
|
||||
kmemset(kernel_dir, 0, sizeof(struct page_dir));
|
||||
current_dir = kernel_dir;
|
||||
|
||||
// We need to identity map (phys addr = virt addr) from
|
||||
|
@ -116,7 +116,7 @@ struct page *get_page(unsigned int address, unsigned char make, struct page_dir
|
|||
if (make) {
|
||||
unsigned int tmp;
|
||||
dir->tables[table_idx] = (struct page_table*)kmalloc_ap(sizeof(struct page_table), &tmp);
|
||||
memset(dir->tables[table_idx], 0, 0x1000);
|
||||
kmemset(dir->tables[table_idx], 0, 0x1000);
|
||||
dir->tables_phys[table_idx] = tmp | 0x7; // PRESENT, RW, US.
|
||||
return &dir->tables[table_idx]->pages[address%1024];
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ void protected_initialize()
|
|||
|
||||
logger_info("Setup IDT.");
|
||||
|
||||
memset(idt_entries, 0, sizeof(idt_entries));
|
||||
kmemset(idt_entries, 0, sizeof(idt_entries));
|
||||
|
||||
idt_set_gate(0, (unsigned int)exception_0, 0x08, 0x8E);
|
||||
idt_set_gate(1, (unsigned int)exception_1, 0x08, 0x8E);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef KERNELMQ_INCLUDED_STDLIB
|
||||
#define KERNELMQ_INCLUDED_STDLIB 1
|
||||
|
||||
void memset(void *buffer, unsigned char value, unsigned int size);
|
||||
unsigned int strlen(const char *s);
|
||||
void itoa(char *buf, int base, int d);
|
||||
void kmemset(void *buffer, unsigned char value, unsigned int size);
|
||||
unsigned int kstrlen(const char *s);
|
||||
void kitoa(char *buf, int base, int d);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void itoa(char *buf, int base, int d)
|
||||
void kitoa(char *buf, int base, int d)
|
||||
{
|
||||
char *p = buf;
|
||||
char *p1, *p2;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void memset(void *const buffer, const unsigned char value, const unsigned int size)
|
||||
void kmemset(void *const buffer, const unsigned char value, const unsigned int size)
|
||||
{
|
||||
const unsigned char *end = buffer + size;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
unsigned int strlen(const char *const s)
|
||||
unsigned int kstrlen(const char *const s)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
|
||||
|
|
18
test/libk/Makefile
Normal file
18
test/libk/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
CC = $(CCPREFIX)gcc
|
||||
|
||||
CFLAGS = -std=gnu99 -Wall -Wextra
|
||||
|
||||
BINS = strlen.bin
|
||||
|
||||
run: all $(addprefix run-, $(BINS))
|
||||
|
||||
all: $(BINS)
|
||||
|
||||
clean:
|
||||
rm -f $(BINS)
|
||||
|
||||
run-%.bin: %.bin
|
||||
@./$< && echo "[ OK ] $*" || echo "[FAIL] $*"
|
||||
|
||||
%.bin: %.c
|
||||
$(CC) $< -o $@ $(CFLAGS) -I "$(I)" "$(LIBK)"
|
13
test/libk/strlen.c
Normal file
13
test/libk/strlen.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <kernelmq/stdlib.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(kstrlen("") == 0);
|
||||
assert(kstrlen("q") == 1);
|
||||
assert(kstrlen("qwe rty") == 7);
|
||||
assert(kstrlen("qwe\0rty") == 3);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue