From 8336422c8ad72b98e3af9c038468b62a9eafac3c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 14 Feb 2015 19:34:49 +0100 Subject: Add first btree test ; fix first btree test. --- src/tests/ktests/btree1/Makefile | 1 + src/tests/ktests/btree1/test.c | 41 ++++++++++++++++++++++++++++++++++++++++ src/tests/ktests/rules.make | 8 ++++---- src/tests/run_tests.sh | 4 ++-- 4 files changed, 48 insertions(+), 6 deletions(-) create mode 120000 src/tests/ktests/btree1/Makefile create mode 100644 src/tests/ktests/btree1/test.c (limited to 'src/tests') 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 + +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 diff --git a/src/tests/run_tests.sh b/src/tests/run_tests.sh index bd23801..470959b 100755 --- a/src/tests/run_tests.sh +++ b/src/tests/run_tests.sh @@ -6,8 +6,8 @@ for FILE in */Makefile */*/Makefile; do TEST=`dirname $FILE` echo -n "Running test $TEST ... " if make -C $TEST run_test > $TEST/test.log 2>&1; then - echo OK + echo -e "\033[0;32mOK\033[0m" else - echo FAIL + echo -e "\033[0;31mFAIL\033[0m" fi done -- cgit v1.2.3