regress revision 4130
12023SN/A#! /usr/bin/env python 22023SN/A# Copyright (c) 2005-2007 The Regents of The University of Michigan 32023SN/A# All rights reserved. 42023SN/A# 52023SN/A# Redistribution and use in source and binary forms, with or without 62023SN/A# modification, are permitted provided that the following conditions are 72023SN/A# met: redistributions of source code must retain the above copyright 82023SN/A# notice, this list of conditions and the following disclaimer; 92023SN/A# redistributions in binary form must reproduce the above copyright 102023SN/A# notice, this list of conditions and the following disclaimer in the 112023SN/A# documentation and/or other materials provided with the distribution; 122023SN/A# neither the name of the copyright holders nor the names of its 132023SN/A# contributors may be used to endorse or promote products derived from 142023SN/A# this software without specific prior written permission. 152023SN/A# 162023SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172023SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182023SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192023SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202023SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212023SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222023SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232023SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242023SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252023SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262023SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272023SN/A# 282665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt 292665Ssaidi@eecs.umich.edu 302665Ssaidi@eecs.umich.eduimport sys 312023SN/Aimport os 324202Sbinkertn@umich.eduimport optparse 332023SN/Aimport datetime 344202Sbinkertn@umich.edu 354997Sgblack@eecs.umich.eduprogname = os.path.basename(sys.argv[0]) 364202Sbinkertn@umich.edu 374202Sbinkertn@umich.eduoptparser = optparse.OptionParser() 384202Sbinkertn@umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true', 394997Sgblack@eecs.umich.edu default=False, 404202Sbinkertn@umich.edu help='echo commands before executing') 414997Sgblack@eecs.umich.eduoptparser.add_option('--builds', dest='builds', 424202Sbinkertn@umich.edu default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS', 434202Sbinkertn@umich.edu help='comma-separated list of build targets to test ' 444997Sgblack@eecs.umich.edu " (default: '%default')" ) 454826Ssaidi@eecs.umich.eduoptparser.add_option('--variants', dest='variants', 462023SN/A default='fast', 474997Sgblack@eecs.umich.edu help='comma-separated list of build variants to test ' 484997Sgblack@eecs.umich.edu " (default: '%default')" ) 494202Sbinkertn@umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='', 504486Sbinkertn@umich.edu help='scons options', metavar='OPTS') 514486Sbinkertn@umich.eduoptparser.add_option('-j', '--jobs', type='int', default=1, 524202Sbinkertn@umich.edu help='number of parallel jobs to use') 534202Sbinkertn@umich.edu 544202Sbinkertn@umich.edu(options, tests) = optparser.parse_args() 554202Sbinkertn@umich.edu 564202Sbinkertn@umich.edu 574202Sbinkertn@umich.edu# split list options on ',' to get Python lists 582023SN/Abuilds = options.builds.split(',') 594202Sbinkertn@umich.eduvariants = options.variants.split(',') 604202Sbinkertn@umich.edu 614202Sbinkertn@umich.edu# Call os.system() and raise exception if return status is non-zero 622023SN/Adef system(cmd): 634202Sbinkertn@umich.edu if options.verbose: 644202Sbinkertn@umich.edu print cmd 652023SN/A status = os.system(cmd) 664202Sbinkertn@umich.edu if status != 0: 674202Sbinkertn@umich.edu upper = (status & 0xff00) >> 8 682023SN/A lower = (status & 0xff) 694202Sbinkertn@umich.edu raise OSError, "shell command '%s' failed, status %d:%d" \ 704202Sbinkertn@umich.edu % (cmd, upper, lower) 712023SN/A 724202Sbinkertn@umich.edu# Quote string s so it can be passed as a shell arg 734202Sbinkertn@umich.edudef shellquote(s): 744202Sbinkertn@umich.edu if ' ' in s: 754202Sbinkertn@umich.edu s = "'%s'" % s 764202Sbinkertn@umich.edu return s 774202Sbinkertn@umich.edu 78try: 79 if not tests: 80 print "No tests specified, just building binaries." 81 targets = ['build/%s/m5.%s' % (build, variant) 82 for build in builds 83 for variant in variants] 84 elif 'all' in tests: 85 targets = ['build/%s/tests/%s' % (build, variant) 86 for build in builds 87 for variant in variants] 88 else: 89 targets = ['build/%s/tests/%s/%s' % (build, variant, test) 90 for build in builds 91 for variant in variants 92 for test in tests] 93 94 scons_opts = options.scons_opts 95 if options.jobs != 1: 96 scons_opts += ' -j %d' % options.jobs 97 98 system('scons %s %s' % (scons_opts, ' '.join(targets))) 99 100 sys.exit(0) 101 102except OSError, exc: 103 print "%s: " % progname, exc 104 sys.exit(1) 105