regress revision 4169:b03a74834dfe
14123Sbinkertn@umich.edu#! /usr/bin/env python
24123Sbinkertn@umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
39983Sstever@gmail.com# All rights reserved.
49983Sstever@gmail.com#
54123Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
64123Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
74123Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
84123Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
94123Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
104123Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
114123Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
124123Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
134123Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
144123Sbinkertn@umich.edu# this software without specific prior written permission.
154123Sbinkertn@umich.edu#
164123Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174123Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184123Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194123Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204123Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214123Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224123Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234123Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244123Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254123Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264123Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274123Sbinkertn@umich.edu#
284123Sbinkertn@umich.edu# Authors: Steve Reinhardt
294123Sbinkertn@umich.edu
304123Sbinkertn@umich.eduimport sys
314123Sbinkertn@umich.eduimport os
324123Sbinkertn@umich.eduimport optparse
334123Sbinkertn@umich.eduimport datetime
349983Sstever@gmail.com
359983Sstever@gmail.comprogname = os.path.basename(sys.argv[0])
369983Sstever@gmail.com
374123Sbinkertn@umich.eduoptparser = optparse.OptionParser()
384123Sbinkertn@umich.eduoptparser.add_option('-v', '--verbose', dest='verbose', action='store_true',
396216Snate@binkert.org                     default=False,
404123Sbinkertn@umich.edu                     help='echo commands before executing')
419356Snilay@cs.wisc.eduoptparser.add_option('--builds', dest='builds',
424123Sbinkertn@umich.edu                     default='ALPHA_SE,ALPHA_FS,MIPS_SE,SPARC_SE,SPARC_FS',
434123Sbinkertn@umich.edu                     help='comma-separated list of build targets to test  '
444123Sbinkertn@umich.edu                     " (default: '%default')" )
456216Snate@binkert.orgoptparser.add_option('--variants', dest='variants',
464123Sbinkertn@umich.edu                     default='fast',
479983Sstever@gmail.com                     help='comma-separated list of build variants to test '
489983Sstever@gmail.com                     " (default: '%default')" )
499983Sstever@gmail.comoptparser.add_option('--scons-opts', dest='scons_opts', default='',
509983Sstever@gmail.com                     help='scons options', metavar='OPTS')
519983Sstever@gmail.comoptparser.add_option('-j', '--jobs', type='int', default=1,
529983Sstever@gmail.com                     help='number of parallel jobs to use')
539983Sstever@gmail.com
549983Sstever@gmail.com(options, tests) = optparser.parse_args()
559983Sstever@gmail.com
569983Sstever@gmail.com
579983Sstever@gmail.com# split list options on ',' to get Python lists
589983Sstever@gmail.combuilds = options.builds.split(',')
599983Sstever@gmail.comvariants = options.variants.split(',')
609983Sstever@gmail.com
619983Sstever@gmail.com# Call os.system() and raise exception if return status is non-zero
629983Sstever@gmail.comdef system(cmd):
639983Sstever@gmail.com    if options.verbose:
649983Sstever@gmail.com        print cmd
659983Sstever@gmail.com    status = os.system(cmd)
669983Sstever@gmail.com    if status != 0:
679983Sstever@gmail.com        upper = (status & 0xff00) >> 8
689983Sstever@gmail.com        lower = (status & 0xff)
699983Sstever@gmail.com        raise OSError, "shell command '%s' failed, status %d:%d" \
709983Sstever@gmail.com              % (cmd, upper, lower)
719983Sstever@gmail.com
729983Sstever@gmail.com# Quote string s so it can be passed as a shell arg
739983Sstever@gmail.comdef shellquote(s):
7410762SCurtis.Dunham@arm.com    if ' ' in s:
7510756SCurtis.Dunham@arm.com        s = "'%s'" % s
764123Sbinkertn@umich.edu    return s
774123Sbinkertn@umich.edu
784123Sbinkertn@umich.edutry:
794123Sbinkertn@umich.edu    if not tests:
804123Sbinkertn@umich.edu        print "No tests specified, just building binaries."
819983Sstever@gmail.com        targets = ['build/%s/m5.%s' % (build, variant)
824123Sbinkertn@umich.edu		   for build in builds
834123Sbinkertn@umich.edu		   for variant in variants]
849983Sstever@gmail.com    elif 'all' in tests:
859983Sstever@gmail.com	targets = ['build/%s/tests/%s' % (build, variant)
869983Sstever@gmail.com		   for build in builds
879983Sstever@gmail.com		   for variant in variants]
889983Sstever@gmail.com    else:
899983Sstever@gmail.com        # Ugly! Since we don't have any quick SPARC_FS tests remove the SPARC_FS target
909983Sstever@gmail.com        # If we ever get a quick SPARC_FS test, this code should be removed
919983Sstever@gmail.com        if 'quick' in tests:
929983Sstever@gmail.com            builds.remove('SPARC_FS')
939983Sstever@gmail.com	targets = ['build/%s/tests/%s/%s' % (build, variant, test)
949983Sstever@gmail.com		   for build in builds
959983Sstever@gmail.com		   for variant in variants
969983Sstever@gmail.com		   for test in tests]
979983Sstever@gmail.com
989983Sstever@gmail.com    scons_opts = options.scons_opts
999983Sstever@gmail.com    if options.jobs != 1:
1009983Sstever@gmail.com        scons_opts += ' -j %d' % options.jobs
10110762SCurtis.Dunham@arm.com
10210762SCurtis.Dunham@arm.com    system('scons %s %s' % (scons_opts, ' '.join(targets)))
10310762SCurtis.Dunham@arm.com
1049983Sstever@gmail.com    sys.exit(0)
1059983Sstever@gmail.com
1067823Ssteve.reinhardt@amd.comexcept OSError, exc:
1074123Sbinkertn@umich.edu    print "%s: " % progname, exc
1089174Satgutier@umich.edu    sys.exit(1)
1099174Satgutier@umich.edu