run.py revision 4977
110086Snilay@cs.wisc.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 210086Snilay@cs.wisc.edu# All rights reserved. 310086Snilay@cs.wisc.edu# 410086Snilay@cs.wisc.edu# Redistribution and use in source and binary forms, with or without 510086Snilay@cs.wisc.edu# modification, are permitted provided that the following conditions are 610086Snilay@cs.wisc.edu# met: redistributions of source code must retain the above copyright 710086Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer; 810086Snilay@cs.wisc.edu# redistributions in binary form must reproduce the above copyright 910086Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer in the 1010086Snilay@cs.wisc.edu# documentation and/or other materials provided with the distribution; 1110086Snilay@cs.wisc.edu# neither the name of the copyright holders nor the names of its 1210086Snilay@cs.wisc.edu# contributors may be used to endorse or promote products derived from 1310086Snilay@cs.wisc.edu# this software without specific prior written permission. 1410086Snilay@cs.wisc.edu# 1510086Snilay@cs.wisc.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1610086Snilay@cs.wisc.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1710086Snilay@cs.wisc.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1810086Snilay@cs.wisc.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1910086Snilay@cs.wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2010086Snilay@cs.wisc.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2110086Snilay@cs.wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2210086Snilay@cs.wisc.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2310086Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2410086Snilay@cs.wisc.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2510086Snilay@cs.wisc.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2610086Snilay@cs.wisc.edu# 2710086Snilay@cs.wisc.edu# Authors: Steve Reinhardt 2810086Snilay@cs.wisc.edu 2911793Sbrandon.potter@amd.comimport os, sys 3011793Sbrandon.potter@amd.com 318092Snilay@cs.wisc.edu# single "path" arg encodes everything we need to know about test 328092Snilay@cs.wisc.edu(category, name, isa, opsys, config) = sys.argv[1].split('/') 338092Snilay@cs.wisc.edu 348092Snilay@cs.wisc.edu# find path to directory containing this file 358174Snilay@cs.wisc.edutests_root = os.path.dirname(__file__) 368174Snilay@cs.wisc.eduif os.path.isdir('/dist/m5/regression/test-progs'): 378092Snilay@cs.wisc.edu test_progs = '/dist/m5/regression/test-progs' 388174Snilay@cs.wisc.eduelse: 3911118Snilay@cs.wisc.edu test_progs = os.path.join(tests_root, 'test-progs') 4011118Snilay@cs.wisc.edu 418174Snilay@cs.wisc.edu# generate path to binary file 4211118Snilay@cs.wisc.edudef binpath(app, file=None): 438174Snilay@cs.wisc.edu # executable has same name as app unless specified otherwise 448174Snilay@cs.wisc.edu if not file: 458174Snilay@cs.wisc.edu file = app 468174Snilay@cs.wisc.edu return os.path.join(test_progs, app, 'bin', isa, opsys, file) 478174Snilay@cs.wisc.edu 488092Snilay@cs.wisc.edu# generate path to input file 499302Snilay@cs.wisc.edudef inputpath(app, file=None): 509302Snilay@cs.wisc.edu # input file has same name as app unless specified otherwise 519302Snilay@cs.wisc.edu if not file: 529302Snilay@cs.wisc.edu file = app 539302Snilay@cs.wisc.edu return os.path.join(test_progs, app, 'input', file) 549302Snilay@cs.wisc.edu 559302Snilay@cs.wisc.edu# build configuration 569302Snilay@cs.wisc.eduexecfile(os.path.join(tests_root, 'configs', config + '.py')) 579302Snilay@cs.wisc.edu 589302Snilay@cs.wisc.edu# set default maxtick... script can override 599302Snilay@cs.wisc.edu# -1 means run forever 609302Snilay@cs.wisc.edufrom m5 import MaxTick 619302Snilay@cs.wisc.edumaxtick = MaxTick 629302Snilay@cs.wisc.edu 639302Snilay@cs.wisc.edu# tweak configuration for specific test 649302Snilay@cs.wisc.edu 659302Snilay@cs.wisc.eduexecfile(os.path.join(tests_root, category, name, 'test.py')) 669302Snilay@cs.wisc.edu 679302Snilay@cs.wisc.edu# instantiate configuration 689302Snilay@cs.wisc.edum5.instantiate(root) 699302Snilay@cs.wisc.edu 709572Sbah13@duke.edu# simulate until program terminates 719572Sbah13@duke.eduexit_event = m5.simulate(maxtick) 7211025Snilay@cs.wisc.edu 739572Sbah13@duke.eduprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause() 749302Snilay@cs.wisc.edu