Rev 3386 | Rev 4263 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1653 | cejka | 1 | /* |
2071 | jermar | 2 | * Copyright (c) 2006 Ondrej Palkovsky |
2188 | decky | 3 | * Copyright (c) 2007 Martin Decky |
1653 | cejka | 4 | * All rights reserved. |
5 | * |
||
6 | * Redistribution and use in source and binary forms, with or without |
||
7 | * modification, are permitted provided that the following conditions |
||
8 | * are met: |
||
9 | * |
||
10 | * - Redistributions of source code must retain the above copyright |
||
11 | * notice, this list of conditions and the following disclaimer. |
||
12 | * - Redistributions in binary form must reproduce the above copyright |
||
13 | * notice, this list of conditions and the following disclaimer in the |
||
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 |
||
16 | * derived from this software without specific prior written permission. |
||
17 | * |
||
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 |
||
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
28 | */ |
||
29 | |||
2188 | decky | 30 | /** @addtogroup tester User space Tester |
31 | * @brief User space testing infrastructure. |
||
1653 | cejka | 32 | * @{ |
33 | */ |
||
34 | /** |
||
35 | * @file |
||
36 | */ |
||
37 | |||
2188 | decky | 38 | #include <unistd.h> |
1596 | palkovsky | 39 | #include <stdio.h> |
2188 | decky | 40 | #include "tester.h" |
1596 | palkovsky | 41 | |
2188 | decky | 42 | int myservice = 0; |
43 | int phones[MAX_PHONES]; |
||
44 | int connections[MAX_CONNECTIONS]; |
||
45 | ipc_callid_t callids[MAX_CONNECTIONS]; |
||
1596 | palkovsky | 46 | |
2188 | decky | 47 | test_t tests[] = { |
48 | #include "thread/thread1.def" |
||
49 | #include "print/print1.def" |
||
2193 | decky | 50 | #include "fault/fault1.def" |
51 | #include "fault/fault2.def" |
||
2188 | decky | 52 | #include "ipc/register.def" |
53 | #include "ipc/connect.def" |
||
2193 | decky | 54 | #include "ipc/send_async.def" |
55 | #include "ipc/send_sync.def" |
||
56 | #include "ipc/answer.def" |
||
57 | #include "ipc/hangup.def" |
||
2594 | cejka | 58 | #include "devmap/devmap1.def" |
4153 | mejdrech | 59 | #include "loop/loop1.def" |
2656 | jermar | 60 | #include "vfs/vfs1.def" |
4153 | mejdrech | 61 | #include "console/console1.def" |
62 | #include "stdio/stdio1.def" |
||
63 | #include "stdio/stdio2.def" |
||
2188 | decky | 64 | {NULL, NULL, NULL} |
65 | }; |
||
1596 | palkovsky | 66 | |
2188 | decky | 67 | static bool run_test(test_t *test) |
1596 | palkovsky | 68 | { |
2188 | decky | 69 | printf("%s\t\t%s\n", test->name, test->desc); |
1596 | palkovsky | 70 | |
2188 | decky | 71 | /* Execute the test */ |
72 | char * ret = test->entry(false); |
||
73 | |||
74 | if (ret == NULL) { |
||
75 | printf("Test passed\n\n"); |
||
76 | return true; |
||
1596 | palkovsky | 77 | } |
78 | |||
2188 | decky | 79 | printf("%s\n\n", ret); |
80 | return false; |
||
1596 | palkovsky | 81 | } |
82 | |||
2188 | decky | 83 | static void run_safe_tests(void) |
1596 | palkovsky | 84 | { |
2785 | jermar | 85 | test_t *test; |
2786 | decky | 86 | unsigned int i = 0; |
87 | unsigned int n = 0; |
||
2785 | jermar | 88 | |
2786 | decky | 89 | printf("\n*** Running all safe tests ***\n\n"); |
2785 | jermar | 90 | |
91 | for (test = tests; test->name != NULL; test++) { |
||
92 | if (test->safe) { |
||
93 | if (run_test(test)) |
||
94 | i++; |
||
95 | else |
||
96 | n++; |
||
97 | } |
||
98 | } |
||
99 | |||
2786 | decky | 100 | printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i); |
1596 | palkovsky | 101 | } |
102 | |||
2188 | decky | 103 | static void list_tests(void) |
1596 | palkovsky | 104 | { |
2188 | decky | 105 | test_t *test; |
106 | char c = 'a'; |
||
1596 | palkovsky | 107 | |
2188 | decky | 108 | for (test = tests; test->name != NULL; test++, c++) |
109 | printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
||
1596 | palkovsky | 110 | |
2188 | decky | 111 | printf("*\t\t\tRun all safe tests\n"); |
1596 | palkovsky | 112 | } |
113 | |||
3222 | svoboda | 114 | int main(int argc, char **argv) |
1596 | palkovsky | 115 | { |
3222 | svoboda | 116 | printf("Number of arguments: %d\n", argc); |
117 | if (argv) { |
||
118 | printf("Arguments:"); |
||
119 | while (*argv) { |
||
120 | printf(" '%s'", *argv++); |
||
121 | } |
||
122 | printf("\n"); |
||
123 | } |
||
124 | |||
1596 | palkovsky | 125 | while (1) { |
2188 | decky | 126 | char c; |
127 | test_t *test; |
||
128 | |||
129 | list_tests(); |
||
130 | printf("> "); |
||
131 | |||
1596 | palkovsky | 132 | c = getchar(); |
2188 | decky | 133 | printf("%c\n", c); |
134 | |||
135 | if ((c >= 'a') && (c <= 'z')) { |
||
136 | for (test = tests; test->name != NULL; test++, c--) |
||
137 | if (c == 'a') |
||
138 | break; |
||
139 | |||
4153 | mejdrech | 140 | if (test->name == NULL) |
2188 | decky | 141 | printf("Unknown test\n\n"); |
142 | else |
||
143 | run_test(test); |
||
3117 | svoboda | 144 | } else if (c == '*') { |
2188 | decky | 145 | run_safe_tests(); |
3117 | svoboda | 146 | } else if (c < 0) { |
147 | /* got EOF */ |
||
148 | break; |
||
149 | } else { |
||
2188 | decky | 150 | printf("Invalid test\n\n"); |
3117 | svoboda | 151 | } |
152 | |||
1596 | palkovsky | 153 | } |
4153 | mejdrech | 154 | |
155 | return 0; |
||
1596 | palkovsky | 156 | } |
1653 | cejka | 157 | |
158 | /** @} |
||
159 | */ |