regress revision 3099:e3f3ff36645b
13900Ssaidi@eecs.umich.edu#! /usr/bin/env python 22632Sstever@eecs.umich.edu# Copyright (c) 2005-2006 The Regents of The University of Michigan 32632Sstever@eecs.umich.edu# All rights reserved. 42632Sstever@eecs.umich.edu# 52632Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 62632Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 72632Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 82632Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 92632Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 102632Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 112632Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 122632Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 132632Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 142632Sstever@eecs.umich.edu# this software without specific prior written permission. 152632Sstever@eecs.umich.edu# 162632Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172632Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182632Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192632Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202632Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212632Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222632Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232632Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242632Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252632Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262632Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272632Sstever@eecs.umich.edu# 282632Sstever@eecs.umich.edu# Authors: Steve Reinhardt 292632Sstever@eecs.umich.edu 302632Sstever@eecs.umich.eduimport sys 312022SN/Aimport os 322022SN/Aimport optparse 332022SN/Aimport datetime 342022SN/A 352022SN/Aprogname = os.path.basename(sys.argv[0]) 362469SN/A 372469SN/Aoptparser = optparse.OptionParser() 382469SN/Aoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true', 392469SN/A default=False, 402516SN/A help='echo commands before executing') 412516SN/Aoptparser.add_option('--builds', dest='builds', 422944Sgblack@eecs.umich.edu default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE', 432482SN/A help='comma-separated list of build targets to test ' 443598Sgblack@eecs.umich.edu " (default: '%default')" ) 453056Sgblack@eecs.umich.eduoptparser.add_option('--variants', dest='variants', 462469SN/A default='opt', 473056Sgblack@eecs.umich.edu help='comma-separated list of build variants to test ' 483056Sgblack@eecs.umich.edu " (default: '%default')" ) 493056Sgblack@eecs.umich.eduoptparser.add_option('--scons-opts', dest='scons_opts', default='', 503598Sgblack@eecs.umich.edu help='scons options', metavar='OPTS') 512516SN/A 523056Sgblack@eecs.umich.edu(options, tests) = optparser.parse_args() 533598Sgblack@eecs.umich.edu 543056Sgblack@eecs.umich.edu 553056Sgblack@eecs.umich.edu# split list options on ',' to get Python lists 563056Sgblack@eecs.umich.edubuilds = options.builds.split(',') 573056Sgblack@eecs.umich.eduvariants = options.variants.split(',') 583056Sgblack@eecs.umich.edu 593056Sgblack@eecs.umich.edu# Call os.system() and raise exception if return status is non-zero 603056Sgblack@eecs.umich.edudef system(cmd): 613598Sgblack@eecs.umich.edu if options.verbose: 623056Sgblack@eecs.umich.edu print cmd 633056Sgblack@eecs.umich.edu status = os.system(cmd) 643598Sgblack@eecs.umich.edu if status != 0: 653056Sgblack@eecs.umich.edu upper = (status & 0xff00) >> 8 663056Sgblack@eecs.umich.edu lower = (status & 0xff) 673056Sgblack@eecs.umich.edu raise OSError, "shell command '%s' failed, status %d:%d" \ 683056Sgblack@eecs.umich.edu % (cmd, upper, lower) 693056Sgblack@eecs.umich.edu 703056Sgblack@eecs.umich.edu# Quote string s so it can be passed as a shell arg 713056Sgblack@eecs.umich.edudef shellquote(s): 723056Sgblack@eecs.umich.edu if ' ' in s: 733056Sgblack@eecs.umich.edu s = "'%s'" % s 743056Sgblack@eecs.umich.edu return s 753056Sgblack@eecs.umich.edu 763056Sgblack@eecs.umich.edutry: 773056Sgblack@eecs.umich.edu if not tests: 783056Sgblack@eecs.umich.edu print "No tests specified." 793056Sgblack@eecs.umich.edu sys.exit(1) 803056Sgblack@eecs.umich.edu 813056Sgblack@eecs.umich.edu if 'all' in tests: 823056Sgblack@eecs.umich.edu targets = ['build/%s/tests/%s' % (build, variant) 833056Sgblack@eecs.umich.edu for build in builds 842482SN/A for variant in variants] 853598Sgblack@eecs.umich.edu else: 863598Sgblack@eecs.umich.edu targets = ['build/%s/tests/%s/%s' % (build, variant, test) 873598Sgblack@eecs.umich.edu for build in builds 883598Sgblack@eecs.umich.edu for variant in variants 893598Sgblack@eecs.umich.edu for test in tests] 903598Sgblack@eecs.umich.edu 913598Sgblack@eecs.umich.edu system('scons %s %s' % (options.scons_opts, ' '.join(targets))) 923598Sgblack@eecs.umich.edu 933598Sgblack@eecs.umich.edu sys.exit(0) 943598Sgblack@eecs.umich.edu 953598Sgblack@eecs.umich.eduexcept OSError, exc: 963598Sgblack@eecs.umich.edu print "%s: " % progname, exc 973598Sgblack@eecs.umich.edu sys.exit(1) 983598Sgblack@eecs.umich.edu