aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:34:49 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 19:34:49 +0100
commit8336422c8ad72b98e3af9c038468b62a9eafac3c (patch)
treeb35e74136b0263e6efbba41de8d1b118c2239b9b /src/tests
parent1ca147f9e08202dfbc78692e204adac280f8238b (diff)
downloadkogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.tar.gz
kogata-8336422c8ad72b98e3af9c038468b62a9eafac3c.zip
Add first btree test ; fix first btree test.
Diffstat (limited to 'src/tests')
l---------src/tests/ktests/btree1/Makefile1
-rw-r--r--src/tests/ktests/btree1/test.c41
-rw-r--r--src/tests/ktests/rules.make8
-rwxr-xr-xsrc/tests/run_tests.sh4
4 files changed, 48 insertions, 6 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
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