1
2
3
4
5
6#include <getopt.h>
7#include <stdlib.h>
8#include <string.h>
9#include <stdio.h>
10
11#include "osnoise.h"
12#include "timerlat.h"
13
14
15
16
17static void rtla_usage(void)
18{
19 int i;
20
21 static const char *msg[] = {
22 "",
23 "rtla version " VERSION,
24 "",
25 " usage: rtla COMMAND ...",
26 "",
27 " commands:",
28 " osnoise - gives information about the operating system noise (osnoise)",
29 " timerlat - measures the timer irq and thread latency",
30 "",
31 NULL,
32 };
33
34 for (i = 0; msg[i]; i++)
35 fprintf(stderr, "%s\n", msg[i]);
36 exit(1);
37}
38
39
40
41
42
43
44
45int run_command(int argc, char **argv, int start_position)
46{
47 if (strcmp(argv[start_position], "osnoise") == 0) {
48 osnoise_main(argc-start_position, &argv[start_position]);
49 goto ran;
50 } else if (strcmp(argv[start_position], "timerlat") == 0) {
51 timerlat_main(argc-start_position, &argv[start_position]);
52 goto ran;
53 }
54
55 return 0;
56ran:
57 return 1;
58}
59
60int main(int argc, char *argv[])
61{
62 int retval;
63
64
65 retval = run_command(argc, argv, 0);
66 if (retval)
67 exit(0);
68
69 if (argc < 2)
70 goto usage;
71
72 if (strcmp(argv[1], "-h") == 0) {
73 rtla_usage();
74 exit(0);
75 } else if (strcmp(argv[1], "--help") == 0) {
76 rtla_usage();
77 exit(0);
78 }
79
80 retval = run_command(argc, argv, 1);
81 if (retval)
82 exit(0);
83
84usage:
85 rtla_usage();
86 exit(1);
87}
88