118
class crashmeTestExecutor(sqlbenchTestExecutor):
119
""" crashme-specific variant of sqlbench executor """
121
def execute_testCase (self):
122
""" Execute a crashme testCase
125
test_execution.testExecutor.execute_testCase(self)
128
self.prepare_config()
131
self.execute_crashme()
134
self.current_test_status = self.process_crashme_output()
135
self.set_server_status(self.current_test_status)
136
self.server_manager.reset_servers(self.name)
138
def prepare_config(self):
139
""" Create the config file crash-me needs to execute """
141
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
143
# remove the existing configuration file to start fresh
144
if os.path.exists(output_filename):
145
logging.info("Removing %s" % output_filename)
146
os.remove(output_filename)
148
output_file= open(output_filename,"w")
149
# don't support '+' for concatenation
150
output_file.writelines("func_extra_concat_as_+=no\n")
151
# new boost libraries are causing us to put these limits in, needs investigation
152
output_file.writelines("max_text_size=1048576\n")
153
output_file.writelines("where_string_size=1048576\n")
154
output_file.writelines("select_string_size=1048576\n")
158
def execute_crashme(self):
159
""" Execute the commandline and return the result.
160
We use subprocess as we can pass os.environ dicts and whatnot
164
output_filename= "%s/drizzle.cfg" % (self.system_manager.workdir)
165
testcase_name = self.current_testcase.fullname
166
self.time_manager.start(testcase_name,'test')
167
crashme_outfile = os.path.join(self.logdir,'crashme.out')
168
crashme_output = open(crashme_outfile,'w')
169
crashme_cmd = self.current_testcase.test_command + " --config-file=%s" %(output_filename)
170
self.logging.info("Executing crash-me: %s" %(crashme_cmd))
172
crashme_subproc = subprocess.Popen( crashme_cmd
174
, cwd=os.path.join(self.system_manager.testdir, 'sql-bench')
175
, env=self.working_environment
176
, stdout = crashme_output
177
, stderr = subprocess.STDOUT
179
crashme_subproc.wait()
180
retcode = crashme_subproc.returncode
181
execution_time = int(self.time_manager.stop(testcase_name)*1000) # millisec
183
crashme_output.close()
184
crashme_file = open(crashme_outfile,'r')
185
output = ''.join(crashme_file.readlines())
186
self.logging.debug(output)
189
self.logging.debug("crashme_retcode: %d" %(retcode))
190
self.current_test_retcode = retcode
191
self.current_test_output = output
192
self.current_test_exec_time = execution_time
194
def process_crashme_output(self):
195
if self.current_test_retcode == 0:
196
infile_name = self.current_test_output.split('\n')[3].split(':')[1].strip()
197
inf= open(infile_name, "r")
198
inlines= inf.readlines()
200
in_error_section = False
201
# crash-me is quite chatty and we don't normally want to sift
202
# through ALL of that stuff. We do allow seeing it via --verbose
204
self.current_test_output = ''
205
for inline in inlines:
206
if in_error_section and not inline.strip().startswith('#'):
207
in_error_section = False
208
if '=error' in inline:
210
in_error_section= True
212
self.current_test_output += inline