Merge ktlim@zizzer:/bk/newmem
[gem5.git] / configs / test / test.py
1 # Simple test script
2 #
3 # Alpha: "m5 test.py"
4 # MIPS: "m5 test.py -c hello_mips"
5
6 import m5
7 import os, optparse, sys
8 m5.AddToPath('../common')
9 from SEConfig import *
10
11 this_dir = os.path.dirname(__file__)
12
13 process = LiveProcess()
14 process.executable = os.path.join(this_dir, options.cmd)
15 process.cmd = options.cmd + " " + options.options
16 if options.input != "":
17 process.input = options.input
18
19 if options.detailed:
20 #check for SMT workload
21 workloads = options.cmd.split(';')
22 if len(workloads) > 1:
23 process = []
24 smt_idx = 0
25 inputs = []
26
27 if options.input != "":
28 inputs = options.input.split(';')
29
30 for wrkld in workloads:
31 smt_process = LiveProcess()
32 smt_process.executable = os.path.join(this_dir, wrkld)
33 smt_process.cmd = wrkld + " " + options.options
34 if inputs and inputs[smt_idx]:
35 smt_process.input = inputs[smt_idx]
36 process += [smt_process, ]
37 smt_idx += 1
38
39 cpu.workload = process
40
41 # instantiate configuration
42 m5.instantiate(root)
43
44 # simulate until program terminates
45 if options.maxtick:
46 exit_event = m5.simulate(options.maxtick)
47 else:
48 exit_event = m5.simulate()
49
50 print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
51