~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/test_run_options.py

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/env python
2
 
# -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
3
 
# vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
 
#
5
 
# Copyright (C) 2010 Patrick Crews
6
 
#
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.
11
 
#
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.
16
 
#
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
20
 
 
21
 
 
22
 
 
23
 
"""Processes command line options for Drizzle test-runner"""
24
 
 
25
 
import sys
26
 
import os
27
 
import exceptions
28
 
import optparse
29
 
 
30
 
# functions
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
37
 
    if '' in input_list:
38
 
        input_list.remove('')
39
 
    if cur_list:
40
 
        value_list = cur_list + input_list 
41
 
    else:
42
 
        value_list = input_list 
43
 
    setattr(parser.values, option.dest, value_list)
44
 
 
45
 
def organize_options(args, test_cases):
46
 
    """Put our arguments in a nice dictionary
47
 
       We use option.dest as dictionary key
48
 
       item = supplied input
49
 
 
50
 
    """
51
 
    variables = {}
52
 
    variables = vars(args)
53
 
    variables['test_cases']= test_cases
54
 
    if variables['manualgdb']:
55
 
        variables['gdb']=True
56
 
    return variables
57
 
 
58
 
# Create the CLI option parser
59
 
parser= optparse.OptionParser()
60
 
 
61
 
# find some default values
62
 
# assume we are in-tree testing in general and operating from root/test(?)
63
 
testdir_default = os.path.abspath(os.getcwd())
64
 
 
65
 
server_default = os.path.abspath(os.path.join(testdir_default,
66
 
                                       '../drizzled/drizzled'))
67
 
 
68
 
workdir_default = os.path.join(testdir_default,'dbqp_work')
69
 
 
70
 
clientbindir_default = os.path.abspath(os.path.join(testdir_default,
71
 
                                       '../client'))
72
 
 
73
 
basedir_default = os.path.split(testdir_default)[0]
74
 
 
75
 
 
76
 
# system_control_group - things like verbose, debug, etc
77
 
# test-runner affecting options
78
 
system_control_group = optparse.OptionGroup(parser, 
79
 
                         "Options for the test-runner itself")
80
 
 
81
 
system_control_group.add_option(
82
 
   "--force"
83
 
 , dest="force"
84
 
 , action="store_true"
85
 
 , default=False
86
 
 , help="Set this to continue test execution beyond the first failed test"
87
 
 )
88
 
 
89
 
system_control_group.add_option(
90
 
    "--start-and-exit"
91
 
  , dest="startandexit"
92
 
  , action="store_true"
93
 
  , default=False
94
 
  , help="Spin up the server(s) for the first specified test then exit (will leave servers running)"
95
 
  )
96
 
 
97
 
system_control_group.add_option(
98
 
    "--verbose"
99
 
   , dest="verbose"
100
 
   , action="store_true"
101
 
   , default = False
102
 
   , help="Produces extensive output about test-runner state.  Distinct from --debug"
103
 
   )
104
 
 
105
 
system_control_group.add_option(
106
 
    "--debug"
107
 
   , dest="debug"
108
 
   , action="store_true"
109
 
   , default = False
110
 
   , help="Provide internal-level debugging output.  Distinct from --verbose"
111
 
   )
112
 
 
113
 
system_control_group.add_option(
114
 
    "--mode"
115
 
  , dest="mode"
116
 
  , default="dtr"
117
 
  , help="Testing mode.  We only support dtr...for now >;) [%default]"
118
 
  )
119
 
 
120
 
system_control_group.add_option(
121
 
    "--record"
122
 
  , dest="record"
123
 
  , action="store_true"
124
 
  , default=False
125
 
  , help="Record a testcase result (if the testing mode supports it) [%default]"
126
 
  )
127
 
 
128
 
system_control_group.add_option(
129
 
    "--fast"
130
 
  , dest="fast"
131
 
  , action="store_true"
132
 
  , default=False
133
 
  , help="Don't try to cleanup from earlier runs (currently just a placeholder) [%default]"
134
 
  )
135
 
 
136
 
parser.add_option_group(system_control_group)
137
 
 
138
 
# end system_control_group
139
 
 
140
 
# test_control_group - things like suite, do-test, skip-test
141
 
# Affect which tests are run
142
 
test_control_group = optparse.OptionGroup(parser, 
143
 
                         "Options for controlling which tests are executed")
144
 
 
145
 
 
146
 
test_control_group.add_option(
147
 
    "--suite"
148
 
  , dest="suitelist"
149
 
  , type='string'
150
 
  , action="callback"
151
 
  , callback=comma_list_split
152
 
  , 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]"
153
 
  )
154
 
 
155
 
test_control_group.add_option(
156
 
    "--suitepath"
157
 
  , dest="suitepaths"
158
 
  , type='string'
159
 
  , action="append"
160
 
  , default = []
161
 
  , help="The path containing the suite(s) you wish to execute.  Use on --suitepath for each suite you want to use."
162
 
  )
163
 
test_control_group.add_option(
164
 
    "--do-test"
165
 
  , dest="dotest"
166
 
  , type='string'
167
 
  , default = None
168
 
  , help="input can either be a prefix or a regex. Will only execute tests that match the provided pattern"
169
 
  )
170
 
 
171
 
test_control_group.add_option(
172
 
    "--skip-test"
173
 
  , dest="skiptest"
174
 
  , type='string'
175
 
  , default = None
176
 
  , help = "input can either be a prefix or a regex.  Will exclude tests that match the provided pattern"
177
 
  )
178
 
 
179
 
test_control_group.add_option(
180
 
    "--reorder"
181
 
  , dest="reorder"
182
 
  , action="store_true"
183
 
  , default=False
184
 
  , help = "sort the testcases so that they are executed optimally for the given mode [%default]"
185
 
  )
186
 
 
187
 
 
188
 
 
189
 
parser.add_option_group(test_control_group)
190
 
# end test_control_group
191
 
 
192
 
# test subject control group
193
 
# terrible name for options tht define the server / code
194
 
# that is under test
195
 
test_subject_control_group = optparse.OptionGroup(parser,
196
 
                                 "Options for defining the code that will be under test")
197
 
 
198
 
test_subject_control_group.add_option(
199
 
    "--basedir"
200
 
  , dest="basedir"
201
 
  , type='string'
202
 
  , default = basedir_default
203
 
  , 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]"
204
 
  )
205
 
 
206
 
test_subject_control_group.add_option(
207
 
    "--serverdir"
208
 
  , dest="serverpath"
209
 
  , type='string'
210
 
  , default = "auto-search"
211
 
  , help = "Path to the server executable.  [%default]"
212
 
  )
213
 
 
214
 
test_subject_control_group.add_option(
215
 
    "--client-bindir"
216
 
  , dest="clientbindir"
217
 
  , type = 'string'
218
 
  , default = "auto-search"
219
 
  , help = "Path to the directory containing client program binaries for use in testing [%default]"
220
 
  )
221
 
 
222
 
 
223
 
test_subject_control_group.add_option(
224
 
    "--default-storage-engine"
225
 
   , dest="defaultengine"
226
 
   , default = 'innodb'
227
 
   , help="Start drizzled using the specified engine [%default]"
228
 
   )    
229
 
 
230
 
 
231
 
parser.add_option_group(test_subject_control_group)
232
 
# end test subject control group
233
 
 
234
 
 
235
 
# environment options
236
 
# define where to find our testsets, working dirs, etc
237
 
environment_control_group = optparse.OptionGroup(parser, 
238
 
                            "Options for defining the testing environment")
239
 
 
240
 
environment_control_group.add_option(
241
 
    "--testdir"
242
 
  , dest="testdir"
243
 
  , type = 'string'
244
 
  , default = testdir_default
245
 
  , help = "Path to the test dir, containing additional files for test execution. [%default]"
246
 
  )
247
 
 
248
 
environment_control_group.add_option(
249
 
    "--workdir"
250
 
  , dest="workdir"
251
 
  , type='string'
252
 
  , default = workdir_default
253
 
  , help = "Path to the directory test-run will use to store generated files and directories. [%default]"
254
 
  )
255
 
 
256
 
environment_control_group.add_option(
257
 
    "--top-srcdir"
258
 
  , dest="topsrcdir"
259
 
  , type='string'
260
 
  , default = basedir_default
261
 
  , help = "build option [%default]"
262
 
  )
263
 
 
264
 
environment_control_group.add_option(
265
 
    "--top-builddir"
266
 
  , dest="topbuilddir"
267
 
  , type='string'
268
 
  , default = basedir_default
269
 
  , help = "build option [%default]"
270
 
  )
271
 
 
272
 
environment_control_group.add_option(
273
 
    "--no-shm"
274
 
  , dest="noshm"
275
 
  , action='store_true'
276
 
  , default=False
277
 
  , help = "By default, we symlink workdir to a location in shm.  Use this flag to not symlink [%default]"
278
 
  )
279
 
 
280
 
environment_control_group.add_option(
281
 
    "--start-dirty"
282
 
  , dest="startdirty"
283
 
  , action='store_true'
284
 
  , default=False
285
 
  , help = "Don't try to clean up working directories before test execution [%default]"
286
 
  )
287
 
 
288
 
environment_control_group.add_option(
289
 
    "--no-secure-file-priv"
290
 
  , dest = "nosecurefilepriv"
291
 
  , action='store_true'
292
 
  , default=False
293
 
  , help = "Turn off the use of --secure-file-priv=vardir for started servers"
294
 
  )
295
 
 
296
 
parser.add_option_group(environment_control_group)
297
 
# end environment control group
298
 
 
299
 
option_passing_group = optparse.OptionGroup(parser,
300
 
                          "Options to pass options on to the server")
301
 
 
302
 
option_passing_group.add_option(
303
 
    "--drizzled"
304
 
  , dest="drizzledoptions"
305
 
  , type='string'
306
 
  , action='append' 
307
 
  , default = []
308
 
  , help = "Pass additional options to the server.  Will be passed to all servers for all tests (mostly for --start-and-exit)"
309
 
  )
310
 
 
311
 
parser.add_option_group(option_passing_group)
312
 
# end option passing group
313
 
 
314
 
 
315
 
analysis_control_group = optparse.OptionGroup(parser, 
316
 
                            "Options for defining the tools we use for code analysis (valgrind, gprof, gcov, etc)")
317
 
 
318
 
analysis_control_group.add_option(
319
 
    "--valgrind"
320
 
  , dest="valgrind"
321
 
  , action='store_true'
322
 
  , default = False
323
 
  , help = "Run drizzletest and drizzled executables using valgrind with default options [%default]"
324
 
  )
325
 
analysis_control_group.add_option(
326
 
    "--valgrind-option"
327
 
  , dest="valgrindarglist"
328
 
  , type='string'
329
 
  , action="append"
330
 
  , help = "Pass an option to valgrind (overrides/removes default valgrind options)"
331
 
  )
332
 
 
333
 
parser.add_option_group(analysis_control_group)
334
 
 
335
 
debugger_control_group = optparse.OptionGroup(parser,
336
 
                           "Options for controlling the use of debuggers with test execution")
337
 
 
338
 
debugger_control_group.add_option(
339
 
    "--gdb"
340
 
  , dest="gdb"
341
 
  , action='store_true'
342
 
  , default=False
343
 
  , help="Start the drizzled server(s) in gdb"
344
 
  )
345
 
 
346
 
debugger_control_group.add_option(
347
 
    "--manual-gdb"
348
 
  , dest="manualgdb"
349
 
  , action='store_true'
350
 
  , default=False
351
 
  , help="Allows you to start the drizzled server(s) in gdb manually (in another window, etc)"
352
 
  )
353
 
 
354
 
parser.add_option_group(debugger_control_group)
355
 
 
356
 
 
357
 
# supplied will be those arguments matching an option, 
358
 
# and test_cases will be everything else
359
 
(args, test_cases)= parser.parse_args()
360
 
 
361
 
variables = {}
362
 
variables = organize_options(args, test_cases)
363