diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 19:34:49 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-02-14 19:34:49 +0100 |
commit | 8336422c8ad72b98e3af9c038468b62a9eafac3c (patch) | |
tree | b35e74136b0263e6efbba41de8d1b118c2239b9b /src/tests/ktests | |
parent | 1ca147f9e08202dfbc78692e204adac280f8238b (diff) | |
download | kogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.tar.gz kogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.zip |
Add first btree test ; fix first btree test.
Diffstat (limited to 'src/tests/ktests')
l--------- | src/tests/ktests/btree1/Makefile | 1 | ||||
-rw-r--r-- | src/tests/ktests/btree1/test.c | 41 | ||||
-rw-r--r-- | src/tests/ktests/rules.make | 8 |
3 files changed, 46 insertions, 4 deletions
diff --git a/src/tests/ktests/btree1/Makefile b/src/tests/ktests/btree1/Makefile new file mode 120000 index 0000000..4630a7c --- /dev/null +++ b/src/tests/ktests/btree1/Makefile @@ -0,0 +1 @@ +../rules.make
\ No newline at end of file diff --git a/src/tests/ktests/btree1/test.c b/src/tests/ktests/btree1/test.c new file mode 100644 index 0000000..1207a28 --- /dev/null +++ b/src/tests/ktests/btree1/test.c @@ -0,0 +1,41 @@ +#include <btree.h> + +void test_btree_1() { + BEGIN_TEST("test-btree-1"); + + // hashtable test + btree_t *ht = create_btree(str_key_cmp_fun, 0); + ASSERT(ht != 0); + + ASSERT(btree_add(ht, "test1", "STRTEST1")); + ASSERT(btree_add(ht, "test2", "STRTEST2")); + ASSERT(btree_find(ht, "test1") != 0 && + strcmp(btree_find(ht, "test1"), "STRTEST1") == 0); + ASSERT(btree_find(ht, "test2") != 0 && + strcmp(btree_find(ht, "test2"), "STRTEST2") == 0); + ASSERT(btree_find(ht, "test") == 0); + + ASSERT(btree_add(ht, "test", "Forever alone")); + ASSERT(btree_find(ht, "test1") != 0 && + strcmp(btree_find(ht, "test1"), "STRTEST1") == 0); + ASSERT(btree_find(ht, "test2") != 0 && + strcmp(btree_find(ht, "test2"), "STRTEST2") == 0); + ASSERT(btree_find(ht, "test") != 0 && + strcmp(btree_find(ht, "test"), "Forever alone") == 0); + + btree_remove(ht, "test1"); + ASSERT(btree_find(ht, "test1") == 0); + ASSERT(btree_find(ht, "test2") != 0 && + strcmp(btree_find(ht, "test2"), "STRTEST2") == 0); + ASSERT(btree_find(ht, "test") != 0 && + strcmp(btree_find(ht, "test"), "Forever alone") == 0); + + delete_btree(ht); + + TEST_OK; +} + +#undef TEST_PLACEHOLDER_AFTER_TASKING +#define TEST_PLACEHOLDER_AFTER_TASKING { test_btree_1(); } + +/* vim: set ts=4 sw=4 tw=0 noet :*/ diff --git a/src/tests/ktests/rules.make b/src/tests/ktests/rules.make index f31ab89..fac175d 100644 --- a/src/tests/ktests/rules.make +++ b/src/tests/ktests/rules.make @@ -1,17 +1,17 @@ LIB = ../../../kernel/kernel.lib -OBJ = kmain.o +OBJ = kmain.o sys.o -CFLAGS = -I . -I ../../../common/include -I ../../../kernel/include -DIS_A_TEST +CFLAGS = -I . -I ../../../common/include -I ../../../kernel/include -DBUILD_KERNEL_TEST LDFLAGS = -T ../../../kernel/linker.ld -Xlinker -Map=test_kernel.map OUT = test_kernel.bin include ../../../rules.make -kmain.o: ../../../kernel/core/kmain.c test.c +%.o: ../../../kernel/core/%.c test.c $(CC) -c $< -o $@ $(CFLAGS) -run_test: all +run_test: rebuild ../run_qemu_test.sh |