Changeset 2d11a7d8 in mainline for uspace/app/tester/tester.c
- Timestamp:
- 2009-06-30T15:54:14Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9c40f883
- Parents:
- db24058
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/tester.c
rdb24058 r2d11a7d8 28 28 */ 29 29 30 /** @addtogroup tester User space Tester31 * @brief 30 /** @addtogroup tester User space tester 31 * @brief User space testing infrastructure. 32 32 * @{ 33 */ 33 */ 34 34 /** 35 35 * @file … … 38 38 #include <unistd.h> 39 39 #include <stdio.h> 40 #include <string.h> 40 41 #include "tester.h" 41 42 42 int myservice = 0; 43 int phones[MAX_PHONES]; 44 int connections[MAX_CONNECTIONS]; 45 ipc_callid_t callids[MAX_CONNECTIONS]; 43 bool test_quiet; 44 int test_argc; 45 char **test_argv; 46 46 47 47 test_t tests[] = { 48 48 #include "thread/thread1.def" 49 49 #include "print/print1.def" 50 #include "print/print2.def" 51 #include "print/print3.def" 50 52 #include "print/print4.def" 51 #include "fault/fault1.def"52 #include "fault/fault2.def"53 #include "ipc/register.def"54 #include "ipc/connect.def"55 #include "ipc/send_async.def"56 #include "ipc/send_sync.def"57 #include "ipc/answer.def"58 #include "ipc/hangup.def"59 #include "ipc/ping_pong.def"60 #include "devmap/devmap1.def"61 #include "loop/loop1.def"62 #include "vfs/vfs1.def"63 53 #include "console/console1.def" 64 54 #include "stdio/stdio1.def" 65 55 #include "stdio/stdio2.def" 66 {NULL, NULL, NULL} 56 #include "fault/fault1.def" 57 #include "fault/fault2.def" 58 #include "vfs/vfs1.def" 59 #include "ipc/ping_pong.def" 60 #include "ipc/register.def" 61 #include "ipc/connect.def" 62 #include "loop/loop1.def" 63 #include "mm/malloc1.def" 64 {NULL, NULL, NULL, false} 67 65 }; 68 66 69 67 static bool run_test(test_t *test) 70 68 { 71 printf("%s\t\t%s\n", test->name, test->desc);72 73 69 /* Execute the test */ 74 char * ret = test->entry(false);70 char *ret = test->entry(); 75 71 76 72 if (ret == NULL) { 77 printf(" Test passed\n\n");73 printf("\nTest passed\n"); 78 74 return true; 79 75 } 80 81 printf(" %s\n\n", ret);76 77 printf("\n%s\n", ret); 82 78 return false; 83 79 } … … 88 84 unsigned int i = 0; 89 85 unsigned int n = 0; 90 86 91 87 printf("\n*** Running all safe tests ***\n\n"); 92 88 93 89 for (test = tests; test->name != NULL; test++) { 94 90 if (test->safe) { 91 printf("%s (%s)\n", test->name, test->desc); 95 92 if (run_test(test)) 96 93 i++; … … 99 96 } 100 97 } 101 102 printf("\n Safe tests completed, %u tests run, %u passed.\n\n", i + n, i);98 99 printf("\nCompleted, %u tests run, %u passed.\n", i + n, i); 103 100 } 104 101 105 102 static void list_tests(void) 106 103 { 104 size_t len = 0; 107 105 test_t *test; 108 char c = 'a'; 106 for (test = tests; test->name != NULL; test++) { 107 if (str_length(test->name) > len) 108 len = str_length(test->name); 109 } 109 110 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 for (test = tests; test->name != NULL; test++) 112 printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); 112 113 113 printf(" *\t\t\tRun all safe tests\n");114 printf("%-*s Run all safe tests\n", len, "*"); 114 115 } 115 116 116 int main(int argc, char * *argv)117 int main(int argc, char *argv[]) 117 118 { 118 printf("Number of arguments: %d\n", argc); 119 if (argv) { 120 printf("Arguments:"); 121 while (*argv) { 122 printf(" '%s'", *argv++); 119 if (argc < 2) { 120 printf("Usage:\n\n"); 121 printf("%s <test> [args ...]\n\n", argv[0]); 122 list_tests(); 123 return 0; 124 } 125 126 test_quiet = false; 127 test_argc = argc - 2; 128 test_argv = argv + 2; 129 130 if (str_cmp(argv[1], "*") == 0) { 131 run_safe_tests(); 132 return 0; 133 } 134 135 test_t *test; 136 for (test = tests; test->name != NULL; test++) { 137 if (str_cmp(argv[1], test->name) == 0) { 138 return (run_test(test) ? 0 : -1); 123 139 } 124 printf("\n");125 140 } 126 127 while (1) { 128 char c; 129 test_t *test; 130 131 list_tests(); 132 printf("> "); 133 fflush(stdout); 134 135 c = getchar(); 136 printf("%c\n", c); 137 138 if ((c >= 'a') && (c <= 'z')) { 139 for (test = tests; test->name != NULL; test++, c--) 140 if (c == 'a') 141 break; 142 143 if (test->name == NULL) 144 printf("Unknown test\n\n"); 145 else 146 run_test(test); 147 } else if (c == '*') { 148 run_safe_tests(); 149 } else if (c < 0) { 150 /* got EOF */ 151 break; 152 } else { 153 printf("Invalid test\n\n"); 154 } 155 156 } 157 158 return 0; 141 142 printf("Unknown test \"%s\"\n", argv[1]); 143 return -2; 159 144 } 160 145
Note:
See TracChangeset
for help on using the changeset viewer.