regress revision 3709
11897Sstever@eecs.umich.edu#! /usr/bin/env python 24130Ssaidi@eecs.umich.edu# Copyright (c) 2005-2006 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.edu 351897Sstever@eecs.umich.eduprogname = os.path.basename(sys.argv[0]) 361897Sstever@eecs.umich.edu 371897Sstever@eecs.umich.eduoptparser = optparse.OptionParser() 381897Sstever@eecs.umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true', 391897Sstever@eecs.umich.edu default=False, 401897Sstever@eecs.umich.edu help='echo commands before executing') 411897Sstever@eecs.umich.eduoptparser.add_option('--builds', dest='builds', 421897Sstever@eecs.umich.edu default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE', 434130Ssaidi@eecs.umich.edu help='comma-separated list of build targets to test ' 443099Sstever@eecs.umich.edu " (default: '%default')" ) 453099Sstever@eecs.umich.eduoptparser.add_option('--variants', dest='variants', 461897Sstever@eecs.umich.edu default='fast', 473709Sstever@eecs.umich.edu help='comma-separated list of build variants to test ' 483099Sstever@eecs.umich.edu " (default: '%default')" ) 493099Sstever@eecs.umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='', 501897Sstever@eecs.umich.edu help='scons options', metavar='OPTS') 513099Sstever@eecs.umich.edu 523725Sstever@eecs.umich.edu(options, tests) = optparser.parse_args() 533725Sstever@eecs.umich.edu 541897Sstever@eecs.umich.edu 551897Sstever@eecs.umich.edu# split list options on ',' to get Python lists 561897Sstever@eecs.umich.edubuilds = options.builds.split(',') 571897Sstever@eecs.umich.eduvariants = options.variants.split(',') 581897Sstever@eecs.umich.edu 591897Sstever@eecs.umich.edu# Call os.system() and raise exception if return status is non-zero 601897Sstever@eecs.umich.edudef system(cmd): 611897Sstever@eecs.umich.edu if options.verbose: 621897Sstever@eecs.umich.edu print cmd 631897Sstever@eecs.umich.edu status = os.system(cmd) 644961Ssaidi@eecs.umich.edu if status != 0: 654961Ssaidi@eecs.umich.edu upper = (status & 0xff00) >> 8 664961Ssaidi@eecs.umich.edu lower = (status & 0xff) 674961Ssaidi@eecs.umich.edu raise OSError, "shell command '%s' failed, status %d:%d" \ 684961Ssaidi@eecs.umich.edu % (cmd, upper, lower) 694961Ssaidi@eecs.umich.edu 704961Ssaidi@eecs.umich.edu# Quote string s so it can be passed as a shell arg 714961Ssaidi@eecs.umich.edudef shellquote(s): 724961Ssaidi@eecs.umich.edu if ' ' in s: 734961Ssaidi@eecs.umich.edu s = "'%s'" % s 744961Ssaidi@eecs.umich.edu return s 754961Ssaidi@eecs.umich.edu 764961Ssaidi@eecs.umich.edutry: 774961Ssaidi@eecs.umich.edu if not tests: 781897Sstever@eecs.umich.edu print "No tests specified." 791897Sstever@eecs.umich.edu sys.exit(1) 801897Sstever@eecs.umich.edu 811897Sstever@eecs.umich.edu if 'all' in tests: 821897Sstever@eecs.umich.edu targets = ['build/%s/tests/%s' % (build, variant) 831897Sstever@eecs.umich.edu for build in builds 841897Sstever@eecs.umich.edu for variant in variants] 854975Ssaidi@eecs.umich.edu else: 864961Ssaidi@eecs.umich.edu targets = ['build/%s/tests/%s/%s' % (build, variant, test) 874961Ssaidi@eecs.umich.edu for build in builds 884961Ssaidi@eecs.umich.edu for variant in variants 894961Ssaidi@eecs.umich.edu for test in tests] 904961Ssaidi@eecs.umich.edu 914961Ssaidi@eecs.umich.edu system('scons %s %s' % (options.scons_opts, ' '.join(targets))) 924961Ssaidi@eecs.umich.edu 934961Ssaidi@eecs.umich.edu sys.exit(0) 944961Ssaidi@eecs.umich.edu 954961Ssaidi@eecs.umich.eduexcept OSError, exc: 964961Ssaidi@eecs.umich.edu print "%s: " % progname, exc 974961Ssaidi@eecs.umich.edu sys.exit(1) 984961Ssaidi@eecs.umich.edu