This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 #include "option.h"
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include "runtime.h"
6 #include <stdlib.h>
7
8 extern char *options;
9 extern int injectfailures;
10 extern float failurechance;
11 extern int debugtask;
12 extern int errors;
13 extern int injectinstructionfailures;
14 extern int failurecount;
15 extern float instfailurechance;
16 extern int numfailures;
17 extern int instaccum;
18 extern char ** environ;
19
20 void processOptions() {
21   int i;
22   options=NULL;
23   for(i=0; environ[i]!=0; i++) {
24     if (strncmp(environ[i],"BRISTLECONE=",12)==0) {
25       options=environ[i]+12;
26       break;
27     }
28   }
29
30   while(options!=NULL) {
31     if (strncmp(options,"-injectfailures",sizeof("-injectfailures")-1)==0) {
32       options=strchr(options,' ');
33       if (options!=NULL) options++;
34       if (options==NULL)
35         break;
36       sscanf(options, "%f", &failurechance);
37       injectfailures=1;
38       printf("Injecting errors with chance=%f\n",failurechance);
39       options=strchr(options,' ');
40       if (options!=NULL) options++;
41     } else if (strncmp(options,"-injectinstructionfailures",sizeof("-injectinstructionfailures")-1)==0) {
42       options=strchr(options,' ');
43       if (options!=NULL) options++;
44       if (options==NULL)
45         break;
46       sscanf(options, "%d", &failurecount);
47       options=strchr(options,' ');
48       if (options!=NULL) options++;
49       if (options==NULL)
50         break;
51
52       sscanf(options, "%f", &instfailurechance);
53       options=strchr(options,' ');
54       if (options!=NULL) options++;
55       if (options==NULL)
56         break;
57
58       sscanf(options, "%d", &numfailures);
59       options=strchr(options,' ');
60       if (options!=NULL) options++;
61
62       instaccum=failurecount;
63       instructioncount=failurecount;
64       injectinstructionfailures=1;
65       printf("Number of failures=%d\n",numfailures);
66       printf("Injecting errors with count=%d\n",failurecount);
67       printf("Injecting errors with chance=%f\n",instfailurechance);
68     } else if (strncmp(options, "-debugtask",sizeof("-debugtask")-1)==0) {
69       options=strchr(options,' ');
70       if (options!=NULL) options++;
71       debugtask=1;
72       printf("Debug task option on.\n");
73     } else if (strncmp(options, "-errors",sizeof("-errors")-1)==0) {
74       options=strchr(options,' ');
75       if (options!=NULL) options++;
76       errors=1;
77       printf("Errors on.\n");
78     } else if (strncmp(options, "-initializerandom", sizeof("-initializerandom")-1)==0) {
79       options=strchr(options,' ');
80       if (options!=NULL) options++;
81       printf("Initializing random number generator.\n");
82       srandom(time(NULL));
83     } else
84       break;
85   }
86 }