regress revision 4961
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', 434130Ssaidi@eecs.umich.edu default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS', 443099Sstever@eecs.umich.edu help='comma-separated list of build targets to test ' 453099Sstever@eecs.umich.edu " (default: '%default')" ) 461897Sstever@eecs.umich.eduoptparser.add_option('--variants', dest='variants', 473709Sstever@eecs.umich.edu default='fast', 483099Sstever@eecs.umich.edu help='comma-separated list of build variants to test ' 493099Sstever@eecs.umich.edu " (default: '%default')" ) 501897Sstever@eecs.umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='', 513099Sstever@eecs.umich.edu help='scons options', metavar='OPTS') 523725Sstever@eecs.umich.eduoptparser.add_option('-j', '--jobs', type='int', default=1, 533725Sstever@eecs.umich.edu help='number of parallel jobs to use') 541897Sstever@eecs.umich.edu 551897Sstever@eecs.umich.edu(options, tests) = optparser.parse_args() 561897Sstever@eecs.umich.edu 571897Sstever@eecs.umich.edu 581897Sstever@eecs.umich.edu# split list options on ',' to get Python lists 591897Sstever@eecs.umich.edubuilds = options.builds.split(',') 601897Sstever@eecs.umich.eduvariants = options.variants.split(',') 611897Sstever@eecs.umich.edu 621897Sstever@eecs.umich.edu# Call os.system() and raise exception if return status is non-zero 631897Sstever@eecs.umich.edudef system(cmd): 644961Ssaidi@eecs.umich.edu try: 654961Ssaidi@eecs.umich.edu retcode = call(cmd, shell=True) 664961Ssaidi@eecs.umich.edu if retcode < 0: 674961Ssaidi@eecs.umich.edu print >>sys.stderr, "Child was terminated by signal", -retcode 684961Ssaidi@eecs.umich.edu print >>sys.stderr, "When attemping to execute: %s" % cmd 694961Ssaidi@eecs.umich.edu sys.exit(1) 704961Ssaidi@eecs.umich.edu elif retcode > 0: 714961Ssaidi@eecs.umich.edu print >>sys.stderr, "Child returned", retcode 724961Ssaidi@eecs.umich.edu print >>sys.stderr, "When attemping to execute: %s" % cmd 734961Ssaidi@eecs.umich.edu sys.exit(1) 744961Ssaidi@eecs.umich.edu except OSError, e: 754961Ssaidi@eecs.umich.edu print >>sys.stderr, "Execution failed:", e 764961Ssaidi@eecs.umich.edu print >>sys.stderr, "When attemping to execute: %s" % cmd 774961Ssaidi@eecs.umich.edu sys.exit(1) 781897Sstever@eecs.umich.edu 791897Sstever@eecs.umich.edu# Quote string s so it can be passed as a shell arg 801897Sstever@eecs.umich.edudef shellquote(s): 811897Sstever@eecs.umich.edu if ' ' in s: 821897Sstever@eecs.umich.edu s = "'%s'" % s 831897Sstever@eecs.umich.edu return s 841897Sstever@eecs.umich.edu 854961Ssaidi@eecs.umich.eduif not tests: 864961Ssaidi@eecs.umich.edu print "No tests specified, just building binaries." 874961Ssaidi@eecs.umich.edu targets = ['build/%s/m5.%s' % (build, variant) 884961Ssaidi@eecs.umich.edu for build in builds 894961Ssaidi@eecs.umich.edu for variant in variants] 904961Ssaidi@eecs.umich.eduelif 'all' in tests: 914961Ssaidi@eecs.umich.edu targets = ['build/%s/tests/%s' % (build, variant) 924961Ssaidi@eecs.umich.edu for build in builds 934961Ssaidi@eecs.umich.edu for variant in variants] 944961Ssaidi@eecs.umich.eduelse: 954961Ssaidi@eecs.umich.edu # Ugly! Since we don't have any quick SPARC_FS tests remove the SPARC_FS target 964961Ssaidi@eecs.umich.edu # If we ever get a quick SPARC_FS test, this code should be removed 974961Ssaidi@eecs.umich.edu if 'quick' in tests and 'SPARC_FS' in builds: 984961Ssaidi@eecs.umich.edu builds.remove('SPARC_FS') 994961Ssaidi@eecs.umich.edu targets = ['build/%s/tests/%s/%s' % (build, variant, test) 1004961Ssaidi@eecs.umich.edu for build in builds 1014961Ssaidi@eecs.umich.edu for variant in variants 1024961Ssaidi@eecs.umich.edu for test in tests] 1031897Sstever@eecs.umich.edu 1044961Ssaidi@eecs.umich.eduscons_opts = options.scons_opts 1054961Ssaidi@eecs.umich.eduif options.jobs != 1: 1064961Ssaidi@eecs.umich.edu scons_opts += ' -j %d' % options.jobs 1073725Sstever@eecs.umich.edu 1084961Ssaidi@eecs.umich.edusystem('scons %s %s' % (scons_opts, ' '.join(targets))) 1091897Sstever@eecs.umich.edu 1104961Ssaidi@eecs.umich.edusys.exit(0) 1111897Sstever@eecs.umich.edu 112