Rev 2186 | Rev 2193 | 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" |
||
50 | #include "ipc/register.def" |
||
51 | #include "ipc/connect.def" |
||
52 | {NULL, NULL, NULL} |
||
53 | }; |
||
1596 | palkovsky | 54 | |
2188 | decky | 55 | static bool run_test(test_t *test) |
1596 | palkovsky | 56 | { |
2188 | decky | 57 | printf("%s\t\t%s\n", test->name, test->desc); |
1596 | palkovsky | 58 | |
2188 | decky | 59 | /* Execute the test */ |
60 | char * ret = test->entry(false); |
||
61 | |||
62 | if (ret == NULL) { |
||
63 | printf("Test passed\n\n"); |
||
64 | return true; |
||
1596 | palkovsky | 65 | } |
66 | |||
2188 | decky | 67 | printf("%s\n\n", ret); |
68 | return false; |
||
1596 | palkovsky | 69 | } |
70 | |||
2188 | decky | 71 | static void run_safe_tests(void) |
1596 | palkovsky | 72 | { |
73 | } |
||
74 | |||
2188 | decky | 75 | static void list_tests(void) |
1596 | palkovsky | 76 | { |
2188 | decky | 77 | test_t *test; |
78 | char c = 'a'; |
||
1596 | palkovsky | 79 | |
2188 | decky | 80 | for (test = tests; test->name != NULL; test++, c++) |
81 | printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
||
1596 | palkovsky | 82 | |
2188 | decky | 83 | printf("*\t\t\tRun all safe tests\n"); |
1596 | palkovsky | 84 | } |
85 | |||
86 | int main(void) |
||
87 | { |
||
88 | while (1) { |
||
2188 | decky | 89 | char c; |
90 | test_t *test; |
||
91 | |||
92 | list_tests(); |
||
93 | printf("> "); |
||
94 | |||
1596 | palkovsky | 95 | c = getchar(); |
2188 | decky | 96 | printf("%c\n", c); |
97 | |||
98 | if ((c >= 'a') && (c <= 'z')) { |
||
99 | for (test = tests; test->name != NULL; test++, c--) |
||
100 | if (c == 'a') |
||
101 | break; |
||
102 | |||
103 | if (c > 'a') |
||
104 | printf("Unknown test\n\n"); |
||
105 | else |
||
106 | run_test(test); |
||
107 | } else if (c == '*') |
||
108 | run_safe_tests(); |
||
109 | else |
||
110 | printf("Invalid test\n\n"); |
||
1596 | palkovsky | 111 | } |
112 | } |
||
1653 | cejka | 113 | |
114 | /** @} |
||
115 | */ |