Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/Makefile	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -214,10 +214,14 @@
 #
 
-ifneq ($(CONFIG_TEST),)
+ifeq ($(CONFIG_TEST),y)
 	DEFS += -DCONFIG_TEST
 	CFLAGS += -Itest/
 	GENERIC_SOURCES += \
 		test/test.c \
-		test/atomic/atomic1.c
+		test/atomic/atomic1.c \
+		test/btree/btree1.c \
+		test/debug/mips1.c \
+		test/fault/fault1.c \
+		test/fpu/fpu1.c
 endif
 
Index: kernel/generic/src/console/cmd.c
===================================================================
--- kernel/generic/src/console/cmd.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/generic/src/console/cmd.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -841,4 +841,5 @@
 }
 
+#ifdef CONFIG_TEST
 /** Command for printing kernel tests list.
  *
@@ -852,6 +853,7 @@
 	
 	for (test = tests; test->name != NULL; test++)
-		printf("%s\t%s\n", test->name, test->desc);
-	
+		printf("%s\t\t%s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
+	
+	printf("*\t\tRun all safe tests\n");
 	return 1;
 }
@@ -865,20 +867,31 @@
 int cmd_test(cmd_arg_t *argv)
 {
-	bool fnd = false;
 	test_t *test;
 	
-	for (test = tests; test->name != NULL; test++) {
-		if (strcmp(test->name, argv->buffer) == 0) {
-			fnd = true;
-			test->entry();
-			break;
+	if (strcmp(argv->buffer, "*") == 0) {
+		for (test = tests; test->name != NULL; test++) {
+			if (test->safe) {
+				printf("\n%s\t\t%s\n\n", test->name, test->desc);
+				test->entry();
+			}
 		}
-	}
-	
-	if (!fnd)
-		printf("Unknown test.\n");
-	
-	return 1;
-}
+	} else {
+		bool fnd = false;
+		
+		for (test = tests; test->name != NULL; test++) {
+			if (strcmp(test->name, argv->buffer) == 0) {
+				fnd = true;
+				test->entry();
+				break;
+			}
+		}
+		
+		if (!fnd)
+			printf("Unknown test.\n");
+	}
+	
+	return 1;
+}
+#endif
 
 /** @}
Index: kernel/kernel.config
===================================================================
--- kernel/kernel.config	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/kernel.config	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -123,3 +123,3 @@
 
 # Benchmark tests
-! [CONFIG_TEST!=] CONFIG_BENCH (y/n)
+! [CONFIG_TEST=y] CONFIG_BENCH (y/n)
Index: kernel/test/atomic/atomic1.c
===================================================================
--- kernel/test/atomic/atomic1.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/test/atomic/atomic1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -64,4 +64,3 @@
 	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
 #endif
-	return;
 }
Index: kernel/test/btree/btree1.c
===================================================================
--- kernel/test/btree/btree1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/btree/btree1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <test.h>
+#include <print.h>
+#include <adt/btree.h>
+#include <debug.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+void *data = (void *) 0xdeadbeef;
+
+void test_btree1(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	btree_t t;
+	int i;
+
+	btree_create(&t);
+
+	printf("Inserting keys.\n");
+	btree_insert(&t, 19, data, NULL);
+	btree_insert(&t, 20, data, NULL);
+	btree_insert(&t, 21, data, NULL);
+	btree_insert(&t, 0, data, NULL);
+	btree_insert(&t, 25, data, NULL);
+	btree_insert(&t, 22, data, NULL);
+	btree_insert(&t, 26, data, NULL);
+	btree_insert(&t, 23, data, NULL);
+	btree_insert(&t, 24, data, NULL);
+	btree_insert(&t, 5, data, NULL);
+	btree_insert(&t, 1, data, NULL);
+	btree_insert(&t, 4, data, NULL);
+	btree_insert(&t, 28, data, NULL);
+	btree_insert(&t, 29, data, NULL);
+	btree_insert(&t, 7, data, NULL);
+	btree_insert(&t, 8, data, NULL);
+	btree_insert(&t, 9, data, NULL);
+	btree_insert(&t, 17, data, NULL);
+	btree_insert(&t, 18, data, NULL);
+	btree_insert(&t, 2, data, NULL);
+	btree_insert(&t, 3, data, NULL);
+	btree_insert(&t, 6, data, NULL);
+	btree_insert(&t, 10, data, NULL);
+	btree_insert(&t, 11, data, NULL);
+	btree_insert(&t, 12, data, NULL);
+	btree_insert(&t, 13, data, NULL);
+	btree_insert(&t, 14, data, NULL);
+	btree_insert(&t, 15, data, NULL);
+	btree_insert(&t, 16, data, NULL);
+	btree_insert(&t, 27, data, NULL);
+
+	for (i = 30; i < 50; i++)
+		btree_insert(&t, i, data, NULL);
+	for (i = 100; i >= 50; i--)
+		btree_insert(&t, i, data, NULL);
+
+	btree_print(&t);
+	
+	printf("Removing keys.\n");
+	btree_remove(&t, 50, NULL);
+	btree_remove(&t, 49, NULL);
+	btree_remove(&t, 51, NULL);
+	btree_remove(&t, 46, NULL);
+	btree_remove(&t, 45, NULL);
+	btree_remove(&t, 48, NULL);
+	btree_remove(&t, 53, NULL);
+	btree_remove(&t, 47, NULL);
+	btree_remove(&t, 52, NULL);
+	btree_remove(&t, 54, NULL);
+	btree_remove(&t, 65, NULL);
+	btree_remove(&t, 60, NULL);
+	btree_remove(&t, 99, NULL);
+	btree_remove(&t, 97, NULL);
+	btree_remove(&t, 57, NULL);
+	btree_remove(&t, 58, NULL);
+	btree_remove(&t, 61, NULL);
+	btree_remove(&t, 64, NULL);
+	btree_remove(&t, 56, NULL);
+	btree_remove(&t, 41, NULL);
+
+	for (i = 5; i < 20; i++)
+		btree_remove(&t, i, NULL);
+
+	btree_remove(&t, 2, NULL);
+	btree_remove(&t, 43, NULL);
+	btree_remove(&t, 22, NULL);
+	btree_remove(&t, 100, NULL);
+	btree_remove(&t, 98, NULL);
+	btree_remove(&t, 96, NULL);
+	btree_remove(&t, 66, NULL);
+	btree_remove(&t, 1, NULL);
+
+	for (i = 70; i < 90; i++)
+		btree_remove(&t, i, NULL);
+
+	btree_remove(&t, 20, NULL);
+	btree_remove(&t, 0, NULL);
+	btree_remove(&t, 40, NULL);
+	btree_remove(&t, 3, NULL);
+	btree_remove(&t, 4, NULL);
+	btree_remove(&t, 21, NULL);
+	btree_remove(&t, 44, NULL);
+	btree_remove(&t, 55, NULL);
+	btree_remove(&t, 62, NULL);
+	btree_remove(&t, 26, NULL);
+	btree_remove(&t, 27, NULL);
+	btree_remove(&t, 28, NULL);
+	btree_remove(&t, 29, NULL);
+	btree_remove(&t, 30, NULL);
+	btree_remove(&t, 31, NULL);
+	btree_remove(&t, 32, NULL);
+	btree_remove(&t, 33, NULL);
+	btree_remove(&t, 93, NULL);
+	btree_remove(&t, 95, NULL);
+	btree_remove(&t, 94, NULL);
+	btree_remove(&t, 69, NULL);
+	btree_remove(&t, 68, NULL);
+	btree_remove(&t, 92, NULL);
+	btree_remove(&t, 91, NULL);
+	btree_remove(&t, 67, NULL);
+	btree_remove(&t, 63, NULL);
+	btree_remove(&t, 90, NULL);
+	btree_remove(&t, 59, NULL);
+	btree_remove(&t, 23, NULL);
+	btree_remove(&t, 24, NULL);
+	btree_remove(&t, 25, NULL);
+	btree_remove(&t, 37, NULL);
+	btree_remove(&t, 38, NULL);
+	btree_remove(&t, 42, NULL);
+	btree_remove(&t, 39, NULL);
+	btree_remove(&t, 34, NULL);
+	btree_remove(&t, 35, NULL);
+	btree_remove(&t, 36, NULL);
+
+	btree_print(&t);
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
Index: rnel/test/btree/btree1/test.c
===================================================================
--- kernel/test/btree/btree1/test.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ 	(revision )
@@ -1,159 +1,0 @@
-/*
- * Copyright (C) 2006 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <test.h>
-#include <print.h>
-#include <adt/btree.h>
-#include <debug.h>
-
-void *data = (void *) 0xdeadbeef;
-
-void test(void)
-{
-	btree_t t;
-	int i;
-
-	btree_create(&t);
-
-	printf("Inserting keys.\n");
-	btree_insert(&t, 19, data, NULL);
-	btree_insert(&t, 20, data, NULL);
-	btree_insert(&t, 21, data, NULL);
-	btree_insert(&t, 0, data, NULL);
-	btree_insert(&t, 25, data, NULL);
-	btree_insert(&t, 22, data, NULL);
-	btree_insert(&t, 26, data, NULL);
-	btree_insert(&t, 23, data, NULL);
-	btree_insert(&t, 24, data, NULL);
-	btree_insert(&t, 5, data, NULL);
-	btree_insert(&t, 1, data, NULL);
-	btree_insert(&t, 4, data, NULL);
-	btree_insert(&t, 28, data, NULL);
-	btree_insert(&t, 29, data, NULL);
-	btree_insert(&t, 7, data, NULL);
-	btree_insert(&t, 8, data, NULL);
-	btree_insert(&t, 9, data, NULL);
-	btree_insert(&t, 17, data, NULL);
-	btree_insert(&t, 18, data, NULL);
-	btree_insert(&t, 2, data, NULL);
-	btree_insert(&t, 3, data, NULL);
-	btree_insert(&t, 6, data, NULL);
-	btree_insert(&t, 10, data, NULL);
-	btree_insert(&t, 11, data, NULL);
-	btree_insert(&t, 12, data, NULL);
-	btree_insert(&t, 13, data, NULL);
-	btree_insert(&t, 14, data, NULL);
-	btree_insert(&t, 15, data, NULL);
-	btree_insert(&t, 16, data, NULL);
-	btree_insert(&t, 27, data, NULL);
-
-	for (i = 30; i < 50; i++)
-		btree_insert(&t, i, data, NULL);
-	for (i = 100; i >= 50; i--)
-		btree_insert(&t, i, data, NULL);
-
-	btree_print(&t);
-	
-	printf("Removing keys.\n");
-	btree_remove(&t, 50, NULL);
-	btree_remove(&t, 49, NULL);
-	btree_remove(&t, 51, NULL);
-	btree_remove(&t, 46, NULL);
-	btree_remove(&t, 45, NULL);
-	btree_remove(&t, 48, NULL);
-	btree_remove(&t, 53, NULL);
-	btree_remove(&t, 47, NULL);
-	btree_remove(&t, 52, NULL);
-	btree_remove(&t, 54, NULL);
-	btree_remove(&t, 65, NULL);
-	btree_remove(&t, 60, NULL);
-	btree_remove(&t, 99, NULL);
-	btree_remove(&t, 97, NULL);
-	btree_remove(&t, 57, NULL);
-	btree_remove(&t, 58, NULL);
-	btree_remove(&t, 61, NULL);
-	btree_remove(&t, 64, NULL);
-	btree_remove(&t, 56, NULL);
-	btree_remove(&t, 41, NULL);
-
-	for (i = 5; i < 20; i++)
-		btree_remove(&t, i, NULL);
-
-	btree_remove(&t, 2, NULL);
-	btree_remove(&t, 43, NULL);
-	btree_remove(&t, 22, NULL);
-	btree_remove(&t, 100, NULL);
-	btree_remove(&t, 98, NULL);
-	btree_remove(&t, 96, NULL);
-	btree_remove(&t, 66, NULL);
-	btree_remove(&t, 1, NULL);
-
-	for (i = 70; i < 90; i++)
-		btree_remove(&t, i, NULL);
-
-	btree_remove(&t, 20, NULL);
-	btree_remove(&t, 0, NULL);
-	btree_remove(&t, 40, NULL);
-	btree_remove(&t, 3, NULL);
-	btree_remove(&t, 4, NULL);
-	btree_remove(&t, 21, NULL);
-	btree_remove(&t, 44, NULL);
-	btree_remove(&t, 55, NULL);
-	btree_remove(&t, 62, NULL);
-	btree_remove(&t, 26, NULL);
-	btree_remove(&t, 27, NULL);
-	btree_remove(&t, 28, NULL);
-	btree_remove(&t, 29, NULL);
-	btree_remove(&t, 30, NULL);
-	btree_remove(&t, 31, NULL);
-	btree_remove(&t, 32, NULL);
-	btree_remove(&t, 33, NULL);
-	btree_remove(&t, 93, NULL);
-	btree_remove(&t, 95, NULL);
-	btree_remove(&t, 94, NULL);
-	btree_remove(&t, 69, NULL);
-	btree_remove(&t, 68, NULL);
-	btree_remove(&t, 92, NULL);
-	btree_remove(&t, 91, NULL);
-	btree_remove(&t, 67, NULL);
-	btree_remove(&t, 63, NULL);
-	btree_remove(&t, 90, NULL);
-	btree_remove(&t, 59, NULL);
-	btree_remove(&t, 23, NULL);
-	btree_remove(&t, 24, NULL);
-	btree_remove(&t, 25, NULL);
-	btree_remove(&t, 37, NULL);
-	btree_remove(&t, 38, NULL);
-	btree_remove(&t, 42, NULL);
-	btree_remove(&t, 39, NULL);
-	btree_remove(&t, 34, NULL);
-	btree_remove(&t, 35, NULL);
-	btree_remove(&t, 36, NULL);
-
-	btree_print(&t);
-}
Index: kernel/test/debug/mips1.c
===================================================================
--- kernel/test/debug/mips1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/debug/mips1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2005 Ondrej Palkovsky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+#include <time/delay.h>
+
+#include <arch.h>
+
+
+void test_mips1(void)
+{
+#ifdef mips32
+	printf("MIPS debug test #1\n");
+
+	printf("You should enter kconsole debug mode now.\n");
+
+	asm __volatile__ ("break");
+
+	printf("Test passed.\n");
+#else
+	printf("This test is availaible only on MIPS32 platform.\n");
+#endif
+}
Index: rnel/test/debug/mips1/test.c
===================================================================
--- kernel/test/debug/mips1/test.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ 	(revision )
@@ -1,50 +1,0 @@
-/*
- * Copyright (C) 2005 Ondrej Palkovsky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-#include <time/delay.h>
-
-#include <arch.h>
-
-
-void test(void)
-{
-	printf("MIPS debug test #1\n");
-
-	printf("You should enter kconsole debug mode now.\n");
-
-	asm __volatile__ ("break");
-
-	printf("Test passed.\n");
-}
Index: kernel/test/fault/fault1.c
===================================================================
--- kernel/test/fault/fault1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/fault/fault1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2005 Jakub Vana
+ * Copyright (C) 2005 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+
+#include <arch.h>
+
+
+void test_fault1(void)
+{
+
+	((int *)(0))[1]=0;  
+
+}
Index: rnel/test/fault/fault1/test.c
===================================================================
--- kernel/test/fault/fault1/test.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Vana
- * Copyright (C) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-
-#include <arch.h>
-
-
-void test(void)
-{
-
-	((int *)(0))[1]=0;  
-
-}
Index: kernel/test/fpu/fpu1.c
===================================================================
--- kernel/test/fpu/fpu1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
+++ kernel/test/fpu/fpu1.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2005 Jakub Vana
+ * Copyright (C) 2005 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <print.h>
+#include <debug.h>
+#include <panic.h>
+
+#include <test.h>
+#include <atomic.h>
+#include <proc/thread.h>
+
+#include <arch.h>
+#include <arch/arch.h>
+
+#ifdef CONFIG_BENCH
+#include <arch/cycle.h>
+#endif
+
+#if (defined(ia32) || defined(amd64) || defined(ia64) || defined(ia32xen))
+
+#define THREADS		150*2
+#define ATTEMPTS	100
+
+#define E_10e8	271828182
+#define PI_10e8	314159265
+
+
+#ifdef KERN_ia32_ARCH_H_
+static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
+#endif
+
+#ifdef KERN_amd64_ARCH_H_
+static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
+#endif
+
+#ifdef KERN_ia64_ARCH_H_
+static inline long double sqrt(long double a) 
+{   
+	long double x =	1;
+	long double lx = 0;
+
+	if(a<0.00000000000000001) return 0;
+		
+	while(x!=lx)
+	{
+		lx=x;
+		x=(x+(a/x))/2;
+	}
+	return x; 
+}
+#endif
+
+
+
+static atomic_t threads_ok;
+static waitq_t can_start;
+
+static void e(void *data)
+{
+	int i;
+	double e,d,le,f;
+
+	thread_detach(THREAD);
+
+	waitq_sleep(&can_start);
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		le=-1;
+		e=0;
+		f=1;
+
+		for(d=1;e!=le;d*=f,f+=1) {
+			le=e;
+			e=e+1/d;
+		}
+
+		if((int)(100000000*e)!=E_10e8)
+			panic("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
+	}
+
+	printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
+	atomic_inc(&threads_ok);
+}
+
+static void pi(void *data)
+{
+
+#ifdef KERN_ia64_ARCH_H_
+#undef PI_10e8	
+#define PI_10e8	3141592
+#endif
+
+
+	int i;
+	double lpi, pi;
+	double n, ab, ad;
+	
+	thread_detach(THREAD);
+
+	waitq_sleep(&can_start);
+
+
+	for (i = 0; i<ATTEMPTS; i++) {
+		lpi = -1;
+		pi = 0;
+
+		for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
+			double sc, cd;
+
+			sc = sqrt(1 - (ab*ab/4));
+			cd = 1 - sc;
+			ad = sqrt(ab*ab/4 + cd*cd);
+			lpi = pi;
+			pi = 2 * n * ad;
+		}
+
+#ifdef KERN_ia64_ARCH_H_
+		if((int)(1000000*pi)!=PI_10e8)
+			panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000*pi),(unative_t) (PI_10e8/100));
+#else
+		if((int)(100000000*pi)!=PI_10e8)
+			panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
+#endif
+
+	}
+
+	printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
+	atomic_inc(&threads_ok);
+}
+
+void test_fpu1(void)
+{
+#ifdef CONFIG_BENCH
+	uint64_t t0 = get_cycle();
+#endif
+	thread_t *t;
+	int i;
+
+	waitq_initialize(&can_start);
+
+	printf("FPU test #1\n");
+	printf("Creating %d threads... ", THREADS);
+
+	for (i=0; i<THREADS/2; i++) {  
+		if (!(t = thread_create(e, NULL, TASK, 0, "e")))
+			panic("could not create thread\n");
+		thread_ready(t);
+		if (!(t = thread_create(pi, NULL, TASK, 0, "pi")))
+			panic("could not create thread\n");
+		thread_ready(t);
+	}
+	printf("ok\n");
+	
+	thread_sleep(1);
+	waitq_wakeup(&can_start, WAKEUP_ALL);
+
+	while (atomic_get(&threads_ok) != THREADS)
+		;
+		
+	printf("Test passed.\n");
+#ifdef CONFIG_BENCH
+	uint64_t dt = get_cycle() - t0;
+	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
+#endif
+}
+
+#else
+
+void test_fpu1(void)
+{
+	printf("This test is available only on Intel/AMD platforms.");
+}
+
+#endif
Index: rnel/test/fpu/fpu1/test.c
===================================================================
--- kernel/test/fpu/fpu1/test.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ 	(revision )
@@ -1,178 +1,0 @@
-/*
- * Copyright (C) 2005 Jakub Vana
- * Copyright (C) 2005 Jakub Jermar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <print.h>
-#include <debug.h>
-#include <panic.h>
-
-#include <test.h>
-#include <atomic.h>
-#include <proc/thread.h>
-
-#include <arch.h>
-#include <arch/arch.h>
-
-#define THREADS		150*2
-#define ATTEMPTS	100
-
-#define E_10e8	271828182
-#define PI_10e8	314159265
-
-
-#ifdef KERN_ia32_ARCH_H_
-static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
-#endif
-
-#ifdef KERN_amd64_ARCH_H_
-static inline double sqrt(double x) { double v; __asm__ ("fsqrt\n" : "=t" (v) : "0" (x)); return v; }
-#endif
-
-#ifdef KERN_ia64_ARCH_H_
-static inline long double sqrt(long double a) 
-{   
-	long double x =	1;
-	long double lx = 0;
-
-	if(a<0.00000000000000001) return 0;
-		
-	while(x!=lx)
-	{
-		lx=x;
-		x=(x+(a/x))/2;
-	}
-	return x; 
-}
-#endif
-
-
-
-static atomic_t threads_ok;
-static waitq_t can_start;
-
-static void e(void *data)
-{
-	int i;
-	double e,d,le,f;
-
-	thread_detach(THREAD);
-
-	waitq_sleep(&can_start);
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		le=-1;
-		e=0;
-		f=1;
-
-		for(d=1;e!=le;d*=f,f+=1) {
-			le=e;
-			e=e+1/d;
-		}
-
-		if((int)(100000000*e)!=E_10e8)
-			panic("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
-	}
-
-	printf("tid%d: e*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*e),(unative_t) E_10e8);
-	atomic_inc(&threads_ok);
-}
-
-static void pi(void *data)
-{
-
-#ifdef KERN_ia64_ARCH_H_
-#undef PI_10e8	
-#define PI_10e8	3141592
-#endif
-
-
-	int i;
-	double lpi, pi;
-	double n, ab, ad;
-	
-	thread_detach(THREAD);
-
-	waitq_sleep(&can_start);
-
-
-	for (i = 0; i<ATTEMPTS; i++) {
-		lpi = -1;
-		pi = 0;
-
-		for (n=2, ab = sqrt(2); lpi != pi; n *= 2, ab = ad) {
-			double sc, cd;
-
-			sc = sqrt(1 - (ab*ab/4));
-			cd = 1 - sc;
-			ad = sqrt(ab*ab/4 + cd*cd);
-			lpi = pi;
-			pi = 2 * n * ad;
-		}
-
-#ifdef KERN_ia64_ARCH_H_
-		if((int)(1000000*pi)!=PI_10e8)
-			panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (1000000*pi),(unative_t) (PI_10e8/100));
-#else
-		if((int)(100000000*pi)!=PI_10e8)
-			panic("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
-#endif
-
-	}
-
-	printf("tid%d: pi*10e8=%zd should be %zd\n", THREAD->tid, (unative_t) (100000000*pi),(unative_t) PI_10e8);
-	atomic_inc(&threads_ok);
-}
-
-void test(void)
-{
-	thread_t *t;
-	int i;
-
-	waitq_initialize(&can_start);
-
-	printf("FPU test #1\n");
-	printf("Creating %d threads... ", THREADS);
-
-	for (i=0; i<THREADS/2; i++) {  
-		if (!(t = thread_create(e, NULL, TASK, 0, "e")))
-			panic("could not create thread\n");
-		thread_ready(t);
-		if (!(t = thread_create(pi, NULL, TASK, 0, "pi")))
-			panic("could not create thread\n");
-		thread_ready(t);
-	}
-	printf("ok\n");
-	
-	thread_sleep(1);
-	waitq_wakeup(&can_start, WAKEUP_ALL);
-
-	while (atomic_get(&threads_ok) != THREADS)
-		;
-		
-	printf("Test passed.\n");
-}
Index: kernel/test/test.c
===================================================================
--- kernel/test/test.c	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/test/test.c	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -39,5 +39,30 @@
 		"atomic1",
 		"Test atomic operations",
-		&test_atomic1
+		&test_atomic1,
+		true
+	},
+	{
+		"btree1",
+		"Test B-tree operations",
+		&test_btree1,
+		true
+	},
+	{
+		"mips1",
+		"MIPS debug test",
+		&test_mips1,
+		true
+	},
+	{
+		"fault1",
+		"Write to NULL (maybe page fault)",
+		&test_fault1,
+		false
+	},
+	{
+		"fpu1",
+		"Intel FPU test",
+		&test_fpu1,
+		true
 	},
 	{NULL, NULL, NULL}
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision 319e60e55b0b59b46de5960c99fbbfe193c9017a)
+++ kernel/test/test.h	(revision 50661ab8590db56556df35c9b7fe8dd1f940ea72)
@@ -43,7 +43,12 @@
 	char * desc;
 	function entry;
+	bool safe;
 } test_t;
 
 extern void test_atomic1(void);
+extern void test_btree1(void);
+extern void test_mips1(void);
+extern void test_fault1(void);
+extern void test_fpu1(void);
 
 extern test_t tests[];
