1 /*
2 * systest.c -- Test code for nooks system calls
3 *
4 * Copyright (C) 2002 Mike Swift
5 *
6 * The source code in this file can be freely used, adapted,
7 * and redistributed in source or binary form, so long as an
8 * acknowledgment appears in derived source files.
9 * No warranty is attached;
10 * we cannot take responsibility for errors or fitness for use.
11 *
12 */
13
14 #include <sys/types.h>
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <string.h>
18 #include <errno.h>
19
20 #include "swifi.h"
21 #include "extra.h"
22
23 void
usage(char * name)24 usage(char *name)
25 {
26 printf("Usage: %s -f module_name pid fault-type fault-count seed\n", name);
27
28 exit(EXIT_FAILURE);
29 }
30
31 int
main(int argc,char * argv[])32 main(int argc, char * argv[])
33 {
34 char * module_name = NULL;
35 int i;
36 unsigned int cmd = 0;
37 unsigned long arg = 0;
38 unsigned long seed = 157;
39
40 if (argc < 2) {
41 usage(argv[0]);
42 }
43
44 for (i = 1; i < argc; i++ ) {
45 if (strcmp(argv[i], "-f") == 0) {
46 if (argc <= i+5) {
47 usage(argv[0]);
48 }
49 module_name = victim_exe = argv[++i];
50 sscanf(argv[++i],"%u", &victim_pid);
51 sscanf(argv[++i],"%u", &cmd);
52 sscanf(argv[++i],"%lu", &arg);
53 sscanf(argv[++i],"%lu", &seed);
54 } else {
55 printf("Unknown command %s\n", argv[i]);
56 usage(argv[0]);
57 }
58 }
59
60 /* Do the injection. */
61 swifi_inject_fault(module_name,
62 cmd, /* fault type */
63 seed, /* random seed */
64 arg); /* numFaults */
65
66 return EXIT_SUCCESS;
67 }
68