2 # Copyright (c) 2005 The Regents of The University of Michigan
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met: redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer;
9 # redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution;
12 # neither the name of the copyright holders nor the names of its
13 # contributors may be used to endorse or promote products derived from
14 # this software without specific prior written permission.
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # Authors: Steve Reinhardt
36 # Regression invocation:
40 # --scons-opts 'BATCH=yes USE_MYSQL=no -j 30 -Q' \
43 progname
= os
.path
.basename(sys
.argv
[0])
45 optparser
= optparse
.OptionParser()
46 optparser
.add_option('-v', '--verbose', dest
='verbose', action
='store_true',
48 help='echo commands before executing')
49 optparser
.add_option('--scratch', dest
='scratch', action
='store_true',
51 help='rebuld from scratch')
52 optparser
.add_option('--builds', dest
='builds',
53 default
='ALPHA_SE,ALPHA_FS,ALPHA_FS_TL',
54 help='comma-separated list of builds to test')
55 optparser
.add_option('--variants', dest
='variants',
57 help='comma-separated list of build variants to test')
58 optparser
.add_option('--workdir', dest
='workdir',
59 help='directory for checked-out source trees')
60 optparser
.add_option('--scons-opts', dest
='scons_opts', default
='',
62 optparser
.add_option('--no-pull', dest
='pull', action
='store_false',
64 help="don't pull changes from repository")
65 optparser
.add_option('--recurse', dest
='recurse', action
='store_true',
67 help='call recursively to get summary up front')
69 (options
, tests
) = optparser
.parse_args()
72 # split list options on ',' to get Python lists
73 builds
= options
.builds
.split(',')
74 variants
= options
.variants
.split(',')
76 # Repositories to clone/update
77 repos
= ['m5', 'm5-test', 'ext']
79 # Call os.system() and raise exception if return status is non-zero
83 status
= os
.system(cmd
)
85 upper
= (status
& 0xff00) >> 8
86 lower
= (status
& 0xff)
87 raise OSError, "shell command '%s' failed, status %d:%d" \
90 # Quote string s so it can be passed as a shell arg
96 # The '--recurse' option invokes scons once to perform any necessary
97 # rebuilds/test runs with the (possibly verbose) output placed in a
98 # log file, then (if the buld was successful) returns scons to print a
99 # summary of the results.
101 sys
.argv
.remove('--recurse') # avoid infinite recursion...
102 timestr
= datetime
.datetime
.now().isoformat('-')[:19]
103 logfile
= '%s-%s' % (progname
, timestr
)
104 # quote args for shell
105 qargs
= [shellquote(a
) for a
in sys
.argv
]
106 # always run the sub-job in verbose mode
108 cmd
= '%s > %s 2>&1' % (' '.join(qargs
), logfile
)
112 print "Error: recursive invocation failed, aborting."
114 print "======================="
115 os
.system('cat %s' % logfile
)
117 # recursive call succeeded... re-run to generate summary
118 # don't *re*-build from scratch now
119 options
.scratch
= False
120 # no need to re-pull since the recursive call shoudl have done that
122 print "Recursive invocation successful, see %s for output." % logfile
127 print 'cd', options
.workdir
128 os
.chdir(options
.workdir
)
132 system('rm -rf %s' % dir)
133 system('bk clone /bk/%s' % dir)
136 system('cd %s; bk pull' % dir)
139 print "No tests specified."
146 targets
= ['%s/test/%s/%s' % (build
, variant
, test
)
147 for build
in builds
for variant
in variants
for test
in tests
]
149 system('scons %s %s' % (options
.scons_opts
, ' '.join(targets
)))
154 print "%s: " % progname
, exc