cputimer: Add more IDs for VMM cputimers.
[dragonfly.git] / tools / regression / p1003_1b / main.c
blobd0907244495d273338d91fcf306767a648bd0b5b
1 /* $FreeBSD: src/tools/regression/p1003_1b/main.c,v 1.1 2000/02/16 14:28:40 dufault Exp $ */
2 #include <stdio.h>
3 #include <string.h>
5 int fifo(int argc, char *argv[]);
6 int memlock(int argc, char *argv[]);
7 int p26(int argc, char *argv[]);
8 int sched(int argc, char *argv[]);
9 int yield(int argc, char *argv[]);
11 static struct {
12 const char *t;
13 int (*f)(int, char *[]);
14 int works;
15 } tab[] = {
16 { "fifo", fifo, 1 },
17 { "memlock", memlock, 0 },
18 { "p26", p26, 1 },
19 { "sched", sched, 1 },
20 { "yield", yield, 1 },
23 #define N(T) (sizeof (T)/ sizeof(T[0]))
25 static int usage(int argc, char *argv[])
27 int i;
28 if (argc > 1)
29 fprintf(stderr, "%s is unknown\n", argv[1]);
31 fprintf(stderr, "usage: %s [-a] or one of [", argv[0]);
32 for (i = 0; i < (sizeof(tab) / sizeof(tab[0])); i++)
33 fprintf(stderr, "%s%s", (i)? " | " : "", tab[i].t);
34 fprintf(stderr, "]\n");
36 return -1;
39 int main(int argc, char *argv[])
41 int i;
43 if (argc == 2 && strcmp(argv[1], "-a") == 0) {
44 #if 1
45 fprintf(stderr,
46 "-a should but doesn't really work"
47 " (my notes say \"because things detach\");\n"
48 "meanwhile do these individual tests and look"
49 " for a non-zero exit code:\n");
50 for (i = 0; i < N(tab); i++)
51 if (tab[i].works)
52 fprintf(stderr, "p1003_1b %s\n", tab[i].t);
53 return -1;
54 #else
56 int r;
57 for (i = 0; i < N(tab); i++) {
58 if (tab[i].works) {
59 if ( (r =
60 (*tab[i].f)(argc - 1, argv + 1)) ) {
61 fprintf(stderr,
62 "%s failed\n", tab[i].t);
63 return r;
67 return 0;
69 #endif
72 if (argc > 1) {
73 for (i = 0; i < N(tab); i++)
74 if (strcmp(tab[i].t, argv[1]) == 0)
75 return (*tab[i].f)(argc - 1, argv + 1);
78 return usage(argc, argv);