20 from yapsy.PluginManager
import PluginManager
22 from ExecutorMTTTool
import *
44 ExecutorMTTTool.__init__(self)
49 IPlugin.activate(self)
53 IPlugin.deactivate(self)
57 return "Sequential executor"
60 lines = testDef.printOptions(self.
options)
69 for step
in testDef.loader.stageOrder:
70 for title
in testDef.config.sections():
77 if step !=
"Reporter":
80 testDef.plugin_trans_sem.release()
81 if (
":" in title
and step
not in title.split(
":")[0])
or \
82 (
":" not in title
and step
not in title):
83 testDef.plugin_trans_sem.acquire()
86 if title
not in testDef.actives:
87 testDef.plugin_trans_sem.acquire()
92 disp_title = title + title_append
94 testDef.logger.verbose_print(disp_title)
103 testDef.plugin_trans_sem.acquire()
107 stage,name = title.split(
':')
108 stage = stage.strip()
113 testDef.logger.stage_start_print(disp_title)
116 if testDef.options[
'executor'] !=
"combinatorial":
118 testDef.fill_env_hidden_section()
120 testDef.fill_log_hidden_section()
122 testDef.logger.verbose_print(
"OPTIONS FOR SECTION: %s" % disp_title)
123 strs_to_print = testDef.logger.get_tuplelist_contents(testDef.config.items(title))
125 for s
in strs_to_print:
126 testDef.logger.verbose_print(
" %s" % s)
128 testDef.logger.verbose_print(
" No options provided for section")
131 stageLog = {
'section':disp_title}
133 stageLog[
"parameters"] = testDef.config.items(title)
139 keyvals = {
'section':disp_title.strip()}
140 for kv
in testDef.config.items(title):
141 keyvals[kv[0].strip()] = kv[1].strip()
142 if 'parent' in keyvals:
143 keyvals[
'parent'] = keyvals[
'parent'] + title_append
149 while stage[i].isspace():
152 stageLog[
'section'] = disp_title[i:].strip()
153 keyvals[
'section'] = disp_title[i:].strip()
154 keyvals[
'asis'] =
True
159 parent = keyvals[
'parent']
160 if parent
is not None:
162 bldlog = testDef.logger.getLog(parent)
165 stageLog[
'status'] = 1
166 stageLog[
'stderr'] = [
"Prior dependent step did not record a log"]
167 testDef.logger.logResults(disp_title, stageLog, testDef)
168 testDef.plugin_trans_sem.acquire()
171 if bldlog[
'status'] != 0:
174 stageLog[
'status'] = bldlog[
'status']
175 stageLog[
'stderr'] = [
"Prior dependent step failed - cannot proceed"]
176 testDef.logger.logResults(disp_title, stageLog, testDef)
177 testDef.plugin_trans_sem.acquire()
181 stageLog[
'status'] = 1
182 stageLog[
'stderr'] = [
"Prior dependent step failed to provide a status"]
183 testDef.logger.logResults(disp_title, stageLog, testDef)
184 testDef.plugin_trans_sem.acquire()
191 module = keyvals[
'plugin']
194 for pluginInfo
in testDef.stages.getPluginsOfCategory(stage):
195 if module == pluginInfo.plugin_object.print_name():
196 plugin = pluginInfo.plugin_object
203 availTools = list(testDef.loader.tools.keys())
204 for tool
in availTools:
205 for pluginInfo
in testDef.tools.getPluginsOfCategory(tool):
206 if module == pluginInfo.plugin_object.print_name():
207 plugin = pluginInfo.plugin_object
209 if plugin
is not None:
213 availUtils = list(testDef.loader.utilities.keys())
214 for util
in availUtils:
215 for pluginInfo
in testDef.utilities.getPluginsOfCategory(util):
216 if module == pluginInfo.plugin_object.print_name():
217 plugin = pluginInfo.plugin_object
219 if plugin
is not None:
222 stageLog[
'status'] = 1
223 stageLog[
'stderr'] =
"Specified plugin",module,
"does not exist in stage",stage,
"or in the available tools and utilities"
224 testDef.logger.logResults(disp_title, stageLog, testDef)
225 testDef.plugin_trans_sem.acquire()
229 testDef.tools.activatePluginByName(module, tool)
232 testDef.stages.activatePluginByName(module, stage)
235 availTools = list(testDef.loader.tools.keys())
236 for tool
in availTools:
237 for pluginInfo
in testDef.tools.getPluginsOfCategory(tool):
238 if module == pluginInfo.plugin_object.print_name():
239 plugin = pluginInfo.plugin_object
241 if plugin
is not None:
245 availUtils = list(testDef.loader.utilities.keys())
246 for util
in availUtils:
247 for pluginInfo
in testDef.utilities.getPluginsOfCategory(util):
248 if module == pluginInfo.plugin_object.print_name():
249 plugin = pluginInfo.plugin_object
251 if plugin
is not None:
254 stageLog[
'status'] = 1
255 stageLog[
'stderr'] =
"Specified plugin",module,
"does not exist in stage",stage,
"or in the available tools and utilities"
256 testDef.logger.logResults(disp_title, stageLog, testDef)
257 testDef.plugin_trans_sem.acquire()
261 testDef.tools.activatePluginByName(module, tool)
265 default =
"Default{0}".format(stage)
266 for pluginInfo
in testDef.stages.getPluginsOfCategory(stage):
267 if default == pluginInfo.plugin_object.print_name():
268 plugin = pluginInfo.plugin_object
272 stageLog[
'status'] = 1
273 stageLog[
'stderr'] =
"Plugin for stage",stage,
"was not specified, and no default is available"
274 testDef.logger.logResults(disp_title, stageLog, testDef)
275 testDef.plugin_trans_sem.acquire()
279 if not plugin.is_activated:
283 testDef.logger.verbose_print(
"Executing plugin %s" % plugin.print_name())
284 plugin.execute(stageLog, keyvals, testDef)
288 if 'stdout' in stageLog
and isinstance(stageLog[
'stdout'], str):
289 stageLog[
'stdout'] = stageLog[
'stdout'].split(
"\n")
290 if 'stderr' in stageLog
and isinstance(stageLog[
'stderr'], str):
291 stageLog[
'stderr'] = stageLog[
'stderr'].split(
"\n")
294 testDef.logger.stage_end_print(disp_title, stageLog)
297 testDef.logger.logResults(disp_title, stageLog, testDef)
299 if testDef.options[
'stop_on_fail']
is not False and stageLog[
'status'] != 0:
300 print(
"Section " + stageLog[
'section'] +
": Status " + str(stageLog[
'status']))
302 print(
"Section " + stageLog[
'section'] +
": Stderr " + str(stageLog[
'stderr']))
308 if stageLog[
'status'] != 0:
312 testDef.plugin_trans_sem.acquire()
314 except KeyboardInterrupt
as e:
316 for p
in testDef.stages.getAllPlugins() \
317 + testDef.tools.getAllPlugins() \
318 + testDef.utilities.getAllPlugins():
319 if not p._getIsActivated():
321 p.plugin_object.deactivate()
322 testDef.logger.logResults(disp_title, stageLog, testDef)
323 testDef.logger.verbose_print(
"=======================================")
324 testDef.logger.verbose_print(
"KeyboardInterrupt exception was raised: %s %s" \
326 testDef.logger.verbose_print(
"=======================================")
327 stageLog[
'status'] = 0
328 stageLog[
'stderr'] = [
"Exception was raised: %s %s" % (type(e), str(e))]
333 except BaseException
as e:
335 for p
in testDef.stages.getAllPlugins() \
336 + testDef.tools.getAllPlugins() \
337 + testDef.utilities.getAllPlugins():
338 if not p._getIsActivated():
340 p.plugin_object.deactivate()
341 testDef.logger.verbose_print(
"=======================================")
342 testDef.logger.verbose_print(
"Exception was raised: %s %s" \
344 testDef.logger.verbose_print(
"=======================================")
345 type_, value_, traceback_ = sys.exc_info()
346 ex = traceback.format_exception(type_, value_, traceback_)
347 testDef.logger.verbose_print(
"\n".join(ex))
348 testDef.logger.verbose_print(
"=======================================")
349 stageLog[
'status'] = 1
350 stageLog[
'stderr'] = [
"Exception was raised: %s %s" % (type(e), str(e))]
351 testDef.logger.logResults(disp_title, stageLog, testDef)
358 testDef.logger.verbose_print(
"ExecuteSequential")
366 testDef.watchdog.__init__(testDef=testDef)
367 testDef.watchdog.activate()
371 testDef.plugin_trans_sem.acquire()
374 if testDef.options[
'duration']:
375 testDef.watchdog.start(timeout=testDef.options[
'duration'])
378 if testDef.options[
'loopforever']:
383 elif testDef.options[
'loop']:
385 timeout=testDef.options[
'loop'])
386 testDef.looping =
True
390 if testDef.options[
"harass_trigger_scripts"]
is not None:
391 stageLog = {
'section':
"DefaultHarasser"}
392 testDef.harasser.execute(stageLog,{
"trigger_scripts": testDef.options[
"harass_trigger_scripts"],
393 "stop_scripts": testDef.options[
"harass_stop_scripts"],
394 "join_timeout": testDef.options[
"harass_join_timeout"]}, testDef)
395 if stageLog[
'status'] != 0:
398 testDef.logger.logResults(
"DefaultHarasser", stageLog, testDef)
409 for p
in testDef.stages.getAllPlugins() \
410 + testDef.tools.getAllPlugins() \
411 + testDef.utilities.getAllPlugins():
412 if p._getIsActivated():
413 p.plugin_object.deactivate()
415 testDef.plugin_trans_sem.release()
def durationTimeoutHandler