00001 #include "tests/threads/tests.h"
00002 #include <debug.h>
00003 #include <string.h>
00004 #include <stdio.h>
00005
00006 struct test
00007 {
00008 const char *name;
00009 test_func *function;
00010 };
00011
00012 static const struct test tests[] =
00013 {
00014 {"alarm-single", test_alarm_single},
00015 {"alarm-multiple", test_alarm_multiple},
00016 {"alarm-simultaneous", test_alarm_simultaneous},
00017 {"alarm-priority", test_alarm_priority},
00018 {"alarm-zero", test_alarm_zero},
00019 {"alarm-negative", test_alarm_negative},
00020 {"priority-change", test_priority_change},
00021 {"priority-donate-one", test_priority_donate_one},
00022 {"priority-donate-multiple", test_priority_donate_multiple},
00023 {"priority-donate-multiple2", test_priority_donate_multiple2},
00024 {"priority-donate-nest", test_priority_donate_nest},
00025 {"priority-donate-sema", test_priority_donate_sema},
00026 {"priority-donate-lower", test_priority_donate_lower},
00027 {"priority-donate-chain", test_priority_donate_chain},
00028 {"priority-fifo", test_priority_fifo},
00029 {"priority-preempt", test_priority_preempt},
00030 {"priority-sema", test_priority_sema},
00031 {"priority-condvar", test_priority_condvar},
00032 {"mlfqs-load-1", test_mlfqs_load_1},
00033 {"mlfqs-load-60", test_mlfqs_load_60},
00034 {"mlfqs-load-avg", test_mlfqs_load_avg},
00035 {"mlfqs-recent-1", test_mlfqs_recent_1},
00036 {"mlfqs-fair-2", test_mlfqs_fair_2},
00037 {"mlfqs-fair-20", test_mlfqs_fair_20},
00038 {"mlfqs-nice-2", test_mlfqs_nice_2},
00039 {"mlfqs-nice-10", test_mlfqs_nice_10},
00040 {"mlfqs-block", test_mlfqs_block},
00041 };
00042
00043 static const char *test_name;
00044
00045
00046 void
00047 run_test (const char *name)
00048 {
00049 const struct test *t;
00050
00051 for (t = tests; t < tests + sizeof tests / sizeof *tests; t++)
00052 if (!strcmp (name, t->name))
00053 {
00054 test_name = name;
00055 msg ("begin");
00056 t->function ();
00057 msg ("end");
00058 return;
00059 }
00060 PANIC ("no test named \"%s\"", name);
00061 }
00062
00063
00064
00065
00066 void
00067 msg (const char *format, ...)
00068 {
00069 va_list args;
00070
00071 printf ("(%s) ", test_name);
00072 va_start (args, format);
00073 vprintf (format, args);
00074 va_end (args);
00075 putchar ('\n');
00076 }
00077
00078
00079
00080
00081
00082 void
00083 fail (const char *format, ...)
00084 {
00085 va_list args;
00086
00087 printf ("(%s) FAIL: ", test_name);
00088 va_start (args, format);
00089 vprintf (format, args);
00090 va_end (args);
00091 putchar ('\n');
00092
00093 PANIC ("test failed");
00094 }
00095
00096
00097 void
00098 pass (void)
00099 {
00100 printf ("(%s) PASS\n", test_name);
00101 }
00102