/** * Once loaded, an agent will always read the byte[] * of the loaded classes. Here we tell it if those byte[] * should be instrumented */ public static void activate(){ checkTransformerState(); MockFramework.enable(); transformer.activate(); LoopCounter.getInstance().setActive(true); }
/** * Stop instrumenting classes */ public static void deactivate(){ checkTransformerState(); MockFramework.disable(); transformer.deactivate(); LoopCounter.getInstance().setActive(false); }
LoopCounter.getInstance().setActive(false); TARGET_CLASS_INSTANCE = Class.forName(TARGET_CLASS, initialise, TestGenerationContext.getInstance().getClassLoaderForSUT()); "* Could not find class under test " + Properties.TARGET_CLASS + ": " + e); } finally { LoopCounter.getInstance().setActive(wasLoopCheckOn);
LoopCounter.getInstance().setActive(true); //be sure it is active here, as JUnit checks might have left it to false
private static List<Class<?>> loadClasses(ClassLoader classLoader, String... classNames) { List<Class<?>> classes = new ArrayList<>(); InstrumentingAgent.activate(); boolean safe = Sandbox.isSafeToExecuteSUTCode(); //assert !Sandbox.isSecurityManagerInitialized() || Sandbox.isOnAndExecutingSUTCode(); for (int i=0; i< classNames.length;i++) { org.evosuite.runtime.Runtime.getInstance().resetRuntime(); String classNameToLoad = classNames[i]; Sandbox.goingToExecuteSUTCode(); boolean wasLoopCheckOn = LoopCounter.getInstance().isActivated(); try { if(!safe){ Sandbox.goingToExecuteUnsafeCodeOnSameThread(); } LoopCounter.getInstance().setActive(false); Class<?> aClass = Class.forName(classNameToLoad, true, classLoader); classes.add(aClass); } catch (Exception | Error ex) { AtMostOnceLogger.error(logger,"Could not initialize " + classNameToLoad + ": " + ex.getMessage()); } finally { if(!safe){ Sandbox.doneWithExecutingUnsafeCodeOnSameThread(); } Sandbox.doneWithExecutingSUTCode(); LoopCounter.getInstance().setActive(wasLoopCheckOn); } } InstrumentingAgent.deactivate(); return classes; }
Method resetMethod = ClassResetter.getInstance().getResetMethod(className); if (resetMethod != null) { LoopCounter.getInstance().setActive(false); resetMethod.invoke(null, (Object[]) null); TestGenerationContext.getInstance().doneWithExecutingSUTCode(); MutationObserver.activateMutation(mutationActive); LoopCounter.getInstance().setActive(wasLoopCheckOn);