Rev 4382 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4382 | Rev 4487 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
3 | * Copyright (c) 2007 Martin Decky |
3 | * Copyright (c) 2007 Martin Decky |
4 | * All rights reserved. |
4 | * All rights reserved. |
5 | * |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
8 | * are met: |
9 | * |
9 | * |
10 | * - Redistributions of source code must retain the above copyright |
10 | * - Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. |
11 | * notice, this list of conditions and the following disclaimer. |
12 | * - Redistributions in binary form must reproduce the above copyright |
12 | * - Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the |
13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. |
14 | * documentation and/or other materials provided with the distribution. |
15 | * - The name of the author may not be used to endorse or promote products |
15 | * - The name of the author may not be used to endorse or promote products |
16 | * derived from this software without specific prior written permission. |
16 | * derived from this software without specific prior written permission. |
17 | * |
17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 "tester.h" |
40 | #include "tester.h" |
41 | 41 | ||
42 | int myservice = 0; |
42 | int myservice = 0; |
43 | int phones[MAX_PHONES]; |
43 | int phones[MAX_PHONES]; |
44 | int connections[MAX_CONNECTIONS]; |
44 | int connections[MAX_CONNECTIONS]; |
45 | ipc_callid_t callids[MAX_CONNECTIONS]; |
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/print4.def" |
50 | #include "print/print4.def" |
51 | #include "fault/fault1.def" |
51 | #include "fault/fault1.def" |
52 | #include "fault/fault2.def" |
52 | #include "fault/fault2.def" |
53 | #include "ipc/register.def" |
53 | #include "ipc/register.def" |
54 | #include "ipc/connect.def" |
54 | #include "ipc/connect.def" |
55 | #include "ipc/send_async.def" |
55 | #include "ipc/send_async.def" |
56 | #include "ipc/send_sync.def" |
56 | #include "ipc/send_sync.def" |
57 | #include "ipc/answer.def" |
57 | #include "ipc/answer.def" |
58 | #include "ipc/hangup.def" |
58 | #include "ipc/hangup.def" |
59 | #include "ipc/ping_pong.def" |
59 | #include "ipc/ping_pong.def" |
60 | #include "devmap/devmap1.def" |
60 | #include "devmap/devmap1.def" |
61 | #include "loop/loop1.def" |
61 | #include "loop/loop1.def" |
62 | #include "vfs/vfs1.def" |
62 | #include "vfs/vfs1.def" |
63 | #include "console/console1.def" |
63 | #include "console/console1.def" |
64 | #include "stdio/stdio1.def" |
64 | #include "stdio/stdio1.def" |
65 | #include "stdio/stdio2.def" |
65 | #include "stdio/stdio2.def" |
66 | {NULL, NULL, NULL} |
66 | {NULL, NULL, NULL} |
67 | }; |
67 | }; |
68 | 68 | ||
69 | static bool run_test(test_t *test) |
69 | static bool run_test(test_t *test) |
70 | { |
70 | { |
71 | printf("%s\t\t%s\n", test->name, test->desc); |
71 | printf("%s\t\t%s\n", test->name, test->desc); |
72 | 72 | ||
73 | /* Execute the test */ |
73 | /* Execute the test */ |
74 | char * ret = test->entry(false); |
74 | char * ret = test->entry(false); |
75 | 75 | ||
76 | if (ret == NULL) { |
76 | if (ret == NULL) { |
77 | printf("Test passed\n\n"); |
77 | printf("Test passed\n\n"); |
78 | return true; |
78 | return true; |
79 | } |
79 | } |
80 | 80 | ||
81 | printf("%s\n\n", ret); |
81 | printf("%s\n\n", ret); |
82 | return false; |
82 | return false; |
83 | } |
83 | } |
84 | 84 | ||
85 | static void run_safe_tests(void) |
85 | static void run_safe_tests(void) |
86 | { |
86 | { |
87 | test_t *test; |
87 | test_t *test; |
88 | unsigned int i = 0; |
88 | unsigned int i = 0; |
89 | unsigned int n = 0; |
89 | unsigned int n = 0; |
90 | 90 | ||
91 | printf("\n*** Running all safe tests ***\n\n"); |
91 | printf("\n*** Running all safe tests ***\n\n"); |
92 | 92 | ||
93 | for (test = tests; test->name != NULL; test++) { |
93 | for (test = tests; test->name != NULL; test++) { |
94 | if (test->safe) { |
94 | if (test->safe) { |
95 | if (run_test(test)) |
95 | if (run_test(test)) |
96 | i++; |
96 | i++; |
97 | else |
97 | else |
98 | n++; |
98 | n++; |
99 | } |
99 | } |
100 | } |
100 | } |
101 | 101 | ||
102 | printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i); |
102 | printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i); |
103 | } |
103 | } |
104 | 104 | ||
105 | static void list_tests(void) |
105 | static void list_tests(void) |
106 | { |
106 | { |
107 | test_t *test; |
107 | test_t *test; |
108 | char c = 'a'; |
108 | char c = 'a'; |
109 | 109 | ||
110 | for (test = tests; test->name != NULL; test++, c++) |
110 | for (test = tests; test->name != NULL; test++, c++) |
111 | printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
111 | printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
112 | 112 | ||
113 | printf("*\t\t\tRun all safe tests\n"); |
113 | printf("*\t\t\tRun all safe tests\n"); |
114 | } |
114 | } |
115 | 115 | ||
116 | int main(int argc, char **argv) |
116 | int main(int argc, char **argv) |
117 | { |
117 | { |
118 | printf("Number of arguments: %d\n", argc); |
118 | printf("Number of arguments: %d\n", argc); |
119 | if (argv) { |
119 | if (argv) { |
120 | printf("Arguments:"); |
120 | printf("Arguments:"); |
121 | while (*argv) { |
121 | while (*argv) { |
122 | printf(" '%s'", *argv++); |
122 | printf(" '%s'", *argv++); |
123 | } |
123 | } |
124 | printf("\n"); |
124 | printf("\n"); |
125 | } |
125 | } |
126 | 126 | ||
127 | while (1) { |
127 | while (1) { |
128 | char c; |
128 | char c; |
129 | test_t *test; |
129 | test_t *test; |
130 | 130 | ||
131 | list_tests(); |
131 | list_tests(); |
132 | printf("> "); |
132 | printf("> "); |
- | 133 | fflush(stdout); |
|
133 | 134 | ||
134 | c = getchar(); |
135 | c = getchar(); |
135 | printf("%c\n", c); |
136 | printf("%c\n", c); |
136 | 137 | ||
137 | if ((c >= 'a') && (c <= 'z')) { |
138 | if ((c >= 'a') && (c <= 'z')) { |
138 | for (test = tests; test->name != NULL; test++, c--) |
139 | for (test = tests; test->name != NULL; test++, c--) |
139 | if (c == 'a') |
140 | if (c == 'a') |
140 | break; |
141 | break; |
141 | 142 | ||
142 | if (test->name == NULL) |
143 | if (test->name == NULL) |
143 | printf("Unknown test\n\n"); |
144 | printf("Unknown test\n\n"); |
144 | else |
145 | else |
145 | run_test(test); |
146 | run_test(test); |
146 | } else if (c == '*') { |
147 | } else if (c == '*') { |
147 | run_safe_tests(); |
148 | run_safe_tests(); |
148 | } else if (c < 0) { |
149 | } else if (c < 0) { |
149 | /* got EOF */ |
150 | /* got EOF */ |
150 | break; |
151 | break; |
151 | } else { |
152 | } else { |
152 | printf("Invalid test\n\n"); |
153 | printf("Invalid test\n\n"); |
153 | } |
154 | } |
154 | 155 | ||
155 | } |
156 | } |
156 | 157 | ||
157 | return 0; |
158 | return 0; |
158 | } |
159 | } |
159 | 160 | ||
160 | /** @} |
161 | /** @} |
161 | */ |
162 | */ |
162 | 163 |