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-priority", test_alarm_priority},
17 {"alarm-zero", test_alarm_zero},
18 {"alarm-negative", test_alarm_negative},
19 {"priority-change", test_priority_change},
20 {"priority-donate-one", test_priority_donate_one},
21 {"priority-donate-multiple", test_priority_donate_multiple},
22 {"priority-donate-nest", test_priority_donate_nest},
23 {"priority-fifo", test_priority_fifo},
24 {"priority-preempt", test_priority_preempt},
25 {"priority-sema", test_priority_sema},
26 {"priority-condvar", test_priority_condvar},
27 {"mlfqs-load-1", test_mlfqs_load_1},
28 {"mlfqs-load-60", test_mlfqs_load_60},
29 {"mlfqs-load-avg", test_mlfqs_load_avg},
30 {"mlfqs-recent-1", test_mlfqs_recent_1},
31 {"mlfqs-fair-2", test_mlfqs_fair_2},
32 {"mlfqs-fair-20", test_mlfqs_fair_20},
33 {"mlfqs-nice-2", test_mlfqs_nice_2},
34 {"mlfqs-nice-10", test_mlfqs_nice_10},
37 static const char *test_name;
39 /* Runs the test named NAME. */
41 run_test (const char *name)
45 for (t = tests; t < tests + sizeof tests / sizeof *tests; t++)
46 if (!strcmp (name, t->name))
54 PANIC ("no test named \"%s\"", name);
57 /* Prints FORMAT as if with printf(),
58 prefixing the output by the name of the test
59 and following it with a new-line character. */
61 msg (const char *format, ...)
65 printf ("(%s) ", test_name);
66 va_start (args, format);
67 vprintf (format, args);
72 /* Prints failure message FORMAT as if with printf(),
73 prefixing the output by the name of the test and FAIL:
74 and following it with a new-line character,
75 and then panics the kernel. */
77 fail (const char *format, ...)
81 printf ("(%s) FAIL: ", test_name);
82 va_start (args, format);
83 vprintf (format, args);
87 PANIC ("test failed");
90 /* Prints a message indicating the current test passed. */
94 printf ("(%s) PASS\n", test_name);