use of org.evosuite.continuous.persistency.StorageManager in project evosuite by EvoSuite.
the class JobHandler method getCommandString.
private List<String> getCommandString(JobDefinition job) {
List<String> commands = new ArrayList<>();
commands.add(JavaExecCmdUtil.getJavaBinExecutablePath());
commands.add("-cp");
commands.add(configureAndGetClasspath());
/*
* FIXME for seeding, need to setup classpath of generated test suites
* - first the currently generated
* - then the old ones
*
* if same test suites happen twice (ie in current and old), then we it would be
* complicated to use both (we would need to change their name)
*/
/*
* it is important to set it before calling EvoSuite, as it has to be read by Master before loading properties.
* Note: the Client will get it automatically from Master
*/
commands.add("-D" + LoggingUtils.USE_DIFFERENT_LOGGING_XML_PARAMETER + "=logback-ctg.xml");
commands.add("-Dlogback.configurationFile=logback-ctg.xml");
StorageManager storage = executor.getStorage();
File logs = storage.getTmpLogs();
commands.add("-Devosuite.log.folder=" + logs.getAbsolutePath() + File.separator + job.cut);
if (Properties.LOG_LEVEL != null && !Properties.LOG_LEVEL.isEmpty()) {
commands.add("-Dlog.level=" + Properties.LOG_LEVEL);
}
/*
* TODO: this will likely need better handling
*/
int masterMB = 250;
int clientMB = job.memoryInMB - masterMB;
commands.add("-Xmx" + masterMB + "m");
if (Properties.CTG_DEBUG_PORT != null) {
// set for Master
commands.add("-Xdebug");
commands.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + Properties.CTG_DEBUG_PORT);
}
/*
Actual call to EvoSuite. "Commands" before this line will be applied
to the spawn process, whereas the ones after will be its input parameters
*/
commands.add(org.evosuite.EvoSuite.class.getName());
if (Properties.CTG_DEBUG_PORT != null) {
// set for Client
commands.add("-Ddebug");
commands.add("-Dport=" + (Properties.CTG_DEBUG_PORT + 1));
}
commands.add("-mem");
commands.add("" + clientMB);
commands.add("-class");
commands.add(job.cut);
if (Properties.SPAWN_PROCESS_MANAGER_PORT != null) {
commands.add("-Dspawn_process_manager_port=" + Properties.SPAWN_PROCESS_MANAGER_PORT);
}
// commands.add("-projectCP");
// commands.add(executor.getProjectClassPath()); might be too long and fail on Windows
String classpath = ClassPathHandler.writeClasspathToFile(executor.getProjectClassPath());
commands.add("-DCP_file_path=" + classpath);
// needs to be called twice, after the Java command
if (Properties.LOG_LEVEL != null && !Properties.LOG_LEVEL.isEmpty()) {
commands.add("-Dlog.level=" + Properties.LOG_LEVEL);
}
if (Properties.LOG_TARGET != null && !Properties.LOG_TARGET.isEmpty()) {
commands.add("-Dlog.target=" + Properties.LOG_TARGET);
}
/*
* TODO for now we ignore the job configuration (ie special parameter settings)
*/
// cmd += " -D<TODO>="+job.configurationId;
/*
* TODO we should check on whether the dependent CUTs have been
* generated in this CTG run, or should rather look at previous runs.
* This could happen for at least 2 reasons:
* - under budget, and we could not run jobs for all CUTs
* - job for dependency crashed, but we have test cases from previous CTG run
*
*
* Regardless of whether dependencies for seeding were calculated, we might
* still want to use seeding based on previous CTG runs, if any test suite
* is available for the CUT
*/
commands.addAll(getPoolInfo(job));
// TODO not just input pool, but also hierarchy
commands.addAll(timeSetUp(job.seconds));
File reports = storage.getTmpReports();
File tests = storage.getTmpTests();
File seedOut = storage.getTmpSeeds();
File seedIn = storage.getSeedInFolder();
commands.add("-Dreport_dir=" + reports.getAbsolutePath() + File.separator + job.cut);
commands.add("-Dtest_dir=" + tests.getAbsolutePath());
String seedsFileName = job.cut + "." + Properties.CTG_SEEDS_EXT;
commands.add("-Dctg_seeds_file_out=" + seedOut.getAbsolutePath() + File.separator + seedsFileName);
commands.add("-Dctg_seeds_file_in=" + seedIn.getAbsolutePath() + File.separator + seedsFileName);
commands.addAll(getOutputVariables());
commands.add("-Danalysis_criteria=" + Properties.ANALYSIS_CRITERIA);
commands.add("-Dcriterion=" + Arrays.toString(Properties.CRITERION).replace("[", "").replace("]", "").replaceAll(", ", ":"));
commands.add("-Djunit_suffix=" + Properties.JUNIT_SUFFIX);
commands.add("-Denable_asserts_for_evosuite=" + Properties.ENABLE_ASSERTS_FOR_EVOSUITE);
String confId = Properties.CONFIGURATION_ID;
if (confId != null && !confId.isEmpty()) {
commands.add("-Dconfiguration_id=" + confId);
} else {
commands.add("-Dconfiguration_id=default");
}
if (Properties.RANDOM_SEED != null) {
commands.add("-Drandom_seed=" + Properties.RANDOM_SEED);
}
commands.add("-Dprint_to_system=" + Properties.PRINT_TO_SYSTEM);
commands.add("-Dp_object_pool=" + Properties.P_OBJECT_POOL);
/*
* these 4 options should always be 'true'.
* Here we take them as parameter, just because for experiments
* we might skip those phases if we do not analyze their results
*/
commands.add("-Dminimize=" + Properties.MINIMIZE);
commands.add("-Dassertions=" + Properties.ASSERTIONS);
commands.add("-Djunit_tests=" + Properties.JUNIT_TESTS);
commands.add("-Djunit_check=" + Properties.JUNIT_CHECK);
commands.add("-Dmax_size=" + Properties.MAX_SIZE);
commands.add("-Dlog_timeout=false");
commands.add("-Dplot=false");
commands.add("-Dtest_comments=false");
commands.add("-Dshow_progress=false");
commands.add("-Dsave_all_data=false");
commands.add("-Dcoverage=" + Properties.COVERAGE);
/*
* for (de)serialization of classes with static fields, inner classes, etc,
* we must have this options set to true
*/
commands.add("-Dreset_static_fields=true");
commands.add("-Dreplace_calls=true");
if (Properties.CTG_HISTORY_FILE != null) {
commands.add("-Dctg_history_file=" + Properties.CTG_HISTORY_FILE);
}
return commands;
}
use of org.evosuite.continuous.persistency.StorageManager in project evosuite by EvoSuite.
the class JobExecutorIntTest method init.
@Before
public void init() {
Properties.CTG_DIR = ".tmp_for_testing_" + JobExecutorIntTest.class.getName();
if (storage != null) {
boolean deleted = storage.clean();
assertTrue(deleted);
} else {
storage = new StorageManager();
storage.clean();
}
}
use of org.evosuite.continuous.persistency.StorageManager in project evosuite by EvoSuite.
the class ContinuousTestGeneration method execute.
/**
* Apply CTG, and return a string with some summary
*
* @return
*/
public String execute() {
// init the local storage manager
StorageManager storage = new StorageManager();
if (!storage.isStorageOk()) {
return "Failed to initialize local storage system";
}
if (Properties.CTG_DELETE_OLD_TMP_FOLDERS) {
storage.deleteAllOldTmpFolders();
}
if (!storage.createNewTmpFolders()) {
return "Failed to create tmp folders";
}
// check project
ProjectAnalyzer analyzer = new ProjectAnalyzer(target, prefix, cuts);
ProjectStaticData data = analyzer.analyze();
if (data.getTotalNumberOfTestableCUTs() == 0) {
return "There is no class to test in the chosen project\n" + "Target: " + target + "\n" + "Prefix: '" + prefix + "'\n";
}
if (Properties.CTG_DEBUG_PORT != null && data.getTotalNumberOfTestableCUTs() != 1) {
throw new IllegalStateException("Cannot debug CTG when more than one CUT is selected");
}
if (Properties.CTG_TIME_PER_CLASS != null) {
configuration = configuration.getWithChangedTime(Properties.CTG_TIME_PER_CLASS, data.getTotalNumberOfTestableCUTs());
}
JobScheduler scheduler = new JobScheduler(data, configuration);
JobExecutor executor = new JobExecutor(storage, projectClassPath, configuration);
// loop: define (partial) schedule
while (scheduler.canExecuteMore()) {
List<JobDefinition> jobs = scheduler.createNewSchedule();
executor.executeJobs(jobs, configuration.getNumberOfUsableCores());
executor.waitForJobs();
}
String description = storage.mergeAndCommitChanges(data, cuts);
if (exportFolder != null) {
try {
exportToFolder(".", exportFolder);
} catch (IOException e) {
return "Failed to export tests: " + e.getMessage();
}
}
// call home
if (configuration.callHome) {
// TODO
}
return description;
}
use of org.evosuite.continuous.persistency.StorageManager in project evosuite by EvoSuite.
the class JobHandler method getPoolInfo.
private List<String> getPoolInfo(JobDefinition job) {
List<String> commands = new ArrayList<String>();
StorageManager storage = executor.getStorage();
File poolFolder = storage.getTmpPools();
String extension = ".pool";
commands.add("-Dwrite_pool=" + poolFolder.getAbsolutePath() + File.separator + job.cut + extension);
if (job.inputClasses != null && job.inputClasses.size() > 0) {
String[] dep = job.inputClasses.toArray(new String[0]);
double poolP = 0.5;
if (Properties.P_OBJECT_POOL > 0) {
// TODO need refactoring, ie a Double initialized with null
poolP = Properties.P_OBJECT_POOL;
}
commands.add("-Dp_object_pool=" + poolP);
String cmd = "-Dobject_pools=";
cmd += poolFolder.getAbsolutePath() + File.separator + dep[0] + extension;
for (int i = 1; i < dep.length; i++) {
cmd += File.pathSeparator + poolFolder.getAbsolutePath() + File.separator + dep[i] + extension;
}
commands.add(cmd);
}
return commands;
}
Aggregations