source: mainline/uspace/app/tester/tester.c@ c07544d3

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

UCS test in userspace.

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