Browse Source

updated tests

master
Mathieu Serandour 7 months ago
parent
commit
b7915b1a6d
  1. 30
      tests/disk_tb.c
  2. 55
      tests/lib/Makefile
  3. 9
      tests/lib/lib_tests.c
  4. 8
      tests/tb.c
  5. 29
      tests/vfs/vfs_tests.c

30
tests/disk_tb.c

@ -28,8 +28,26 @@ void dread(struct driver* this,
assert(fread(sbuf, size, count, data->f) == count);
memcpy(buf, sbuf, size*count);
free(sbuf);
printf("READ %u blocks\n", count);
}
static
void dasync_read(struct driver* this,
uint64_t lba,
void* buf,
size_t count
) {
dread(this,lba,buf,count);
}
static void dsync(struct driver* this) {
printf("SYNC\n");
(void) this;
}
static
void dwrite(struct driver* this,
uint64_t lba,
@ -63,11 +81,13 @@ int install(driver_t* this) {
this->name = (string_t){"tb disk controller", 0},
data->si = (struct storage_interface) {
.capacity = ftell(dfile),
.driver = this,
.lbashift = 9,
.read = dread,
.write = dwrite,
.capacity = ftell(dfile),
.driver = this,
.lbashift = 9,
.read = dread,
.async_read = dasync_read,
.sync = dsync,
.write = dwrite,
};
data->f = dfile;

55
tests/lib/Makefile

@ -1,55 +0,0 @@
.PHONY = run all clean
EXE = ./vfs
DISKFILE := ./disk.bin
CC := gcc
LD := gcc
ASM := nasm
ASM_FLAGS := -felf64
PY := python3
KERNEL=../../kernel/
DEFINES := -DDISKFILE=\"$(DISKFILE)\" -DTEST
CFLAGS = -Wall -Wextra -O0 -pipe -I$(KERNEL) $(DEFINES) -fno-inline -g -no-stdlib
CFILES := $(shell find ./ -type f -name '*.c')
CFILES += ../tb.c
KCFILES += $(KERNEL)/lib/string.c
OBJ := $(CFILES:.c=.o) $(KCFILES:.c=.test.o)
run: all
$(EXE)
debug: all
gdb $(EXE)
all: $(EXE)
cp ../../disk.bin $(DISKFILE)
$(EXE): $(OBJ)
$(LD) $(OBJ) -o $(EXE)
%.test.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf *.o
find $(KERNEL) -name "*.test.o" | rm -rf

9
tests/lib/lib_tests.c

@ -1,9 +0,0 @@
#include <lib/logging.h>
#include <lib/string.h>
#include <stdlib.h>
int main() {
const char*
}

8
tests/tb.c

@ -44,6 +44,12 @@ size_t heap_get_size() {
size_t heap_get_brk(void) {
return 0;
}
void heap_defragment(void) {
}
void heap_print(void) {
}
size_t stack_size = 4096;
void* stack_base = NULL;
@ -58,3 +64,5 @@ void ps2kb_poll_wait_for_key(uint8_t key) {
getchar();
}

29
tests/vfs/vfs_tests.c

@ -232,22 +232,23 @@ void test_disk_overflow(void) {
#ifndef DISKFILE
#define DISKFILE "disk.bin"
#warning DISKFILE undefined
#endif
void test_vfs() {
int main() {
vfs_init();
atshutdown(gpt_cleanup);
printf("DISKFILE: %s\n", DISKFILE);
disk_tb_install(DISKFILE);
disk_part_t* part = search_partition("Bincows2");
disk_part_t* part = search_partition("Bincows");
assert(part);
vfs_mount(part, "/fs");
TEST(test_disk_overflow());
//TEST(test_print_file(441));
//TEST(test_disk_overflow());
TEST(test_print_file(441));
//TEST(read_seek_big_file(1));
//TEST(read_seek_big_file(234));
@ -258,6 +259,24 @@ int main() {
//TEST(test_write());
//TEST(test_file_write_extend());
//vfs_unmount(part)
shutdown();
}
void kfree(void* addr) {
free(addr);
}
void* kmalloc(size_t s) {
return malloc(s);
}
void* krealloc(void* p, size_t s) {
return realloc(p,s);
}
int main() {
test_vfs();
test_vfs();
test_vfs();
}

Loading…
Cancel
Save