source: mainline/uspace/app/tester/tester.c@ 04b687b

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 04b687b was 04b687b, checked in by Jiri Svoboda <jirik.svoboda@…>, 17 years ago

Some ANSI C stream functions (stdio).

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
3 * Copyright (c) 2007 Martin Decky
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
30/** @addtogroup tester User space Tester
31 * @brief User space testing infrastructure.
32 * @{
33 */
34/**
35 * @file
36 */
37
38#include <unistd.h>
39#include <stdio.h>
40#include "tester.h"
41
42int myservice = 0;
43int phones[MAX_PHONES];
44int connections[MAX_CONNECTIONS];
45ipc_callid_t callids[MAX_CONNECTIONS];
46
47test_t tests[] = {
48#include "thread/thread1.def"
49#include "print/print1.def"
50#include "fault/fault1.def"
51#include "fault/fault2.def"
52#include "ipc/register.def"
53#include "ipc/connect.def"
54#include "ipc/send_async.def"
55#include "ipc/send_sync.def"
56#include "ipc/answer.def"
57#include "ipc/hangup.def"
58#include "devmap/devmap1.def"
59#include "loop/loop1.def"
60#include "vfs/vfs1.def"
61#include "console/console1.def"
62#include "stdio/stdio1.def"
63 {NULL, NULL, NULL}
64};
65
66static bool run_test(test_t *test)
67{
68 printf("%s\t\t%s\n", test->name, test->desc);
69
70 /* Execute the test */
71 char * ret = test->entry(false);
72
73 if (ret == NULL) {
74 printf("Test passed\n\n");
75 return true;
76 }
77
78 printf("%s\n\n", ret);
79 return false;
80}
81
82static void run_safe_tests(void)
83{
84 test_t *test;
85 unsigned int i = 0;
86 unsigned int n = 0;
87
88 printf("\n*** Running all safe tests ***\n\n");
89
90 for (test = tests; test->name != NULL; test++) {
91 if (test->safe) {
92 if (run_test(test))
93 i++;
94 else
95 n++;
96 }
97 }
98
99 printf("\nSafe tests completed, %u tests run, %u passed.\n\n", i + n, i);
100}
101
102static void list_tests(void)
103{
104 test_t *test;
105 char c = 'a';
106
107 for (test = tests; test->name != NULL; test++, c++)
108 printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
109
110 printf("*\t\t\tRun all safe tests\n");
111}
112
113int main(int argc, char **argv)
114{
115 printf("Number of arguments: %d\n", argc);
116 if (argv) {
117 printf("Arguments:");
118 while (*argv) {
119 printf(" '%s'", *argv++);
120 }
121 printf("\n");
122 }
123
124 while (1) {
125 char c;
126 test_t *test;
127
128 list_tests();
129 printf("> ");
130
131 c = getchar();
132 printf("%c\n", c);
133
134 if ((c >= 'a') && (c <= 'z')) {
135 for (test = tests; test->name != NULL; test++, c--)
136 if (c == 'a')
137 break;
138
139 if (test->name == NULL)
140 printf("Unknown test\n\n");
141 else
142 run_test(test);
143 } else if (c == '*') {
144 run_safe_tests();
145 } else if (c < 0) {
146 /* got EOF */
147 break;
148 } else {
149 printf("Invalid test\n\n");
150 }
151
152 }
153
154 return 0;
155}
156
157/** @}
158 */
Note: See TracBrowser for help on using the repository browser.