LoggingUtils.getEvoLogger().info("* Starting " + getIdentifier()); ClientProcess process = new ClientProcess(); TimeController.resetSingleton(); process.run(); if (!onThread) { logger.error(getPrettyPrintIdentifier() + "Error when generating tests for: " + Properties.TARGET_CLASS + " with seed " + Randomness.getSeed()+". Configuration id : "+Properties.CONFIGURATION_ID, t); t.printStackTrace();
@Override public void run() { /* * NOTE: the handling of the parameters "-D" should be handled * directly in JUnit by setting the different values in Properties */ ClientProcess.main(new String[0]); } };
setupRuntimeProperties(); handleShadingSpecialCases(); JDKClassResetter.init(); Sandbox.setCheckForInitialization(Properties.SANDBOX); initializeToolJar(); LoggingUtils.getEvoLogger().info("* " + getPrettyPrintIdentifier() + "Connecting to master process on port " + Properties.PROCESS_COMMUNICATION_PORT); boolean registered = ClientServices.getInstance().registerServices(getIdentifier()); throw new RuntimeException(getPrettyPrintIdentifier() + "Could not connect to master process on port " + Properties.PROCESS_COMMUNICATION_PORT);
@Override public void collectBestSolutions(Set<? extends Chromosome> solutions) throws RemoteException { logger.debug(ClientProcess.getPrettyPrintIdentifier() + "added solution to set"); bestSolutions.add(solutions); }
LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Analyzing classpath: "); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Instrumentation exceeds Java's 64K limit per method in target class"); Properties.Criterion[] newCriteria = Arrays.stream(Properties.CRITERION).filter(t -> !t.equals(Properties.Criterion.STRONGMUTATION) && !t.equals(Properties.Criterion.WEAKMUTATION) && !t.equals(Properties.Criterion.MUTATION)).toArray(Properties.Criterion[]::new); if(newCriteria.length < Properties.CRITERION.length) { TestGenerationContext.getInstance().resetContext(); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Attempting re-instrumentation without mutation"); Properties.CRITERION = newCriteria; if(Properties.NEW_STATISTICS) { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Deactivating EvoSuite statistics because of instrumentation problem"); Properties.NEW_STATISTICS = false; LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Deactivating assertion minimization because mutation instrumentation does not work"); Properties.ASSERTION_STRATEGY = AssertionStrategy.ALL; LoggingUtils.getEvoLogger().error("* " + ClientProcess.getPrettyPrintIdentifier() + "Error while initializing target class: " + (e.getMessage() != null ? e.getMessage() : e.toString())); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Generating tests for class " + Properties.TARGET_CLASS); TestSuiteGeneratorHelper.printTestCriterion(); if (ClientProcess.DEFAULT_CLIENT_NAME.equals(ClientProcess.getIdentifier())) { postProcessTests(testCases);
@Override public void sendBestSolution(Set<? extends Chromosome> solutions) { try { logger.debug(ClientProcess.getPrettyPrintIdentifier() + "sending best solutions to " + ClientProcess.DEFAULT_CLIENT_NAME); masterNode.evosuite_collectBestSolutions(clientRmiIdentifier, solutions); } catch (RemoteException e) { logger.error(ClientProcess.getPrettyPrintIdentifier() + "Cannot send best solution to master", e); } }
ClientServices.getInstance().getClientNode().deleteListener(listener); if (ClientProcess.DEFAULT_CLIENT_NAME.equals(ClientProcess.getIdentifier())) { logger.debug(ClientProcess.getPrettyPrintIdentifier() + "Sending " + solutionsSet.size() + " solutions to " + ClientProcess.DEFAULT_CLIENT_NAME); ClientServices.getInstance().getClientNode().sendBestSolution(solutionsSet);
@Override public void emigrate(Set<? extends Chromosome> immigrants) { try { logger.debug(ClientProcess.getPrettyPrintIdentifier() + "Sending " + immigrants.size() + " immigrants"); masterNode.evosuite_migrate(clientRmiIdentifier, immigrants); } catch (RemoteException e) { logger.error(ClientProcess.getPrettyPrintIdentifier() + "Cannot send immigrating individuals to master", e); } }
@Override public void immigrate(Set<? extends Chromosome> migrants) throws RemoteException { logger.debug(ClientProcess.getPrettyPrintIdentifier() + "receiving " + (migrants != null ? migrants.size() : 0) + " immigrants"); fireEvent(migrants); }
static void printTestCriterion() { if (Properties.CRITERION.length > 1) { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Test criteria:"); } else { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier()+ "Test criterion:"); } for (int i = 0; i < Properties.CRITERION.length; i++) { printTestCriterion(Properties.CRITERION[i]); } }
/** * Prints out all information regarding this GAs stopping conditions * * So far only used for testing purposes in TestSuiteGenerator */ public void printBudget(GeneticAlgorithm<?> algorithm) { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Search Budget:"); for (StoppingCondition sc : algorithm.getStoppingConditions()) LoggingUtils.getEvoLogger().info("\t- " + sc.toString()); }
private void writeObjectPool(TestSuiteChromosome suite) { if (!Properties.WRITE_POOL.isEmpty()) { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Writing sequences to pool"); ObjectPool pool = ObjectPool.getPoolFromTestSuite(suite); pool.writePool(Properties.WRITE_POOL); } }
private static List<Class<?>> getTestClasses() { List<Class<?>> testClasses = new ArrayList<Class<?>>(); logger.debug("JUNIT: "+Properties.JUNIT); for(String prefix : Properties.JUNIT.split(":")) { LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Analyzing entry: "+prefix); // If the target name is a path analyze it File path = new File(prefix); if (path.exists()) { if (Properties.JUNIT.endsWith(".jar")) testClasses.addAll(getTestClassesJar(path)); else testClasses.addAll(getTestClasses(path)); } else { try { Class<?> clazz = Class.forName(prefix, true, TestGenerationContext.getInstance().getClassLoaderForSUT()); testClasses.add(clazz); } catch (ClassNotFoundException e) { // Second, try if the target name is a package name testClasses.addAll(getTestClassesFromClasspath()); } } } return testClasses; }
@Override public void changeState(ClientState state, ClientStateInformation information) { if (this.state != state){ logger.info(ClientProcess.getPrettyPrintIdentifier() + "Client changing state from " + this.state + " to " + state); } this.state = state; TimeController.getInstance().updateState(state); try { masterNode.evosuite_informChangeOfStateInClient(clientRmiIdentifier, state,information); } catch (RemoteException e) { logger.error("Cannot inform master of change of state", e); } if (this.state.equals(ClientState.DONE)) { doneLatch.countDown(); } if (this.state.equals(ClientState.FINISHED)) { finishedLatch.countDown(); } }
ClassPathHandler.getInstance().getTargetProjectClasspath(), prefix, false); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Found " + suts.size() + " classes with prefix '" + prefix + "'"); if (!suts.isEmpty()) {
private static List<JUnitResult> executeTests(Class<?>... testClasses) { ExecutionTracer.enable(); ExecutionTracer.setCheckCallerThread(false); ExecutionTracer.getExecutionTracer().clear(); List<JUnitResult> results = new ArrayList<JUnitResult>(); for (Class<?> testClass : testClasses) { LoggingUtils.getEvoLogger().info(" Executing " + testClass.getSimpleName()); // Set the context classloader in case the SUT requests it Thread.currentThread().setContextClassLoader(testClass.getClassLoader()); JUnitRunner jR = new JUnitRunner(testClass); jR.run(); results.addAll(jR.getTestResults()); } ExecutionTracer.disable(); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Executed " + results.size() + " unit " + "test(s)"); ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Tests_Executed, results.size()); return results; }
private void initializeTargetClass() throws Throwable { String cp = ClassPathHandler.getInstance().getTargetProjectClasspath(); // Here is where the <clinit> code should be invoked for the first time DefaultTestCase test = buildLoadTargetClassTestCase(Properties.TARGET_CLASS); ExecutionResult execResult = TestCaseExecutor.getInstance().execute(test, Integer.MAX_VALUE); if (hasThrownInitializerError(execResult)) { // create single test suite with Class.forName() writeJUnitTestSuiteForFailedInitialization(); ExceptionInInitializerError ex = getInitializerError(execResult); throw ex; } else if (!execResult.getAllThrownExceptions().isEmpty()) { // some other exception has been thrown during initialization Throwable t = execResult.getAllThrownExceptions().iterator().next(); throw t; } DependencyAnalysis.analyzeClass(Properties.TARGET_CLASS, Arrays.asList(cp.split(File.pathSeparator))); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Finished analyzing classpath"); }
LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Target class " + Properties.TARGET_CLASS); ClientServices.getInstance().getClientNode().updateProperty("TARGET_CLASS", Properties.TARGET_CLASS); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Total number of covered goals: " + totalCoveredGoals + " / " + "" + totalGoals); ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Total_Goals, totalGoals); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Total coverage: " + NumberFormat.getPercentInstance().format(coverage)); ClientServices.getInstance().getClientNode().trackOutputVariable(RuntimeVariable.Coverage, coverage);
try { InheritanceTree tree = readInheritanceTree(Properties.INHERITANCE_FILE); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Inheritance tree loaded from {}", Properties.INHERITANCE_FILE); return tree; LoggingUtils.getEvoLogger().warn("* " + ClientProcess.getPrettyPrintIdentifier() + "Error loading inheritance tree: {}", e);
LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Finished analyzing classpath"); } catch (Throwable e) { LoggingUtils.getEvoLogger().error("* " + ClientProcess.getPrettyPrintIdentifier() + "Error while initializing target class: " + (e.getMessage() != null ? e.getMessage() : e.toString())); LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Found " + testClasses.size() + " test class(es)"); if (testClasses.isEmpty()) LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Executing test(s)"); if (Properties.SELECTED_JUNIT == null) { boolean origUseAgent = EvoRunner.useAgent; LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier() + "Coverage analysis for criterion " + pc);