0001
0002
0003
0004
0005
0006 #include <getopt.h>
0007 #include <stdlib.h>
0008 #include <string.h>
0009 #include <stdio.h>
0010
0011 #include "osnoise.h"
0012 #include "timerlat.h"
0013
0014
0015
0016
0017 static void rtla_usage(void)
0018 {
0019 int i;
0020
0021 static const char *msg[] = {
0022 "",
0023 "rtla version " VERSION,
0024 "",
0025 " usage: rtla COMMAND ...",
0026 "",
0027 " commands:",
0028 " osnoise - gives information about the operating system noise (osnoise)",
0029 " timerlat - measures the timer irq and thread latency",
0030 "",
0031 NULL,
0032 };
0033
0034 for (i = 0; msg[i]; i++)
0035 fprintf(stderr, "%s\n", msg[i]);
0036 exit(1);
0037 }
0038
0039
0040
0041
0042
0043
0044
0045 int run_command(int argc, char **argv, int start_position)
0046 {
0047 if (strcmp(argv[start_position], "osnoise") == 0) {
0048 osnoise_main(argc-start_position, &argv[start_position]);
0049 goto ran;
0050 } else if (strcmp(argv[start_position], "timerlat") == 0) {
0051 timerlat_main(argc-start_position, &argv[start_position]);
0052 goto ran;
0053 }
0054
0055 return 0;
0056 ran:
0057 return 1;
0058 }
0059
0060 int main(int argc, char *argv[])
0061 {
0062 int retval;
0063
0064
0065 retval = run_command(argc, argv, 0);
0066 if (retval)
0067 exit(0);
0068
0069 if (argc < 2)
0070 goto usage;
0071
0072 if (strcmp(argv[1], "-h") == 0) {
0073 rtla_usage();
0074 exit(0);
0075 } else if (strcmp(argv[1], "--help") == 0) {
0076 rtla_usage();
0077 exit(0);
0078 }
0079
0080 retval = run_command(argc, argv, 1);
0081 if (retval)
0082 exit(0);
0083
0084 usage:
0085 rtla_usage();
0086 exit(1);
0087 }