Skip to content

Commit

Permalink
Merge cef8d5d into a7d6bd4
Browse files Browse the repository at this point in the history
  • Loading branch information
Pouria Derakhshanfar committed Apr 7, 2021
2 parents a7d6bd4 + cef8d5d commit a3b2d11
Show file tree
Hide file tree
Showing 52 changed files with 3,508 additions and 81 deletions.
45 changes: 45 additions & 0 deletions botsing-commons/evosuite-tests/_ESTest.java
@@ -0,0 +1,45 @@
/*
* This file was automatically generated by EvoSuite
* Wed Apr 07 15:24:06 CEST 2021
*/


import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;

@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)
public class _ESTest extends _ESTest_scaffolding {

@Test(timeout = 4000)
public void test0() throws Throwable {
String string0 = "";
String string1 = "";
string1.equals(string0);
string1.equals(string0);
string0.equals(string1);
String string2 = "";
string1.equals(string2);
String string3 = "6AUEy9";
string2.equals(string3);
String string4 = "\\i'>tc#N{_";
String string5 = "1>9YQA$+].yyp\"";
string5.equals(string4);
String string6 = "";
string2.equals(string4);
String string7 = "D";
string7.equals(string5);
Object object0 = null;
string5.equals(object0);
String string8 = "wT$>vEo (hCvWU-Mv";
string8.equals(string6);
string5.equals(string0);
string6.equals(string8);
String string9 = "";
string9.equals(string2);
String string10 = "H+-#khW5oV";
string5.equals(string10);
}
}
71 changes: 71 additions & 0 deletions botsing-commons/evosuite-tests/_ESTest_scaffolding.java
@@ -0,0 +1,71 @@
/**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Wed Apr 07 15:24:06 CEST 2021
*/


import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
import org.evosuite.runtime.sandbox.Sandbox;
import org.evosuite.runtime.sandbox.Sandbox.SandboxMode;

@EvoSuiteClassExclude
public class _ESTest_scaffolding {

@org.junit.Rule
public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();

private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);


@BeforeClass
public static void initEvoSuiteFramework() {
org.evosuite.runtime.RuntimeSettings.className = "";
org.evosuite.runtime.GuiSupport.initialize();
org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100;
org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED;
org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT();
org.evosuite.runtime.classhandling.JDKClassResetter.init();
setSystemProperties();
initializeClasses();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
}

@Before
public void initTestCase(){
threadStopper.storeCurrentThreads();
threadStopper.startRecordingTime();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler();
org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode();
org.evosuite.runtime.GuiSupport.setHeadless();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
org.evosuite.runtime.agent.InstrumentingAgent.activate();
}

@After
public void doneWithTestCase(){
threadStopper.killAndJoinClientThreads();
org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks();
org.evosuite.runtime.classhandling.JDKClassResetter.reset();
resetClasses();
org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode();
org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
}

public static void setSystemProperties() {

/*No java.lang.System property to set*/
}

private static void initializeClasses() {
}

private static void resetClasses() {
}
}
19 changes: 19 additions & 0 deletions botsing-commons/evosuite-tests/_Failed_ESTest.java
@@ -0,0 +1,19 @@
/*
* This file was automatically generated by EvoSuite
* Wed Apr 07 15:24:06 CEST 2021
*/


import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;

@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true)
public class _Failed_ESTest extends _Failed_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
18 changes: 18 additions & 0 deletions botsing-commons/evosuite-tests/_Failed_ESTest_scaffolding.java
@@ -0,0 +1,18 @@
/**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Wed Apr 07 15:24:06 CEST 2021
*/


import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
import org.evosuite.runtime.sandbox.Sandbox;
import org.evosuite.runtime.sandbox.Sandbox.SandboxMode;

@EvoSuiteClassExclude
public class _Failed_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
@@ -1,7 +1,6 @@
package eu.stamp.botsing.commons;

import org.evosuite.Properties;
import org.evosuite.TestSuiteGeneratorHelper;
import org.evosuite.TimeController;
import org.evosuite.contracts.FailingTestSet;
import org.evosuite.coverage.TestFitnessFactory;
Expand All @@ -28,8 +27,10 @@
public class PostProcessUtility {
private static final Logger LOG = LoggerFactory.getLogger(PostProcessUtility.class);

public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) {

public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories, boolean keepTestsCoveringSameGoal) {
LOG.info("test size before post-process: {}",testSuite.size());

if (Properties.INLINE) {
ConstantInliner inliner = new ConstantInliner();
inliner.inline(testSuite);
Expand All @@ -39,10 +40,14 @@ public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitn
if (Properties.MINIMIZE) {
double before = testSuite.getFitness();

TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories);


LOG.info("* Minimizing test suite");
minimizer.minimize(testSuite, true);
if(!keepTestsCoveringSameGoal){
TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories);
minimizer.minimize(testSuite, true);
}


double after = testSuite.getFitness();
if (after > before + 0.01d) { // assume minimization
Expand All @@ -51,10 +56,7 @@ public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitn
}
LOG.info("test size after post-process: {}",testSuite.size());

if (Properties.ASSERTIONS) {
LOG.info("Generating assertions");
TestSuiteGeneratorHelper.addAssertions(testSuite);
}



compileAndCheckTests(testSuite);
Expand Down
Expand Up @@ -35,6 +35,8 @@ public class MOSA<T extends Chromosome> extends AbstractMOSA<T> {

private long startTime;

private List<T> offspringPopulation;


public MOSA(ChromosomeFactory factory, CrossOverFunction crossOverOperator, Mutation mutationOperator, FitnessFunctions fitnessCollector) {
super(factory, fitnessCollector);
Expand All @@ -46,7 +48,7 @@ public MOSA(ChromosomeFactory factory, CrossOverFunction crossOverOperator, Muta

@Override
protected void evolve() {
List<T> offspringPopulation = this.breedNextGeneration();
offspringPopulation = this.breedNextGeneration();

// Create the union of parents and offSpring
List<T> union = new ArrayList<T>();
Expand Down Expand Up @@ -299,10 +301,16 @@ protected int getNumberOfCoveredGoals() {
return n_covered_goals;
}


public List<T> getOffspringPopulation() {
return offspringPopulation;
}

@Override
protected List<T> getNonDominatedSolutions(List<T> solutions) {
return super.getNonDominatedSolutions(solutions);
}



}
Expand Up @@ -58,7 +58,7 @@ public void testWithoutSearchObjective(){
TestFitnessFactory testFitnessFactory = Mockito.mock(TestFitnessFactory.class);
ArrayList testFitnessFactoryList = new ArrayList();
testFitnessFactoryList.add(testFitnessFactory);
PostProcessUtility.postProcessTests(testSuite, testFitnessFactoryList);
PostProcessUtility.postProcessTests(testSuite, testFitnessFactoryList,false);
// Minimization suppose to remove the test because there is no search objective
assert(testSuite.getTests().size() == 0);
}
Expand All @@ -76,7 +76,7 @@ public void testWithSearchObjective(){
Mockito.when(testFitnessFactory.getCoverageGoals()).thenReturn(coverageGoals);
ArrayList testFitnessFactoryList = new ArrayList();
testFitnessFactoryList.add(testFitnessFactory);
PostProcessUtility.postProcessTests(testSuite, testFitnessFactoryList);
PostProcessUtility.postProcessTests(testSuite, testFitnessFactoryList,true);
assert(testSuite.getTests().size() == 1);
}

Expand Down
Binary file modified botsing-reproduction/evosuite-client-botsing-1.1.1.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions botsing-reproduction/pom.xml
Expand Up @@ -45,6 +45,12 @@
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.uma.jmetal</groupId>-->
<!-- <artifactId>jmetal-algorithm</artifactId>-->
<!-- <version>${jmetal.version}</version>-->
<!-- </dependency>-->
</dependencies>

<build>
Expand Down
18 changes: 17 additions & 1 deletion botsing-reproduction/src/main/java/eu/stamp/botsing/Botsing.java
Expand Up @@ -92,6 +92,10 @@ public List<TestGenerationResult> parseCommandLine(String[] args) {
if(commands.hasOption(MODEL_PATH_OPT)){
setupModelSeedingRelatedProperties(commands);
}
// Continue search after first crash reproduction
if(commands.hasOption(CONTINUE_AFTER_REPRODUCTION)){
CrashProperties.stopAfterFirstCrashReproduction = false;
}
// execute
return CrashReproduction.execute();
}
Expand All @@ -100,7 +104,19 @@ public List<TestGenerationResult> parseCommandLine(String[] args) {
}

private void setFF(String fitnessFunction) {
CrashProperties.fitnessFunctions = new CrashProperties.FitnessFunction[]{CrashProperties.FitnessFunction.valueOf(fitnessFunction)};
if (fitnessFunction.contains(":")){
String[] ffs = fitnessFunction.split(":");
CrashProperties.FitnessFunction[] newFitnessFunctionsArray = new CrashProperties.FitnessFunction[ffs.length];
int index = 0;
for (String ff: ffs){
newFitnessFunctionsArray[index]=CrashProperties.FitnessFunction.valueOf(ff);
index++;
}
CrashProperties.fitnessFunctions = newFitnessFunctionsArray;
}else {
CrashProperties.fitnessFunctions = new CrashProperties.FitnessFunction[]{CrashProperties.FitnessFunction.valueOf(fitnessFunction)};
}

}

private void setSearchAlgorithm(String algorithm) {
Expand Down
Expand Up @@ -36,6 +36,7 @@ public class CommandLineParameters {
public static final String IO_DIVERSITY = "io_diversity";
public static final String SEARCH_ALGORITHM = "search_algorithm";
public static final String FITNESS_FUNCTION = "fitness";
public static final String CONTINUE_AFTER_REPRODUCTION = "continue_after_reproduction";

public static Options getCommandLineOptions() {
Options options = new Options();
Expand Down Expand Up @@ -83,6 +84,10 @@ public static Options getCommandLineOptions() {
.desc("Use integration testing for crash reproduction")
.build());

// Continue after first crash reproduction
options.addOption(Option.builder(CONTINUE_AFTER_REPRODUCTION)
.desc("Continues the search process after finding the first crash reproducing test case")
.build());
// Help message
options.addOption(Option.builder(HELP_OPT)
.desc("Prints this help message.")
Expand Down
Expand Up @@ -69,8 +69,12 @@ public enum FitnessFunction {
WeightedSum,
SimpleSum,
TestLen,
CallDiversity,
IntegrationIndexedAccess,
IntegrationSingleObjective;
IntegrationSingleObjective,
LineCoverage,
ExceptionType,
StackTraceSimilarity;
FitnessFunction() {
}
}
Expand All @@ -79,6 +83,10 @@ public enum SearchAlgorithm {
Single_Objective_GGA,
Guided_MOSA,
NSGA_II,
SPEA2,
MOEAD,
PESA_II,
FEMO,
DynaMOSA;

SearchAlgorithm() {
Expand Down Expand Up @@ -115,6 +123,36 @@ public enum SearchAlgorithm {
@Parameter(key = "io_diversity", group = "Crash reproduction", description = "Enables I/O diversity as extra goals to MOSA")
public static boolean IODiversity = false;

@Parameter(key = "stop_after_first_crash_reproduction", group = "Crash reproduction", description = "Stops the search process after finding the first crash reproducing test case")
public static boolean stopAfterFirstCrashReproduction = true;

@Parameter(key = "neighborhood_selection_probability", group = "MOEAD", description = "neighborhood Selection Probability")
public static double neighborhoodSelectionProbability = 0.2;

@Parameter(key = "maximum_number_of_replaced_solutions", group = "MOEAD", description = "Maximum Number Of Replaced Solutions")
public static int maximumNumberOfReplacedSolutions = 100;

@Parameter(key = "ideal_point_shift", group = "MOEAD", description = "Shift objectives of ideal point to a better situation (to avoid local optimum)")
public static double idealPointShift = 0.1;


public enum DistanceCalculator {
WS, // Weighted Sum
TE, // Tchebycheff (default)
PBI, // Penalty-based boundary intersection
}

@Parameter(key = "distance_calculator", group = "MOEAD", description = "neighborhood Selection Probability")
public static CrashProperties.DistanceCalculator distanceCalculator = DistanceCalculator.TE;

@Parameter(key = "archive_bisections", group = "PESA", description = "Number of bisections for each objective for archive's grids creation")
public static int archiveBisections = 5;

@Parameter(key = "archive_size", group = "PESA", description = "Size of archive")
public static int archiveSize = 50;

// @Parameter(key = "multi_objectivization", group = "Multi Objectivization", description = "Size of archive")
// public static boolean multiObjectivization = false;

static java.util.Properties configFile = new java.util.Properties();

Expand Down

0 comments on commit a3b2d11

Please sign in to comment.