All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.stamp.botsing.fitnessfunction.FitnessFunctionHelper Maven / Gradle / Ivy

Go to download

The reproduction plugin contains the evolutionary algorithm used to reproduce a crash.

The newest version!
package eu.stamp.botsing.fitnessfunction;


/*-
 * #%L
 * botsing-reproduction
 * %%
 * Copyright (C) 2017 - 2018 eu.stamp-project
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import eu.stamp.botsing.CrashProperties;
import eu.stamp.botsing.StackTrace;
import org.evosuite.graphs.cfg.BytecodeInstruction;
import org.evosuite.testcase.TestFitnessFunction;

public class FitnessFunctionHelper {

    public boolean isConstructor(BytecodeInstruction targetInstruction){
        String methodName = targetInstruction.getMethodName();
        methodName = methodName.substring(0, methodName.indexOf('('));
        String classPath = targetInstruction.getClassName();
        int lastOccurrence = classPath.lastIndexOf(".");
        if (lastOccurrence == -1){
            return false;
        }
        String className = classPath.substring(lastOccurrence+1);
        return className.equals(methodName);

    }

    public TestFitnessFunction getSingleObjective(){
        return getFF(CrashProperties.fitnessFunctions[0],CrashProperties.getInstance().getStackTrace(0));
    }
    public TestFitnessFunction[] getMultiObjectives(){
        if(CrashProperties.fitnessFunctions.length > 1){
            // Here, we have 1 crash and multiple fitness functions
            TestFitnessFunction[] result =  new TestFitnessFunction[CrashProperties.fitnessFunctions.length];
            StackTrace singleCrash = CrashProperties.getInstance().getStackTrace(0);
            for (int i = 0; i 1){
            // Here, we have multiple crashes and 1 fitness function
            int numberOfCrashes = CrashProperties.getInstance().getCrashesSize();
            TestFitnessFunction[] result =  new TestFitnessFunction[numberOfCrashes];
            for (int i = 0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy