Skip to content

Commit

Permalink
test(spgroup#31): add Interprocedural Override Assignment Test Cases
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Dec 9, 2020
1 parent 3cdf69c commit 7e36e2a
Show file tree
Hide file tree
Showing 10 changed files with 620 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class ClassFieldConflictAnalysisTest {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(7);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldConflictInterProceduralSample", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(8);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldConflictInterProceduralSample", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(1, analysis.getConflicts().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class ClassFieldConflictAnalysisTest2 {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(7);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldConflictInterProceduralSample2", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(8);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldConflictInterProceduralSample2", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(1, analysis.getConflicts().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class ClassFieldNotConflictAnalysisTest {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(8);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldNotConflictInterProceduralSample", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(10);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldNotConflictInterProceduralSample", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(0, analysis.getConflicts().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class ClassFieldNotConflictAnalysisTest2 {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(8);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldNotConflictInterProceduralSample2", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(10);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldNotConflictInterProceduralSample2", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(0, analysis.getConflicts().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class ClassFieldWithParameterNotConflictAnalysisTest {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(8);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldWithParameterNotConflictInterProceduralSample", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(9);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentClassFieldWithParameterNotConflictInterProceduralSample", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(0, analysis.getConflicts().size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package br.unb.cic.analysis.ioa;

import br.unb.cic.analysis.AbstractMergeConflictDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import soot.G;
import soot.PackManager;
import soot.Transform;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Ignore
public class LocalVariablesNotConflictAnalysisTest {

private InterproceduralOverrideAssignment analysis;

@Before
public void configure() {
G.reset();

AbstractMergeConflictDefinition definition = new AbstractMergeConflictDefinition() {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(6);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentLocalVariablesNotConflictInterProceduralSample", lines);
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = new ArrayList<>();
lines.add(7);
res.put("br.unb.cic.analysis.samples.OverridingAssignmentLocalVariablesNotConflictInterProceduralSample", lines);
return res;
}
};

analysis = new InterproceduralOverrideAssignment(definition);

PackManager.v().getPack("wjtp").add(new Transform("wjtp.analysis", analysis));
soot.options.Options.v().setPhaseOption("cg.spark", "on");
soot.options.Options.v().setPhaseOption("cg.spark", "verbose:true");
// PhaseOptions.v().setPhaseOption("jb", "use-original-names:true");

String testClasses = "target/test-classes/";
soot.Main.main(new String[]{"-w", "-allow-phantom-refs", "-f", "J", "-keep-line-number", "-process-dir", testClasses});
}

@Test
public void interproceduralOverridingAssignmentTest() {
Assert.assertEquals(0, analysis.getConflicts().size());
}

}
Loading

0 comments on commit 7e36e2a

Please sign in to comment.