Index: kernel/test/mm/falloc1.c
===================================================================
--- kernel/test/mm/falloc1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/falloc1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -26,4 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #include <print.h>
 #include <test.h>
@@ -36,18 +37,11 @@
 #include <align.h>
 
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
 #define MAX_FRAMES 1024
 #define MAX_ORDER 8
 #define TEST_RUNS 2
 
-void test_falloc1(void) {
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
-	uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
-	int results[MAX_ORDER+1];
+char * test_falloc1(void) {
+	uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
+	int results[MAX_ORDER + 1];
 	
 	int i, order, run;
@@ -55,5 +49,6 @@
 
 	ASSERT(TEST_RUNS > 1);
-	ASSERT(frames != NULL)
+	if (frames == NULL)
+		return "Unable to allocate frames";
 
 	for (run = 0; run < TEST_RUNS; run++) {
@@ -65,28 +60,27 @@
 				
 				if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
-					panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
+					printf("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
+					return "Test failed";
 				}
 				
-				if (frames[allocated]) {
+				if (frames[allocated])
 					allocated++;
-				} else {
+				else {
 					printf("done. ");
 					break;
 				}
 			}
-		
+			
 			printf("%d blocks allocated.\n", allocated);
 		
 			if (run) {
-				if (results[order] != allocated) {
-					panic("Test failed. Frame leak possible.\n");
-				}
+				if (results[order] != allocated)
+					return "Possible frame leak";
 			} else
 				results[order] = allocated;
 			
 			printf("Deallocating ... ");
-			for (i = 0; i < allocated; i++) {
+			for (i = 0; i < allocated; i++)
 				frame_free(KA2PA(frames[i]));
-			}
 			printf("done.\n");
 		}
@@ -95,9 +89,4 @@
 	free(frames);
 	
-	printf("Test passed.\n");
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif
+	return NULL;
 }
-
Index: kernel/test/mm/falloc1.def
===================================================================
--- kernel/test/mm/falloc1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/falloc1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"falloc1",
+	"Frame allocator test 1",
+	&test_falloc1,
+	true
+},
Index: kernel/test/mm/falloc2.c
===================================================================
--- kernel/test/mm/falloc2.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/falloc2.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -26,4 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #include <print.h>
 #include <test.h>
@@ -39,8 +40,4 @@
 #include <arch.h>
 
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
 #define MAX_FRAMES 256
 #define MAX_ORDER 8
@@ -49,10 +46,8 @@
 #define THREADS 8
 
-static void falloc(void * arg);
-static void failed(void);
+static atomic_t thread_count;
+static atomic_t thread_fail;
 
-static atomic_t thread_count;
-
-void falloc(void * arg)
+static void falloc(void * arg)
 {
 	int order, run, allocated, i;
@@ -61,5 +56,10 @@
 	
 	uintptr_t * frames =  (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
-	ASSERT(frames != NULL);
+	if (frames == NULL) {
+		printf("Thread #%d (cpu%d): Unable to allocate frames\n", THREAD->tid, CPU->id);
+		atomic_inc(&thread_fail);
+		atomic_dec(&thread_count);
+		return;
+	}
 	
 	thread_detach(THREAD);
@@ -74,7 +74,6 @@
 					memsetb(frames[allocated], FRAME_SIZE << order, val);
 					allocated++;
-				} else {
+				} else
 					break;
-				}
 			}
 			printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
@@ -85,5 +84,6 @@
 					if (((uint8_t *) frames[i])[k] != val) {
 						printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
-						failed();
+						atomic_inc(&thread_fail);
+						goto cleanup;
 					}
 				}
@@ -93,5 +93,6 @@
 		}
 	}
-	
+
+cleanup:	
 	free(frames);
 	printf("Thread #%d (cpu%d): Exiting\n", THREAD->tid, CPU->id);
@@ -99,36 +100,28 @@
 }
 
-
-void failed(void)
+char * test_falloc2(void)
 {
-	panic("Test failed.\n");
-}
-
-
-void test_falloc2(void)
-{
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
-	int i;
+	unsigned int i;
 
 	atomic_set(&thread_count, THREADS);
+	atomic_set(&thread_fail, 0);
 		
 	for (i = 0; i < THREADS; i++) {
-		thread_t * thrd;
-		thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
-		if (thrd)
-			thread_ready(thrd);
-		else
-			failed();
+		thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc");
+		if (!thrd) {
+			printf("Could not create thread %d\n", i);
+			break;
+		}
+		thread_ready(thrd);
 	}
 	
-	while (thread_count.count)
-		;
-
-	printf("Test passed.\n");
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif
+	while (atomic_get(&thread_count) > 0) {
+		printf("Threads left: %d\n", atomic_get(&thread_count));
+		thread_sleep(1);
+	}
+	
+	if (atomic_get(&thread_fail) == 0)
+		return NULL;
+	
+	return "Test failed";
 }
Index: kernel/test/mm/falloc2.def
===================================================================
--- kernel/test/mm/falloc2.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/falloc2.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"falloc2",
+	"Frame allocator test 2",
+	&test_falloc2,
+	true
+},
Index: kernel/test/mm/mapping1.c
===================================================================
--- kernel/test/mm/mapping1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/mapping1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -26,4 +26,5 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #include <print.h>
 #include <test.h>
@@ -35,8 +36,4 @@
 #include <debug.h>
 
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
 #define PAGE0	0x10000000
 #define PAGE1	(PAGE0+PAGE_SIZE)
@@ -45,13 +42,8 @@
 #define VALUE1	0x89abcdef
 
-void test_mapping1(void)
+char * test_mapping1(void)
 {
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
 	uintptr_t frame0, frame1;
 	uint32_t v0, v1;
-
-	printf("Memory management test mapping #1\n");
 
 	frame0 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
@@ -88,8 +80,4 @@
 	ASSERT(v1 == 0);
 	
-	printf("Test passed.\n");
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif	
+	return NULL;	
 }
Index: kernel/test/mm/mapping1.def
===================================================================
--- kernel/test/mm/mapping1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/mapping1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"mapping1",
+	"Mapping test",
+	&test_mapping1,
+	false
+},
Index: kernel/test/mm/purge1.c
===================================================================
--- kernel/test/mm/purge1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/purge1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -27,4 +27,6 @@
  */
 
+#ifdef ia64
+
 #include <print.h>
 #include <test.h>
@@ -37,14 +39,12 @@
 #include <debug.h>
 
-#ifdef ia64
-
 extern void tlb_invalidate_all(void);
 extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
 
-void test(void)
+char * test(void)
 {
 	tlb_entry_t entryi;
 	tlb_entry_t entryd;
-
+	
 	int i;
 																																													
@@ -81,11 +81,6 @@
 	
 	/*tlb_invalidate_all();*/
-}
-
-#else
-
-void test_purge1(void)
-{
-	printf("This test is availaible only on IA64 platform.\n");
+	
+	return NULL;
 }
 
Index: kernel/test/mm/purge1.def
===================================================================
--- kernel/test/mm/purge1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/purge1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,8 @@
+#ifdef ia64
+{
+	"purge1",
+	"Itanium TLB purge test",
+	&test_purge1,
+	true
+},
+#endif
Index: kernel/test/mm/slab1.c
===================================================================
--- kernel/test/mm/slab1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/slab1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -35,8 +35,4 @@
 #include <memstr.h>
 
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
 #define VAL_COUNT   1024
 
@@ -52,11 +48,11 @@
 				  SLAB_CACHE_NOMAGAZINE);	
 	printf("Allocating %d items...", count);
-	for (i=0; i < count; i++) {
+	for (i = 0; i < count; i++) {
 		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
+		memsetb((uintptr_t) data[i], size, 0);
 	}
 	printf("done.\n");
 	printf("Freeing %d items...", count);
-	for (i=0; i < count; i++) {
+	for (i = 0; i < count; i++) {
 		slab_free(cache, data[i]);
 	}
@@ -64,24 +60,24 @@
 
 	printf("Allocating %d items...", count);
-	for (i=0; i < count; i++) {
+	for (i = 0; i < count; i++) {
 		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
+		memsetb((uintptr_t) data[i], size, 0);
 	}
 	printf("done.\n");
 
-	printf("Freeing %d items...", count/2);
-	for (i=count-1; i >= count/2; i--) {
+	printf("Freeing %d items...", count / 2);
+	for (i = count - 1; i >= count / 2; i--) {
 		slab_free(cache, data[i]);
 	}
 	printf("done.\n");	
 
-	printf("Allocating %d items...", count/2);
-	for (i=count/2; i < count; i++) {
+	printf("Allocating %d items...", count / 2);
+	for (i = count / 2; i < count; i++) {
 		data[i] = slab_alloc(cache, 0);
-		memsetb((uintptr_t)data[i], size, 0);
+		memsetb((uintptr_t) data[i], size, 0);
 	}
 	printf("done.\n");
 	printf("Freeing %d items...", count);
-	for (i=0; i < count; i++) {
+	for (i = 0; i < count; i++) {
 		slab_free(cache, data[i]);
 	}
@@ -104,29 +100,28 @@
 }
 
-
 #define THREADS     6
 #define THR_MEM_COUNT   1024
 #define THR_MEM_SIZE    128
 
-void * thr_data[THREADS][THR_MEM_COUNT];
-slab_cache_t *thr_cache;
-semaphore_t thr_sem;
+static void * thr_data[THREADS][THR_MEM_COUNT];
+static slab_cache_t *thr_cache;
+static semaphore_t thr_sem;
 
 static void slabtest(void *data)
 {
-	int offs = (int)(unative_t) data;
-	int i,j;
+	int offs = (int) (unative_t) data;
+	int i, j;
 	
 	thread_detach(THREAD);
 	
 	printf("Starting thread #%d...\n",THREAD->tid);
-	for (j=0; j<10; j++) {
-		for (i=0; i<THR_MEM_COUNT; i++)
+	for (j = 0; j < 10; j++) {
+		for (i = 0; i < THR_MEM_COUNT; i++)
 			thr_data[offs][i] = slab_alloc(thr_cache,0);
-		for (i=0; i<THR_MEM_COUNT/2; i++)
+		for (i = 0; i < THR_MEM_COUNT / 2; i++)
 			slab_free(thr_cache, thr_data[offs][i]);
-		for (i=0; i< THR_MEM_COUNT/2; i++)
+		for (i = 0; i < THR_MEM_COUNT / 2; i++)
 			thr_data[offs][i] = slab_alloc(thr_cache, 0);
-		for (i=0; i<THR_MEM_COUNT;i++)
+		for (i = 0; i < THR_MEM_COUNT; i++)
 			slab_free(thr_cache, thr_data[offs][i]);
 	}
@@ -143,12 +138,13 @@
 				      NULL, NULL, 
 				      SLAB_CACHE_NOMAGAZINE);
-	semaphore_initialize(&thr_sem,0);
-	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest")))
-			panic("could not create thread\n");
-		thread_ready(t);
+	semaphore_initialize(&thr_sem, 0);
+	for (i = 0; i < THREADS; i++) {  
+		if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest")))
+			printf("Could not create thread %d\n", i);
+		else
+			thread_ready(t);
 	}
 
-	for (i=0; i<THREADS; i++)
+	for (i = 0; i < THREADS; i++)
 		semaphore_down(&thr_sem);
 	
@@ -158,14 +154,9 @@
 }
 
-void test_slab1(void)
+char * test_slab1(void)
 {
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
 	testsimple();
 	testthreads();
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif
+	
+	return NULL;
 }
Index: kernel/test/mm/slab1.def
===================================================================
--- kernel/test/mm/slab1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/slab1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"slab1",
+	"SLAB test 1",
+	&test_slab1,
+	true
+},
Index: kernel/test/mm/slab2.c
===================================================================
--- kernel/test/mm/slab2.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/slab2.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -38,8 +38,4 @@
 #include <synch/mutex.h>
 
-#ifdef CONFIG_BENCH
-#include <arch/cycle.h>
-#endif
-
 #define ITEM_SIZE 256
 
@@ -78,5 +74,5 @@
 		olddata1 = data1;
 		olddata2 = data2;
-	}while(1);
+	} while(1);
 	printf("done.\n");
 	/* We do not have memory - now deallocate cache2 */
@@ -129,5 +125,5 @@
 static void slabtest(void *priv)
 {
-	void *data=NULL, *new;
+	void *data = NULL, *new;
 
 	thread_detach(THREAD);
@@ -173,10 +169,8 @@
 	}
 
-
 	printf("Thread #%d finished\n", THREAD->tid);
 	slab_print_list();
 	semaphore_up(&thr_sem);
 }
-
 
 static void multitest(int size)
@@ -196,13 +190,14 @@
 				      0);
 	semaphore_initialize(&thr_sem,0);
-	for (i=0; i<THREADS; i++) {  
+	for (i = 0; i < THREADS; i++) {  
 		if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest")))
-			panic("could not create thread\n");
-		thread_ready(t);
+			printf("Could not create thread %d\n", i);
+		else
+			thread_ready(t);
 	}
 	thread_sleep(1);
 	condvar_broadcast(&thread_starter);
 
-	for (i=0; i<THREADS; i++)
+	for (i = 0; i < THREADS; i++)
 		semaphore_down(&thr_sem);
 	
@@ -211,13 +206,9 @@
 }
 
-void test_slab2(void)
-{
-#ifdef CONFIG_BENCH
-	uint64_t t0 = get_cycle();
-#endif
-
-	printf("Running reclaim single-thread test .. pass1\n");
+char * test_slab2(void)
+{
+	printf("Running reclaim single-thread test .. pass 1\n");
 	totalmemtest();
-	printf("Running reclaim single-thread test .. pass2\n");
+	printf("Running reclaim single-thread test .. pass 2\n");
 	totalmemtest();
 	printf("Reclaim test OK.\n");
@@ -227,8 +218,5 @@
 	multitest(8192);
 	printf("All done.\n");
-
-#ifdef CONFIG_BENCH
-	uint64_t dt = get_cycle() - t0;
-	printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
-#endif
-}
+	
+	return NULL;
+}
Index: kernel/test/mm/slab2.def
===================================================================
--- kernel/test/mm/slab2.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/mm/slab2.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"slab2",
+	"SLAB test 2",
+	&test_slab2,
+	true
+},
Index: kernel/test/print/print1.c
===================================================================
--- kernel/test/print/print1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/print/print1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -31,5 +31,5 @@
 #define BUFFER_SIZE 32
 
-void test_print1(void)
+char * test_print1(void)
 {
 	int retval;
@@ -37,6 +37,4 @@
 	
 	char buffer[BUFFER_SIZE];
-	
-	printf(" Printf test \n");
 	
 	printf(" text 10.8s %*.*s \n", 5, 3, "text");
@@ -52,5 +50,5 @@
 	printf("'%#llx' 64bit, '%#x' 32bit, '%#hhx' 8bit, '%#hx' 16bit, unative_t '%#zx'. '%#llx' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, nat, 0x1234567887654321ull, "Lovely string" );
 	
-	printf(" Print to NULL '%s'\n",NULL);
+	printf(" Print to NULL '%s'\n", NULL);
 
 	retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
@@ -68,4 +66,4 @@
 	printf("Result is: '%s', retval = %d\n", buffer, retval);
 	
-	return;
+	return NULL;
 }
Index: kernel/test/print/print1.def
===================================================================
--- kernel/test/print/print1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/print/print1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"print1",
+	"Printf test",
+	&test_print1,
+	true
+},
Index: kernel/test/synch/rwlock1.c
===================================================================
--- kernel/test/synch/rwlock1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -41,8 +41,6 @@
 static rwlock_t rwlock;
 
-void test_rwlock1(void)
+char * test_rwlock1(void)
 {
-	printf("Read/write locks test #1\n");
-
 	rwlock_initialize(&rwlock);
 
@@ -74,5 +72,5 @@
 	rwlock_read_lock(&rwlock);
 	rwlock_read_unlock(&rwlock);
-
-	printf("Test passed.\n");
+	
+	return NULL;
 }
Index: kernel/test/synch/rwlock1.def
===================================================================
--- kernel/test/synch/rwlock1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"rwlock1",
+	"RW-lock test 1",
+	&test_rwlock1,
+	true
+},
Index: kernel/test/synch/rwlock2.c
===================================================================
--- kernel/test/synch/rwlock2.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock2.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -40,7 +40,4 @@
 static rwlock_t rwlock;
 
-static void writer(void *arg);
-static void failed(void);
-
 static void writer(void *arg)
 {
@@ -59,16 +56,8 @@
 }
 
-static void failed()
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_rwlock2(void)
+char * test_rwlock2(void)
 {
 	thread_t *thrd;
 	
-	printf("Read/write locks test #2\n");
-    
 	rwlock_initialize(&rwlock);
 
@@ -82,6 +71,5 @@
 		thread_ready(thrd);
 	else
-		failed();
-
+		return "Could not create thread";
 
 	thread_sleep(1);
@@ -90,5 +78,6 @@
 	rwlock_read_unlock(&rwlock);
 	rwlock_read_unlock(&rwlock);
-	rwlock_read_unlock(&rwlock);	
-
+	rwlock_read_unlock(&rwlock);
+	
+	return NULL;
 }
Index: kernel/test/synch/rwlock2.def
===================================================================
--- kernel/test/synch/rwlock2.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock2.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"rwlock2",
+	"RW-lock test 2",
+	&test_rwlock2,
+	true
+},
Index: kernel/test/synch/rwlock3.c
===================================================================
--- kernel/test/synch/rwlock3.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock3.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -40,7 +40,4 @@
 static rwlock_t rwlock;
 
-static void reader(void *arg);
-static void failed(void);
-
 static void reader(void *arg)
 {
@@ -57,37 +54,26 @@
 	rwlock_write_unlock(&rwlock);
 	printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);    			
-	
-	printf("Test passed.\n");	
-
 }
 
-static void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_rwlock3(void)
+char * test_rwlock3(void)
 {
 	int i;
 	thread_t *thrd;
 	
-	printf("Read/write locks test #3\n");
-    
 	rwlock_initialize(&rwlock);
-
 	rwlock_write_lock(&rwlock);
 	
-	for (i=0; i<4; i++) {
+	for (i = 0; i < 4; i++) {
 		thrd = thread_create(reader, NULL, TASK, 0, "reader");
 		if (thrd)
 			thread_ready(thrd);
 		else
-			failed();
+			printf("Could not create reader %d\n", i);
 	}
-
 
 	thread_sleep(1);
 	
 	rwlock_write_unlock(&rwlock);
+	
+	return NULL;
 }
Index: kernel/test/synch/rwlock3.def
===================================================================
--- kernel/test/synch/rwlock3.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock3.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"rwlock3",
+	"RW-lock test 3",
+	&test_rwlock3,
+	true
+},
Index: kernel/test/synch/rwlock4.c
===================================================================
--- kernel/test/synch/rwlock4.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock4.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -53,10 +53,4 @@
 static uint32_t seed = 0xdeadbeef;
 
-static uint32_t random(uint32_t max);
-
-static void writer(void *arg);
-static void reader(void *arg);
-static void failed(void);
-
 static uint32_t random(uint32_t max)
 {
@@ -69,5 +63,4 @@
 	return rc;
 }
-
 
 static void writer(void *arg)
@@ -83,5 +76,5 @@
 		printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
 		return;
-	};
+	}
 	printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
 
@@ -113,49 +106,40 @@
 }
 
-static void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_rwlock4(void)
+char * test_rwlock4(void)
 {
 	context_t ctx;
 	uint32_t i, k;
 	
-	printf("Read/write locks test #4\n");
-    
 	waitq_initialize(&can_start);
 	rwlock_initialize(&rwlock);
 	
-	for (;;) {
-		thread_t *thrd;
-		
-		context_save(&ctx);
-		printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
-		
-		k = random(7) + 1;
-		printf("Creating %d readers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(reader, NULL, TASK, 0, "reader");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
+	thread_t *thrd;
+	
+	context_save(&ctx);
+	printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in);
+	
+	k = random(7) + 1;
+	printf("Creating %d readers\n", k);
+	for (i = 0; i < k; i++) {
+		thrd = thread_create(reader, NULL, TASK, 0, "reader");
+		if (thrd)
+			thread_ready(thrd);
+		else
+			printf("Could not create reader %d\n", i);
+	}
 
-		k = random(5) + 1;
-		printf("Creating %d writers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(writer, NULL, TASK, 0, "writer");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
-		
-		thread_usleep(20000);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	}		
-
+	k = random(5) + 1;
+	printf("Creating %d writers\n", k);
+	for (i=0; i<k; i++) {
+		thrd = thread_create(writer, NULL, TASK, 0, "writer");
+		if (thrd)
+			thread_ready(thrd);
+		else
+			printf("Could not create writer %d\n", i);
+	}
+	
+	thread_usleep(20000);
+	waitq_wakeup(&can_start, WAKEUP_ALL);
+	
+	return NULL;
 }
Index: kernel/test/synch/rwlock4.def
===================================================================
--- kernel/test/synch/rwlock4.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock4.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"rwlock4",
+	"RW-lock test 4",
+	&test_rwlock4,
+	true
+},
Index: kernel/test/synch/rwlock5.c
===================================================================
--- kernel/test/synch/rwlock5.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock5.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -45,9 +45,5 @@
 static atomic_t items_written;
 
-static void writer(void *arg);
-static void reader(void *arg);
-static void failed(void);
-
-void writer(void *arg)
+static void writer(void *arg)
 {
 	thread_detach(THREAD);
@@ -60,5 +56,5 @@
 }
 
-void reader(void *arg)
+static void reader(void *arg)
 {
 	thread_detach(THREAD);
@@ -71,21 +67,13 @@
 }
 
-void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_rwlock5(void)
+char * test_rwlock5(void)
 {
 	int i, j, k;
 	count_t readers, writers;
 	
-	printf("Read/write locks test #5\n");
-    
 	waitq_initialize(&can_start);
 	rwlock_initialize(&rwlock);
 	
-	for (i=1; i<=3; i++) {
+	for (i = 1; i <= 3; i++) {
 		thread_t *thrd;
 
@@ -93,23 +81,23 @@
 		atomic_set(&items_written, 0);
 
-		readers = i*READERS;
-		writers = (4-i)*WRITERS;
+		readers = i * READERS;
+		writers = (4 - i) * WRITERS;
 
 		printf("Creating %ld readers and %ld writers...", readers, writers);
 		
-		for (j=0; j<(READERS+WRITERS)/2; j++) {
-			for (k=0; k<i; k++) {
+		for (j = 0; j < (READERS + WRITERS) / 2; j++) {
+			for (k = 0; k < i; k++) {
 				thrd = thread_create(reader, NULL, TASK, 0, "reader");
 				if (thrd)
 					thread_ready(thrd);
 				else
-					failed();
+					printf("Could not create reader %d\n", k);
 			}
-			for (k=0; k<(4-i); k++) {
+			for (k = 0; k < (4 - i); k++) {
 				thrd = thread_create(writer, NULL, TASK, 0, "writer");
 				if (thrd)
 					thread_ready(thrd);
 				else
-					failed();
+					printf("Could not create writer %d\n", k);
 			}
 		}
@@ -120,9 +108,10 @@
 		waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-		while (items_read.count != readers || items_written.count != writers) {
+		while ((items_read.count != readers) || (items_written.count != writers)) {
 			printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
 			thread_usleep(100000);
 		}
 	}
-	printf("Test passed.\n");
+	
+	return NULL;
 }
Index: kernel/test/synch/rwlock5.def
===================================================================
--- kernel/test/synch/rwlock5.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/rwlock5.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"rwlock5",
+	"RW-lock test 5",
+	&test_rwlock5,
+	true
+},
Index: kernel/test/synch/semaphore1.c
===================================================================
--- kernel/test/synch/semaphore1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/semaphore1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -46,8 +46,4 @@
 static atomic_t items_consumed;
 
-static void consumer(void *arg);
-static void producer(void *arg);
-static void failed(void);
-
 static void producer(void *arg)
 {
@@ -74,22 +70,13 @@
 }
 
-static void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_semaphore1(void)
+char * test_semaphore1(void)
 {
 	int i, j, k;
 	int consumers, producers;
 	
-	printf("Semaphore test #1\n");
-    
 	waitq_initialize(&can_start);
 	semaphore_initialize(&sem, AT_ONCE);
 
-
-	for (i=1; i<=3; i++) {
+	for (i = 1; i <= 3; i++) {
 		thread_t *thrd;
 
@@ -98,22 +85,22 @@
 		
 		consumers = i * CONSUMERS;
-		producers = (4-i) * PRODUCERS;
+		producers = (4 - i) * PRODUCERS;
 		
 		printf("Creating %d consumers and %d producers...", consumers, producers);
 	
-		for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
-			for (k=0; k<i; k++) {
+		for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
+			for (k = 0; k < i; k++) {
 				thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
 				if (thrd)
 					thread_ready(thrd);
 				else
-					failed();
+					printf("could not create consumer %d\n", i);
 			}
-			for (k=0; k<(4-i); k++) {
+			for (k = 0; k < (4 - i); k++) {
 				thrd = thread_create(producer, NULL, TASK, 0, "producer");
 				if (thrd)
 					thread_ready(thrd);
 				else
-					failed();
+					printf("could not create producer %d\n", i);
 			}
 		}
@@ -124,9 +111,10 @@
 		waitq_wakeup(&can_start, WAKEUP_ALL);
 	
-		while (items_consumed.count != consumers || items_produced.count != producers) {
+		while ((items_consumed.count != consumers) || (items_produced.count != producers)) {
 			printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
 			thread_sleep(1);
 		}
 	}
-	printf("Test passed.\n");
+	
+	return NULL;
 }
Index: kernel/test/synch/semaphore1.def
===================================================================
--- kernel/test/synch/semaphore1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/semaphore1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"semaphore1",
+	"Semaphore test 1",
+	&test_semaphore1,
+	true
+},
Index: kernel/test/synch/semaphore2.c
===================================================================
--- kernel/test/synch/semaphore2.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/semaphore2.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -48,9 +48,4 @@
 static uint32_t seed = 0xdeadbeef;
 
-static uint32_t random(uint32_t max);
-
-static void consumer(void *arg);
-static void failed(void);
-
 static uint32_t random(uint32_t max)
 {
@@ -63,5 +58,4 @@
 	return rc;
 }
-
 
 static void consumer(void *arg)
@@ -88,37 +82,26 @@
 }
 
-static void failed(void)
-{
-	printf("Test failed prematurely.\n");
-	thread_exit();
-}
-
-void test_semaphore2(void)
+char * test_semaphore2(void)
 {
 	uint32_t i, k;
 	
-	printf("Semaphore test #2\n");
-    
 	waitq_initialize(&can_start);
 	semaphore_initialize(&sem, 5);
 	
-
+	thread_t *thrd;
 	
-	for (; ;) {
-		thread_t *thrd;
-		
-		k = random(7) + 1;
-		printf("Creating %d consumers\n", k);
-		for (i=0; i<k; i++) {
-			thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
-			if (thrd)
-				thread_ready(thrd);
-			else
-				failed();
-		}
-		
-		thread_usleep(20000);
-		waitq_wakeup(&can_start, WAKEUP_ALL);
-	}		
-
+	k = random(7) + 1;
+	printf("Creating %d consumers\n", k);
+	for (i = 0; i < k; i++) {
+		thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
+		if (thrd)
+			thread_ready(thrd);
+		else
+			printf("Error creating thread\n");
+	}
+	
+	thread_usleep(20000);
+	waitq_wakeup(&can_start, WAKEUP_ALL);
+	
+	return NULL;
 }
Index: kernel/test/synch/semaphore2.def
===================================================================
--- kernel/test/synch/semaphore2.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/synch/semaphore2.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"semaphore2",
+	"Semaphore test 2",
+	&test_semaphore2,
+	true
+},
Index: kernel/test/sysinfo/sysinfo1.c
===================================================================
--- kernel/test/sysinfo/sysinfo1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/sysinfo/sysinfo1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -33,22 +33,8 @@
 #include <test.h>
 #include <sysinfo/sysinfo.h>
-/*
-static unative_t counter(sysinfo_item_t *root)
+
+char * test_sysinfo1(void)
 {
-	static unative_t i=0;
-	return i++;
-}*/
-
-void test_sysinfo1(void)
-{
-/*	sysinfo_set_item_val("Ahoj.lidi.uaaaa",NULL,9);
-	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,15);
-	sysinfo_set_item_val("Ahoj.lidi",NULL,64);
-	sysinfo_set_item_function("Ahoj",NULL,counter);
-	sysinfo_dump(NULL,0);
-	sysinfo_set_item_val("Ahoj.lidi.ubbbb",NULL,75);
-	sysinfo_dump(NULL,0);
-	sysinfo_dump(NULL,0);
-	sysinfo_dump(NULL,0);*/
-	sysinfo_dump(NULL,0);
+	sysinfo_dump(NULL, 0);
+	return NULL;
 }
Index: kernel/test/sysinfo/sysinfo1.def
===================================================================
--- kernel/test/sysinfo/sysinfo1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/sysinfo/sysinfo1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"sysinfo1",
+	"Sysinfo test",
+	&test_sysinfo1,
+	true
+},
Index: kernel/test/test.c
===================================================================
--- kernel/test/test.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/test.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -43,101 +43,19 @@
 #include <fpu/sse1.def>
 #include <fpu/mips2.def>
-	/*
-	{
-		"falloc1",
-		"Frame allocator test 1",
-		&test_falloc1,
-		true
-	},
-	{
-		"falloc2",
-		"Frame allocator test 2",
-		&test_falloc2,
-		true
-	},
-	{
-		"mapping1",
-		"Mapping test",
-		&test_mapping1,
-		true
-	},
-	{
-		"slab1",
-		"SLAB test 1",
-		&test_slab1,
-		true
-	},
-	{
-		"slab2",
-		"SLAB test 2",
-		&test_slab2,
-		true
-	},
-	{
-		"purge1",
-		"Itanium TLB purge test",
-		&test_purge1,
-		true
-	},
-	{
-		"rwlock1",
-		"RW-lock test 1",
-		&test_rwlock1,
-		true
-	},
-	{
-		"rwlock2",
-		"RW-lock test 2",
-		&test_rwlock2,
-		true
-	},
-	{
-		"rwlock3",
-		"RW-lock test 3",
-		&test_rwlock3,
-		true
-	},
-	{
-		"rwlock4",
-		"RW-lock test 4",
-		&test_rwlock4,
-		true
-	},
-	{
-		"rwlock5",
-		"RW-lock test 5",
-		&test_rwlock5,
-		true
-	},
-	{
-		"semaphore1",
-		"Semaphore test 1",
-		&test_semaphore1,
-		true
-	},
-	{
-		"semaphore2",
-		"Semaphore test 2",
-		&test_semaphore2,
-		true
-	},
-	{
-		"print1",
-		"Printf test",
-		&test_print1,
-		true
-	},
-	{
-		"thread1",
-		"Thread test",
-		&test_thread1,
-		true
-	},
-	{
-		"sysinfo1",
-		"Sysinfo test",
-		&test_sysinfo1,
-		true
-	},*/
+#include <mm/falloc1.def>
+#include <mm/falloc2.def>
+#include <mm/mapping1.def>
+#include <mm/slab1.def>
+#include <mm/slab2.def>
+#include <synch/rwlock1.def>
+#include <synch/rwlock2.def>
+#include <synch/rwlock3.def>
+#include <synch/rwlock4.def>
+#include <synch/rwlock5.def>
+#include <synch/semaphore1.def>
+#include <synch/semaphore2.def>
+#include <print/print1.def>
+#include <thread/thread1.def>
+#include <sysinfo/sysinfo1.def>
 	{NULL, NULL, NULL}
 };
Index: kernel/test/test.h
===================================================================
--- kernel/test/test.h	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/test.h	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -55,20 +55,20 @@
 extern char * test_sse1(void);
 extern char * test_mips2(void);
-extern void test_falloc1(void);
-extern void test_falloc2(void);
-extern void test_mapping1(void);
-extern void test_purge1(void);
-extern void test_slab1(void);
-extern void test_slab2(void);
-extern void test_rwlock1(void);
-extern void test_rwlock2(void);
-extern void test_rwlock3(void);
-extern void test_rwlock4(void);
-extern void test_rwlock5(void);
-extern void test_semaphore1(void);
-extern void test_semaphore2(void);
-extern void test_print1(void);
-extern void test_thread1(void);
-extern void test_sysinfo1(void);
+extern char * test_falloc1(void);
+extern char * test_falloc2(void);
+extern char * test_mapping1(void);
+extern char * test_purge1(void);
+extern char * test_slab1(void);
+extern char * test_slab2(void);
+extern char * test_rwlock1(void);
+extern char * test_rwlock2(void);
+extern char * test_rwlock3(void);
+extern char * test_rwlock4(void);
+extern char * test_rwlock5(void);
+extern char * test_semaphore1(void);
+extern char * test_semaphore2(void);
+extern char * test_print1(void);
+extern char * test_thread1(void);
+extern char * test_sysinfo1(void);
 
 extern test_t tests[];
Index: kernel/test/thread/thread1.c
===================================================================
--- kernel/test/thread/thread1.c	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/thread/thread1.c	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -40,23 +40,44 @@
 #define THREADS 5
 
+static atomic_t finish;
+static atomic_t threads_finished;
+
 static void threadtest(void *data)
 {
-
 	thread_detach(THREAD);	
 
-	while (1)
-		printf("%d\n",(int)(THREAD->tid));
+	while (atomic_get(&finish)) {
+		printf("%d\n", (int) (THREAD->tid));
+		thread_usleep(100);
+	}
+	atomic_inc(&threads_finished);
 }
 
-void test_thread1(void)
+char * test_thread1(void)
 {
-	thread_t *t;
-	int i;
+	unsigned int i, total = 0;
+	
+	atomic_set(&finish, 1);
+	atomic_set(&threads_finished, 0);
 
-	for (i=0; i<THREADS; i++) {  
-		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest")))
-			panic("could not create thread\n");
+	for (i = 0; i < THREADS; i++) {  
+		thread_t *t;
+		if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest"))) {
+			printf("Could not create thread %d\n", i);
+			break;
+		}
 		thread_ready(t);
+		total++;
 	}
-	printf("ok\n");
+	
+	printf("Running threads for 10 seconds...\n");
+	thread_sleep(10);
+	
+	atomic_set(&finish, 0);
+	while (atomic_get(&threads_finished) < total) {
+		printf("Threads left: %d\n", total - atomic_get(&threads_finished));
+		thread_sleep(1);
+	}
+	
+	return NULL;
 }
Index: kernel/test/thread/thread1.def
===================================================================
--- kernel/test/thread/thread1.def	(revision 34db7fa828e4d10ee2a902fb4143704b3feda184)
+++ kernel/test/thread/thread1.def	(revision 96348adc5fd6e05c187a0b5ada4b3c219815b609)
@@ -0,0 +1,6 @@
+{
+	"thread1",
+	"Thread test",
+	&test_thread1,
+	true
+},
