regress revision 4130:a611c874376e
12623SN/A#! /usr/bin/env python
22623SN/A# Copyright (c) 2005-2007 The Regents of The University of Michigan
32623SN/A# All rights reserved.
42623SN/A#
52623SN/A# Redistribution and use in source and binary forms, with or without
62623SN/A# modification, are permitted provided that the following conditions are
72623SN/A# met: redistributions of source code must retain the above copyright
82623SN/A# notice, this list of conditions and the following disclaimer;
92623SN/A# redistributions in binary form must reproduce the above copyright
102623SN/A# notice, this list of conditions and the following disclaimer in the
112623SN/A# documentation and/or other materials provided with the distribution;
122623SN/A# neither the name of the copyright holders nor the names of its
132623SN/A# contributors may be used to endorse or promote products derived from
142623SN/A# this software without specific prior written permission.
152623SN/A#
162623SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172623SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182623SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192623SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202623SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212623SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222623SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232623SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242623SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252623SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262623SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu#
282665Ssaidi@eecs.umich.edu# Authors: Steve Reinhardt
292623SN/A
302623SN/Aimport sys
313170Sstever@eecs.umich.eduimport os
323806Ssaidi@eecs.umich.eduimport optparse
332623SN/Aimport datetime
344040Ssaidi@eecs.umich.edu
352623SN/Aprogname = os.path.basename(sys.argv[0])
362623SN/A
373348Sbinkertn@umich.eduoptparser = optparse.OptionParser()
383348Sbinkertn@umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true',
394762Snate@binkert.org                     default=False,
402901Ssaidi@eecs.umich.edu                     help='echo commands before executing')
412623SN/Aoptparser.add_option('--builds', dest='builds',
422623SN/A                     default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS',
432623SN/A                     help='comma-separated list of build targets to test  '
442623SN/A                     " (default: '%default')" )
452623SN/Aoptparser.add_option('--variants', dest='variants',
465606Snate@binkert.org                     default='fast',
472623SN/A                     help='comma-separated list of build variants to test '
482623SN/A                     " (default: '%default')" )
492623SN/Aoptparser.add_option('--scons-opts', dest='scons_opts', default='',
502623SN/A                     help='scons options', metavar='OPTS')
512623SN/Aoptparser.add_option('-j', '--jobs', type='int', default=1,
522623SN/A                     help='number of parallel jobs to use')
532623SN/A
542623SN/A(options, tests) = optparser.parse_args()
552623SN/A
562623SN/A
572623SN/A# split list options on ',' to get Python lists
585336Shines@cs.fsu.edubuilds = options.builds.split(',')
592623SN/Avariants = options.variants.split(',')
604873Sstever@eecs.umich.edu
612623SN/A# Call os.system() and raise exception if return status is non-zero
622623SN/Adef system(cmd):
632856Srdreslin@umich.edu    if options.verbose:
642856Srdreslin@umich.edu        print cmd
652856Srdreslin@umich.edu    status = os.system(cmd)
662856Srdreslin@umich.edu    if status != 0:
672856Srdreslin@umich.edu        upper = (status & 0xff00) >> 8
682856Srdreslin@umich.edu        lower = (status & 0xff)
692856Srdreslin@umich.edu        raise OSError, "shell command '%s' failed, status %d:%d" \
704968Sacolyte@umich.edu              % (cmd, upper, lower)
714968Sacolyte@umich.edu
724968Sacolyte@umich.edu# Quote string s so it can be passed as a shell arg
734968Sacolyte@umich.edudef shellquote(s):
742856Srdreslin@umich.edu    if ' ' in s:
752856Srdreslin@umich.edu        s = "'%s'" % s
762856Srdreslin@umich.edu    return s
772623SN/A
782623SN/Atry:
792623SN/A    if not tests:
802623SN/A        print "No tests specified, just building binaries."
812623SN/A        targets = ['build/%s/m5.%s' % (build, variant)
825310Ssaidi@eecs.umich.edu		   for build in builds
832623SN/A		   for variant in variants]
842680Sktlim@umich.edu    elif 'all' in tests:
852680Sktlim@umich.edu	targets = ['build/%s/tests/%s' % (build, variant)
862623SN/A		   for build in builds
872623SN/A		   for variant in variants]
885310Ssaidi@eecs.umich.edu    else:
892623SN/A	targets = ['build/%s/tests/%s/%s' % (build, variant, test)
902623SN/A		   for build in builds
914968Sacolyte@umich.edu		   for variant in variants
924968Sacolyte@umich.edu		   for test in tests]
934968Sacolyte@umich.edu
944968Sacolyte@umich.edu    scons_opts = options.scons_opts
954968Sacolyte@umich.edu    if options.jobs != 1:
964968Sacolyte@umich.edu        scons_opts += ' -j %d' % options.jobs
975310Ssaidi@eecs.umich.edu
985310Ssaidi@eecs.umich.edu    system('scons %s %s' % (scons_opts, ' '.join(targets)))
995310Ssaidi@eecs.umich.edu
1002623SN/A    sys.exit(0)
1012623SN/A
1022623SN/Aexcept OSError, exc:
1033349Sbinkertn@umich.edu    print "%s: " % progname, exc
1042623SN/A    sys.exit(1)
1053184Srdreslin@umich.edu