regress revision 5247
11897Sstever@eecs.umich.edu#! /usr/bin/env python
24130Ssaidi@eecs.umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
31897Sstever@eecs.umich.edu# All rights reserved.
41897Sstever@eecs.umich.edu#
51897Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
61897Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
71897Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
81897Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
91897Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
101897Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
111897Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
121897Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
131897Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
141897Sstever@eecs.umich.edu# this software without specific prior written permission.
151897Sstever@eecs.umich.edu#
161897Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171897Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181897Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191897Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201897Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211897Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221897Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231897Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241897Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251897Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261897Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271897Sstever@eecs.umich.edu#
281897Sstever@eecs.umich.edu# Authors: Steve Reinhardt
291897Sstever@eecs.umich.edu
301897Sstever@eecs.umich.eduimport sys
311897Sstever@eecs.umich.eduimport os
321897Sstever@eecs.umich.eduimport optparse
331897Sstever@eecs.umich.eduimport datetime
344961Ssaidi@eecs.umich.edufrom subprocess import call
351897Sstever@eecs.umich.edu
361897Sstever@eecs.umich.eduprogname = os.path.basename(sys.argv[0])
371897Sstever@eecs.umich.edu
381897Sstever@eecs.umich.eduoptparser = optparse.OptionParser()
391897Sstever@eecs.umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true',
401897Sstever@eecs.umich.edu                     default=False,
411897Sstever@eecs.umich.edu                     help='echo commands before executing')
421897Sstever@eecs.umich.eduoptparser.add_option('--builds', dest='builds',
435187Sgblack@eecs.umich.edu                     default='ALPHA_SE,ALPHA_FS,MIPS_SE,' + \
445187Sgblack@eecs.umich.edu                     'SPARC_SE,SPARC_FS,X86_SE',
453099Sstever@eecs.umich.edu                     help='comma-separated list of build targets to test  '
463099Sstever@eecs.umich.edu                     " (default: '%default')" )
471897Sstever@eecs.umich.eduoptparser.add_option('--variants', dest='variants',
483709Sstever@eecs.umich.edu                     default='fast',
493099Sstever@eecs.umich.edu                     help='comma-separated list of build variants to test '
503099Sstever@eecs.umich.edu                     " (default: '%default')" )
511897Sstever@eecs.umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='',
523099Sstever@eecs.umich.edu                     help='scons options', metavar='OPTS')
533725Sstever@eecs.umich.eduoptparser.add_option('-j', '--jobs', type='int', default=1,
543725Sstever@eecs.umich.edu                     help='number of parallel jobs to use')
555247Sstever@gmail.comoptparser.add_option('-k', '--keep-going', action='store_true',
565247Sstever@gmail.com                     help='keep going after errors')
571897Sstever@eecs.umich.edu
581897Sstever@eecs.umich.edu(options, tests) = optparser.parse_args()
591897Sstever@eecs.umich.edu
601897Sstever@eecs.umich.edu
611897Sstever@eecs.umich.edu# split list options on ',' to get Python lists
621897Sstever@eecs.umich.edubuilds = options.builds.split(',')
631897Sstever@eecs.umich.eduvariants = options.variants.split(',')
641897Sstever@eecs.umich.edu
651897Sstever@eecs.umich.edu# Call os.system() and raise exception if return status is non-zero
661897Sstever@eecs.umich.edudef system(cmd):
674961Ssaidi@eecs.umich.edu    try:
684961Ssaidi@eecs.umich.edu        retcode = call(cmd, shell=True)
694961Ssaidi@eecs.umich.edu        if retcode < 0:
704961Ssaidi@eecs.umich.edu            print >>sys.stderr, "Child was terminated by signal", -retcode
714961Ssaidi@eecs.umich.edu            print >>sys.stderr, "When attemping to execute: %s" % cmd
724961Ssaidi@eecs.umich.edu            sys.exit(1)
734961Ssaidi@eecs.umich.edu        elif retcode > 0:
744961Ssaidi@eecs.umich.edu            print >>sys.stderr, "Child returned", retcode
754961Ssaidi@eecs.umich.edu            print >>sys.stderr, "When attemping to execute: %s" % cmd
764961Ssaidi@eecs.umich.edu            sys.exit(1)
774961Ssaidi@eecs.umich.edu    except OSError, e:
784961Ssaidi@eecs.umich.edu        print >>sys.stderr, "Execution failed:", e
794961Ssaidi@eecs.umich.edu        print >>sys.stderr, "When attemping to execute: %s" % cmd
804961Ssaidi@eecs.umich.edu        sys.exit(1)
811897Sstever@eecs.umich.edu
821897Sstever@eecs.umich.edu# Quote string s so it can be passed as a shell arg
831897Sstever@eecs.umich.edudef shellquote(s):
841897Sstever@eecs.umich.edu    if ' ' in s:
851897Sstever@eecs.umich.edu        s = "'%s'" % s
861897Sstever@eecs.umich.edu    return s
871897Sstever@eecs.umich.edu
884961Ssaidi@eecs.umich.eduif not tests:
894961Ssaidi@eecs.umich.edu    print "No tests specified, just building binaries."
904961Ssaidi@eecs.umich.edu    targets = ['build/%s/m5.%s' % (build, variant)
914961Ssaidi@eecs.umich.edu               for build in builds
924961Ssaidi@eecs.umich.edu               for variant in variants]
934961Ssaidi@eecs.umich.eduelif 'all' in tests:
944961Ssaidi@eecs.umich.edu    targets = ['build/%s/tests/%s' % (build, variant)
954961Ssaidi@eecs.umich.edu               for build in builds
964961Ssaidi@eecs.umich.edu               for variant in variants]
974961Ssaidi@eecs.umich.eduelse:
984961Ssaidi@eecs.umich.edu    # Ugly! Since we don't have any quick SPARC_FS tests remove the SPARC_FS target
994961Ssaidi@eecs.umich.edu    # If we ever get a quick SPARC_FS test, this code should be removed
1004961Ssaidi@eecs.umich.edu    if 'quick' in tests and 'SPARC_FS' in builds:
1014961Ssaidi@eecs.umich.edu        builds.remove('SPARC_FS')
1024961Ssaidi@eecs.umich.edu    targets = ['build/%s/tests/%s/%s' % (build, variant, test)
1034961Ssaidi@eecs.umich.edu               for build in builds
1044961Ssaidi@eecs.umich.edu               for variant in variants
1054961Ssaidi@eecs.umich.edu               for test in tests]
1061897Sstever@eecs.umich.edu
1074961Ssaidi@eecs.umich.eduscons_opts = options.scons_opts
1084961Ssaidi@eecs.umich.eduif options.jobs != 1:
1094961Ssaidi@eecs.umich.edu    scons_opts += ' -j %d' % options.jobs
1105247Sstever@gmail.comif options.keep_going:
1115247Sstever@gmail.com    scons_opts += ' -k'
1123725Sstever@eecs.umich.edu
1134975Ssaidi@eecs.umich.edusystem('scons IGNORE_STYLE=True %s %s' % (scons_opts, ' '.join(targets)))
1141897Sstever@eecs.umich.edu
1154961Ssaidi@eecs.umich.edusys.exit(0)
116