From 4b872fe1c447a48d71f239486b1d8bf5761ea090 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 7 Nov 2006 05:32:43 +0000 Subject: [PATCH] Failure injection command changed --- Robust/src/Runtime/runtime.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index f227e463..23e5b29a 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -37,6 +37,7 @@ int debugtask=0; int injectinstructionfailures; int failurecount; float instfailurechance=0; +int numfailures; void processOptions() { int i; @@ -69,14 +70,23 @@ void processOptions() { if (options!=NULL) options++; if (options==NULL) break; + + sscanf(options, "%f", &instfailurechance); options=strchr(options,' '); if (options!=NULL) options++; + if (options==NULL) + break; + + sscanf(options, "%d", &numfailures); + options=strchr(options,' '); + if (options!=NULL) options++; + instructioncount=failurecount; injectinstructionfailures=1; + printf("Number of failures=%d\n",numfailures); printf("Injecting errors with count=%d\n",failurecount); printf("Injecting errors with chance=%f\n",instfailurechance); - } else if (strncmp(options, "-debugtask",sizeof("-debugtask")-1)==0) { options=strchr(options,' '); if (options!=NULL) options++; @@ -448,6 +458,10 @@ void processtasks() { void injectinstructionfailure() { #ifdef TASK if (injectinstructionfailures) { + if (numfailures==0) + return; + if (numfailures>0) + numfailures--; instructioncount=failurecount; if ((((double)random())/RAND_MAX)