96
98
def process_sqlbench_output(self):
99
if self.current_test_retcode == 0:
100
# Check for 'Failed' in sql-bench output
101
# The tests don't die on a failed test and
102
# require some checking of the output file
103
infile_name = self.current_test_output.split('\n')[1].strip()
104
inf= open(infile_name, "r")
105
inlines= inf.readlines()
107
for inline in inlines:
108
if 'Failed' in inline:
110
logging.info(inline.strip())
112
self.current_test_output += ''.join(inlines)
113
if self.current_test_retcode == 0 and not error_flag:
163
177
self.system_manager.create_symlinks(needed_symlinks)
180
class crashmeTestExecutor(sqlbenchTestExecutor):
181
""" crashme-specific variant of sqlbench executor """
183
def execute_testCase (self):
184
""" Execute a crashme testCase
187
test_execution.testExecutor.execute_testCase(self)
190
self.prepare_config()
193
self.execute_crashme()
196
self.current_test_status = self.process_crashme_output()
197
self.set_server_status(self.current_test_status)
198
self.server_manager.reset_servers(self.name)
200
def prepare_config(self):
201
""" Create the config file crash-me needs to execute """
203
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
205
# remove the existing configuration file to start fresh
206
if os.path.exists(output_filename):
207
logging.info("Removing %s" % output_filename)
208
os.remove(output_filename)
210
output_file= open(output_filename,"w")
211
# don't support '+' for concatenation
212
output_file.writelines("func_extra_concat_as_+=no\n")
213
# new boost libraries are causing us to put these limits in, needs investigation
214
output_file.writelines("max_text_size=1048576\n")
215
output_file.writelines("where_string_size=1048576\n")
216
output_file.writelines("select_string_size=1048576\n")
220
def execute_crashme(self):
221
""" Execute the commandline and return the result.
222
We use subprocess as we can pass os.environ dicts and whatnot
226
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
227
testcase_name = self.current_testcase.fullname
228
self.time_manager.start(testcase_name,'test')
229
crashme_outfile = os.path.join(self.logdir,'crashme.out')
230
crashme_output = open(crashme_outfile,'w')
231
crashme_cmd = self.current_testcase.test_command + " --config-file=%s" %(output_filename)
232
self.logging.info("Executing crash-me: %s" %(crashme_cmd))
234
crashme_subproc = subprocess.Popen( crashme_cmd
236
, cwd=os.path.join(self.system_manager.testdir, 'sql-bench')
237
, env=self.working_environment
238
, stdout = crashme_output
239
, stderr = subprocess.STDOUT
241
crashme_subproc.wait()
242
retcode = crashme_subproc.returncode
243
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
245
crashme_output.close()
246
crashme_file = open(crashme_outfile,'r')
247
output = ''.join(crashme_file.readlines())
249
self.logging.debug(output)
253
self.logging.debug("crashme_retcode: %d" %(retcode))
254
self.current_test_retcode = retcode
255
self.current_test_output = output
256
self.current_test_exec_time = execution_time
258
def process_crashme_output(self):
259
infile_name = self.current_test_output.split('\n')[3].split(':')[1].strip()
260
inf= open(infile_name, "r")
261
inlines= inf.readlines()
263
in_error_section = False
264
# crash-me is quite chatty and we don't normally want to sift
265
# through ALL of that stuff. We do allow seeing it via --verbose
267
self.current_test_output = ''
268
for inline in inlines:
269
if in_error_section and not inline.strip().startswith('#'):
270
in_error_section = False
271
if '=error' in inline:
273
in_error_section= True
275
self.current_test_output += inline
277
if self.current_test_retcode == 0 and not error_flag: