Add the bytes field in the mptp_dest structure.
[swifty.git] / src / kernel / test / test.c
1 /*
2  * Test swift. Imports functions from test_sw_* files and runs tests.
3  */
4
5 #include <stdio.h>
6 #include <string.h>
7 #include <stdlib.h>
8
9 #include "debug.h"
10 #include "util.h"
11
12 #include "test_sw.h"
13
14 static void (*test_fun_array[])(void) = {
15         NULL,
16         test_dummy,
17         socket_test_suite,
18         bind_test_suite,
19         getsockname_test_suite,
20         getsockopt_test_suite,
21         sendto_test_suite,
22         recvfrom_test_suite,
23         sendmsg_test_suite,
24         recvmsg_test_suite,
25         close_test_suite,
26 };
27
28 static void usage(const char *argv0)
29 {
30         fprintf(stderr, "Usage: %s [test_no]\n\n", argv0);
31         exit(EXIT_FAILURE);
32 }
33
34 /*
35  * In case of no arguments call all functions defined in test_fun_array.
36  */
37
38 int main(int argc, char **argv)
39 {
40         int test_idx;
41
42         /* No arguments: call all test functions. */
43         if (argc == 1) {
44                 int i;
45                 for (i = 1; i < sizeof(test_fun_array)/sizeof(test_fun_array[0]); i++)
46                         test_fun_array[i]();
47                 return 0;
48         }
49
50         if (argc != 2)
51                 usage(argv[0]);
52
53         test_idx = atoi(argv[1]);
54
55         if (test_idx < 1 || test_idx >= sizeof(test_fun_array)/sizeof(test_fun_array[0])) {
56                 fprintf(stderr, "Error: test index %d is out of bounds\n", test_idx);
57                 exit(EXIT_FAILURE);
58         }
59
60         test_fun_array[test_idx]();
61
62         return 0;
63 }