run.py revision 5523
11689SN/A# Copyright (c) 2006-2007 The Regents of The University of Michigan
22316SN/A# All rights reserved.
31689SN/A#
41689SN/A# Redistribution and use in source and binary forms, with or without
51689SN/A# modification, are permitted provided that the following conditions are
61689SN/A# met: redistributions of source code must retain the above copyright
71689SN/A# notice, this list of conditions and the following disclaimer;
81689SN/A# redistributions in binary form must reproduce the above copyright
91689SN/A# notice, this list of conditions and the following disclaimer in the
101689SN/A# documentation and/or other materials provided with the distribution;
111689SN/A# neither the name of the copyright holders nor the names of its
121689SN/A# contributors may be used to endorse or promote products derived from
131689SN/A# this software without specific prior written permission.
141689SN/A#
151689SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161689SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171689SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
181689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
191689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
201689SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
211689SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
221689SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
231689SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
241689SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
251689SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261689SN/A#
272665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
282665Ssaidi@eecs.umich.edu
292965Sksewell@umich.eduimport os
301689SN/Aimport sys
311689SN/Aimport m5
322733Sktlim@umich.edu
332733Sktlim@umich.edu# Since we're in batch mode, dont allow tcp socket connections
342733Sktlim@umich.edum5.disableAllListeners()
352292SN/A
362329SN/A# single "path" arg encodes everything we need to know about test
372292SN/A(category, name, isa, opsys, config) = sys.argv[1].split('/')
383577Sgblack@eecs.umich.edu
395953Ssaidi@eecs.umich.edu# find path to directory containing this file
402292SN/Atests_root = os.path.dirname(__file__)
411060SN/Aif os.path.isdir('/dist/m5/regression/test-progs'):
422292SN/A    test_progs = '/dist/m5/regression/test-progs'
431717SN/Aelse:
442292SN/A    test_progs = os.path.join(tests_root, 'test-progs')
452292SN/A
462790Sktlim@umich.edu# generate path to binary file
472790Sktlim@umich.edudef binpath(app, file=None):
482790Sktlim@umich.edu    # executable has same name as app unless specified otherwise
492790Sktlim@umich.edu    if not file:
505529Snate@binkert.org        file = app
515529Snate@binkert.org    return os.path.join(test_progs, app, 'bin', isa, opsys, file)
521061SN/A
532292SN/A# generate path to input file
542292SN/Adef inputpath(app, file=None):
555606Snate@binkert.org    # input file has same name as app unless specified otherwise
561060SN/A    if not file:
575769Snate@binkert.org        file = app
581060SN/A    return os.path.join(test_progs, app, 'input', file)
591060SN/A
601061SN/A# build configuration
611060SN/Aexecfile(os.path.join(tests_root, 'configs', config + '.py'))
622292SN/A
631062SN/A# set default maxtick... script can override
642316SN/A# -1 means run forever
652316SN/Amaxtick = m5.MaxTick
662292SN/A
672292SN/A# tweak configuration for specific test
682292SN/A
692292SN/Aexecfile(os.path.join(tests_root, category, name, 'test.py'))
702292SN/A
715336Shines@cs.fsu.edu# instantiate configuration
722292SN/Am5.instantiate(root)
734873Sstever@eecs.umich.edu
742292SN/A# simulate until program terminates
752292SN/Aexit_event = m5.simulate(maxtick)
762292SN/A
775529Snate@binkert.orgprint 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
784329Sktlim@umich.edu