2
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5
# Copyright (C) 2010 Patrick Crews
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
"""Processes command line options for Drizzle test-runner"""
31
def comma_list_split(option, opt, value, parser):
32
"""Callback for splitting input expected in list form"""
33
cur_list = getattr(parser.values, option.dest,[])
34
input_list = value.split(',')
35
# this is a hack to work with make target - we
36
# don't deal with a dangling ',' in our list
40
value_list = cur_list + input_list
42
value_list = input_list
43
setattr(parser.values, option.dest, value_list)
45
def organize_options(args, test_cases):
46
"""Put our arguments in a nice dictionary
47
We use option.dest as dictionary key
52
variables = vars(args)
53
variables['test_cases']= test_cases
54
# This code should become a function once
55
# enough thought has been given to it
56
if variables['manualgdb']:
58
if variables['repeat'] <= 0:
59
print "Setting --repeat=1. You chose a silly value that I will ignore :P"
60
variables['repeat'] = 1
63
# Create the CLI option parser
64
parser= optparse.OptionParser()
66
# find some default values
67
# assume we are in-tree testing in general and operating from root/test(?)
68
testdir_default = os.path.abspath(os.getcwd())
70
server_default = os.path.abspath(os.path.join(testdir_default,
71
'../drizzled/drizzled'))
73
workdir_default = os.path.join(testdir_default,'dbqp_work')
75
clientbindir_default = os.path.abspath(os.path.join(testdir_default,
78
basedir_default = os.path.split(testdir_default)[0]
81
# system_control_group - things like verbose, debug, etc
82
# test-runner affecting options
83
system_control_group = optparse.OptionGroup(parser,
84
"Options for the test-runner itself")
86
system_control_group.add_option(
91
, help="Set this to continue test execution beyond the first failed test"
94
system_control_group.add_option(
99
, help="Spin up the server(s) for the first specified test then exit (will leave servers running)"
102
system_control_group.add_option(
105
, action="store_true"
107
, help="Produces extensive output about test-runner state. Distinct from --debug"
110
system_control_group.add_option(
113
, action="store_true"
115
, help="Provide internal-level debugging output. Distinct from --verbose"
118
system_control_group.add_option(
122
, help="Testing mode. We only support dtr...for now >;) [%default]"
125
system_control_group.add_option(
128
, action="store_true"
130
, help="Record a testcase result (if the testing mode supports it) [%default]"
133
system_control_group.add_option(
136
, action="store_true"
138
, help="Don't try to cleanup from earlier runs (currently just a placeholder) [%default]"
141
parser.add_option_group(system_control_group)
143
# end system_control_group
145
# test_control_group - things like suite, do-test, skip-test
146
# Affect which tests are run
147
test_control_group = optparse.OptionGroup(parser,
148
"Options for controlling which tests are executed")
151
test_control_group.add_option(
156
, callback=comma_list_split
157
, help="The name of the suite containing tests we want. Can accept comma-separated list (with no spaces). Additional --suite args are appended to existing list [autosearch]"
160
test_control_group.add_option(
166
, help="The path containing the suite(s) you wish to execute. Use on --suitepath for each suite you want to use."
168
test_control_group.add_option(
173
, help="input can either be a prefix or a regex. Will only execute tests that match the provided pattern"
176
test_control_group.add_option(
181
, help = "input can either be a prefix or a regex. Will exclude tests that match the provided pattern"
184
test_control_group.add_option(
187
, action="store_true"
189
, help = "sort the testcases so that they are executed optimally for the given mode [%default]"
192
test_control_group.add_option(
198
, help = "Run each test case the specified number of times. For a given sequence, the first test will be run n times, then the second, etc [%default]"
201
parser.add_option_group(test_control_group)
202
# end test_control_group
204
# test subject control group
205
# terrible name for options tht define the server / code
207
test_subject_control_group = optparse.OptionGroup(parser,
208
"Options for defining the code that will be under test")
210
test_subject_control_group.add_option(
214
, default = basedir_default
215
, help = "Pass this argument to signal to the test-runner that this is an in-tree test. We automatically set a number of variables relative to the argument (client-bindir, serverdir, testdir) [%default]"
218
test_subject_control_group.add_option(
222
, default = "auto-search"
223
, help = "Path to the server executable. [%default]"
226
test_subject_control_group.add_option(
228
, dest="clientbindir"
230
, default = "auto-search"
231
, help = "Path to the directory containing client program binaries for use in testing [%default]"
235
test_subject_control_group.add_option(
236
"--default-storage-engine"
237
, dest="defaultengine"
239
, help="Start drizzled using the specified engine [%default]"
243
parser.add_option_group(test_subject_control_group)
244
# end test subject control group
247
# environment options
248
# define where to find our testsets, working dirs, etc
249
environment_control_group = optparse.OptionGroup(parser,
250
"Options for defining the testing environment")
252
environment_control_group.add_option(
256
, default = testdir_default
257
, help = "Path to the test dir, containing additional files for test execution. [%default]"
260
environment_control_group.add_option(
264
, default = workdir_default
265
, help = "Path to the directory test-run will use to store generated files and directories. [%default]"
268
environment_control_group.add_option(
272
, default = basedir_default
273
, help = "build option [%default]"
276
environment_control_group.add_option(
280
, default = basedir_default
281
, help = "build option [%default]"
284
environment_control_group.add_option(
287
, action='store_true'
289
, help = "By default, we symlink workdir to a location in shm. Use this flag to not symlink [%default]"
292
environment_control_group.add_option(
295
, action='store_true'
297
, help = "Don't try to clean up working directories before test execution [%default]"
300
environment_control_group.add_option(
301
"--no-secure-file-priv"
302
, dest = "nosecurefilepriv"
303
, action='store_true'
305
, help = "Turn off the use of --secure-file-priv=vardir for started servers"
308
parser.add_option_group(environment_control_group)
309
# end environment control group
311
option_passing_group = optparse.OptionGroup(parser,
312
"Options to pass options on to the server")
314
option_passing_group.add_option(
316
, dest="drizzledoptions"
320
, help = "Pass additional options to the server. Will be passed to all servers for all tests (mostly for --start-and-exit)"
323
parser.add_option_group(option_passing_group)
324
# end option passing group
327
analysis_control_group = optparse.OptionGroup(parser,
328
"Options for defining the tools we use for code analysis (valgrind, gprof, gcov, etc)")
330
analysis_control_group.add_option(
333
, action='store_true'
335
, help = "Run drizzletest and drizzled executables using valgrind with default options [%default]"
337
analysis_control_group.add_option(
339
, dest="valgrindarglist"
342
, help = "Pass an option to valgrind (overrides/removes default valgrind options)"
345
parser.add_option_group(analysis_control_group)
347
debugger_control_group = optparse.OptionGroup(parser,
348
"Options for controlling the use of debuggers with test execution")
350
debugger_control_group.add_option(
353
, action='store_true'
355
, help="Start the drizzled server(s) in gdb"
358
debugger_control_group.add_option(
361
, action='store_true'
363
, help="Allows you to start the drizzled server(s) in gdb manually (in another window, etc)"
366
parser.add_option_group(debugger_control_group)
369
# supplied will be those arguments matching an option,
370
# and test_cases will be everything else
371
(args, test_cases)= parser.parse_args()
374
variables = organize_options(args, test_cases)