run.py revision 9384
14977Ssaidi@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 22997Sstever@eecs.umich.edu# All rights reserved. 32997Sstever@eecs.umich.edu# 42997Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 52997Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 62997Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 72997Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 82997Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 92997Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 102997Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 112997Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 122997Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 132997Sstever@eecs.umich.edu# this software without specific prior written permission. 142997Sstever@eecs.umich.edu# 152997Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 162997Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 172997Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 182997Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 192997Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 202997Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 212997Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 222997Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 232997Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 242997Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 252997Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 262997Sstever@eecs.umich.edu# 272997Sstever@eecs.umich.edu# Authors: Steve Reinhardt 282997Sstever@eecs.umich.edu 295523Snate@binkert.orgimport os 305523Snate@binkert.orgimport sys 316928SBrad.Beckmann@amd.comimport re 326928SBrad.Beckmann@amd.comimport string 336289Snate@binkert.org 346289Snate@binkert.orgfrom os.path import join as joinpath 356289Snate@binkert.org 365523Snate@binkert.orgimport m5 375523Snate@binkert.org 385523Snate@binkert.org# Since we're in batch mode, dont allow tcp socket connections 395523Snate@binkert.orgm5.disableAllListeners() 402997Sstever@eecs.umich.edu 412997Sstever@eecs.umich.edu# single "path" arg encodes everything we need to know about test 428802Sgblack@eecs.umich.edu(category, mode, name, isa, opsys, config) = sys.argv[1].split('/')[-6:] 432997Sstever@eecs.umich.edu 442997Sstever@eecs.umich.edu# find path to directory containing this file 452997Sstever@eecs.umich.edutests_root = os.path.dirname(__file__) 466874SSteve.Reinhardt@amd.comtest_progs = os.environ.get('M5_TEST_PROGS', '/dist/m5/regression/test-progs') 476874SSteve.Reinhardt@amd.comif not os.path.isdir(test_progs): 486289Snate@binkert.org test_progs = joinpath(tests_root, 'test-progs') 492998Sstever@eecs.umich.edu 502998Sstever@eecs.umich.edu# generate path to binary file 512998Sstever@eecs.umich.edudef binpath(app, file=None): 522998Sstever@eecs.umich.edu # executable has same name as app unless specified otherwise 532998Sstever@eecs.umich.edu if not file: 542998Sstever@eecs.umich.edu file = app 556289Snate@binkert.org return joinpath(test_progs, app, 'bin', isa, opsys, file) 562997Sstever@eecs.umich.edu 573475Sktlim@umich.edu# generate path to input file 583475Sktlim@umich.edudef inputpath(app, file=None): 593475Sktlim@umich.edu # input file has same name as app unless specified otherwise 603475Sktlim@umich.edu if not file: 613475Sktlim@umich.edu file = app 626289Snate@binkert.org return joinpath(test_progs, app, 'input', file) 633475Sktlim@umich.edu 642997Sstever@eecs.umich.edu# build configuration 656289Snate@binkert.orgsys.path.append(joinpath(tests_root, 'configs')) 666928SBrad.Beckmann@amd.comtest_filename = config 676928SBrad.Beckmann@amd.com# for ruby configurations, remove the protocol name from the test filename 686928SBrad.Beckmann@amd.comif re.search('-ruby', test_filename): 696928SBrad.Beckmann@amd.com test_filename = test_filename.split('-ruby')[0]+'-ruby' 706928SBrad.Beckmann@amd.comexecfile(joinpath(tests_root, 'configs', test_filename + '.py')) 712997Sstever@eecs.umich.edu 722997Sstever@eecs.umich.edu# set default maxtick... script can override 732998Sstever@eecs.umich.edu# -1 means run forever 745523Snate@binkert.orgmaxtick = m5.MaxTick 752997Sstever@eecs.umich.edu 762997Sstever@eecs.umich.edu# tweak configuration for specific test 778802Sgblack@eecs.umich.edusys.path.append(joinpath(tests_root, category, mode, name)) 788802Sgblack@eecs.umich.eduexecfile(joinpath(tests_root, category, mode, name, 'test.py')) 792997Sstever@eecs.umich.edu 809384SAndreas.Sandberg@arm.com# Initialize all CPUs in a system 819384SAndreas.Sandberg@arm.comdef initCPUs(sys): 829384SAndreas.Sandberg@arm.com def initCPU(cpu): 839384SAndreas.Sandberg@arm.com # We might actually have a MemTest object or something similar 849384SAndreas.Sandberg@arm.com # here that just pretends to be a CPU. 859384SAndreas.Sandberg@arm.com if isinstance(cpu, BaseCPU): 869384SAndreas.Sandberg@arm.com cpu.createThreads() 879384SAndreas.Sandberg@arm.com 889384SAndreas.Sandberg@arm.com # The CPU attribute doesn't exist in some cases, e.g. the Ruby 899384SAndreas.Sandberg@arm.com # testers. 909384SAndreas.Sandberg@arm.com if not hasattr(sys, "cpu"): 919384SAndreas.Sandberg@arm.com return 929384SAndreas.Sandberg@arm.com 939384SAndreas.Sandberg@arm.com # The CPU can either be a list of CPUs or a single object. 949384SAndreas.Sandberg@arm.com if isinstance(sys.cpu, list): 959384SAndreas.Sandberg@arm.com [ initCPU(cpu) for cpu in sys.cpu ] 969384SAndreas.Sandberg@arm.com else: 979384SAndreas.Sandberg@arm.com initCPU(sys.cpu) 989384SAndreas.Sandberg@arm.com 999384SAndreas.Sandberg@arm.com# We might be creating a single system or a dual system. Try 1009384SAndreas.Sandberg@arm.com# initializing the CPUs in all known system attributes. 1019384SAndreas.Sandberg@arm.comfor sysattr in [ "system", "testsys", "drivesys" ]: 1029384SAndreas.Sandberg@arm.com if hasattr(root, sysattr): 1039384SAndreas.Sandberg@arm.com initCPUs(getattr(root, sysattr)) 1049384SAndreas.Sandberg@arm.com 1052997Sstever@eecs.umich.edu# instantiate configuration 1067525Ssteve.reinhardt@amd.comm5.instantiate() 1072997Sstever@eecs.umich.edu 1082997Sstever@eecs.umich.edu# simulate until program terminates 1092997Sstever@eecs.umich.eduexit_event = m5.simulate(maxtick) 1102997Sstever@eecs.umich.edu 1112997Sstever@eecs.umich.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 112