old_contents: #!/usr/bin/env python
  
  import argparse
  from subprocess import call
  
  import os, sys
  sys.path.append(os.getcwd() + "/configs/fault_injector")
  
  from FaultParser import *
  
  parser = argparse.ArgumentParser(description='Gem5')
  parser.add_argument('-b', '--benchmarks', type=str, dest='benchmarks',
                      nargs='+', help='Benchmark set for the simulation')
  
  parser.add_argument('-i', '--fault-input', type=str, dest='faultInput',
                      nargs='+', help='Fault source files')
  
  args = parser.parse_args()
  
  for benchmark in args.benchmarks:
      print "\n\nRunning " + benchmark + " GOLDEN\n"
      call(["./build/ALPHA/gem5.opt",
          "--stats-file", benchmark.split("/")[-1] + "_" +
          "GOLDEN.txt",
          "configs/fault_injector/injector_system.py",
          "-b", benchmark ])
  
      for inputFile in args.faultInput:
          fp = FaultParser(inputFile)
          while fp.hasNext():
              fe = fp.next()
              print "\n\nRunning " + benchmark + " with fault:\n" + str(fe)
              call(["./build/ALPHA/gem5.opt",
                  "--stats-file", benchmark.split("/")[-1] + "_" +
                  fe.label + ".txt",
                  "configs/fault_injector/injector_system.py",
                  "-fe",
                  "-b", benchmark,
                  "-l", fe.label,
                  "-sb", fe.stuckBit,
                  "-f", fe.field,
                  "-e", fe.entry,
                  "-bp", fe.bitPosition,
                  "-tb", fe.tickBegin,
                  "-te", fe.tickEnd])
  
new_contents: #!/usr/bin/env python
  
  import argparse
  from subprocess import call
  
  import os, sys
  sys.path.append(os.getcwd() + "/configs/fault_injector")
  
  from FaultParser import *
  
  parser = argparse.ArgumentParser(description='Gem5')
  parser.add_argument('-b', '--benchmarks', type=str, dest='benchmarks',
                      nargs='+', help='Benchmark set for the simulation')
  
  parser.add_argument('-i', '--fault-input', type=str, dest='faultInput',
                      nargs='+', help='Fault source files')
  
  args = parser.parse_args()
  
  # Run a simulation for each specified benchmark program
  for benchmark in args.benchmarks:
      print "\n\nRunning " + benchmark + " GOLDEN\n"
  
      # Create a folder to store stats releated to the current benchmark
      statFolder = benchmark.split("/")[-1]
      if not os.path.exists("m5out/" + statFolder):
          os.makedirs("m5out/" + statFolder)
  
      # Run Golden simulation
      call(["./build/ALPHA/gem5.opt",
          "--stats-file", statFolder + "/" +
          "GOLDEN.txt",
          "configs/fault_injector/injector_system.py",
          "-b", benchmark ])
  
      # Read all fault input files
      for inputFile in args.faultInput:
          fp = FaultParser(inputFile)
          while fp.hasNext():
              # Load the next fault entry
              fe = fp.next()
  
              print "\n\nRunning " + benchmark + " with fault:\n" + str(fe)
  
              # Run faulted simulation
              call(["./build/ALPHA/gem5.opt",
                  "--stats-file", statFolder + "/" +
                  fe.label + ".txt",
                  "configs/fault_injector/injector_system.py",
                  "-fe",
                  "-b", benchmark,
                  "-l", fe.label,
                  "-sb", fe.stuckBit,
                  "-f", fe.field,
                  "-e", fe.entry,
                  "-bp", fe.bitPosition,
                  "-tb", fe.tickBegin,
                  "-te", fe.tickEnd])
  
subject: create stat folder in m5out before running any simulation from fault-injection-simulation script