Subversion Repositories HelenOS

Rev

Rev 2188 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2188 Rev 2193
1
/*
1
/*
2
 * Copyright (c) 2006 Ondrej Palkovsky
2
 * Copyright (c) 2006 Ondrej Palkovsky
3
 * Copyright (c) 2007 Martin Decky
3
 * Copyright (c) 2007 Martin Decky
4
 * All rights reserved.
4
 * All rights reserved.
5
 *
5
 *
6
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
7
 * modification, are permitted provided that the following conditions
8
 * are met:
8
 * are met:
9
 *
9
 *
10
 * - Redistributions of source code must retain the above copyright
10
 * - Redistributions of source code must retain the above copyright
11
 *   notice, this list of conditions and the following disclaimer.
11
 *   notice, this list of conditions and the following disclaimer.
12
 * - Redistributions in binary form must reproduce the above copyright
12
 * - Redistributions in binary form must reproduce the above copyright
13
 *   notice, this list of conditions and the following disclaimer in the
13
 *   notice, this list of conditions and the following disclaimer in the
14
 *   documentation and/or other materials provided with the distribution.
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
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.
16
 *   derived from this software without specific prior written permission.
17
 *
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
28
 */
29
 
29
 
30
/** @addtogroup tester User space Tester
30
/** @addtogroup tester User space Tester
31
 * @brief   User space testing infrastructure.
31
 * @brief   User space testing infrastructure.
32
 * @{
32
 * @{
33
 */
33
 */
34
/**
34
/**
35
 * @file
35
 * @file
36
 */
36
 */
37
 
37
 
38
#include <unistd.h>
38
#include <unistd.h>
39
#include <stdio.h>
39
#include <stdio.h>
40
#include "tester.h"
40
#include "tester.h"
41
 
41
 
42
int myservice = 0;
42
int myservice = 0;
43
int phones[MAX_PHONES];
43
int phones[MAX_PHONES];
44
int connections[MAX_CONNECTIONS];
44
int connections[MAX_CONNECTIONS];
45
ipc_callid_t callids[MAX_CONNECTIONS];
45
ipc_callid_t callids[MAX_CONNECTIONS];
46
 
46
 
47
test_t tests[] = {
47
test_t tests[] = {
48
#include "thread/thread1.def"
48
#include "thread/thread1.def"
49
#include "print/print1.def"
49
#include "print/print1.def"
-
 
50
#include "fault/fault1.def"
-
 
51
#include "fault/fault2.def"
50
#include "ipc/register.def"
52
#include "ipc/register.def"
51
#include "ipc/connect.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"
52
    {NULL, NULL, NULL}
58
    {NULL, NULL, NULL}
53
};
59
};
54
 
60
 
55
static bool run_test(test_t *test)
61
static bool run_test(test_t *test)
56
{
62
{
57
    printf("%s\t\t%s\n", test->name, test->desc);
63
    printf("%s\t\t%s\n", test->name, test->desc);
58
   
64
   
59
    /* Execute the test */
65
    /* Execute the test */
60
    char * ret = test->entry(false);
66
    char * ret = test->entry(false);
61
   
67
   
62
    if (ret == NULL) {
68
    if (ret == NULL) {
63
        printf("Test passed\n\n");
69
        printf("Test passed\n\n");
64
        return true;
70
        return true;
65
    }
71
    }
66
 
72
 
67
    printf("%s\n\n", ret);
73
    printf("%s\n\n", ret);
68
    return false;
74
    return false;
69
}
75
}
70
 
76
 
71
static void run_safe_tests(void)
77
static void run_safe_tests(void)
72
{
78
{
73
}
79
}
74
 
80
 
75
static void list_tests(void)
81
static void list_tests(void)
76
{
82
{
77
    test_t *test;
83
    test_t *test;
78
    char c = 'a';
84
    char c = 'a';
79
   
85
   
80
    for (test = tests; test->name != NULL; test++, c++)
86
    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)"));
87
        printf("%c\t%s\t\t%s%s\n", c, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
82
   
88
   
83
    printf("*\t\t\tRun all safe tests\n");
89
    printf("*\t\t\tRun all safe tests\n");
84
}
90
}
85
 
91
 
86
int main(void)
92
int main(void)
87
{
93
{
88
    while (1) {
94
    while (1) {
89
        char c;
95
        char c;
90
        test_t *test;
96
        test_t *test;
91
       
97
       
92
        list_tests();
98
        list_tests();
93
        printf("> ");
99
        printf("> ");
94
       
100
       
95
        c = getchar();
101
        c = getchar();
96
        printf("%c\n", c);
102
        printf("%c\n", c);
97
       
103
       
98
        if ((c >= 'a') && (c <= 'z')) {
104
        if ((c >= 'a') && (c <= 'z')) {
99
            for (test = tests; test->name != NULL; test++, c--)
105
            for (test = tests; test->name != NULL; test++, c--)
100
                if (c == 'a')
106
                if (c == 'a')
101
                    break;
107
                    break;
102
           
108
           
103
            if (c > 'a')
109
            if (c > 'a')
104
                printf("Unknown test\n\n");
110
                printf("Unknown test\n\n");
105
            else
111
            else
106
                run_test(test);
112
                run_test(test);
107
        } else if (c == '*')
113
        } else if (c == '*')
108
            run_safe_tests();
114
            run_safe_tests();
109
        else
115
        else
110
            printf("Invalid test\n\n");
116
            printf("Invalid test\n\n");
111
    }
117
    }
112
}
118
}
113
 
119
 
114
/** @}
120
/** @}
115
 */
121
 */
116
 
122