Rev 4389 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4389 | Rev 4691 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | */ |
28 | */ |
29 | 29 | ||
30 | /** @addtogroup tester User space Tester |
30 | /** @addtogroup tester User space tester |
31 | * @brief User space testing infrastructure. |
31 | * @brief User space testing infrastructure. |
32 | * @{ |
32 | * @{ |
33 | */ |
33 | */ |
34 | /** |
34 | /** |
35 | * @file |
35 | * @file |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #include <unistd.h> |
38 | #include <unistd.h> |
39 | #include <stdio.h> |
39 | #include <stdio.h> |
- | 40 | #include <string.h> |
|
40 | #include "tester.h" |
41 | #include "tester.h" |
41 | 42 | ||
42 | int myservice = 0; |
43 | bool test_quiet; |
43 | int phones[MAX_PHONES]; |
44 | int test_argc; |
44 | int connections[MAX_CONNECTIONS]; |
45 | char **test_argv; |
45 | ipc_callid_t callids[MAX_CONNECTIONS]; |
- | |
46 | 46 | ||
47 | test_t tests[] = { |
47 | test_t tests[] = { |
48 | #include "thread/thread1.def" |
48 | #include "thread/thread1.def" |
49 | #include "print/print1.def" |
49 | #include "print/print1.def" |
- | 50 | #include "print/print2.def" |
|
- | 51 | #include "print/print3.def" |
|
50 | #include "print/print4.def" |
52 | #include "print/print4.def" |
- | 53 | #include "console/console1.def" |
|
- | 54 | #include "stdio/stdio1.def" |
|
- | 55 | #include "stdio/stdio2.def" |
|
51 | #include "fault/fault1.def" |
56 | #include "fault/fault1.def" |
52 | #include "fault/fault2.def" |
57 | #include "fault/fault2.def" |
- | 58 | #include "vfs/vfs1.def" |
|
- | 59 | #include "ipc/ping_pong.def" |
|
53 | #include "ipc/register.def" |
60 | #include "ipc/register.def" |
54 | #include "ipc/connect.def" |
61 | #include "ipc/connect.def" |
55 | #include "ipc/send_async.def" |
- | |
56 | #include "ipc/send_sync.def" |
- | |
57 | #include "ipc/answer.def" |
- | |
58 | #include "ipc/hangup.def" |
- | |
59 | #include "ipc/ping_pong.def" |
- | |
60 | #include "devmap/devmap1.def" |
- | |
61 | #include "loop/loop1.def" |
62 | #include "loop/loop1.def" |
62 | #include "vfs/vfs1.def" |
63 | #include "mm/malloc1.def" |
63 | #include "console/console1.def" |
- | |
64 | #include "stdio/stdio1.def" |
- | |
65 | #include "stdio/stdio2.def" |
- | |
66 | {NULL, NULL, NULL} |
64 | {NULL, NULL, NULL, false} |
67 | }; |
65 | }; |
68 | 66 | ||
69 | static bool run_test(test_t *test) |
67 | static bool run_test(test_t *test) |
70 | { |
68 | { |
71 | printf("%s\t\t%s\n", test->name, test->desc); |
- | |
72 | - | ||
73 | /* Execute the test */ |
69 | /* Execute the test */ |
74 | char * ret = test->entry(false); |
70 | char *ret = test->entry(); |
75 | 71 | ||
76 | if (ret == NULL) { |
72 | if (ret == NULL) { |
77 | printf("Test passed\n\n"); |
73 | printf("\nTest passed\n"); |
78 | return true; |
74 | return true; |
79 | } |
75 | } |
80 | 76 | ||
81 | printf("%s\n\n", ret); |
77 | printf("\n%s\n", ret); |
82 | return false; |
78 | return false; |
83 | } |
79 | } |
84 | 80 | ||
85 | static void run_safe_tests(void) |
81 | static void run_safe_tests(void) |
86 | { |
82 | { |
87 | test_t *test; |
83 | test_t *test; |
88 | unsigned int i = 0; |
84 | unsigned int i = 0; |
89 | unsigned int n = 0; |
85 | unsigned int n = 0; |
90 | 86 | ||
91 | printf("\n*** Running all safe tests ***\n\n"); |
87 | printf("\n*** Running all safe tests ***\n\n"); |
92 | 88 | ||
93 | for (test = tests; test->name != NULL; test++) { |
89 | for (test = tests; test->name != NULL; test++) { |
94 | if (test->safe) { |
90 | if (test->safe) { |
- | 91 | printf("%s (%s)\n", test->name, test->desc); |
|
95 | if (run_test(test)) |
92 | if (run_test(test)) |
96 | i++; |
93 | i++; |
97 | else |
94 | else |
98 | n++; |
95 | n++; |
99 | } |
96 | } |
100 | } |
97 | } |
101 | 98 | ||
102 | printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i); |
99 | printf("\nCompleted, %u tests run, %u passed.\n", i + n, i); |
103 | } |
100 | } |
104 | 101 | ||
105 | static void list_tests(void) |
102 | static void list_tests(void) |
106 | { |
103 | { |
- | 104 | size_t len = 0; |
|
107 | test_t *test; |
105 | test_t *test; |
- | 106 | for (test = tests; test->name != NULL; test++) { |
|
- | 107 | if (str_length(test->name) > len) |
|
108 | char c = 'a'; |
108 | len = str_length(test->name); |
- | 109 | } |
|
109 | 110 | ||
110 | for (test = tests; test->name != NULL; test++, c++) |
111 | for (test = tests; test->name != NULL; test++) |
111 | printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
112 | printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
112 | 113 | ||
113 | printf("*\t\t\tRun all safe tests\n"); |
114 | printf("%-*s Run all safe tests\n", len, "*"); |
114 | } |
115 | } |
115 | 116 | ||
116 | int main(int argc, char **argv) |
117 | int main(int argc, char *argv[]) |
117 | { |
118 | { |
118 | printf("Number of arguments: %d\n", argc); |
- | |
119 | if (argv) { |
119 | if (argc < 2) { |
120 | printf("Arguments:"); |
120 | printf("Usage:\n\n"); |
121 | while (*argv) { |
- | |
122 | printf(" '%s'", *argv++); |
121 | printf("%s <test> [args ...]\n\n", argv[0]); |
123 | } |
- | |
124 | printf("\n"); |
- | |
125 | } |
- | |
126 | - | ||
127 | while (1) { |
- | |
128 | char c; |
- | |
129 | test_t *test; |
- | |
130 | - | ||
131 | list_tests(); |
122 | list_tests(); |
132 | printf("> "); |
123 | return 0; |
133 | 124 | } |
|
- | 125 | ||
134 | c = getchar(); |
126 | test_quiet = false; |
- | 127 | test_argc = argc - 2; |
|
135 | printf("%c\n", c); |
128 | test_argv = argv + 2; |
136 | 129 | ||
137 | if ((c >= 'a') && (c <= 'z')) { |
130 | if (str_cmp(argv[1], "*") == 0) { |
138 | for (test = tests; test->name != NULL; test++, c--) |
- | |
139 | if (c == 'a') |
131 | run_safe_tests(); |
140 | break; |
132 | return 0; |
141 | 133 | } |
|
142 | if (test->name == NULL) |
- | |
143 | printf("Unknown test\n\n"); |
- | |
144 | else |
134 | |
145 | run_test(test); |
135 | test_t *test; |
146 | } else if (c == '*') { |
136 | for (test = tests; test->name != NULL; test++) { |
147 | run_safe_tests(); |
- | |
148 | } else if (c < 0) { |
137 | if (str_cmp(argv[1], test->name) == 0) { |
149 | /* got EOF */ |
- | |
150 | break; |
- | |
151 | } else { |
- | |
152 | printf("Invalid test\n\n"); |
138 | return (run_test(test) ? 0 : -1); |
153 | } |
139 | } |
154 | - | ||
155 | } |
140 | } |
156 | 141 | ||
- | 142 | printf("Unknown test \"%s\"\n", argv[1]); |
|
157 | return 0; |
143 | return -2; |
158 | } |
144 | } |
159 | 145 | ||
160 | /** @} |
146 | /** @} |
161 | */ |
147 | */ |