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 injectinstructionfailures;
13 extern int failurecount;
14 extern float instfailurechance;
15 extern int numfailures;
16 extern int instaccum;
17 extern char ** environ;
18
19 void processOptions() {
20   int i;
21   options=NULL;
22   for(i=0;environ[i]!=0;i++) {
23     if (strncmp(environ[i],"BRISTLECONE=",12)==0) {
24       options=environ[i]+12;
25       break;
26     }
27   }
28   
29   while(options!=NULL) {
30     if (strncmp(options,"-injectfailures",sizeof("-injectfailures")-1)==0) {
31       options=strchr(options,' ');
32       if (options!=NULL) options++;
33       if (options==NULL)
34         break;
35       sscanf(options, "%f", &failurechance);
36       injectfailures=1;
37       printf("Injecting errors with chance=%f\n",failurechance);
38       options=strchr(options,' ');
39       if (options!=NULL) options++;
40     } else if (strncmp(options,"-injectinstructionfailures",sizeof("-injectinstructionfailures")-1)==0) {
41       options=strchr(options,' ');
42       if (options!=NULL) options++;
43       if (options==NULL)
44         break;
45       sscanf(options, "%d", &failurecount);
46       options=strchr(options,' ');
47       if (options!=NULL) options++;
48       if (options==NULL)
49         break;
50
51       sscanf(options, "%f", &instfailurechance);
52       options=strchr(options,' ');
53       if (options!=NULL) options++;
54       if (options==NULL)
55         break;
56
57       sscanf(options, "%d", &numfailures);
58       options=strchr(options,' ');
59       if (options!=NULL) options++;
60
61       instaccum=failurecount;
62       instructioncount=failurecount;
63       injectinstructionfailures=1;
64       printf("Number of failures=%d\n",numfailures);
65       printf("Injecting errors with count=%d\n",failurecount);
66       printf("Injecting errors with chance=%f\n",instfailurechance);
67     } else if (strncmp(options, "-debugtask",sizeof("-debugtask")-1)==0) {
68       options=strchr(options,' ');
69       if (options!=NULL) options++;
70       debugtask=1;
71       printf("Debug task option on.\n");
72     } else if (strncmp(options, "-initializerandom", sizeof("-initializerandom")-1)==0) {
73       options=strchr(options,' ');
74       if (options!=NULL) options++;
75       printf("Initializing random number generator.\n");
76       srandom(time(NULL));
77     } else
78       break;
79   }
80 }