summaryrefslogtreecommitdiffstats
path: root/tests/intro/alarm-clock
diff options
context:
space:
mode:
Diffstat (limited to 'tests/intro/alarm-clock')
-rw-r--r--tests/intro/alarm-clock/Make.tests15
-rw-r--r--tests/intro/alarm-clock/Rubric7
l---------tests/intro/alarm-clock/alarm-multiple.ck1
l---------tests/intro/alarm-clock/alarm-negative.c1
l---------tests/intro/alarm-clock/alarm-negative.ck1
l---------tests/intro/alarm-clock/alarm-simultaneous.c1
l---------tests/intro/alarm-clock/alarm-simultaneous.ck1
l---------tests/intro/alarm-clock/alarm-single.ck1
l---------tests/intro/alarm-clock/alarm-wait.c1
l---------tests/intro/alarm-clock/alarm-zero.c1
l---------tests/intro/alarm-clock/alarm-zero.ck1
-rw-r--r--tests/intro/alarm-clock/tests.c80
12 files changed, 111 insertions, 0 deletions
diff --git a/tests/intro/alarm-clock/Make.tests b/tests/intro/alarm-clock/Make.tests
new file mode 100644
index 0000000..55ad443
--- /dev/null
+++ b/tests/intro/alarm-clock/Make.tests
@@ -0,0 +1,15 @@
1# -*- makefile -*-
2tests/intro/alarm-clock/%.output: SIMULATOR = bochs
3tests/intro/alarm-clock/%.output: PINTOSOPTS += --kernel-test
4tests/intro/alarm-clock/%.output: FILESYSSOURCE = --filesys-size=1
5
6# Test names.
7tests/intro/alarm-clock_TESTS = $(addprefix tests/intro/alarm-clock/,alarm-single \
8alarm-multiple alarm-simultaneous alarm-zero alarm-negative)
9
10# Sources for tests.
11tests/intro/alarm-clock_SRC = tests/intro/alarm-clock/tests.c
12tests/intro/alarm-clock_SRC += tests/intro/alarm-clock/alarm-wait.c
13tests/intro/alarm-clock_SRC += tests/intro/alarm-clock/alarm-simultaneous.c
14tests/intro/alarm-clock_SRC += tests/intro/alarm-clock/alarm-zero.c
15tests/intro/alarm-clock_SRC += tests/intro/alarm-clock/alarm-negative.c
diff --git a/tests/intro/alarm-clock/Rubric b/tests/intro/alarm-clock/Rubric
new file mode 100644
index 0000000..0cf3dc1
--- /dev/null
+++ b/tests/intro/alarm-clock/Rubric
@@ -0,0 +1,7 @@
1Functionality and robustness of alarm clock:
24 alarm-single
34 alarm-multiple
44 alarm-simultaneous
51 alarm-zero
61 alarm-negative
7
diff --git a/tests/intro/alarm-clock/alarm-multiple.ck b/tests/intro/alarm-clock/alarm-multiple.ck
new file mode 120000
index 0000000..f3a9edc
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-multiple.ck
@@ -0,0 +1 @@
../../threads/alarm-multiple.ck \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-negative.c b/tests/intro/alarm-clock/alarm-negative.c
new file mode 120000
index 0000000..483aa63
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-negative.c
@@ -0,0 +1 @@
../../threads/alarm-negative.c \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-negative.ck b/tests/intro/alarm-clock/alarm-negative.ck
new file mode 120000
index 0000000..279520e
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-negative.ck
@@ -0,0 +1 @@
../../threads/alarm-negative.ck \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-simultaneous.c b/tests/intro/alarm-clock/alarm-simultaneous.c
new file mode 120000
index 0000000..6362b61
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-simultaneous.c
@@ -0,0 +1 @@
../../threads/alarm-simultaneous.c \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-simultaneous.ck b/tests/intro/alarm-clock/alarm-simultaneous.ck
new file mode 120000
index 0000000..7226d0c
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-simultaneous.ck
@@ -0,0 +1 @@
../../threads/alarm-simultaneous.ck \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-single.ck b/tests/intro/alarm-clock/alarm-single.ck
new file mode 120000
index 0000000..7f98a51
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-single.ck
@@ -0,0 +1 @@
../../threads/alarm-single.ck \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-wait.c b/tests/intro/alarm-clock/alarm-wait.c
new file mode 120000
index 0000000..2755ae5
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-wait.c
@@ -0,0 +1 @@
../../threads/alarm-wait.c \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-zero.c b/tests/intro/alarm-clock/alarm-zero.c
new file mode 120000
index 0000000..a1f3ca7
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-zero.c
@@ -0,0 +1 @@
../../threads/alarm-zero.c \ No newline at end of file
diff --git a/tests/intro/alarm-clock/alarm-zero.ck b/tests/intro/alarm-clock/alarm-zero.ck
new file mode 120000
index 0000000..3f98d64
--- /dev/null
+++ b/tests/intro/alarm-clock/alarm-zero.ck
@@ -0,0 +1 @@
../../threads/alarm-zero.ck \ No newline at end of file
diff --git a/tests/intro/alarm-clock/tests.c b/tests/intro/alarm-clock/tests.c
new file mode 100644
index 0000000..4a96360
--- /dev/null
+++ b/tests/intro/alarm-clock/tests.c
@@ -0,0 +1,80 @@
1#include "tests/threads/tests.h"
2#include <debug.h>
3#include <string.h>
4#include <stdio.h>
5
6struct test
7 {
8 const char *name;
9 test_func *function;
10 };
11
12static const struct test tests[] =
13 {
14 {"alarm-single", test_alarm_single},
15 {"alarm-multiple", test_alarm_multiple},
16 {"alarm-simultaneous", test_alarm_simultaneous},
17 {"alarm-zero", test_alarm_zero},
18 {"alarm-negative", test_alarm_negative},
19 };
20
21static const char *test_name;
22
23/* Runs the test named NAME. */
24void
25run_test (const char *name)
26{
27 const struct test *t;
28
29 for (t = tests; t < tests + sizeof tests / sizeof *tests; t++)
30 if (!strcmp (name, t->name))
31 {
32 test_name = name;
33 msg ("begin");
34 t->function ();
35 msg ("end");
36 return;
37 }
38 PANIC ("no test named \"%s\"", name);
39}
40
41/* Prints FORMAT as if with printf(),
42 prefixing the output by the name of the test
43 and following it with a new-line character. */
44void
45msg (const char *format, ...)
46{
47 va_list args;
48
49 printf ("(%s) ", test_name);
50 va_start (args, format);
51 vprintf (format, args);
52 va_end (args);
53 putchar ('\n');
54}
55
56/* Prints failure message FORMAT as if with printf(),
57 prefixing the output by the name of the test and FAIL:
58 and following it with a new-line character,
59 and then panics the kernel. */
60void
61fail (const char *format, ...)
62{
63 va_list args;
64
65 printf ("(%s) FAIL: ", test_name);
66 va_start (args, format);
67 vprintf (format, args);
68 va_end (args);
69 putchar ('\n');
70
71 PANIC ("test failed");
72}
73
74/* Prints a message indicating the current test passed. */
75void
76pass (void)
77{
78 printf ("(%s) PASS\n", test_name);
79}
80