167
165
ld_lib_paths = [ os.path.join(self.basedir,"lib")]
168
166
return ld_lib_paths
168
class mysqlTree(codeTree):
169
""" What a MySQL code tree should look like to the test-runner
173
def __init__(self, variables,system_manager):
174
self.system_manager = system_manager
175
self.logging = self.system_manager.logging
176
self.skip_keys = ['ld_lib_paths']
177
self.debug = variables['debug']
178
self.verbose = variables['verbose']
179
self.basedir = self.system_manager.find_path([os.path.abspath(variables['basedir'][0])])
180
self.source_dist = os.path.isdir(os.path.join(self.basedir, 'mysqld'))
181
self.builddir = self.system_manager.find_path([os.path.abspath(self.basedir)])
182
self.top_builddir = variables['topbuilddir']
183
self.testdir = self.system_manager.find_path([os.path.abspath(variables['testdir'])])
184
self.clientbindir = self.system_manager.find_path([os.path.join(self.basedir, 'client_release')
185
, os.path.join(self.basedir, 'client_debug')
186
, os.path.join(self.basedir, 'client')
187
, os.path.join(self.basedir, 'bin')])
188
self.charsetdir = self.system_manager.find_path([os.path.join(self.basedir, 'mysql/charsets')
189
, os.path.join(self.basedir, 'sql/share/charsets')
190
, os.path.join(self.basedir, 'share/charsets')])
191
self.langdir = self.system_manager.find_path([os.path.join(self.basedir, 'share/mysql')
192
, os.path.join(self.basedir, 'sql/share')
193
, os.path.join(self.basedir, 'share')])
196
self.srcdir = self.system_manager.find_path([self.basedir])
197
self.suite_paths = variables['suitepaths']
199
self.mysql_client = self.system_manager.find_path([os.path.join(self.clientbindir,
202
self.mysqldump = self.system_manager.find_path([os.path.join(self.clientbindir,
205
self.mysqlimport = self.system_manager.find_path([os.path.join(self.clientbindir,
208
self.mysqladmin = self.system_manager.find_path([os.path.join(self.clientbindir,
211
self.mysql_server = self.system_manager.find_path([ os.path.join(self.basedir, '/sql/mysqld-debug')
212
, os.path.join(self.basedir, '/libexec/mysqld-debug')
213
, os.path.join(self.basedir, '/sbin/mysqld-debug')
214
, os.path.join(self.basedir, '/bin/mysqld-debug')
215
, os.path.join(self.basedir, '/sql/mysqld')
216
, os.path.join(self.basedir, '/libexec/mysqld')
217
, os.path.join(self.basedir, '/sbin/mysqld')
218
, os.path.join(self.basedir, '/bin/mysqld')
219
, os.path.join(self.basedir, '/sql/mysqld-max-nt')
220
, os.path.join(self.basedir, '/libexec/mysqld-max-nt')
221
, os.path.join(self.basedir, '/sbin/mysqld-max-nt')
222
, os.path.join(self.basedir, '/bin/mysqld-max-nt')
223
, os.path.join(self.basedir, '/sql/mysqld-max')
224
, os.path.join(self.basedir, '/libexec/mysqld-max')
225
, os.path.join(self.basedir, '/sbin/mysqld-max')
226
, os.path.join(self.basedir, '/bin/mysqld-max')
227
, os.path.join(self.basedir, '/sql/mysqld-nt')
228
, os.path.join(self.basedir, '/libexec/mysqld-nt')
229
, os.path.join(self.basedir, '/sbin/mysqld-nt')
230
, os.path.join(self.basedir, '/bin/mysqld-nt')
235
self.mysqlslap = self.system_manager.find_path([os.path.join(self.clientbindir,
238
self.mysqltest = self.system_manager.find_path([os.path.join(self.clientbindir,
240
self.server_version_string = None
241
self.server_executable = None
242
self.server_version = None
243
self.server_compile_os = None
244
self.server_platform = None
245
self.server_compile_comment = None
247
self.process_server_version()
248
self.ld_lib_paths = self.get_ld_lib_paths()
249
self.bootstrap_path = os.path.join( self.system_manager.workdir
250
, 'mysql_bootstrap.sql' )
251
self.generate_bootstrap()
255
self.logging.debug_class(self)
258
self.logging.info("Using mysql source tree:")
259
report_keys = ['basedir'
266
for key in report_keys:
267
self.logging.info("%s: %s" %(key, vars(self)[key]))
269
def process_server_version(self):
270
""" Get the server version number from the found server executable """
271
(retcode, self.server_version_string) = self.system_manager.execute_cmd(("%s --no-defaults --version" %(self.mysql_server)))
272
# This is a bit bobo, but we're doing it, so nyah
274
self.server_executable, data_string = [data_item.strip() for data_item in self.server_version_string.split('Ver ')]
275
self.server_version, data_string = [data_item.strip() for data_item in data_string.split('for ')]
276
self.server_compile_os, data_string = [data_item.strip() for data_item in data_string.split(' on')]
277
self.server_platform = data_string.split(' ')[0].strip()
278
self.server_comment = data_string.replace(self.server_platform,'').strip()
280
def get_ld_lib_paths(self):
281
""" Return a list of paths we want added to LD_LIB variables
283
These are processed later at the server_manager level, but we want to
284
specify them here (for a mysql source tree) and now
289
ld_lib_paths = [ os.path.join(self.basedir,"libmysql/.libs/")
290
, os.path.join(self.basedir,"libmysql_r/.libs")
291
, os.path.join(self.basedir,"zlib/.libs")
294
ld_lib_paths = [ os.path.join(self.basedir,"lib")
295
, os.path.join(self.basedir,"lib/mysql")]
298
def generate_bootstrap(self):
299
""" We do the voodoo that we need to in order to create the bootstrap
303
found_new_sql = False
304
# determine if we have a proper area for our sql or if we
305
# use the rigged method from 5.0 / 5.1
306
# first we search various possible locations
307
test_file = "mysql_system_tables.sql"
308
for candidate_dir in [ "mysql"
313
candidate_path = os.path.join(self.basedir, candidate_dir, test_file)
314
if os.path.exists(candidate_path):
315
bootstrap_file = open(self.bootstrap_path,'w')
316
bootstrap_file.write("use mysql\n")
317
for sql_file in [ 'mysql_system_tables.sql' #official mysql system tables
318
, 'mysql_system_tables_data.sql' #initial data for sys tables
319
, 'mysql_test_data_timezone.sql' # subset of full tz table data for testing
320
, 'fill_help_tables.sql' # fill help tables populated only w/ src dist(?)
322
sql_file_path = os.path.join(self.basedir,candidate_dir,sql_file)
323
sql_file_handle = open(sql_file_path,'r')
324
bootstrap_file.write(sql_file_handle.readlines())
325
sql_file_handle.close()
328
if not found_new_sql:
329
# Install the system db's from init_db.sql
330
# that is in early 5.1 and 5.0 versions of MySQL
331
sql_file_path = os.path.join(self.basedir,'mysql-test/lib/init_db.sql')
332
self.logging.info("Attempting to use bootstrap file - %s" %(sql_file_path))
334
in_file = open(sql_file_path,'r')
335
bootstrap_file = open(self.bootstrap_path,'w')
336
bootstrap_file.write(in_file.readlines())
339
self.logging.error("Cannot find data for generating bootstrap file")
340
self.logging.error("Cannot proceed without this, system exiting...")
342
# Remove anonymous users
343
bootstrap_file.write("DELETE FROM mysql.user where user= '';\n")
344
# Create mtr database
345
bootstrap_file.write("CREATE DATABASE mtr;\n")
346
for sql_file in [ 'mtr_warnings.sql' # help tables + data for warning detection / suppression
347
, 'mtr_check.sql' # Procs for checking proper restore post-testcase
349
sql_file_path = os.path.join(self.basedir,'mysql-test/include',sql_file)
350
sql_file_handle = open(sql_file_path,'r')
351
bootstrap_file.write(sql_file_handle.readlines())
352
sql_file_handle.close()
353
bootstrap_file.close()