regress revision 4961
18112Sgblack@eecs.umich.edu#! /usr/bin/env python 28112Sgblack@eecs.umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan 38112Sgblack@eecs.umich.edu# All rights reserved. 48112Sgblack@eecs.umich.edu# 58112Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 68112Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are 78112Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright 88112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 98112Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 108112Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 118112Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution; 128112Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its 138112Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from 148112Sgblack@eecs.umich.edu# this software without specific prior written permission. 158112Sgblack@eecs.umich.edu# 168112Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 178112Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 188112Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 198112Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 208112Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 218112Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 228112Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 238112Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 248112Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258112Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 268112Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 278112Sgblack@eecs.umich.edu# 288112Sgblack@eecs.umich.edu# Authors: Steve Reinhardt 298113Sgblack@eecs.umich.edu 308113Sgblack@eecs.umich.eduimport sys 318113Sgblack@eecs.umich.eduimport os 328113Sgblack@eecs.umich.eduimport optparse 338113Sgblack@eecs.umich.eduimport datetime 348113Sgblack@eecs.umich.edufrom subprocess import call 358113Sgblack@eecs.umich.edu 368113Sgblack@eecs.umich.eduprogname = os.path.basename(sys.argv[0]) 378113Sgblack@eecs.umich.edu 388113Sgblack@eecs.umich.eduoptparser = optparse.OptionParser() 398113Sgblack@eecs.umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true', 408113Sgblack@eecs.umich.edu default=False, 418113Sgblack@eecs.umich.edu help='echo commands before executing') 428113Sgblack@eecs.umich.eduoptparser.add_option('--builds', dest='builds', 438113Sgblack@eecs.umich.edu default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS', 448113Sgblack@eecs.umich.edu help='comma-separated list of build targets to test ' 458113Sgblack@eecs.umich.edu " (default: '%default')" ) 468113Sgblack@eecs.umich.eduoptparser.add_option('--variants', dest='variants', 478113Sgblack@eecs.umich.edu default='fast', 488113Sgblack@eecs.umich.edu help='comma-separated list of build variants to test ' 498113Sgblack@eecs.umich.edu " (default: '%default')" ) 508113Sgblack@eecs.umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='', 518113Sgblack@eecs.umich.edu help='scons options', metavar='OPTS') 528117Sgblack@eecs.umich.eduoptparser.add_option('-j', '--jobs', type='int', default=1, 538113Sgblack@eecs.umich.edu help='number of parallel jobs to use') 548113Sgblack@eecs.umich.edu 558113Sgblack@eecs.umich.edu(options, tests) = optparser.parse_args() 568113Sgblack@eecs.umich.edu 578113Sgblack@eecs.umich.edu 588113Sgblack@eecs.umich.edu# split list options on ',' to get Python lists 598113Sgblack@eecs.umich.edubuilds = options.builds.split(',') 608113Sgblack@eecs.umich.eduvariants = options.variants.split(',') 618113Sgblack@eecs.umich.edu 628113Sgblack@eecs.umich.edu# Call os.system() and raise exception if return status is non-zero 638113Sgblack@eecs.umich.edudef system(cmd): 648113Sgblack@eecs.umich.edu try: 658113Sgblack@eecs.umich.edu retcode = call(cmd, shell=True) 668113Sgblack@eecs.umich.edu if retcode < 0: 678113Sgblack@eecs.umich.edu print >>sys.stderr, "Child was terminated by signal", -retcode 68 print >>sys.stderr, "When attemping to execute: %s" % cmd 69 sys.exit(1) 70 elif retcode > 0: 71 print >>sys.stderr, "Child returned", retcode 72 print >>sys.stderr, "When attemping to execute: %s" % cmd 73 sys.exit(1) 74 except OSError, e: 75 print >>sys.stderr, "Execution failed:", e 76 print >>sys.stderr, "When attemping to execute: %s" % cmd 77 sys.exit(1) 78 79# Quote string s so it can be passed as a shell arg 80def shellquote(s): 81 if ' ' in s: 82 s = "'%s'" % s 83 return s 84 85if not tests: 86 print "No tests specified, just building binaries." 87 targets = ['build/%s/m5.%s' % (build, variant) 88 for build in builds 89 for variant in variants] 90elif 'all' in tests: 91 targets = ['build/%s/tests/%s' % (build, variant) 92 for build in builds 93 for variant in variants] 94else: 95 # Ugly! Since we don't have any quick SPARC_FS tests remove the SPARC_FS target 96 # If we ever get a quick SPARC_FS test, this code should be removed 97 if 'quick' in tests and 'SPARC_FS' in builds: 98 builds.remove('SPARC_FS') 99 targets = ['build/%s/tests/%s/%s' % (build, variant, test) 100 for build in builds 101 for variant in variants 102 for test in tests] 103 104scons_opts = options.scons_opts 105if options.jobs != 1: 106 scons_opts += ' -j %d' % options.jobs 107 108system('scons %s %s' % (scons_opts, ' '.join(targets))) 109 110sys.exit(0) 111 112