1 #include "tests/threads/tests.h"
12 static const struct test tests[] =
14 {"alarm-single", test_alarm_single},
15 {"alarm-multiple", test_alarm_multiple},
16 {"alarm-simultaneous", test_alarm_simultaneous},
17 {"alarm-priority", test_alarm_priority},
18 {"alarm-zero", test_alarm_zero},
19 {"alarm-negative", test_alarm_negative},
20 {"priority-change", test_priority_change},
21 {"priority-donate-one", test_priority_donate_one},
22 {"priority-donate-multiple", test_priority_donate_multiple},
23 {"priority-donate-multiple2", test_priority_donate_multiple2},
24 {"priority-donate-nest", test_priority_donate_nest},
25 {"priority-donate-sema", test_priority_donate_sema},
26 {"priority-donate-lower", test_priority_donate_lower},
27 {"priority-fifo", test_priority_fifo},
28 {"priority-preempt", test_priority_preempt},
29 {"priority-sema", test_priority_sema},
30 {"priority-condvar", test_priority_condvar},
31 {"mlfqs-load-1", test_mlfqs_load_1},
32 {"mlfqs-load-60", test_mlfqs_load_60},
33 {"mlfqs-load-avg", test_mlfqs_load_avg},
34 {"mlfqs-recent-1", test_mlfqs_recent_1},
35 {"mlfqs-fair-2", test_mlfqs_fair_2},
36 {"mlfqs-fair-20", test_mlfqs_fair_20},
37 {"mlfqs-nice-2", test_mlfqs_nice_2},
38 {"mlfqs-nice-10", test_mlfqs_nice_10},
39 {"mlfqs-block", test_mlfqs_block},
42 static const char *test_name;
44 /* Runs the test named NAME. */
46 run_test (const char *name)
50 for (t = tests; t < tests + sizeof tests / sizeof *tests; t++)
51 if (!strcmp (name, t->name))
59 PANIC ("no test named \"%s\"", name);
62 /* Prints FORMAT as if with printf(),
63 prefixing the output by the name of the test
64 and following it with a new-line character. */
66 msg (const char *format, ...)
70 printf ("(%s) ", test_name);
71 va_start (args, format);
72 vprintf (format, args);
77 /* Prints failure message FORMAT as if with printf(),
78 prefixing the output by the name of the test and FAIL:
79 and following it with a new-line character,
80 and then panics the kernel. */
82 fail (const char *format, ...)
86 printf ("(%s) FAIL: ", test_name);
87 va_start (args, format);
88 vprintf (format, args);
92 PANIC ("test failed");
95 /* Prints a message indicating the current test passed. */
99 printf ("(%s) PASS\n", test_name);