Skip to content

Commit

Permalink
Fixed hanlding of case where BB test sequence file is not generated d…
Browse files Browse the repository at this point in the history
…uring

ctd-amplified test generation

Signed-off-by: Saurabh Sinha <[email protected]>
  • Loading branch information
sinha108 committed Sep 29, 2023
1 parent f3d8a9c commit 00b1428
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__pycache__/
*.py[cod]
.python-version
venv/
venv*/
*.egg-info/

# IDE, log, backup files
Expand Down
2 changes: 1 addition & 1 deletion doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TackleTest-Unit performs CTD modeling and test-plan generation using the [NIST A

### Prerequisites for TackleTest-Unit

1. Install Python 3.9
1. Install Python 3.9+ (tested on Python 3.9, 3.10, 3.11)

2. Install a JDK (versions 8-11 are supported). The JDK home directory has to be specified as a configuration option;
see [tkltest-unit Configuration Options](unit/tkltest_unit_config_options.md) for details on
Expand Down
21 changes: 17 additions & 4 deletions tkltest/unit/generate/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@ def generate_ctd_amplified_tests(config, output_dir):
tkltest_status("Generating basic block test sequences with "+test_generator_name+" took " +
str(round(time.time() - start_time, 2)) + " seconds")

# list of generated BB sequences files
bb_seq_files = []
if test_generator_name == constants.COMBINED_TEST_GENERATOR_NAME:
bb_seq_file = app_name+"_RandoopTestGenerator"+constants.TKL_BB_SEQ_FILE_SUFFIX+"," + \
app_name + "_EvoSuiteTestGenerator" + constants.TKL_BB_SEQ_FILE_SUFFIX
for testgen in ['EvoSuiteTestGenerator', 'RandoopTestGenerator']:
bb_seq_file = f'{app_name}_{testgen}{constants.TKL_BB_SEQ_FILE_SUFFIX}'
if os.path.isfile(bb_seq_file):
bb_seq_files.append(bb_seq_file)
else:
bb_seq_file = app_name + "_" + test_generator_name + constants.TKL_BB_SEQ_FILE_SUFFIX
bb_seq_file = f'{app_name}_{test_generator_name}{constants.TKL_BB_SEQ_FILE_SUFFIX}'
if os.path.isfile(bb_seq_file):
bb_seq_files.append(bb_seq_file)

# if no BB sequences files created, exit
if not bb_seq_files:
tkltest_status(f'No basic block sequences generated using "{test_generator_name}"')
sys.exit(0)

start_time = time.time()

Expand All @@ -171,7 +182,7 @@ def generate_ctd_amplified_tests(config, output_dir):
tmp_test_directory = test_directory + constants.TKLTEST_TEMP_DIR_SUFFIX
# generate extended test sequences
extend_sequences(app_name=app_name, monolith_app_path=monolith_app_path, app_classpath_file=app_classpath_file,
ctd_file=ctd_file, bb_seq_file=bb_seq_file, jdk_path=jdk_path,
ctd_file=ctd_file, bb_seq_file=','.join(bb_seq_files), jdk_path=jdk_path,
no_diff_assertions=config['generate']['no_diff_assertions'],
no_ctd_coverage=config['generate']['ctd_amplified']['no_ctd_coverage'],
interaction_level=config['generate']['ctd_amplified']['interaction_level'],
Expand Down Expand Up @@ -432,6 +443,8 @@ def run_bb_test_generator(app_name, ctd_file, monolith_app_path, app_classpath_f
command_util.run_command(command=tg_command, verbose=False)
except subprocess.CalledProcessError as e:
tkltest_status('Generating basic block sequences failed: {}\n{}'.format(e, e.stderr), error=True)
if 'Test generator failed to generate any tests' in e.stderr:
return
sys.exit(1)


Expand Down

0 comments on commit 00b1428

Please sign in to comment.