regress revision 4949:302707329b7e
1298SN/A#! /usr/bin/env python 211270Sandreas.sandberg@arm.com# Copyright (c) 2005-2007 The Regents of The University of Michigan 38142SAli.Saidi@ARM.com# All rights reserved. 48142SAli.Saidi@ARM.com# 58142SAli.Saidi@ARM.com# Redistribution and use in source and binary forms, with or without 68142SAli.Saidi@ARM.com# modification, are permitted provided that the following conditions are 78142SAli.Saidi@ARM.com# met: redistributions of source code must retain the above copyright 88142SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer; 98142SAli.Saidi@ARM.com# redistributions in binary form must reproduce the above copyright 108142SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer in the 118142SAli.Saidi@ARM.com# documentation and/or other materials provided with the distribution; 128142SAli.Saidi@ARM.com# neither the name of the copyright holders nor the names of its 138142SAli.Saidi@ARM.com# contributors may be used to endorse or promote products derived from 148580Ssteve.reinhardt@amd.com# this software without specific prior written permission. 152188SN/A# 16298SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17298SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18298SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19298SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20298SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21298SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22298SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23298SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24298SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25298SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26298SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27298SN/A# 28298SN/A# Authors: Steve Reinhardt 29298SN/A 30298SN/Aimport sys 31298SN/Aimport os 32298SN/Aimport optparse 33298SN/Aimport datetime 34298SN/A 35298SN/Aprogname = os.path.basename(sys.argv[0]) 36298SN/A 37298SN/Aoptparser = optparse.OptionParser() 38298SN/Aoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true', 39298SN/A default=False, 402665Ssaidi@eecs.umich.edu help='echo commands before executing') 412665Ssaidi@eecs.umich.eduoptparser.add_option('--builds', dest='builds', 42298SN/A default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS', 43298SN/A help='comma-separated list of build targets to test ' 44954SN/A " (default: '%default')" ) 45956SN/Aoptparser.add_option('--variants', dest='variants', 46956SN/A default='fast', 478229Snate@binkert.org help='comma-separated list of build variants to test ' 484078Sbinkertn@umich.edu " (default: '%default')" ) 49299SN/Aoptparser.add_option('--scons-opts', dest='scons_opts', default='', 509659SAndreas.Sandberg@ARM.com help='scons options', metavar='OPTS') 51299SN/Aoptparser.add_option('-j', '--jobs', type='int', default=1, 528777Sgblack@eecs.umich.edu help='number of parallel jobs to use') 539659SAndreas.Sandberg@ARM.com 542170SN/A(options, tests) = optparser.parse_args() 5510553Salexandru.dutu@amd.com 565882Snate@binkert.org 578734Sdam.sunwoo@arm.com# split list options on ',' to get Python lists 586658Snate@binkert.orgbuilds = options.builds.split(',') 591717SN/Avariants = options.variants.split(',') 608229Snate@binkert.org 612680Sktlim@umich.edu# Call os.system() and raise exception if return status is non-zero 628232Snate@binkert.orgdef system(cmd): 639733Sandreas@sandberg.pp.se if options.verbose: 648232Snate@binkert.org print cmd 658232Snate@binkert.org status = os.system(cmd) 665529Snate@binkert.org if status != 0: 678784Sgblack@eecs.umich.edu upper = (status & 0xff00) >> 8 6810553Salexandru.dutu@amd.com lower = (status & 0xff) 693565Sgblack@eecs.umich.edu raise OSError, "shell command '%s' failed, status %d:%d" \ 70298SN/A % (cmd, upper, lower) 715606Snate@binkert.org 72298SN/A# Quote string s so it can be passed as a shell arg 73695SN/Adef shellquote(s): 74695SN/A if ' ' in s: 75954SN/A s = "'%s'" % s 762080SN/A return s 77298SN/A 78299SN/Atry: 791052SN/A if not tests: 80729SN/A print "No tests specified, just building binaries." 812107SN/A targets = ['build/%s/m5.%s' % (build, variant) 82298SN/A for build in builds 835504Snate@binkert.org for variant in variants] 845504Snate@binkert.org elif 'all' in tests: 858784Sgblack@eecs.umich.edu targets = ['build/%s/tests/%s' % (build, variant) 868784Sgblack@eecs.umich.edu for build in builds 878784Sgblack@eecs.umich.edu for variant in variants] 888784Sgblack@eecs.umich.edu else: 898784Sgblack@eecs.umich.edu # Ugly! Since we don't have any quick SPARC_FS tests remove the SPARC_FS target 905780Ssteve.reinhardt@amd.com # If we ever get a quick SPARC_FS test, this code should be removed 919659SAndreas.Sandberg@ARM.com if 'quick' in tests and 'SPARC_FS' in builds: 929659SAndreas.Sandberg@ARM.com builds.remove('SPARC_FS') 939659SAndreas.Sandberg@ARM.com targets = ['build/%s/tests/%s/%s' % (build, variant, test) 949659SAndreas.Sandberg@ARM.com for build in builds 959659SAndreas.Sandberg@ARM.com for variant in variants 969733Sandreas@sandberg.pp.se for test in tests] 979733Sandreas@sandberg.pp.se 989659SAndreas.Sandberg@ARM.com scons_opts = options.scons_opts 999659SAndreas.Sandberg@ARM.com if options.jobs != 1: 1009659SAndreas.Sandberg@ARM.com scons_opts += ' -j %d' % options.jobs 1019659SAndreas.Sandberg@ARM.com 1029659SAndreas.Sandberg@ARM.com system('scons IGNORE_STYLE=True %s %s' % (scons_opts, ' '.join(targets))) 1039879Sandreas@sandberg.pp.se 1049879Sandreas@sandberg.pp.se sys.exit(0) 1059879Sandreas@sandberg.pp.se 1069879Sandreas@sandberg.pp.seexcept OSError, exc: 1079659SAndreas.Sandberg@ARM.com print "%s: " % progname, exc 1089659SAndreas.Sandberg@ARM.com sys.exit(1) 1099659SAndreas.Sandberg@ARM.com