Writing drivers for testcase tools¶
The following steps must be followed to implement a new driver. The final driver may be pushed to the muteria’s github repository, to be used by others.
The driver’s code must be located in the folder
muteria/drivers/testgeneration/tools_by_languages/<Language>/<Driver-Folder>.An
__init__.pyfile must be created in the driver folder (<Driver-Folder>) and assign the driver’s class name to eitherStaticCriteriaToolorDynamicTestcaseToolas following:StaticCriteriaTool = <Driver-Class>orDynamicTestcaseTool = <Driver-Class>. If the testcase tool uses existing tests to generate new tests, then assign the class name toDynamicTestcaseToolandNonetoStaticTestcaseTool, and vice versa.See for example the case of KLEE’s driver inmuteria/drivers/testgeneration/tools_by_languages/c/klee/__init__.pyThe driver’s class must extend the class
BaseTestcaseTool, located inmuteria/drivers/testgeneration/base_testcasetool.py, and implement all the abstract methods (see for example KLEE’s driver inmuteria/drivers/testgeneration/tools_by_languages/c/klee/klee.py). The abstract methods that must be implemented are listed bellow.
@classmethod
def installed(cls, custom_binary_dir=None)
This method checks whether the tool is installed. It returns a boolean representing whether the tool is installed (executable is accessible on the path) or not. True means that the tool is installed, else False is returned.
Paramter |
Type |
Description |
|---|---|---|
|
|
custom directory to look for the relevant executable files for the corresponding tool. None means that the file are on the PATH. |
def get_testcase_info_object(self)
This method returns the info object for all tests managed/generated by the tool. The info object for testcases is an object of the class TestcasesInfoObject, defined in the file muteria/drivers/testgeneration/testcases_info.py
def _prepare_executable (self, exe_path_map, env_vars, \
collect_output=False):
This method is called before every test execution. Put any setup here.
Paramter |
Type |
Description |
|---|---|---|
|
|
map each repository file to the corresponding instrumented file intended location. |
|
|
env vars that are set for the execution. |
|
|
map each repository file to the corresponding instrumented file intended location. |
def restore_default_executable (self, exe_path_map, env_vars, \
collect_output=False):
This method is called after every test execution. Put any teardown here.
Paramter |
Type |
Description |
|---|---|---|
|
|
map each repository file to the corresponding instrumented file intended location. |
|
|
env vars that are set for the execution. |
|
|
map each repository file to the corresponding instrumented file intended location. |
def _execute_a_test (self, testcase, exe_path_map, env_vars, \
callback_object=None, timeout=None, collect_output=None)
This method is called after every test execution. Put any teardown here.
Paramter |
Type |
Description |
|---|---|---|
|
|
name of test case to execute. |
|
|
map each repository file to the corresponding instrumented file intended location. |
|
|
env vars that are set for the execution. |
|
|
instace of implementation of Callback object (defined in |
|
|
timeout for the test execution. |
|
|
map each repository file to the corresponding instrumented file intended location. |
def _do_generate_tests (self, exe_path_map, code_builds_factory, \
meta_criteria_tool_obj=None, \
max_time=None)
This method generates the test cases by calling the underlying tool. For reference, see muteria/drivers/testgeneration/tools_by_languages/c/klee/klee.py)
Paramter |
Type |
Description |
|---|---|---|
|
|
map each repository file to the corresponding instrumented file intended location. |
|
|
Class that defines methods to handle repository tasks, such as building code, … (see file |
|
|
MetaCriteriaTool object that managing the criterion tool with intrumented code on which the test generation should be conducted (example mutants to target). The MetaCriteriaTool is defined in |
|
|
timeout for the test generation. |