diff --git a/README.md b/README.md
index c1d5f730..9d5f32ba 100644
--- a/README.md
+++ b/README.md
@@ -21,12 +21,9 @@ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/
You can see whether the setup was successful or not by seeing the text files under `logs/`.
If your setup is failed due to `testrunner-maven-plugin` you can solve this error by do the followings.
-- First clone the repo ```https://github.com/ReedOei/testrunner``` to your local machine
-- Run ```mvn install``` inside the ```testrunner``` directory
-- Upload the `testrunner-maven-plugin` to your local `.m2` folder using the command inside `testrunner-maven-plugin/target`
-```
-mvn install:install-file -Dfile=testrunner-maven-plugin-0.1-SNAPSHOT.jar -DgroupId=com.reedoei -DartifactId=testrunner-maven-plugin -Dversion=0.1-SNAPSHOT -Dpackaging=jar -DgeneratePom=true
-```
+1. First clone the repo ```https://github.com/ReedOei/testrunner``` to your local machine
+2. Run ```mvn install``` inside the ```testrunner``` directory
+
## Relevant contents of this directory
- ```setup.sh``` main script to setup the metadata needed for the regression testing algorithms (Step 1)
- ```compute-deps.sh``` main script to compute dependencies for the regression testing algorithms (Step 2)
diff --git a/dt-impact-tracer/pom.xml b/dt-impact-tracer/pom.xml
index 2b0f8f52..bd1bd537 100644
--- a/dt-impact-tracer/pom.xml
+++ b/dt-impact-tracer/pom.xml
@@ -38,6 +38,9 @@
TestMethodPrinter
+
+ com.fasterxml.jackson
+
jar-with-dependencies
@@ -59,7 +62,7 @@
maven-central
- http://repo1.maven.org/maven2
+ https://repo1.maven.org/maven2
soot-snapshot
@@ -70,14 +73,44 @@
- com.reedoei
+ edu.illinois.cs
testrunner-maven-plugin
- 0.1-SNAPSHOT
+ 1.2.1
+
+
+ edu.illinois.cs
+ testrunner-running
+ 1.2.1
+
+
+ edu.illinois.cs
+ testrunner-testing
+ 1.2.1
+
+
+ edu.illinois.cs
+ testrunner-core-plugin
+ 1.2.1
- ca.mcgill.sable
+ org.soot-oss
soot
- 3.2.0
+ 4.3.0
+
+
+ org.ow2.asm
+ asm
+ 9.2
+
+
+ org.ow2.asm
+ asm-commons
+ 9.2
+
+
+ org.ow2.asm
+ asm-tree
+ 9.2
org.hamcrest
@@ -91,6 +124,11 @@
4.12
test
+
+ com.reedoei
+ eunomia
+ 1.4.1
+
java_cup
java_cup
@@ -113,11 +151,6 @@
dom4j
2.1.0
-
- com.reedoei
- eunomia
- 1.3.2
-
com.google.code.gson
gson
@@ -138,6 +171,26 @@
commons-csv
1.4
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+ 2.11.0
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.11.0
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.11.0
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.11.0
+
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/InstrumentationMain.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/InstrumentationMain.java
index f37a249b..bf30fce4 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/InstrumentationMain.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/InstrumentationMain.java
@@ -1,27 +1,33 @@
/**
* Copyright 2014 University of Washington. All Rights Reserved.
* @author Wing Lam
- *
+ *
* Main class to instrument a project.
*/
package edu.washington.cs.dt.impact.Main;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import edu.washington.cs.dt.impact.tools.FailedTestRemover;
-import soot.Pack;
-import soot.PackManager;
-import soot.Scene;
-import soot.Transform;
+import edu.washington.cs.dt.impact.util.InstrumenterXML;
+import soot.*;
import edu.washington.cs.dt.impact.util.Constants;
import edu.washington.cs.dt.impact.util.Constants.TECHNIQUE;
import edu.washington.cs.dt.impact.util.Instrumenter;
+import soot.PackManager;
+import soot.Transform;
+import soot.options.Options;
+
public class InstrumentationMain {
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
/* check the arguments */
if (args.length == 0) {
System.err.println("Usage: java InstrumentationMain [options] classname");
@@ -65,8 +71,8 @@ public static void main(String[] args) {
int techniqueNameIndex = techniqueIndex + 1;
if (techniqueNameIndex >= argsList.size()) {
System.err
- .println("Technique argument is specified but technique name is not."
- + " Please use the format: -technique aTechniqueName");
+ .println("Technique argument is specified but technique name is not."
+ + " Please use the format: -technique aTechniqueName");
System.exit(0);
}
@@ -79,8 +85,8 @@ public static void main(String[] args) {
techniqueName = TECHNIQUE.PARALLELIZATION;
} else {
System.err
- .println("Technique name is invalid. Try \"prioritization-absolute\","
- + " \"prioritization-relative\", \"random\" or \"selection\".");
+ .println("Technique name is invalid. Try \"prioritization-absolute\","
+ + " \"prioritization-relative\", \"random\" or \"selection\".");
System.exit(0);
}
argsList.remove(techniqueNameIndex);
@@ -93,26 +99,198 @@ public static void main(String[] args) {
sootClasspath = FailedTestRemover.buildClassPath(argsList.get(sootClasspathIndex + 1).split(":"));
argsList.remove(sootClasspathIndex + 1);
argsList.remove(sootClasspathIndex);
+
+ }
+ int outputPathindex= argsList.indexOf("-outputPath");
+ String outputPath="";
+ if(outputPathindex!=-1)
+ {
+ int outputPathNameindex = outputPathindex + 1;
+ outputPath= argsList.get(outputPathNameindex);
+ argsList.remove(outputPathNameindex);
+ argsList.remove(outputPathindex);
+ }
+ int inputModeIndex= argsList.indexOf("-compare");
+ int inputStaticIndex= argsList.indexOf("-staticAnalysis");
+ if (inputModeIndex != -1)
+ {
+ argsList.remove(inputModeIndex);
+ Pack wjtp = PackManager.v().getPack("wjtp");
+ List targetTestMethodNames = new ArrayList();
+ //targetTestMethodNames.add("com.github.kevinsawicki.http.EncodeTest.encode");
+
+ int changedMethodIndex= argsList.indexOf("-changedFiles");
+ if(changedMethodIndex!=-1)
+ {
+ int changedMethodNameIndex = changedMethodIndex + 1;
+ for (String methodname : argsList.get(changedMethodNameIndex).split(",")) {
+ targetTestMethodNames.add(methodname);
+ }
+ argsList.remove(changedMethodNameIndex);
+ argsList.remove(changedMethodIndex);
+ }
+ int conditionalStatementLimit=0;
+ int loopIterationCount=1;
+ InstrumenterXML instrumenter = new InstrumenterXML(techniqueName, targetTestMethodNames,conditionalStatementLimit,loopIterationCount,true);
+ wjtp.add(new Transform("wjtp.instrumenter", instrumenter));
+
+ Scene.v().setSootClassPath(sootClasspath);
+
+ Options.v().set_output_format(Options.output_format_class);
+
+ // Set the output directory for the instrumented .class files
+ Options.v().set_output_dir("/home/pious/Documents/work/dependent-tests-impact/testgui");
+
+ argsList.add("-w");
+ argsList.add("-p");
+ argsList.add("cg");
+ argsList.add("all-reachable:true");
+ argsList.add("-keep-line-number");
+ argsList.add("-pp");
+ argsList.add("-allow-phantom-refs");
+ argsList.add("-p");
+ argsList.add("jb");
+ argsList.add("use-original-names:true");
+ // enable loop unrolling optimization pack and set unroll depth to 4
+ /*argsList.add("-p");
+ argsList.add("jb.ls:unroll-depth=4");
+
+// enable loop peeling optimization pack and set peel depth to 2
+ argsList.add("-p");
+ argsList.add("jb.ulp:peel-depth=2");*/
+ /**/
+// argsList.add("-p");
+// argsList.add("wjtp.tnlp");
+// argsList.add("enabled:false");
+ /*argsList.add("--no-bodies-for-excluded");
+ argsList.add("--loop-opts-enabled");*/
+ /*argsList.add("--num-loop-detection");
+ argsList.add("3");*/
+
+
+ int inputDirNameIndex = inputDirIndex + 1;
+ String inputDirName = argsList.get(inputDirNameIndex);
+
+ List classNames = getClassesFromDirectory(new File(inputDirName));
+
+ for (String className : classNames) {
+ SootClass clazz = Scene.v().forceResolve(className, SootClass.BODIES);
+ clazz.setApplicationClass();
+ }
+
+ for (SootClass sc : Scene.v().getClasses()) {
+ Scene.v().addBasicClass(sc.getName(), SootClass.BODIES);
+ }
+
+
+ String[] sootArgs = argsList.toArray(new String[0]);
+
+ soot.Main.main(sootArgs);
+ instrumenter.generateXML(outputPath,"output.xml");
+ instrumenter.mergeXML(outputPath);
}
+ else if(inputStaticIndex!= -1)
+ {
+ argsList.remove(inputStaticIndex);
+ Pack wjtp = PackManager.v().getPack("wjtp");
+ int conditionalStatementLimit=0;
+ int loopIterationCount=4;
+ List targetTestMethodNames = new ArrayList();
+ InstrumenterXML instrumenter = new InstrumenterXML(techniqueName, targetTestMethodNames,conditionalStatementLimit,loopIterationCount,false);
+ wjtp.add(new Transform("wjtp.instrumenter", instrumenter));
- /* add a phase to transformer pack by call Pack.add */
- Pack jtp = PackManager.v().getPack("jtp");
- jtp.add(new Transform("jtp.instrumenter",
- new Instrumenter(techniqueName)));
+ Scene.v().setSootClassPath(sootClasspath);
- Scene.v().setSootClassPath(sootClasspath);
+ Options.v().set_output_format(Options.output_format_class);
- argsList.add("-keep-line-number");
- argsList.add("-pp");
- argsList.add("-allow-phantom-refs");
- String[] sootArgs = argsList.toArray(new String[0]);
+ // Set the output directory for the instrumented .class files
+ //Options.v().set_output_dir("/home/pious/Documents/work/dependent-tests-impact/testgui");
- System.out.println(argsList);
+ argsList.add("-w");
+ argsList.add("-p");
+ argsList.add("cg");
+ argsList.add("all-reachable:true");
+ argsList.add("-keep-line-number");
+ argsList.add("-pp");
+ argsList.add("-allow-phantom-refs");
+ argsList.add("-p");
+ argsList.add("jb");
+ argsList.add("use-original-names:true");
+ int inputDirNameIndex = inputDirIndex + 1;
+ String inputDirName = argsList.get(inputDirNameIndex);
+
+ List classNames = getClassesFromDirectory(new File(inputDirName));
+
+ for (String className : classNames) {
+ SootClass clazz = Scene.v().forceResolve(className, SootClass.BODIES);
+ clazz.setApplicationClass();
+ }
+
+ for (SootClass sc : Scene.v().getClasses()) {
+ Scene.v().addBasicClass(sc.getName(), SootClass.BODIES);
+ }
+
+
+ String[] sootArgs = argsList.toArray(new String[0]);
+
+ soot.Main.main(sootArgs);
+ //outputPath=outputPath+"sootXML-firstVers/";
+ instrumenter.generateXML(outputPath,"firstVers-static.xml");
+ }
+ else {
+
+ Pack jtp = PackManager.v().getPack("jtp");
+ jtp.add(new Transform("jtp.instrumenter",
+ new Instrumenter(techniqueName)));
+
+ Scene.v().setSootClassPath(sootClasspath);
+
+ argsList.add("-keep-line-number");
+ argsList.add("-pp");
+ argsList.add("-allow-phantom-refs");
+ String[] sootArgs = argsList.toArray(new String[0]);
+
+
+
+ /**Give control to Soot to process all options,
+ * Instrumenter.internalTransform will get called.*/
+
+ soot.Main.main(sootArgs);
+
+ }
+
+ }
+ public static List getClassesFromDirectory(File directory) {
+ List classNames = new ArrayList<>();
+ if (directory.exists() && directory.isDirectory()) {
+ try {
+ Path basePath = directory.toPath();
+ Files.walk(basePath).forEach(path -> {
+ if (Files.isRegularFile(path) && path.toString().endsWith(".class")) {
+ String className = basePath.relativize(path).toString().replace(File.separator, ".");
+ className = className.substring(0, className.length() - ".class".length());
+ classNames.add(className);
+ }
+ });
+ } catch (IOException e) {
+ throw new RuntimeException("Error getting classes from directory", e);
+ }
+ }
+ return classNames;
+ }
+ public static String getFullyQualifiedMethodName(String filePath, String methodName) {
+ String packageName = extractPackageName(filePath);
+ String className = extractClassName(filePath);
+ return packageName + "." + className + "." + methodName;
+ }
+
+ private static String extractPackageName(String filePath) {
+ String packagePath = filePath.substring(filePath.indexOf("java") + 5, filePath.lastIndexOf(File.separator));
+ return packagePath.replace(File.separator, ".");
+ }
- /*
- * Give control to Soot to process all options,
- * Instrumenter.internalTransform will get called.
- */
- soot.Main.main(sootArgs);
+ private static String extractClassName(String filePath) {
+ String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
+ return fileName.replace(".java", "");
}
}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/RunnerMain.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/RunnerMain.java
index 16f0313f..675022b4 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/RunnerMain.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/Main/RunnerMain.java
@@ -11,12 +11,12 @@
import java.util.LinkedList;
import java.util.List;
-import com.reedoei.testrunner.configuration.Configuration;
-import com.reedoei.testrunner.data.framework.TestFramework;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.SmartRunner;
-import com.reedoei.testrunner.runner.TestInfoStore;
+import edu.illinois.cs.testrunner.configuration.Configuration;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.runner.TestInfoStore;
import edu.washington.cs.dt.main.ImpactMain;
@@ -95,11 +95,14 @@ public static void main(String[] args) {
SmartRunner runner = new SmartRunner(TestFramework.junitTestFramework(), new TestInfoStore(), classpath, new HashMap(), Paths.get("/dev/null"));
Configuration.config().setDefault("testplugin.classpath", "");
- long start = System.nanoTime();
+ long start =System.currentTimeMillis();
//TestExecResults results = runner.run();
+ //System.out.println(tests+"---------\n");
+ System.out.println(start+"----------start---------------");
TestRunResult result = runner.runListWithCp(classpath, tests).get();
- long total = System.nanoTime() - start;
- System.out.println("Total execution time: " + total);
+ System.out.println(System.currentTimeMillis()+"--------------end-----------");
+ long total = System.currentTimeMillis() - start;
+ System.out.println("Total execution time--: " + total);
// Print out the result in the format as expected by running ImpactMain
// Assume only one run in one JVM of all tests
@@ -120,6 +123,13 @@ public static void main(String[] args) {
failing++;
break;
case ERROR:
+ sb.append(result.results().get(test)+"\n");
+ sb.append("----------------"+test+"\n");
+ StackTraceElement[] res=result.results().get(test).stackTrace();
+ //System.out.println("getStackTrace()");
+ for (int i = 1; i < res.length; i++)
+ //System.out.println("\tat " + res[i]);
+ sb.append("\tat " + res[i]+"\n");
error++;
break;
case SKIPPED:
@@ -146,4 +156,4 @@ public static void main(String[] args) {
sb.append(System.getProperty("line.separator"));
System.out.println(sb.toString());
}
-}
+}
\ No newline at end of file
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/TestInfo.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/TestInfo.java
index 5a9909b6..bfa39449 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/TestInfo.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/TestInfo.java
@@ -1,6 +1,6 @@
package edu.washington.cs.dt.impact.data;
-import com.reedoei.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.Result;
/**
* Created by winglam on 7/1/18.
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/WrapperTestList.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/WrapperTestList.java
index e314a05d..cc56b47b 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/WrapperTestList.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/data/WrapperTestList.java
@@ -1,8 +1,8 @@
package edu.washington.cs.dt.impact.data;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
import edu.washington.cs.dt.RESULT;
import edu.washington.cs.dt.TestExecResult;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/ConfigurationData.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/ConfigurationData.java
index c3130408..95d35568 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/ConfigurationData.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/ConfigurationData.java
@@ -10,7 +10,7 @@
import com.reedoei.eunomia.string.searching.StringSearch;
import com.reedoei.eunomia.util.OptUtil;
-import com.reedoei.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.Result;
import edu.washington.cs.dt.impact.data.EnhancedValues;
import edu.washington.cs.dt.impact.data.TestInfo;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/FigureGenerator.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/FigureGenerator.java
index e01cbea6..f131c69a 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/FigureGenerator.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/figure/generator/FigureGenerator.java
@@ -17,7 +17,7 @@
import com.reedoei.eunomia.collections.ListUtil;
-import com.reedoei.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.Result;
import edu.washington.cs.dt.impact.data.TestInfo;
import edu.washington.cs.dt.impact.data.Project;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/Plugins.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/Plugins.java
index 8adb4ad2..f7793933 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/Plugins.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/Plugins.java
@@ -1,12 +1,12 @@
package edu.washington.cs.dt.impact.plugins;
-import com.reedoei.testrunner.configuration.Configuration;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.mavenplugin.TestPluginPlugin;
-import com.reedoei.testrunner.mavenplugin.TestPlugin;
-import com.reedoei.testrunner.runner.RunnerFactory;
-import com.reedoei.testrunner.runner.SmartRunner;
-import com.reedoei.testrunner.runner.TestInfoStore;
+import edu.illinois.cs.testrunner.configuration.Configuration;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.mavenplugin.TestPluginPlugin;
+import edu.illinois.cs.testrunner.mavenplugin.TestPlugin;
+import edu.illinois.cs.testrunner.runner.RunnerFactory;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.runner.TestInfoStore;
import edu.washington.cs.dt.impact.runner.OneConfigurationRunner;
import edu.washington.cs.dt.impact.runner.Runner;
@@ -81,7 +81,7 @@ protected enum Mode {DEBUG, NORMAL}
protected void setProject(MavenProject project) {
this.project = project;
- com.reedoei.testrunner.runner.Runner testrunner = RunnerFactory.from(project).get();
+ edu.illinois.cs.testrunner.runner.Runner testrunner = RunnerFactory.from(project).get();
this.runner = new SmartRunner(testrunner.framework(), new TestInfoStore(), testrunner.classpath(),
testrunner.environment(), testrunner.outputPath());
}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/PrecomputeDependencies.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/PrecomputeDependencies.java
index b6c8cca7..a61c4b9f 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/PrecomputeDependencies.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/PrecomputeDependencies.java
@@ -6,8 +6,9 @@
import java.nio.file.Files;
import java.util.List;
-import com.reedoei.testrunner.mavenplugin.TestPluginPlugin;
-import com.reedoei.testrunner.testobjects.TestLocator;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.mavenplugin.TestPluginPlugin;
+import edu.illinois.cs.testrunner.testobjects.TestLocator;
import edu.washington.cs.dt.impact.tools.OutputPrecomputedDependences;
import edu.washington.cs.dt.impact.tools.detectors.FailingTestDetector;
import org.apache.commons.io.FileUtils;
@@ -73,7 +74,7 @@ private void humanWrittenTests(MavenProject project){
if (!new File(origOrderFile).isFile()) {
try {
// Generates orig-order.txt
- final List tests = JavaConverters.bufferAsJavaList(TestLocator.tests(project).toBuffer());
+ final List tests = JavaConverters.bufferAsJavaList(TestLocator.tests(project, TestFramework.junitTestFramework()).toBuffer());
FileWriter writer = new FileWriter(new File(origOrderFile));
for(String str: tests) {
writer.write(str);
@@ -85,8 +86,8 @@ private void humanWrittenTests(MavenProject project){
}
} else {
TestPluginPlugin.info(String.format("The relevant files already exist. " +
- "Skipping finding human written tests.\n" +
- " %s\n", origOrderFile));
+ "Skipping finding human written tests.\n" +
+ " %s\n", origOrderFile));
}
}
@@ -117,8 +118,8 @@ private void handleFailedTests(MavenProject project){
}
} else {
TestPluginPlugin.info(String.format("The relevant files already exist. " +
- "Skipping locating and removing failed tests.\n" +
- " %s\n %s\n", origOrderFile, ignoreOrderFile));
+ "Skipping locating and removing failed tests.\n" +
+ " %s\n %s\n", origOrderFile, ignoreOrderFile));
}
// Adjust MACHINES (Less Tests Than Number Of Cores)
@@ -267,8 +268,8 @@ private void setupTestParallelization(){
}
} else {
TestPluginPlugin.info(String.format("The relevant files already exist. " +
- "Skipping getting time of tests.\n" +
- " %s\n", origTimeFile));
+ "Skipping getting time of tests.\n" +
+ " %s\n", origTimeFile));
}
}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/RunWithDependencies.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/RunWithDependencies.java
index ced8799a..41584815 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/RunWithDependencies.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/plugins/RunWithDependencies.java
@@ -1,7 +1,8 @@
package edu.washington.cs.dt.impact.plugins;
-import com.reedoei.testrunner.mavenplugin.TestPluginPlugin;
-import com.reedoei.testrunner.testobjects.TestLocator;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.mavenplugin.TestPluginPlugin;
+import edu.illinois.cs.testrunner.testobjects.TestLocator;
import org.apache.commons.io.FileUtils;
import org.apache.maven.cli.MavenCli;
import org.apache.maven.project.MavenProject;
@@ -97,7 +98,7 @@ private void humanWrittenTests(MavenProject project){
TestPluginPlugin.info("Finding Human Written Tests (new version, original tests)");
try {
// Generates orig-order.txt
- final List tests = JavaConverters.bufferAsJavaList(TestLocator.tests(project).toBuffer());
+ final List tests = JavaConverters.bufferAsJavaList(TestLocator.tests(project, TestFramework.junitTestFramework()).toBuffer());
FileWriter writer = new FileWriter(new File(newDTResults + "/new-orig-order.txt"));
for(String str: tests) {
writer.write(str);
@@ -357,4 +358,4 @@ private void runTestParallelization(String classpath){
}
}
}
-}
+}
\ No newline at end of file
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunner.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunner.java
index 17c74143..bc22f806 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunner.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunner.java
@@ -35,12 +35,12 @@
import java.util.Map;
import java.util.Set;
-import com.reedoei.testrunner.configuration.Configuration;
-import com.reedoei.testrunner.data.framework.TestFramework;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.SmartRunner;
-import com.reedoei.testrunner.runner.TestInfoStore;
+import edu.illinois.cs.testrunner.configuration.Configuration;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.runner.TestInfoStore;
import edu.washington.cs.dt.TestExecResult;
import edu.washington.cs.dt.TestExecResults;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/RemoveFailedTestRunner.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/RemoveFailedTestRunner.java
index 839097be..d1877317 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/RemoveFailedTestRunner.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/RemoveFailedTestRunner.java
@@ -26,16 +26,16 @@ public static void main(final String[] args) throws Exception {
@Override
protected void run() throws Exception {
- final String classPath = getArgValue("classpath")
+ final String classPath = getArg("classpath")
.map(s -> ImpactMain.buildClassPath(s.split(":")))
.orElse(System.getProperty("java.class.path"));
Preconditions.checkArgument(Arrays.stream(classPath.split(":")).allMatch(s -> Files.exists(Paths.get(s))),
"Some directories or files in the classpath do not exist!");
- final List testOrder = Files.readAllLines(Paths.get(getRequiredArg("testOrder")));
+ final List testOrder = Files.readAllLines(Paths.get(getArgRequired("testOrder")));
final TestExecResults results = new FixedOrderRunner(classPath, testOrder).run();
- final Path outputFile = Paths.get(getArgValue("output").orElse("failing-tests.txt"));
+ final Path outputFile = Paths.get(getArg("output").orElse("failing-tests.txt"));
final Map failingTests = results.getExecutionRecords().get(0).getNameToResultsMap();
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/Runner.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/Runner.java
index e393a1a7..48eb742b 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/Runner.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/runner/Runner.java
@@ -12,8 +12,8 @@
import java.util.Map;
import java.util.TreeMap;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
import edu.washington.cs.dt.TestExecResult;
import edu.washington.cs.dt.TestExecResults;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/CrossReferencer.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/CrossReferencer.java
index b615ce10..7fff0a41 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/CrossReferencer.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/CrossReferencer.java
@@ -23,7 +23,7 @@
import java.util.Map;
import java.util.Set;
-import com.reedoei.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.Result;
public class CrossReferencer {
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/DependentTestFinder.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/DependentTestFinder.java
index cee54f9c..51066c66 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/DependentTestFinder.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/DependentTestFinder.java
@@ -20,11 +20,11 @@
import java.util.List;
import java.util.Map;
-import com.reedoei.testrunner.data.framework.TestFramework;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.SmartRunner;
-import com.reedoei.testrunner.runner.TestInfoStore;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.runner.TestInfoStore;
import edu.washington.cs.dt.impact.util.Constants;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/EnhancedResultAverager.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/EnhancedResultAverager.java
index 52afbc96..3d0abc5b 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/EnhancedResultAverager.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/EnhancedResultAverager.java
@@ -4,6 +4,7 @@
import com.reedoei.eunomia.collections.ListUtil;
import com.reedoei.eunomia.functional.Func;
import com.reedoei.eunomia.io.files.FileUtil;
+import com.reedoei.eunomia.collections.ListUtil;
import com.reedoei.eunomia.math.Averager;
import com.reedoei.eunomia.util.Util;
import edu.washington.cs.dt.impact.figure.generator.EnhancedResults;
@@ -108,7 +109,7 @@ public String latexString() throws IOException {
// We only need the results files paths for the subject name, so we can just use the first one.
EnhancedResultsFigureGenerator.setup(true, origOrAuto, resultFilesPaths.get(0), outputPath);
- final List values = Func.map(Averager::mean, averagers);
+ final List values = ListUtil.map(Averager::mean, averagers);
switch (technique) {
case PRIORITIZATION:
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/FileTools.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/FileTools.java
index d71f6458..e3998e0e 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/FileTools.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/FileTools.java
@@ -18,7 +18,7 @@
import java.util.LinkedList;
import java.util.List;
-import com.reedoei.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.Result;
public class FileTools {
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/MutantMatrix.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/MutantMatrix.java
index b798fed2..7f39c8e1 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/MutantMatrix.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/MutantMatrix.java
@@ -2,6 +2,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.reedoei.eunomia.collections.ListUtil;
import com.reedoei.eunomia.functional.Func;
import com.reedoei.eunomia.util.Util;
import edu.washington.cs.dt.impact.order.Standard;
@@ -70,7 +71,7 @@ public List createMutationGroups(final int groupSize, final int g
final List> groups = Lists.partition(mutations, groupSize);
final List mutationGroups =
- Func.mapWithIndex(
+ ListUtil.mapWithIndex(
MutationGroup::new,
groups.subList(0, Math.min(groupCount, groups.size())));
Preconditions.checkState(!mutationGroups.isEmpty(), "No mutation groups generated!");
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/PitResultAnalyzer.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/PitResultAnalyzer.java
index d6129651..97b5f21e 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/PitResultAnalyzer.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/PitResultAnalyzer.java
@@ -7,9 +7,9 @@
import com.reedoei.eunomia.string.matching.LineMatch;
import com.reedoei.eunomia.string.searching.Searcher;
import com.reedoei.eunomia.string.searching.StringSearch;
-import com.reedoei.eunomia.util.FileUtil;
+import com.reedoei.eunomia.io.files.FileUtil;
import com.reedoei.eunomia.util.StandardMain;
-import com.reedoei.eunomia.util.StringUtil;
+import com.reedoei.eunomia.string.StringUtil;
import edu.washington.cs.dt.impact.util.Constants;
import org.dom4j.DocumentException;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/SilentRunner.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/SilentRunner.java
index 5f87a2e1..ed8fa2a6 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/SilentRunner.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/SilentRunner.java
@@ -1,7 +1,7 @@
package edu.washington.cs.dt.impact.tools;
-import com.reedoei.eunomia.io.CaptureOutStream;
-import com.reedoei.eunomia.io.CapturedOutput;
+import com.reedoei.eunomia.io.capture.CapturedOutput;
+import com.reedoei.eunomia.io.capture.CaptureOutStream;
import edu.washington.cs.dt.TestExecResult;
import edu.washington.cs.dt.runners.FixedOrderRunner;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/detectors/FailingTestDetector.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/detectors/FailingTestDetector.java
index 733a1559..f9410a25 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/detectors/FailingTestDetector.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/detectors/FailingTestDetector.java
@@ -2,15 +2,15 @@
import com.reedoei.eunomia.util.StandardMain;
-import com.reedoei.testrunner.configuration.Configuration;
-import com.reedoei.testrunner.data.framework.TestFramework;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestResult;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.Runner;
-import com.reedoei.testrunner.runner.RunnerFactory;
-import com.reedoei.testrunner.runner.SmartRunner;
-import com.reedoei.testrunner.runner.TestInfoStore;
+import edu.illinois.cs.testrunner.configuration.Configuration;
+import edu.illinois.cs.testrunner.data.framework.TestFramework;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestResult;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.Runner;
+import edu.illinois.cs.testrunner.runner.RunnerFactory;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.runner.TestInfoStore;
import org.apache.commons.io.FileUtils;
import org.apache.maven.project.MavenProject;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/lifetime/Lifetimes.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/lifetime/Lifetimes.java
index 34c748e8..82ef074f 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/lifetime/Lifetimes.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/lifetime/Lifetimes.java
@@ -22,7 +22,7 @@ public static Date dateFromDir(final Path path) {
final String dirName = path.getFileName().toString();
final List parts = ListUtil.fromArray(dirName.split("-"));
// Folders are in format: subj-name-yyyy-mm-dd-H-M-S-commit so we want just the date part.
- final List dateParts = Func.map(Integer::parseInt, parts.subList(parts.size() - 7, parts.size() - 1));
+ final List dateParts = ListUtil.map(Integer::parseInt, parts.subList(parts.size() - 7, parts.size() - 1));
return DateUtil.makeDate(dateParts.get(0), dateParts.get(1), dateParts.get(2), dateParts.get(3), dateParts.get(4), dateParts.get(5));
}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/MinimizeTestsResult.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/MinimizeTestsResult.java
index 985bf32a..5faacfbd 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/MinimizeTestsResult.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/MinimizeTestsResult.java
@@ -4,9 +4,9 @@
import com.reedoei.eunomia.collections.ListUtil;
import com.reedoei.eunomia.io.IOUtil;
import com.reedoei.eunomia.io.files.FileUtil;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.runner.Runner;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.runner.Runner;
import java.io.IOException;
import java.nio.file.Files;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/TestMinimizer.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/TestMinimizer.java
index 4a060248..b2623195 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/TestMinimizer.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/tools/minimizer/TestMinimizer.java
@@ -7,10 +7,10 @@
import com.reedoei.eunomia.io.files.FileUtil;
import com.reedoei.eunomia.util.RuntimeThrower;
import com.reedoei.eunomia.util.Util;
-import com.reedoei.testrunner.data.results.Result;
-import com.reedoei.testrunner.data.results.TestRunResult;
-import com.reedoei.testrunner.mavenplugin.TestPluginPlugin;
-import com.reedoei.testrunner.runner.SmartRunner;
+import edu.illinois.cs.testrunner.data.results.Result;
+import edu.illinois.cs.testrunner.data.results.TestRunResult;
+import edu.illinois.cs.testrunner.mavenplugin.TestPluginPlugin;
+import edu.illinois.cs.testrunner.runner.SmartRunner;
import java.nio.file.Files;
import java.util.ArrayList;
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Instrumenter.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Instrumenter.java
index 115ec876..a0a02276 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Instrumenter.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Instrumenter.java
@@ -1,34 +1,25 @@
/**
* Copyright 2014 University of Washington. All Rights Reserved.
* @author Wing Lam
- *
+ *
* Tool used to instrument class and test files.
*/
package edu.washington.cs.dt.impact.util;
import edu.washington.cs.dt.impact.util.Constants.TECHNIQUE;
-import soot.Body;
-import soot.BodyTransformer;
-import soot.Local;
-import soot.PatchingChain;
-import soot.RefType;
-import soot.Scene;
-import soot.SootClass;
-import soot.SootMethod;
-import soot.Type;
-import soot.Unit;
-import soot.jimple.IdentityStmt;
-import soot.jimple.InvokeExpr;
-import soot.jimple.Jimple;
-import soot.jimple.RetStmt;
-import soot.jimple.ReturnStmt;
-import soot.jimple.ReturnVoidStmt;
-import soot.jimple.Stmt;
-import soot.jimple.StringConstant;
+import org.jf.dexlib2.iface.AnnotationElement;
+import soot.*;
+import soot.jimple.*;
+import soot.jimple.toolkits.callgraph.CallGraph;
+import soot.jimple.toolkits.callgraph.Edge;
+import soot.jimple.toolkits.callgraph.Targets;
+import soot.options.Options;
+import soot.tagkit.AnnotationIntElem;
import soot.tagkit.AnnotationTag;
import soot.tagkit.LineNumberTag;
import soot.tagkit.VisibilityAnnotationTag;
+import soot.toolkits.exceptions.ThrowAnalysis;
import soot.toolkits.graph.ExceptionalUnitGraph;
import soot.toolkits.graph.UnitGraph;
import soot.util.Chain;
@@ -39,15 +30,18 @@
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
+import java.util.*;
+
+import soot.SootMethod;
+import soot.coffi.annotation;
+import soot.tagkit.AnnotationElem;
+import soot.Body;
+import soot.Unit;
+import soot.jimple.Jimple;
+import soot.jimple.JimpleBody;
+import soot.jimple.ThrowStmt;
+import soot.toolkits.exceptions.ThrowAnalysis;
public class Instrumenter extends BodyTransformer{
private static SootClass tracerClass;
@@ -64,7 +58,7 @@ public class Instrumenter extends BodyTransformer{
private static TECHNIQUE technique = Constants.DEFAULT_TECHNIQUE;
public Instrumenter() {
- Scene.v().setSootClassPath(System.getProperty("java.class.path"));
+ Scene.v().setSootClassPath(System.getProperty("java.class.path"));
tracerClass = Scene.v().loadClassAndSupport("edu.washington.cs.dt.impact.util.Tracer");
trace = tracerClass.getMethodByName("trace");
@@ -90,7 +84,8 @@ public Instrumenter(TECHNIQUE t) {
*/
@Override
protected void internalTransform(Body body, String phase,
- @SuppressWarnings("rawtypes") Map options) {
+ @SuppressWarnings("rawtypes") Map options) {
+
SootMethod method = body.getMethod();
if (method.getName().equals("") || method.getName().equals("")) {
@@ -105,7 +100,9 @@ protected void internalTransform(Body body, String phase,
boolean isJUnit4 = false;
VisibilityAnnotationTag vat = (VisibilityAnnotationTag) method.getTag(JUNIT4_TAG);
+
if (vat != null) {
+ //System.out.println("---vat--"+vat);
List tags = vat.getAnnotations();
for (AnnotationTag at : tags) {
if (!isJUnit4) {
@@ -127,6 +124,7 @@ protected void internalTransform(Body body, String phase,
boolean isJUnit3 = false;
boolean extendsJUnit = false;
+
if (!isJUnit4 && method.getName().length() > 3) {
String retType = method.getReturnType().toString();
String prefix = method.getName().substring(0, 4);
@@ -138,13 +136,21 @@ protected void internalTransform(Body body, String phase,
}
superClass = superClass.getSuperclass();
}
+
+ if (Objects.equals(superClass.getName(), JUNIT3_CLASS)) {
+
+ extendsJUnit = true;
+ }
+
+
+
isJUnit3 = method.isPublic() && retType.equals(JUNIT3_RETURN)
&& extendsJUnit && prefix.equals(JUNIT3_METHOD_PREFIX);
}
// exclude the instrumentation of setups/teardowns
// and JUnit3 methods that are not tests
- if ((extendsJUnit && !isJUnit3)) {
+ if ((extendsJUnit && !isJUnit3) || isSetupOrTeardown) {
return;
}
@@ -153,29 +159,37 @@ protected void internalTransform(Body body, String phase,
// mutate the chain when iterating over it.
Iterator stmtIt = units.snapshotIterator();
+ Iterator stmtItpre = units.snapshotIterator();
+
+
String packageMethodName = method.getDeclaringClass().getName() + "." + method.getName();
+ SootClass thrwCls = Scene.v().getSootClass("java.lang.Throwable");
+ List probe = new ArrayList();
+ PatchingChain pchain = body.getUnits();
+
+ Stmt sFirstNonId = getFirstNonIdStmt(pchain);
+ Stmt sLast = (Stmt) pchain.getLast();
+ Stmt sFirst = (Stmt) pchain.getFirst();
+ StringBuffer testOutputBuffer = new StringBuffer();
+ String part = "body";
+ if (isBefore) {
+ part = "before";
+ } else if (isAfter){
+ part = "after";
+ }
+
+
if (isJUnit4 || isJUnit3 || isSetupOrTeardown) {
+
// instrumentation of JUnit files
// get access to Throwable class and toString method
- SootClass thrwCls = Scene.v().getSootClass("java.lang.Throwable");
- List probe = new ArrayList();
- PatchingChain pchain = body.getUnits();
-
- Stmt sFirstNonId = getFirstNonIdStmt(pchain);
- Stmt sLast = (Stmt) pchain.getLast();
- Stmt sFirst = (Stmt) pchain.getFirst();
- StringBuffer testOutputBuffer = new StringBuffer();
- String part = "body";
- if (isBefore) {
- part = "before";
- } else if (isAfter){
- part = "after";
- }
InvokeExpr firstExpr = Jimple.v().newStaticInvokeExpr(startExecution.makeRef(),StringConstant.v(packageMethodName), StringConstant.v(part));
Stmt firstStmt = Jimple.v().newInvokeStmt(firstExpr);
units.insertAfter(firstStmt, sFirst);
+
+
InvokeExpr lastExpr = Jimple.v().newStaticInvokeExpr(endExecution.makeRef(),StringConstant.v(packageMethodName), StringConstant.v(part), StringConstant.v(" "));
Stmt lastStmt = Jimple.v().newInvokeStmt(lastExpr);
units.insertBefore(lastStmt, sLast);
@@ -191,88 +205,39 @@ protected void internalTransform(Body body, String phase,
Stmt sGotoLast = Jimple.v().newGotoStmt(sLast);
probe.add(sGotoLast);
- Local lException1 = getCreateLocal(body, "", RefType.v(thrwCls));
- Stmt sCatch = Jimple.v().newIdentityStmt(lException1, Jimple.v().newCaughtExceptionRef());
- probe.add(sCatch);
+ String testclassname=method.getDeclaringClass().getName();
+ Scene.v().loadClassAndSupport(testclassname);
+ SootClass testClass = Scene.v().getSootClass(testclassname);
+ SootMethod testMethod = method;
+ VisibilityAnnotationTag tag = (VisibilityAnnotationTag) testMethod.getTag("VisibilityAnnotationTag");
+ if (tag != null) {
+ for (AnnotationTag annotation : tag.getAnnotations()) {
+ if (annotation.getType().equals("Lorg/junit/Test;")) {
+ String elementValue = annotation.getElems().toString();
+ String[] parts = elementValue.replaceAll("[\\[\\]]", "").split("\\s+");
+ if (parts.length == 8 && parts[0].equals("Annotation") && parts[1].equals("Element:") && parts[2].equals("kind:") && parts[6].equals("decription:") && parts[3].equals("c")) {
+ if(Objects.equals(parts[5], "expected"))
+ {
+ String description = parts[7].substring(1, parts[7].length() - 1);
+ description=description.replaceAll("/", ".");
+ InvokeExpr lExceptionMessage = Jimple.v().newStaticInvokeExpr(exceptionMessage.makeRef(), StringConstant.v(packageMethodName), StringConstant.v(part),StringConstant.v("-expected- "+description));
+ Stmt exceptionStmt = Jimple.v().newInvokeStmt(lExceptionMessage);
+ units.insertAfter(exceptionStmt, firstStmt);
+ //System.out.println("Description: " + description);
+ }
+ } else {
+ //System.out.println("Invalid AnnotationElement value");
+ }
+ break;
+ }
- // TODO after catching an exception in a test, throw the exception back
- // Type throwType = thrwCls.getType();
- // Local lSysOut = getCreateLocal(body, "", throwType);
- // Stmt callThrow = Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(lException1, initThrow.makeRef(),
- // lSysOut));
- // probe.add(callThrow);
+ }
+ }
insertRightBeforeNoRedirect(pchain, probe, sLast);
- // insert trap (catch)
- body.getTraps().add(Jimple.v().newTrap(thrwCls, sFirstNonId, sGotoLast, sCatch));
-
- // Do not forget to insert instructions to report the counter
- stmtIt = units.snapshotIterator();
-
- while (stmtIt.hasNext()) {
- Stmt stmt = (Stmt)stmtIt.next();
-
- if (internalOrInitStatementNotInvoked(stmt)) {
-
- testOutputBuffer.append(stmt.getInvokeExpr().getMethodRef().getDeclaringClass().getName() + "." + stmt.getInvokeExpr().getMethod().getName() + "\n");
-// InvokeExpr startExpr= Jimple.v().newStaticInvokeExpr(startTimer.makeRef());
-// Stmt startStmt = Jimple.v().newInvokeStmt(startExpr);
-// units.insertBefore(startStmt, stmt);
-//
-// InvokeExpr endExpr= Jimple.v().newStaticInvokeExpr(endTimer.makeRef());
-// Stmt endStmt = Jimple.v().newInvokeStmt(endExpr);
-// units.insertAfter(endStmt, stmt);
-
- // reset the timer
- InvokeExpr resetExpr = Jimple.v().newStaticInvokeExpr(timerOutput.makeRef(),
- StringConstant.v(packageMethodName) ,
- StringConstant.v(stmt.getInvokeExpr().getMethod().getName()),
- StringConstant.v(stmt.getInvokeExpr().getMethodRef().getDeclaringClass().getName()));
- Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
- units.insertBefore(resetStmt, stmt);
- }
-
- if ((stmt instanceof ReturnStmt)
- ||(stmt instanceof ReturnVoidStmt)) {
-
- if (technique != TECHNIQUE.SELECTION) {
- // output the contents of the tracer
- InvokeExpr reportExpr= Jimple.v().newStaticInvokeExpr(output.makeRef(),
- StringConstant.v(packageMethodName));
- Stmt reportStmt = Jimple.v().newInvokeStmt(reportExpr);
- units.insertBefore(reportStmt, stmt);
-
- // reset the tracer
- InvokeExpr resetExpr= Jimple.v().newStaticInvokeExpr(reset.makeRef());
- Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
- units.insertAfter(resetStmt, reportStmt);
- } else {
- // output the contents of the tracer
- InvokeExpr reportExpr= Jimple.v().newStaticInvokeExpr(
- selectionOutput.makeRef(), StringConstant.v(packageMethodName));
- Stmt reportStmt = Jimple.v().newInvokeStmt(reportExpr);
- units.insertBefore(reportStmt, stmt);
-
- // reset the tracer
- InvokeExpr resetExpr= Jimple.v().newStaticInvokeExpr(reset.makeRef());
- Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
- units.insertAfter(resetStmt, reportStmt);
- }
- }
- }
- Chain new_units = body.getUnits();
- Iterator new_stmtIt = new_units.snapshotIterator();
- while (new_stmtIt.hasNext()) {
- Stmt stmt = (Stmt) new_stmtIt.next();
- InvokeExpr lExceptionMessage = Jimple.v().newStaticInvokeExpr(exceptionMessage.makeRef(), StringConstant.v(packageMethodName), StringConstant.v(part));
- Stmt exceptionStmt = Jimple.v().newInvokeStmt(lExceptionMessage);
- if(stmt.toString().contains("@caughtexception")){
- units.insertAfter(exceptionStmt, stmt);
- }
- }
- selectionOutput(packageMethodName, testOutputBuffer, "testOutput");
} else {
+
if (technique == TECHNIQUE.SELECTION) {
// instrumentation of class files for test selection
// creates selectionOutput directory containing what statements
@@ -361,6 +326,69 @@ protected void internalTransform(Body body, String phase,
selectionOutput(packageMethodName, functionBodyBuffer, "methodOutput");
}
}
+
+
+ while (stmtItpre.hasNext()) {
+ Stmt stmt = (Stmt)stmtItpre.next();
+
+ if (internalOrInitStatementNotInvoked(stmt)) {
+ testOutputBuffer.append(stmt.getInvokeExpr().getMethodRef().getDeclaringClass().getName() + "." + stmt.getInvokeExpr().getMethod().getName() + "\n");
+
+ InvokeExpr resetExpr = Jimple.v().newStaticInvokeExpr(timerOutput.makeRef(),
+ StringConstant.v(packageMethodName) ,
+ StringConstant.v(stmt.getInvokeExpr().getMethod().getName()),
+ StringConstant.v(stmt.getInvokeExpr().getMethodRef().getDeclaringClass().getName()));
+
+
+ Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
+
+ units.insertBefore(resetStmt, stmt);
+ }
+
+
+ if ((stmt instanceof ReturnStmt)
+ ||(stmt instanceof ReturnVoidStmt)) {
+
+
+ if (technique != TECHNIQUE.SELECTION) {
+
+ InvokeExpr reportExpr= Jimple.v().newStaticInvokeExpr(output.makeRef(),
+ StringConstant.v(packageMethodName));
+ Stmt reportStmt = Jimple.v().newInvokeStmt(reportExpr);
+ units.insertBefore(reportStmt, stmt);
+
+ InvokeExpr resetExpr= Jimple.v().newStaticInvokeExpr(reset.makeRef());
+ Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
+ units.insertAfter(resetStmt, reportStmt);
+ } else {
+
+ InvokeExpr reportExpr= Jimple.v().newStaticInvokeExpr(
+ selectionOutput.makeRef(), StringConstant.v(packageMethodName));
+ Stmt reportStmt = Jimple.v().newInvokeStmt(reportExpr);
+ units.insertBefore(reportStmt, stmt);
+
+ // reset the tracer
+ InvokeExpr resetExpr= Jimple.v().newStaticInvokeExpr(reset.makeRef());
+ Stmt resetStmt = Jimple.v().newInvokeStmt(resetExpr);
+ units.insertAfter(resetStmt, reportStmt);
+ }
+ }
+
+ }
+
+ Chain new_units = body.getUnits();
+ Iterator new_stmtIt = new_units.snapshotIterator();
+ while (new_stmtIt.hasNext()) {
+ Stmt stmt = (Stmt) new_stmtIt.next();
+ String exceptionTypes = TrapManager.getExceptionTypesOf(stmt, body).toString();
+ InvokeExpr lExceptionMessage = Jimple.v().newStaticInvokeExpr(exceptionMessage.makeRef(), StringConstant.v(packageMethodName), StringConstant.v(part),StringConstant.v(exceptionTypes));
+ Stmt exceptionStmt = Jimple.v().newInvokeStmt(lExceptionMessage);
+
+ if(stmt.toString().contains("@caughtexception")){
+ units.insertAfter(exceptionStmt, stmt);
+ }
+ }
+ selectionOutput(packageMethodName, testOutputBuffer, "testOutput");
}
private static boolean internalOrInitStatementNotInvoked(Stmt stmt) {
@@ -407,7 +435,7 @@ private static void selectionOutput(String packageMethodName, StringBuffer sb, S
}
private void insertRightBeforeNoRedirect(PatchingChain pchain,
- List instrumCode, Stmt s) {
+ List instrumCode, Stmt s) {
assert !(s instanceof IdentityStmt);
for (Object stmt : instrumCode) {
pchain.insertBeforeNoRedirect((Unit) stmt, s);
@@ -450,4 +478,4 @@ private static Local getLocal(Body b, String localName) {
}
return null;
}
-}
+}
\ No newline at end of file
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/InstrumenterXML.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/InstrumenterXML.java
new file mode 100644
index 00000000..59d9ac92
--- /dev/null
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/InstrumenterXML.java
@@ -0,0 +1,566 @@
+package edu.washington.cs.dt.impact.util;
+
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import soot.*;
+
+
+import soot.jimple.*;
+import soot.jimple.internal.JLookupSwitchStmt;
+import soot.jimple.internal.JTableSwitchStmt;
+import soot.jimple.toolkits.annotation.logic.Loop;
+import soot.jimple.toolkits.annotation.logic.LoopFinder;
+import soot.tagkit.AnnotationTag;
+import soot.tagkit.Tag;
+import soot.tagkit.VisibilityAnnotationTag;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import soot.toolkits.graph.BriefUnitGraph;
+import soot.toolkits.graph.ExceptionalUnitGraph;
+import soot.toolkits.graph.UnitGraph;
+import soot.toolkits.scalar.SimpleLocalDefs;
+import soot.toolkits.scalar.SimpleLocalUses;
+import soot.*;
+import soot.jimple.*;
+import soot.tagkit.*;
+import soot.toolkits.graph.ExceptionalUnitGraph;
+import soot.toolkits.scalar.SimpleLocalDefs;
+import soot.toolkits.scalar.SimpleLocalUses;
+import soot.toolkits.scalar.UnitValueBoxPair;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import soot.toolkits.graph.StronglyConnectedComponentsFast;
+import soot.toolkits.scalar.ArraySparseSet;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+public class InstrumenterXML extends SceneTransformer {
+ private static Constants.TECHNIQUE technique = Constants.DEFAULT_TECHNIQUE;
+ private Document doc;
+ private Element rootElement;
+ private Set visitedMethods = new HashSet<>();
+ private int testMethodIdCounter = 1;
+ private Map testClassElements = new HashMap<>();
+ private List targetTestMethodNames;
+ private boolean useTargetTestMethodNamesFilter;
+ private int loopIterationCount;
+ private int conditionControlFlag;
+ public InstrumenterXML(Constants.TECHNIQUE t, List targetTestMethodNames,int conditionControlFlag,int loopIterationCount, boolean useTargetTestMethodNamesFilter) {
+ this.technique = t;
+ this.targetTestMethodNames = targetTestMethodNames;
+ this.conditionControlFlag = conditionControlFlag;
+ this.loopIterationCount=loopIterationCount;
+ this.useTargetTestMethodNamesFilter = useTargetTestMethodNamesFilter;
+ try {
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ doc = docBuilder.newDocument();
+ } catch (Exception e) {
+ throw new RuntimeException("Error initializing Instumrnterxml", e);
+ }
+ }
+
+ protected boolean isTestMethod(SootMethod method) {
+ if (!method.isConcrete()) {
+ return false;
+ }
+
+ for (Tag tag : method.getTags()) {
+ if (tag instanceof VisibilityAnnotationTag) {
+ VisibilityAnnotationTag vat = (VisibilityAnnotationTag) tag;
+ for (AnnotationTag at : vat.getAnnotations()) {
+ if (at.getType().equals("Lorg/junit/Test;")) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void internalTransform(String phaseName, Map options) {
+ for (SootClass sootClass : Scene.v().getApplicationClasses()) {
+ for (SootMethod method : sootClass.getMethods()) {
+ String fullyQualifiedName = method.getDeclaringClass().getName() + "." + method.getName();
+ boolean containsTargetTestMethod = targetTestMethodNames.stream().anyMatch(fullyQualifiedName::equals);
+ targetTestMethodNames.removeIf(fullyQualifiedName::equals);
+
+ // check if the method should be instrumented based on the useTargetTestMethodNamesFilter flag
+ if (method.hasActiveBody() && (useTargetTestMethodNamesFilter ? isTestMethod(method) && containsTargetTestMethod : true)) {
+ //System.out.println("Instrumenting method: " + method.getSignature());
+ internalTransform(method.getActiveBody(), phaseName, options);
+ }
+ }
+ }
+ }
+
+
+ protected void internalTransform(Body body, String phaseName, Map options) {
+ SootMethod method = body.getMethod();
+ if (isTestMethod(method)) {
+ if (rootElement == null) {
+ rootElement = doc.createElement("testList");
+ doc.appendChild(rootElement);
+ }
+ Element testClassElement = getTestClassElement(method.getDeclaringClass().getName());
+ processMethodCallTree(method, doc, testClassElement, testMethodIdCounter++); // Increment the testMethodIdCounter after processing
+ }
+ }
+ private Element getTestClassElement(String className) {
+ Element testClassElement = testClassElements.get(className);
+ if (testClassElement == null) {
+ testClassElement = doc.createElement("testClass");
+ testClassElement.setAttribute("name", className);
+ rootElement.appendChild(testClassElement);
+ testClassElements.put(className, testClassElement);
+ }
+ return testClassElement;
+ }
+
+ private void processMethodCallTree(SootMethod method, Document doc, Element parentElement, int index) {
+ visitedMethods.add(method.getSignature());
+ if (method.hasActiveBody()) {
+ processMethod(method, doc, parentElement, index);
+ }
+ }
+ private boolean hasAncestorWithTag(Element element, String tagName) {
+ Node parentNode = element.getParentNode();
+ while (parentNode != null && parentNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (((Element) parentNode).getTagName().equals(tagName)) {
+ return true;
+ }
+ parentNode = parentNode.getParentNode();
+ }
+ return false;
+ }
+
+ private void processMethod(SootMethod method, Document doc, Element parentElement, int index) {
+ try {
+ //System.out.println("Processing method: " + method.getSignature());
+
+ if (method.getName().equals("")) {
+ return;
+ }
+
+ if (method.hasActiveBody()) {
+ Body body = method.getActiveBody();
+ Element methodElement = parentElement;
+
+ // Create a List to store method call information in order
+ List methodCallInfos = new ArrayList<>();
+
+ // Create a LoopFinder to identify loops in the method
+ LoopFinder loopFinder = new LoopFinder();
+ loopFinder.transform(body);
+ UnitGraph graph = new BriefUnitGraph(body);
+ Set loops = loopFinder.getLoops(graph);
+
+ // Iterate through all units in the method's body
+ int conditionLevel = 0;
+ for (Unit unit : body.getUnits()) {
+ if (unit instanceof IfStmt || unit instanceof SwitchStmt) {
+ conditionLevel++;
+ } else if (unit instanceof ExitMonitorStmt) {
+ conditionLevel--;
+ }
+
+ if (unit instanceof Stmt) {
+ Stmt stmt = (Stmt) unit;
+ if (stmt.containsInvokeExpr()) {
+ if ((conditionControlFlag == 1 && conditionLevel <= 1) ||
+ (conditionControlFlag == 2 && conditionLevel == 0) ||
+ (conditionControlFlag == 0)) {
+ InvokeExpr invokeExpr = stmt.getInvokeExpr();
+ SootMethod invokedMethod = invokeExpr.getMethod();
+
+ // Calculate loop multiplier
+ int loopMultiplier = 1;
+ for (Loop loop : loops) {
+ if (loop.getLoopStatements().contains(stmt)) {
+ // Estimate the loop count
+ loopMultiplier = loopIterationCount; // Use a constant for now
+ break;
+ }
+ }
+
+ // Add the method call info to the List
+ String methodSignature = invokedMethod.getSignature();
+ methodCallInfos.add(new MethodCallInfo(methodSignature, loopMultiplier));
+ }
+ }
+ }
+ }
+
+
+ if (!hasAncestorWithTag(parentElement, "testMethod")) {
+ methodElement = doc.createElement(isTestMethod(method) ? "testMethod" : "method");
+ methodElement.setAttribute("id", Integer.toString(index));
+ methodElement.setAttribute("name", method.getDeclaringClass().getName() + "." + method.getName());
+ methodElement.setAttribute("testType", Boolean.toString(isTestMethod(method)));
+ methodElement.setAttribute("time", "");
+ methodElement.setAttribute("throwException", "false");
+ parentElement.appendChild(methodElement);
+ }
+
+ // Process the method call counts and create XML elements
+ int invokedMethodIndex = 1;
+ for (MethodCallInfo methodCallInfo : methodCallInfos) {
+ String methodSignature = methodCallInfo.methodSignature;
+ int callCount = methodCallInfo.callCount;
+ SootMethod invokedMethod = Scene.v().getMethod(methodSignature);
+
+ if ((invokedMethod.getName().equals(""))) {
+ continue;
+ }
+
+ for (int i = 0; i < callCount; i++) {
+ String invokedMethodId = methodElement.getAttribute("id") + "." + invokedMethodIndex++;
+
+ Element invokedMethodElement = doc.createElement("method");
+ invokedMethodElement.setAttribute("id", invokedMethodId);
+ invokedMethodElement.setAttribute("name", invokedMethod.getDeclaringClass().getName() + "." + invokedMethod.getName());
+ invokedMethodElement.setAttribute("testType", Boolean.toString(isTestMethod(invokedMethod)));
+ invokedMethodElement.setAttribute("time", "");
+ invokedMethodElement.setAttribute("throwException", "false");
+ methodElement.appendChild(invokedMethodElement);
+
+ if (isTestMethod(method)) {
+ // Recursively process the invoked method and its children
+ processMethod(invokedMethod, doc, invokedMethodElement, invokedMethodIndex - 1);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("Error while processing method " + method.getSignature() + ": " + e.getMessage());
+ }
+ }
+ private boolean processConditionalStatements(Stmt stmt, int conditionControlFlag) {
+ if (conditionControlFlag == 1) {
+ if (stmt instanceof IfStmt) {
+ return true;
+ } else if (stmt instanceof JLookupSwitchStmt || stmt instanceof JTableSwitchStmt) {
+ return false;
+ }
+ } else if (conditionControlFlag == 2) {
+ return !(stmt instanceof IfStmt || stmt instanceof JLookupSwitchStmt || stmt instanceof JTableSwitchStmt);
+ }
+ return true;
+ }
+
+ /*public void generateXML(String dirpath,String filename){
+ String outputFilePath=dirpath+filename;
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+
+ // Check if the document is empty
+ if (doc.getDocumentElement() == null || doc.getDocumentElement().getChildNodes().getLength() == 0) {
+ // Create a new XML document with the desired root element
+ DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
+ Document newDoc = documentBuilder.newDocument();
+ Element rootElement = newDoc.createElement("testList");
+ newDoc.appendChild(rootElement);
+
+ // Update the doc reference
+ doc = newDoc;
+ }
+
+ DOMSource source = new DOMSource(doc);
+
+ OutputStream outputStream = new FileOutputStream(outputFilePath);
+ StreamResult result = new StreamResult(outputStream);
+
+ transformer.transform(source, result);
+ outputStream.close();
+ System.out.println("XML saved to " + outputFilePath);
+ } catch (Exception e) {
+ throw new RuntimeException("Error generating XML", e);
+ }
+ }*/
+ public void generateXML(String dirpath, String filename){
+ String outputFilePath = dirpath + filename;
+ String csvOutputFilePath = dirpath + "methodList.csv"; // output csv file path
+
+ Set methodNames = new HashSet<>(); // to store unique method names
+
+ try {
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+
+ // Check if the document is empty
+ if (doc.getDocumentElement() == null || doc.getDocumentElement().getChildNodes().getLength() == 0) {
+ // Create a new XML document with the desired root element
+ DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();
+ Document newDoc = documentBuilder.newDocument();
+ Element rootElement = newDoc.createElement("testList");
+ newDoc.appendChild(rootElement);
+
+ // Update the doc reference
+ doc = newDoc;
+ }
+
+ DOMSource source = new DOMSource(doc);
+
+ OutputStream outputStream = new FileOutputStream(outputFilePath);
+ StreamResult result = new StreamResult(outputStream);
+
+ transformer.transform(source, result);
+ outputStream.close();
+ System.out.println("XML saved to " + outputFilePath);
+
+ // After generating the XML, iterate through all method and testMethod elements and add their names to the set
+ NodeList methodNodes = doc.getElementsByTagName("method");
+ NodeList testMethodNodes = doc.getElementsByTagName("testMethod");
+
+ for (int i = 0; i < methodNodes.getLength(); i++) {
+ methodNames.add(((Element) methodNodes.item(i)).getAttribute("name"));
+ }
+
+ for (int i = 0; i < testMethodNodes.getLength(); i++) {
+ methodNames.add(((Element) testMethodNodes.item(i)).getAttribute("name"));
+ }
+
+
+ // Now write the method names to the CSV file
+ Files.write(Paths.get(csvOutputFilePath), (Iterable) methodNames.stream()::iterator);
+ System.out.println("CSV saved to " + csvOutputFilePath);
+ } catch (Exception e) {
+ throw new RuntimeException("Error generating XML or CSV", e);
+ }
+ }
+
+ public void mergeXML(String dirpath)
+ {
+ String xmlFile1 = dirpath+"sootXML-firstVers/firstVers-runtime.xml";
+ String xmlFile2 = dirpath+"output.xml";
+ String outputFile = dirpath+"secondVers-merged.xml";
+ try {
+ compareAndGenerateXML(xmlFile1, xmlFile2, outputFile, targetTestMethodNames);
+ } catch (IOException | ParserConfigurationException | TransformerException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ private static Element createOutputTestClassWithoutTargetMethods(Document output, Node inputTestClass, List targetTestMethodNames) {
+ NodeList inputTestMethods = inputTestClass.getChildNodes();
+ Element outputTestClass = output.createElement("testClass");
+ outputTestClass.setAttribute("name", inputTestClass.getAttributes().getNamedItem("name").getNodeValue());
+
+ boolean hasTestMethod = false;
+ for (int i = 0; i < inputTestMethods.getLength(); i++) {
+ Node inputTestMethod = inputTestMethods.item(i);
+ if (inputTestMethod.getNodeType() == Node.ELEMENT_NODE && !targetTestMethodNames.contains(inputTestMethod.getAttributes().getNamedItem("name").getNodeValue())) {
+ outputTestClass.appendChild(output.importNode(inputTestMethod, true));
+ hasTestMethod = true;
+ }
+ }
+
+ return hasTestMethod ? outputTestClass : null;
+ }
+ public static void compareAndGenerateXML(String inputFile1, String inputFile2, String outputFile, List targetTestMethodNames) throws IOException, ParserConfigurationException, TransformerException, SAXException {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+
+ Document input1 = dBuilder.parse(new File(inputFile1));
+ Document input2 = dBuilder.parse(new File(inputFile2));
+ Document output = dBuilder.newDocument();
+
+ input1.getDocumentElement().normalize();
+ input2.getDocumentElement().normalize();
+
+ Element testList = output.createElement("testList");
+ output.appendChild(testList);
+
+ Map input1TestClassesMap = new HashMap<>();
+ Map input2TestClassesMap = new HashMap<>();
+
+ NodeList input1TestClasses = input1.getElementsByTagName("testClass");
+ NodeList input2TestClasses = input2.getElementsByTagName("testClass");
+
+ for (int i = 0; i < input1TestClasses.getLength(); i++) {
+ Node input1TestClass = input1TestClasses.item(i);
+ input1TestClassesMap.put(input1TestClass.getAttributes().getNamedItem("name").getNodeValue(), input1TestClass);
+ }
+
+ for (int i = 0; i < input2TestClasses.getLength(); i++) {
+ Node input2TestClass = input2TestClasses.item(i);
+ input2TestClassesMap.put(input2TestClass.getAttributes().getNamedItem("name").getNodeValue(), input2TestClass);
+ }
+
+ Set allTestClassNames = new HashSet<>(input1TestClassesMap.keySet());
+ allTestClassNames.addAll(input2TestClassesMap.keySet());
+
+ for (String testClassName : allTestClassNames) {
+ Node input1TestClass = input1TestClassesMap.get(testClassName);
+ Node input2TestClass = input2TestClassesMap.get(testClassName);
+
+ if (input1TestClass == null && input2TestClass != null) {
+ Element outputTestClass = createOutputTestClassWithoutTargetMethods(output, input2TestClass, targetTestMethodNames);
+ if (outputTestClass != null) {
+ testList.appendChild(outputTestClass);
+ }
+ continue;
+ } else if (input1TestClass != null && input2TestClass == null) {
+ Element outputTestClass = createOutputTestClassWithoutTargetMethods(output, input1TestClass, targetTestMethodNames);
+ if (outputTestClass != null) {
+ testList.appendChild(outputTestClass);
+ }
+ continue;
+ }
+
+ Element outputTestClass = output.createElement("testClass");
+ outputTestClass.setAttribute("name", testClassName);
+ testList.appendChild(outputTestClass);
+
+ Map input1TestMethodsMap = new HashMap<>();
+ Map input2TestMethodsMap = new HashMap<>();
+
+ NodeList input1TestMethods = input1TestClass.getChildNodes();
+ NodeList input2TestMethods = input2TestClass.getChildNodes();
+
+ for (int j = 0; j < input1TestMethods.getLength(); j++) {
+ Node input1TestMethod = input1TestMethods.item(j);
+ if (input1TestMethod.getNodeType() == Node.ELEMENT_NODE) {
+ input1TestMethodsMap.put(input1TestMethod.getAttributes().getNamedItem("name").getNodeValue(), input1TestMethod);
+ }
+ }
+
+ for (int j = 0; j < input2TestMethods.getLength(); j++) {
+ Node input2TestMethod = input2TestMethods.item(j);
+ if (input2TestMethod.getNodeType() == Node.ELEMENT_NODE) {
+ input2TestMethodsMap.put(input2TestMethod.getAttributes().getNamedItem("name").getNodeValue(), input2TestMethod);
+ }
+ }
+
+ Set allTestMethodNames = new HashSet<>(input1TestMethodsMap.keySet());
+ allTestMethodNames.addAll(input2TestMethodsMap.keySet());
+
+ for (String testMethodName : allTestMethodNames) {
+ int deletedflag=0;
+ for (String testName : targetTestMethodNames) {
+
+ if (testName.equals(testMethodName)) {
+ deletedflag=1;
+ break;
+ }
+ }
+ if(deletedflag==1)
+ {
+ continue;
+ }
+ Node input1TestMethod = input1TestMethodsMap.get(testMethodName);
+ Node input2TestMethod = input2TestMethodsMap.get(testMethodName);
+
+ if (input1TestMethod == null && input2TestMethod != null) {
+ outputTestClass.appendChild(output.importNode(input2TestMethod, true));
+ } else if (input1TestMethod != null && input2TestMethod == null) {
+ outputTestClass.appendChild(output.importNode(input1TestMethod, true));
+ } else {
+ Element mergedTestMethod = mergeTestMethods(output, input1TestMethod, input2TestMethod);
+ outputTestClass.appendChild(mergedTestMethod);
+ }
+ }
+ }
+
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ DOMSource source = new DOMSource(output);
+ StreamResult result = new StreamResult(new File(outputFile));
+ transformer.transform(source, result);
+ }
+ private static Element mergeTestMethods(Document output, Node input1TestMethod, Node input2TestMethod) {
+ Element mergedTestMethod = (Element) output.importNode(input2TestMethod, true);
+ NodeList input1Methods = input1TestMethod.getChildNodes();
+ NodeList mergedMethods = mergedTestMethod.getChildNodes();
+
+ Map> input1NestedMethodsMap = new HashMap<>();
+ buildNestedMethodsList(input1Methods, input1NestedMethodsMap, 0); // Include level parameter
+
+ mergeChildMethods(mergedMethods, input1NestedMethodsMap, 0);
+
+ // Update mergedTestMethod attributes
+ mergedTestMethod.setAttribute("id", input1TestMethod.getAttributes().getNamedItem("id").getNodeValue());
+ mergedTestMethod.setAttribute("name", input2TestMethod.getAttributes().getNamedItem("name").getNodeValue());
+ mergedTestMethod.setAttribute("testType", input2TestMethod.getAttributes().getNamedItem("testType").getNodeValue());
+ mergedTestMethod.setAttribute("throwException", input2TestMethod.getAttributes().getNamedItem("throwException").getNodeValue());
+ mergedTestMethod.setAttribute("time", input2TestMethod.getAttributes().getNamedItem("time").getNodeValue());
+
+ return mergedTestMethod;
+ }
+
+
+ private static void buildNestedMethodsList(NodeList nodes, Map> map, int level) {
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ String key = level + "-" + element.getTagName();
+ List elements = map.getOrDefault(key, new ArrayList<>());
+ elements.add(element);
+ map.put(key, elements);
+
+ buildNestedMethodsList(node.getChildNodes(), map, level + 1);
+ }
+ }
+ }
+ private static boolean mergeChildMethods(NodeList mergedMethods, Map> input1NestedMethodsMap, int level) {
+ boolean notMatchedFlag = false;
+ for (int i = 0; i < mergedMethods.getLength(); i++) {
+ Node mergedMethod = mergedMethods.item(i);
+ if (mergedMethod.getNodeType() == Node.ELEMENT_NODE) {
+ String key = level + "-" + mergedMethod.getNodeName();
+ List input1Methods = input1NestedMethodsMap.getOrDefault(key, new ArrayList<>());
+ boolean currentMethodMatched = false;
+ if (!input1Methods.isEmpty()) {
+ Element input1Method = input1Methods.get(0);
+ if (mergedMethod.getAttributes().getNamedItem("name").getNodeValue().equals(input1Method.getAttribute("name"))) {
+ if(!notMatchedFlag)
+ {
+ mergedMethod.getAttributes().getNamedItem("time").setNodeValue(input1Method.getAttribute("time"));
+ }
+ input1Methods.remove(0);
+ currentMethodMatched = true;
+ }
+ }
+
+ boolean childNotMatched = mergeChildMethods(mergedMethod.getChildNodes(), input1NestedMethodsMap, level + 1);
+
+ // If current method and its children didn't match, set the time attribute to an empty string
+ if (!currentMethodMatched || childNotMatched) {
+ mergedMethod.getAttributes().getNamedItem("time").setNodeValue("");
+ notMatchedFlag = true;
+ }
+ }
+ }
+ return notMatchedFlag;
+ }
+}
+class MethodCallInfo {
+ String methodSignature;
+ int callCount;
+
+ public MethodCallInfo(String methodSignature, int callCount) {
+ this.methodSignature = methodSignature;
+ this.callCount = callCount;
+ }
+}
\ No newline at end of file
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Method.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Method.java
new file mode 100644
index 00000000..a1e59b83
--- /dev/null
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Method.java
@@ -0,0 +1,179 @@
+package edu.washington.cs.dt.impact.util;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+import java.util.*;
+
+
+
+public class Method {
+ @JacksonXmlProperty(isAttribute = true)
+ private String id;
+ @JacksonXmlProperty(isAttribute = true)
+ private String name;
+ @JacksonXmlProperty(isAttribute = true)
+ private boolean testType=true;
+ @JacksonXmlProperty(isAttribute = true)
+ private long time;
+ @JacksonXmlProperty(isAttribute = true)
+ private boolean throwException=false;
+ @JacksonXmlElementWrapper(useWrapping = false)
+ @JacksonXmlProperty(localName = "method")
+ public ArrayList method;
+
+ public Method(String id,String name,long time,boolean testType,boolean throwException) {
+ this.id = id;
+ this.name=name;
+ this.testType=testType;
+ this.time=time;
+ this.throwException=throwException;
+ this.method = new ArrayList();
+ }
+
+ public Method findParent(String parentname,ArrayList meth,long time,Method res,boolean throwException)
+ {
+ ListIterator e
+ = meth.listIterator(meth.size());
+ while ((e.hasPrevious())) {
+ Method temp = e.previous();
+ if(Objects.equals(temp.getName(), parentname))
+ {
+ res=temp;
+ break;
+ }
+ long newtime= temp.getTime()+time;
+ temp.setTime(newtime);
+ return findParent(parentname,temp.getMethod(),time,res,throwException);
+
+ }
+ return res;
+
+ }
+ public String addChild(String parentname,String id,String name,long time,boolean throwException) {
+ int i=0,expFlag=0;
+ //this.setTime(this.getTime()+time);
+ if(name.contains("Exception:"))
+ {
+ throwException=true;
+ //this.setThrowException(true);
+ }
+ Method temp=findParent(parentname,this.method,time,null,throwException);
+ if(Objects.equals(name, "END"))
+ {
+ return null;
+ }
+ if(Objects.equals(this.getName(), parentname))
+ {
+ String[] arrOfStr = id.split("\\.");
+ int last=Integer.parseInt(arrOfStr[0])+1;
+ String lastPart=Integer.toString(last);
+ String idChild=this.getId()+"."+lastPart;
+ Method newParent= new Method(idChild,name,time,false,throwException);
+ this.method.add(newParent);
+ return idChild;
+ }
+ if(temp!=null)
+ {
+ temp.setThrowException(throwException);
+ ListIterator internal
+ = temp.getMethod().listIterator();
+ String lastChildId=temp.getId();
+ int hasChild=0;
+ while (internal.hasNext())
+ {
+ Method tempChild = internal.next();
+ try {
+ hasChild=1;
+ lastChildId = tempChild.getId();
+ }catch (NoSuchElementException err)
+ {
+ continue;
+ }
+ }
+ String internalID=id;
+ if(hasChild==0)
+ {
+ internalID=lastChildId+".1";
+ }
+ else {
+ String[] arrOfStr = lastChildId.split("\\.");
+ int lastInternal=Integer.parseInt(arrOfStr[arrOfStr.length-1])+1;
+ String lastPartInternal=Integer.toString(lastInternal);
+ internalID=temp.getId()+"."+lastPartInternal;
+ }
+
+ i=1;
+ try{
+ temp.getMethod().add(new Method(internalID,name,time,false,throwException));
+ long newtime= temp.getTime()+time;
+ temp.setTime(newtime);
+ //this.addAllTime(time,temp.getMethod(),parentname);
+ return internalID;
+ }
+ catch (NoSuchElementException err)
+ {
+ return internalID;
+ }
+ }else
+ {
+ String[] arrOfStr = id.split("\\.");
+ int last=Integer.parseInt(arrOfStr[0])+1;
+ String lastPart=Integer.toString(last);
+ String idChild=this.getId()+"."+lastPart;
+ Method newParent= new Method(idChild,parentname,time,false,throwException);
+ this.method.add(newParent);
+ newParent.getMethod().add(new Method(idChild+"."+"1",name,time,false,throwException));
+ return idChild+"."+"1";
+ }
+ }
+
+
+ public void addTime(long timeDiff)
+ {
+ this.time+=timeDiff;
+ }
+
+
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public void setTime(long time) {
+ this.time = time;
+ }
+
+ public ArrayList getMethod() {
+ return method;
+ }
+
+ public void setMethod(ArrayList method) {
+ this.method = method;
+ }
+
+ public boolean isThrowException() {
+ return throwException;
+ }
+
+ public void setThrowException(boolean throwException) {
+ this.throwException = throwException;
+ }
+}
+
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeComparator.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeComparator.java
new file mode 100644
index 00000000..8c77827a
--- /dev/null
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeComparator.java
@@ -0,0 +1,151 @@
+package edu.washington.cs.dt.impact.util;
+
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVPrinter;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+
+public class RuntimeComparator {
+ private static void tryCreateDirectory(final File theDir) {
+ try {
+ Files.createDirectory(theDir.toPath());
+ } catch (FileAlreadyExistsException ignored) {
+ // The directory must have been created in between the check above and our attempt to create it.
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {
+ List argsList = new ArrayList(Arrays.asList(args));
+ int inputTestListIndex = argsList.indexOf("-inputFile");
+ int inputTestList = inputTestListIndex + 1;
+ File theDir = new File("sootCsvOutput");
+ tryCreateDirectory(theDir);
+ String testOutput = argsList.get(inputTestList)+"target/surefire-reports/";
+
+ File folder = new File(testOutput);
+ String[] paths = argsList.get(inputTestList).split("/");
+ File[] listOfFiles = folder.listFiles();
+ //String projectPath=currpath.substring(0, currpath.length() - 13);
+ int inputxmlIndex = argsList.indexOf("-inputName")+1;
+ String SootXml=argsList.get(inputxmlIndex)+"sootXML-"+paths[paths.length - 4]+"/"+paths[paths.length - 4]+"-runtime.xml";
+ File xmlfile= new File(SootXml);
+ DocumentBuilderFactory dbfxml= DocumentBuilderFactory.newInstance();
+ DocumentBuilder dbxml = dbfxml.newDocumentBuilder();
+ Document docxml = dbxml.parse(xmlfile);
+ docxml.getDocumentElement().normalize();
+ //System.out.println("--testoutput----"+testOutput);
+ //System.out.println(SootXml);
+
+ FileWriter fileWriter = null;
+ BufferedWriter bufferedWriter = null;
+ fileWriter = new FileWriter("sootCsvOutput" + File.separator + paths[paths.length - 4] + "-comparedResult.csv");
+ bufferedWriter = new BufferedWriter(fileWriter);
+ CSVPrinter csvPrinter = new CSVPrinter(bufferedWriter, CSVFormat.DEFAULT.withHeader("Test Name", "Method Under Test Name", "Surefire result","Test result","Surefire reported execution time(msec.)", "Tested execution time(msec)"));
+ for(int i = 0; i < listOfFiles.length; i++){
+ String filename = listOfFiles[i].getName();
+
+ if(filename.endsWith(".xml")||filename.endsWith(".XML")) {
+ //System.out.println("--file----"+filename);
+ File file = new File(testOutput+filename);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(file);
+ doc.getDocumentElement().normalize();
+
+ //System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
+ NodeList nList = doc.getElementsByTagName("testcase");
+
+
+ for (int temp = 0; temp < nList.getLength(); temp++) {
+ Node nNode = nList.item(temp);
+ //System.out.println("\nCurrent Element :" + nNode.getNodeName());
+ //System.out.println("\n");
+ if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) nNode;
+ /*System.out.println("Test name: "
+ + eElement.getAttribute("classname"));
+ System.out.println("Method name: "
+ + eElement.getAttribute("name"));
+ System.out.println("Execution Time: "
+ + eElement.getAttribute("time"));*/
+ String surefireTestResult="";
+ if(!eElement.getAttribute("failure").isEmpty())
+ {
+ surefireTestResult="failure";
+ }
+ else if(!eElement.getAttribute("error").isEmpty())
+ {
+ surefireTestResult="failed";
+ }else {
+ surefireTestResult="pass";
+ }
+
+ NodeList nListxml= docxml.getElementsByTagName("testMethod");
+
+ float time=0.1F;
+ String testResult="";
+ for (int tempxml = 0; tempxml < nListxml.getLength(); tempxml++) {
+ Node nNodexml = nListxml.item(tempxml);
+ try {
+ if (nNodexml.getNodeType() == nNodexml.ELEMENT_NODE) {
+ Element eElementxml = (Element) nNodexml;
+
+ if((Objects.equals(eElementxml.getAttribute("name"), eElement.getAttribute("classname")+"."+eElement.getAttribute("name"))) && (eElementxml.getAttribute("testType").equals("true")))
+ {
+ time=Float.parseFloat(eElementxml.getAttribute("time"));
+ if(time==0)
+ {
+ time=0.5F;
+ }
+ if((eElementxml.getAttribute("throwException").equals("true")))
+ {
+ testResult="failed";
+ }else {
+ testResult="pass";
+ }
+ break;
+ }
+ }
+ }catch (NullPointerException e)
+ {
+ System.err.println(e.getMessage());
+ }
+
+
+
+ }
+ float surefireTime=Float.parseFloat(eElement.getAttribute("time"))*1000;
+ if(surefireTime==0)
+ {
+ surefireTime= 0.5F;
+ }
+ csvPrinter.printRecord(eElement.getAttribute("classname"),eElement.getAttribute("name"),surefireTestResult,testResult,surefireTime,time);
+
+ }
+ }
+ csvPrinter.flush();
+ }
+ }
+
+
+ }
+}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeGenerator.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeGenerator.java
index 87205971..bf1b24e1 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeGenerator.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/RuntimeGenerator.java
@@ -1,19 +1,20 @@
package edu.washington.cs.dt.impact.util;
-import org.apache.commons.csv.CSVFormat;
-import org.apache.commons.csv.CSVPrinter;
-import org.apache.commons.io.FileUtils;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import java.io.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Scanner;
+import java.util.*;
+
+import static com.github.javaparser.utils.Utils.assertNotNull;
/**
- * This class is responsible for creating runtime csv
+ * This class is responsible for creating runtime xml
*/
public class RuntimeGenerator {
private static void tryCreateDirectory(final File theDir) {
@@ -25,123 +26,171 @@ private static void tryCreateDirectory(final File theDir) {
throw new RuntimeException(e);
}
}
- public static void main(String[] args) throws IOException {
+
+ public static void main(String[] args) throws IOException{
List argsList = new ArrayList(Arrays.asList(args));
int inputTestListIndex = argsList.indexOf("-inputFile");
int inputTestList = inputTestListIndex + 1;
- File theDir = new File("sootCsvOutput");
+ File theDir = new File("sootXMLOutput");
String[] paths = argsList.get(inputTestList).split("/");
System.out.println("File: " + paths[paths.length - 4]);
tryCreateDirectory(theDir);
FileWriter fileWriter = null;
- BufferedWriter bufferedWriter = null;
- try {
- fileWriter = new FileWriter("sootCsvOutput" + File.separator + paths[paths.length - 4] + "-runtime.csv");
- bufferedWriter = new BufferedWriter(fileWriter);
- CSVPrinter csvPrinter = new CSVPrinter(bufferedWriter, CSVFormat.DEFAULT.withHeader("Test Name", "Part", "Method Under Test Name", "Execution Time", "Throw Exception"));
- try {
- File rootFile = new File(argsList.get(inputTestList)+"sootSeqOutput/functionSequence");
- Scanner fileReader = new Scanner(rootFile);
- while (fileReader.hasNextLine()) {
- String data = fileReader.nextLine();
- String[] testInfo = data.split(" > ");
- String initial = testInfo[0].trim();
- if (!initial.equals("Started")){
- continue;
- }
- String nameInfo = testInfo[1].trim();
- String part = nameInfo.split(" >> ")[0].trim();
- String nameWithTime = nameInfo.split(" >> ")[1].trim();
- String name = nameWithTime.split("#")[0];
- String timeStamp = nameWithTime.split("#")[1];
-
- String execInfo = testInfo[4].trim();
- String returnFrom = execInfo.split(" >> ").length == 1 ? "" : execInfo.split(">>")[0].trim();
- String startTest = "startTest", endTest = "endTest";
- if (part.contains("before")) {
- startTest = "startBefore";
- endTest = "endBefore";
- } else if (part.contains("after")) {
- startTest = "startAfter";
- endTest = "endAfter";
+ File rootFile = new File(argsList.get(inputTestList) + "sootTracerData/tempTracerData.txt");
+ //tryCreateDirectory(rootFile);
+ Scanner fileReader = new Scanner(rootFile);
+ String path="sootXMLOutput" + File.separator + paths[paths.length - 4] + "-runtime.xml";
+ FileWriter xmlFile = new FileWriter(path);
+ xmlFile.write("\n");
+ xmlFile.write("");
+ //String id="1";
+ int parentId=1;
+ String dataParent=null;
+ String prevData="";
+ XmlMapper xmlMapper = new XmlMapper();
+ xmlMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ xmlMapper.getFactory().getXMLOutputFactory().setProperty("javax.xml.stream.isRepairingNamespaces", false);
+ TestClass tc = new TestClass("");
+ while (fileReader.hasNextLine())
+ {
+
+
+ if(parentId==1){
+
+ prevData= fileReader.nextLine();
+ String[] prevInfo = prevData.split(",");
+ tc.setName(prevInfo[1]);
+ dataParent=fileReader.nextLine();
+ }
+ else
+ {
+ String[] prevInfo = prevData.split(",");
+ //tc.setName(prevInfo[1]);
+ if(tc.getTestClassByName(prevInfo[1])==null)
+ {
+ String xml = xmlMapper.writeValueAsString(tc);
+ assertNotNull(xml);
+ xmlFile.write(xml + "\n");
+ tc = new TestClass(prevInfo[1]);
+
+ }
+ dataParent=fileReader.nextLine();
+ }
+ String[] testInfoParent = dataParent.split(",");
+
+ String parentMethod=testInfoParent[0];
+ String nextmethod=testInfoParent[1];
+ long prevTime= Long.parseLong(testInfoParent[2]);
+ int prev=0;
+ long timeDiff=0;
+ Method parent = new Method(Integer.toString(parentId),parentMethod,timeDiff,true,false);
+ int expectedexceptionflag=0;
+ String expectedexc="";
+ if(nextmethod.contains("Exception:-expected-"))
+ {
+ expectedexceptionflag=1;
+ expectedexc=nextmethod.replaceAll("Exception:-expected- ", "");
+ }
+ String childId="0";
+ int skipflag=0;
+ int exceptionflag=0;
+ while (fileReader.hasNextLine())
+ {
+ String data = fileReader.nextLine();
+ prevData=data;
+ String[] testInfo = data.split(",");
+
+ String startMethod=testInfo[0];
+ String endMethod=testInfo[1];
+ long time= Long.parseLong(testInfo[2]);
+ if((expectedexceptionflag==1)&&(endMethod.contains(expectedexc)))
+ {
+ timeDiff=time-prevTime;
+ prevTime=time;
+ String currentId=parent.addChild(startMethod,childId,endMethod,timeDiff,true);
+ String[] arrOfStr = currentId.split("\\.");
+ childId="";
+ for (int i=1;i>> ")[1];
- csvPrinter.printRecord(name, part, methodNameInfo.split(" : ")[0].trim(), methodNameInfo.split(" : ")[1].trim(), returnFrom);
- }
- subReader.close();
- } catch (FileNotFoundException e) {
- System.err.println(e.getMessage());
+ parent.addTime(timeDiff);
+ expectedexceptionflag=2;
+ }
+ if(endMethod.contains("Exception:"))
+ {
+ exceptionflag=1;
+ }
+ if(Objects.equals(startMethod, "START"))
+ {
+ dataParent=data;
+ break;
+ }
+ else if(skipflag==1)
+ {
+ continue;
+ }
+ else if(Objects.equals(endMethod, "END"))
+ {
+ timeDiff=time-prevTime;
+ skipflag=1;
+ parent.addChild(startMethod,childId,endMethod,timeDiff,false);
+
+ }
+ else if(Objects.equals(endMethod, "") || Objects.equals(endMethod, " "))
+ {
+ continue;
+ }
+ else if(endMethod.toString().contains(""))
+ {
+ continue;
+ }
+ else{
+ timeDiff=time-prevTime;
+ prevTime=time;
+ String currentId=parent.addChild(startMethod,childId,endMethod,timeDiff,false);
+ String[] arrOfStr = currentId.split("\\.");
+ childId="";
+ for (int i=1;i result = new ArrayList();
- try {
- File testDir = new File(testOutput+name);
- Scanner testReader = new Scanner(testDir);
- File temp = new File("new_csv.txt");
- FileWriter output = new FileWriter(temp);
- BufferedWriter writer_2 = new BufferedWriter(output);
- while(testReader.hasNextLine()){
- String fullMethodName = testReader.nextLine();
- File subDir = new File(subFile+name);
- Scanner subReader = new Scanner(subDir);
- while(subReader.hasNextLine()){
- String method_name = subReader.nextLine();
- String subMethod = method_name.split(" >>> ")[1];
- if(subMethod.split(" : ")[0].trim().equals(fullMethodName.trim())){
- csvPrinter.printRecord(name, part, subMethod.split(" : ")[0].trim(), subMethod.split(" : ")[1].trim(), returnFrom);
- result.add(subMethod);
- break;
- }
- }
- subReader.close();
- }
- testReader.close();
- File subDir = new File(subFile+name);
- Scanner subReader = new Scanner(subDir);
- while(subReader.hasNextLine()){
- String methodName = subReader.nextLine();
- String subMethod = methodName.split(" >>> ")[1];
- Boolean found = false;
- for (int i = 0; i < result.size(); i++) {
- if(subMethod.trim().equals(result.get(i).trim())){
- result.remove(i);
- found = true;
- break;
- }
- }
- if (!found) {
- writer_2.write(methodName + "\n");
- }
- }
- subReader.close();
- writer_2.close();
- temp.renameTo(subDir);
- } catch (FileNotFoundException e) {
- System.err.println(e.getMessage());
+ else {
+ childId+=arrOfStr[i]+".";
}
}
- csvPrinter.printRecord(name, endTest, "", testInfo[3].trim().split("#")[1], "");
+ parent.addTime(timeDiff);
}
- fileReader.close();
- } catch (FileNotFoundException e) {
- System.err.println(e.getMessage());
}
- csvPrinter.flush();
- } catch (IOException e){
- System.err.println(e.getMessage());
- } finally {
- fileWriter.close();
- bufferedWriter.close();
+ if((skipflag==0) &&(exceptionflag==1))
+ {
+ parent.setThrowException(true);
+ }
+ if(expectedexceptionflag==2)
+ {
+ parent.setThrowException(false);
+ }
+
+ tc.addMethod(parent);
+
+ parentId++;
}
+ String xml = xmlMapper.writeValueAsString(tc);
+ assertNotNull(xml);
+ xmlFile.write(xml + "\n");
+ xmlFile.write("");
+ xmlFile.flush();
+ xmlFile.close();
}
+
+
+
}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/TestClass.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/TestClass.java
new file mode 100644
index 00000000..da909307
--- /dev/null
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/TestClass.java
@@ -0,0 +1,50 @@
+package edu.washington.cs.dt.impact.util;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@JacksonXmlRootElement(localName = "testClass")
+public class TestClass {
+ @JacksonXmlProperty(isAttribute = true, localName = "name")
+ private String name;
+ @JacksonXmlElementWrapper(useWrapping = false)
+ @JacksonXmlProperty(localName = "testMethod")
+ private ArrayList method;
+ private static List allTestClasses = new ArrayList<>();
+
+ public TestClass(String name) {
+ this.name = name;
+ this.method = new ArrayList();
+ allTestClasses.add(this);
+ }
+
+ public void addMethod(Method m) {
+ this.method.add(m);
+ }
+
+ public ArrayList getMethod() {
+ return method;
+ }
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ public static List getAllTestClasses() {
+ return allTestClasses;
+ }
+ public TestClass getTestClassByName(String name) {
+ for (TestClass testClass : allTestClasses) {
+ if (testClass.getName().equals(name)) {
+ return testClass;
+ }
+ }
+ return null;
+ }
+}
diff --git a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Tracer.java b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Tracer.java
index 569adf3a..a5033707 100644
--- a/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Tracer.java
+++ b/dt-impact-tracer/src/main/java/edu/washington/cs/dt/impact/util/Tracer.java
@@ -1,17 +1,16 @@
/**
* Copyright 2014 University of Washington. All Rights Reserved.
* @author Wing Lam
- *
+ *
* Used by the Instrumenter to record the statements a test case covers.
*/
package edu.washington.cs.dt.impact.util;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+
+import java.io.*;
+import java.nio.charset.Charset;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.util.Collections;
@@ -58,7 +57,8 @@ public static void output(String packageMethodName) {
}
}
} catch (Exception e) {
- throw new RuntimeException(e);
+ //throw new RuntimeException(e);
+ System.out.println(e);
} finally {
try {
if (writer != null) {
@@ -152,27 +152,54 @@ public static void endTimer(){
timer.setEndTime();
}
- public static void exceptionMessage(String packageMethodName, String prefix){
- endExecution(packageMethodName, prefix, "Exception");
+ public static void exceptionMessage(String packageMethodName, String prefix,String type) throws IOException {
+ packageMethodName=packageMethodName.replaceAll("\\$\\d+", "");
+ long time=System.currentTimeMillis();
+ type = type.replaceAll(",",";");
+ writeforinputXML("sootTracerData",packageMethodName,"Exception:"+type, time);
+ //endExecution(packageMethodName, prefix, "Exception: "+type);
writeToFile("sootException", "Caught Exception in : " + packageMethodName + "\n", "functionException");
}
- public static void timerOutput(String packageMethodName, String methodName, String declaringClass){
+ public static void timerOutput(String packageMethodName, String methodName, String declaringClass) throws IOException {
// long elapsedTime = timer.getTotalTime();
// timer.reset();
+ packageMethodName=packageMethodName.replaceAll("\\$\\d+", "");
+ methodName=methodName.replaceAll("\\$\\d+", "");
+ declaringClass=declaringClass.replaceAll("\\$\\d+", "");
+ long time=System.currentTimeMillis();
+ writeforinputXML("sootTracerData",packageMethodName,declaringClass + "." +methodName, time);
String text = packageMethodName + " >>> " + declaringClass + "." + methodName + " : " + System.currentTimeMillis() + "\n";
writeToFile("sootTimerOutput", text, packageMethodName);
}
- public static void startExecution(String packageMethodName, String prefix){
+ public static void startExecution(String packageMethodName, String prefix) throws IOException {
// totalExecutionTime.setStartTime();
+ packageMethodName=packageMethodName.replaceAll("\\$\\d+", "");
+ String[] arrOfStr = packageMethodName.split("\\.");
+ packageMethodName="";
+ for (int i=0;i " + prefix +" >> " + packageMethodName+"#"+System.currentTimeMillis() , "functionSequence");
}
- public static void endExecution(String packageMethodName, String prefix, String endMethod){
+ public static void endExecution(String packageMethodName, String prefix, String endMethod) throws IOException {
// totalExecutionTime.setEndTime();
// long elapsedTime = totalExecutionTime.getTotalTime();
// totalExecutionTime.reset();
+ packageMethodName=packageMethodName.replaceAll("\\$\\d+", "");
+ long time=System.currentTimeMillis();
+ writeforinputXML("sootTracerData",packageMethodName,"END", time);
String text = " > Ended > " + packageMethodName+"#"+System.currentTimeMillis() + " > " + endMethod + " >> " + "Time : " + "elapsedTime" + " " + "\n";
writeToFile("sootSeqOutput", text, "functionSequence");
}
@@ -203,4 +230,31 @@ private static void writeToFile(String folderPath, String text, String fileName)
}
}
}
-}
+ public static void writeforinputXML(String folderPath, String startMethod,String endMethod, long time) throws IOException {
+ File theDir = new File(folderPath);
+ tryCreateDirectory(theDir);
+ FileWriter output = null;
+ BufferedWriter writer = null;
+ String text=startMethod+","+endMethod+","+time+"\n";
+ try {
+ output = new FileWriter(folderPath + File.separator + "tempTracerData.txt", true);
+ writer = new BufferedWriter(output);
+ writer.write(text);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ try {
+ if (writer != null) {
+ writer.close();
+ }
+ if (output != null) {
+ output.close();
+ }
+ } catch (IOException e) {
+ // Ignore issues during closing
+ System.err.println(e.toString());
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/dt-impact-tracer/src/test/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunnerTest.java b/dt-impact-tracer/src/test/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunnerTest.java
index eef5a7bb..8b22c451 100644
--- a/dt-impact-tracer/src/test/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunnerTest.java
+++ b/dt-impact-tracer/src/test/java/edu/washington/cs/dt/impact/runner/OneConfigurationRunnerTest.java
@@ -4,7 +4,7 @@
import com.reedoei.eunomia.string.matching.LineMatch;
import com.reedoei.eunomia.string.searching.Searcher;
import com.reedoei.eunomia.string.searching.StringSearch;
-import com.reedoei.eunomia.util.FileUtil;
+import com.reedoei.eunomia.io.files.FileUtil;
import edu.washington.cs.dt.RESULT;
import edu.washington.cs.dt.impact.figure.generator.PrecomputedTimeFigureGenerator;
import edu.washington.cs.dt.impact.util.Constants;
diff --git a/example.sh b/example.sh
index e1542584..ac4c18c5 100644
--- a/example.sh
+++ b/example.sh
@@ -17,37 +17,44 @@ machines=$2
# Clear any existing logs
rm -rf ${scripts_folder}/logs/
mkdir -p ${scripts_folder}/logs/
-
# Clone the firstVers if it doesn't exist
if [[ ! -d "firstVers" ]]; then
echo "Cloning firstVers"
- git clone https://github.com/kevinsawicki/http-request.git firstVers &> ${scripts_folder}/logs/firstVers-clone-log.txt
+ git clone https://github.com/Apache/Struts firstVers &> ${scripts_folder}/logs/firstVers-clone-log.txt
echo "Compiling firstVers"
- cd firstVers/lib
- git checkout d0ba95cf3c621c74a023887814e8c1f73b5da1b2 &> ${scripts_folder}/logs/checkout-firstVers.txt
+ cd firstVers
+ git checkout 13d9053050c9e4fb2ef049db6a37d3f6eebf48fa &> ${scripts_folder}/logs/checkout-firstVers.txt
mvn install dependency:copy-dependencies -DskipTests &> ${scripts_folder}/logs/install-log-firstVers.txt
cd ${scripts_folder}
fi
-
+exit 1
+#cd firstVers
+#git checkout b19048b72669fc0e96665b1b125dc1fda21f5993 &> ${scripts_folder}/logs/checkout-firstVers.txt
+#mvn install dependency:copy-dependencies -DskipTests
+#mvn install dependency:copy-dependencies -DskipTests -pl dropwizard-logging/ -am &> ${scripts_folder}/logs/install-log-firstVers.txt
+#cd ${scripts_folder}
# Clone the secondVers if it doesn't exist
if [[ ! -d "secondVers" ]]; then
echo "Cloning secondVers"
- git clone https://github.com/kevinsawicki/http-request.git secondVers &> ${scripts_folder}/logs/secondVers-clone-log.txt
+ git clone https://github.com/kevinsawicki/http-request secondVers &> ${scripts_folder}/logs/secondVers-clone-log.txt
echo "Compiling secondVers"
cd secondVers/lib
- git checkout ef89ec663e6d192c08b77dd1d9b8649975c1419c &> ${scripts_folder}/logs/checkout-secondVers.txt
+ git checkout f6600a6df2dce52b18cc985a1897a47f510547b6 &> ${scripts_folder}/logs/checkout-secondVers.txt
mvn install dependency:copy-dependencies -DskipTests &> ${scripts_folder}/logs/install-log-secondVers.txt
cd ${scripts_folder}
fi
-
# Clear any existing results
rm -rf lib-results/
+#rm -rf lib-results/methodOutput-plugins
+#rm -rf lib-results/sootComparedCSV-plugins
+#rm -rf lib-results/sootTestOutput-orig
+#rm -rf lib-results/sootXML-plugins
echo "Setting up the two versions for regression testing"
bash setup.sh firstVers/lib $algo secondVers/lib &> logs/setup.txt
-echo "Running the unenhanced regression testing algorithm on the secondVers"
-bash run.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/run-unenhanced.txt
-echo "Computing dependencies on the firstVers"
-bash compute-deps.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/compute-deps.txt
-echo "Running the enhanced regression testing algorithm on the secondVers"
-bash run.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/run-enhanced.txt
+#echo "Running the unenhanced regression testing algorithm on the secondVers"
+#bash run.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/run-unenhanced.txt
+#echo "Computing dependencies on the firstVers"
+#bash compute-deps.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/compute-deps.txt
+#echo "Running the enhanced regression testing algorithm on the secondVers"
+#bash run.sh firstVers/lib $algo secondVers/lib "$machines" &> logs/run-enhanced.txt
diff --git a/setup/setup-prio-para.sh b/setup/setup-prio-para.sh
index 6c88c208..13168c4c 100644
--- a/setup/setup-prio-para.sh
+++ b/setup/setup-prio-para.sh
@@ -1,7 +1,6 @@
#!/bin/bash
# Runs commands for "Instructions to setup a subject for test prioritization" section.
-
set -e
cd $DT_SUBJ
@@ -10,17 +9,33 @@ cd ..
rm -rf sootTimerOutput/
rm -rf sootSeqOutput/
rm -rf sootException/
+rm -rf sootTracerData/
+rm -rf sootXMLOutput/
+#rm -rf sootCsvOutput/
+#echo "[DEBUG] checking vars"
+#echo $DT_TESTS
+#echo $DT_CLASS
+#echo $DT_LIBS
+#echo $DT_TOOLS
+#echo "[DEBUG] checking 2nd vars"
+#echo $NEW_DT_CLASS
+#echo $NEW_DT_TESTS
+#echo $NEW_DT_LIBS
+#echo $NEW_DT_SUBJ_ROOT
+#echo $fullyQualifiedMethodNames
# 1. Find the human-written tests in the old subject.
cd $DT_SUBJ
echo "[DEBUG] Finding human written tests in old subject."
bash "$DT_SCRIPTS/shared/get-test-order.sh" old
# 2. Instrument the source and test files.
-echo "[DEBUG] Instrumenting source and test files for old subject."
rm -rf sootOutput/
rm -rf methodOutput/
+echo "[DEBUG] Static analysis source and test files for old subject."
+java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_TESTS --soot-cp $DT_LIBS:$DT_CLASS:$DT_TESTS:$JAVA_HOME/jre/lib/* -staticAnalysis -outputPath $DT_SCRIPTS/${SUBJ_NAME}-results/
+echo "[DEBUG] Instrumenting source and test files for old subject."
#echo "java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_TESTS --soot-cp $DT_LIBS:$DT_CLASS:$DT_TESTS:$JAVA_HOME/jre/lib/*"
java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_TESTS --soot-cp $DT_LIBS:$DT_CLASS:$DT_TESTS:$JAVA_HOME/jre/lib/*
@@ -28,7 +43,7 @@ java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.Instru
java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $DT_CLASS --soot-cp $DT_LIBS:$DT_CLASS:$JAVA_HOME/jre/lib/*
rm -rf $DT_SCRIPTS/${SUBJ_NAME}-results/methodOutput-${VER_NAME}/
-mv methodOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/methodOutput-${VER_NAME}/
+#mv methodOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/methodOutput-${VER_NAME}/
# Copy over any resource files from the classes/ and test-classes/ directories (e.g. configuration files).
# Make sure we don't copy any .class files though.
@@ -45,14 +60,25 @@ rsync -av test-classes/ sootOutput/ --exclude-from=exclude-list.txt
# 3. Run the instrumented tests.
echo "[DEBUG] Running instrumented tests."
cd $DT_SUBJ_SRC
-#echo "[DEBUG] java -cp $DT_TOOLS: edu.washington.cs.dt.impact.Main.RunnerMain -classpath $DT_LIBS:$DT_TOOLS:$DT_SUBJ/sootOutput/: -inputTests $DT_SUBJ/$SUBJ_NAME-orig-order"
-java -cp $DT_TOOLS: edu.washington.cs.dt.impact.Main.RunnerMain -classpath $DT_LIBS:$DT_TOOLS:$DT_SUBJ/sootOutput/: -inputTests $DT_SCRIPTS/${SUBJ_NAME}-results/$SUBJ_NAME-orig-order > /dev/null
+echo "[DEBUG] java -cp $DT_TOOLS: edu.washington.cs.dt.impact.Main.RunnerMain -classpath $DT_LIBS:$DT_TOOLS:$DT_SUBJ/sootOutput/: -inputTests $DT_SCRIPTS/${SUBJ_NAME}-results/$SUBJ_NAME-orig-order"
+java -cp $DT_TOOLS: edu.washington.cs.dt.impact.Main.RunnerMain -classpath $DT_LIBS:$DT_TOOLS:$DT_SUBJ/sootOutput/: -inputTests $DT_SCRIPTS/${SUBJ_NAME}-results/$SUBJ_NAME-orig-order> /home/pious/Documents/work/dependent-tests-impact/runneroutput
+# -Djava.security.manager -Djava.security.policy=all_permissions.policy
echo "[DEBUG] Generating runtime for each test method under test cases"
java -cp $DT_TOOLS: edu.washington.cs.dt.impact.util.RuntimeGenerator -inputFile $DT_SUBJ/../ -inputName $DT_SUBJ
+
+
rm -rf $DT_SCRIPTS/${SUBJ_NAME}-results/sootTestOutput-orig
mv sootTestOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootTestOutput-orig
-mv sootCsvOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootCSV-${VER_NAME}/
+mv sootXMLOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootXML-${VER_NAME}/
+exit 1
+echo "[DEBUG] Generating first-var vs second-var xml"
+java -cp $DT_TOOLS:$JAVA_HOME/jre/lib/*: edu.washington.cs.dt.impact.Main.InstrumentationMain -inputDir $NEW_DT_TESTS --soot-cp $NEW_DT_LIBS:$NEW_DT_CLASS:$NEW_DT_TESTS:$JAVA_HOME/jre/lib/* -compare -outputPath $DT_SCRIPTS/${SUBJ_NAME}-results/ -changedFiles $fullyQualifiedMethodNames
+
+echo "[DEBUG] Generating report for surefire vs our test result"
+java -cp $DT_TOOLS: edu.washington.cs.dt.impact.util.RuntimeComparator -inputFile $DT_SUBJ/../ -inputName $DT_SCRIPTS/${SUBJ_NAME}-results/
+mv sootCsvOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootComparedCSV-${VER_NAME}/
+
cd $DT_SUBJ
rm -rf sootOutput/
diff --git a/setup/setup-sele-firstVers.sh b/setup/setup-sele-firstVers.sh
index dfeba7bc..f047164e 100644
--- a/setup/setup-sele-firstVers.sh
+++ b/setup/setup-sele-firstVers.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Runs commands for "Instructions to setup a subject for test selection" section.
-
+exit 1
set -e
cd $DT_SUBJ
@@ -10,6 +10,9 @@ cd ..
rm -rf sootTimerOutput/
rm -rf sootSeqOutput/
rm -rf sootException/
+rm -rf sootTracerData/
+rm -rf sootXMLOutput/
+rm -rf sootCsvOutput/
cd $DT_SUBJ
echo "[DEBUG] Finding human written tests in old subject."
@@ -53,7 +56,7 @@ java -cp $DT_TOOLS: edu.washington.cs.dt.impact.util.RuntimeGenerator -inputFile
rm -rf $DT_SCRIPTS/${SUBJ_NAME}-results/sootTestOutput-orig-selection
mv sootTestOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootTestOutput-orig
-mv sootCsvOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootCSV-${VER_NAME}/
+mv sootXMLOutput/ $DT_SCRIPTS/${SUBJ_NAME}-results/sootXML-${VER_NAME}/
cd $DT_SUBJ
rm -rf sootOutput/
diff --git a/setup/setup-sele-subseqVers.sh b/setup/setup-sele-subseqVers.sh
index 6a4d9453..c120f19d 100644
--- a/setup/setup-sele-subseqVers.sh
+++ b/setup/setup-sele-subseqVers.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-
+exit 1
# Runs commands for "Instructions to setup a subject for test selection" section.
set -e
diff --git a/shared/get-test-order.sh b/shared/get-test-order.sh
index 825caccd..419564f2 100644
--- a/shared/get-test-order.sh
+++ b/shared/get-test-order.sh
@@ -41,8 +41,9 @@ fi
cd $ROOT_DIR
mvn install -Dmavanagaiata.skip=true -Drat.skip=true -Ddependency-check.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true -Dmaven-source.skip=true -Dcobertura.skip -DskipTests -pl . -am > "install-log.txt"
)
-mvn test -Dmavanagaiata.skip=true -Drat.skip=true -Ddependency-check.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true -Dmaven-source.skip=true -Dcobertura.skip > "test-log.txt"
+mvn test -Dmavanagaiata.skip=true -Drat.skip=true -Ddependency-check.skip=true -Dcheckstyle.skip=true -Dmaven.javadoc.skip=true -Dmaven-source.skip=true -Dcobertura.skip -Dsurefire.runOrder=reversealphabetical > "test-log.txt"
+#mvn -X test | grep "Running" | awk '{print $2}'
java -cp $DT_TOOLS: edu.washington.cs.dt.impact.tools.GetOriginalOrder $output_file_name "target/" "test-log.txt"
mv "test-log.txt" $DT_SCRIPTS/${SUBJ_NAME}-results/
mv "install-log.txt" $DT_SCRIPTS/${SUBJ_NAME}-results/
diff --git a/shared/impact-tools/asm-9.2.jar b/shared/impact-tools/asm-9.2.jar
new file mode 100644
index 00000000..3557ae41
Binary files /dev/null and b/shared/impact-tools/asm-9.2.jar differ
diff --git a/shared/impact-tools/asm-commons-9.2.jar b/shared/impact-tools/asm-commons-9.2.jar
new file mode 100644
index 00000000..01028a00
Binary files /dev/null and b/shared/impact-tools/asm-commons-9.2.jar differ
diff --git a/shared/impact-tools/asm-debug-all-5.2.jar b/shared/impact-tools/asm-debug-all-5.2.jar
deleted file mode 100644
index 7a78ef51..00000000
Binary files a/shared/impact-tools/asm-debug-all-5.2.jar and /dev/null differ
diff --git a/shared/impact-tools/asm-tree-9.2.jar b/shared/impact-tools/asm-tree-9.2.jar
new file mode 100644
index 00000000..0a6833a6
Binary files /dev/null and b/shared/impact-tools/asm-tree-9.2.jar differ
diff --git a/shared/impact-tools/asm-util-9.2.jar b/shared/impact-tools/asm-util-9.2.jar
new file mode 100644
index 00000000..3afe6e69
Binary files /dev/null and b/shared/impact-tools/asm-util-9.2.jar differ
diff --git a/shared/impact-tools/dt-impact-tracer-1.0.5.3.jar b/shared/impact-tools/dt-impact-tracer-1.0.5.3.jar
index f2f72843..bdd56951 100644
Binary files a/shared/impact-tools/dt-impact-tracer-1.0.5.3.jar and b/shared/impact-tools/dt-impact-tracer-1.0.5.3.jar differ
diff --git a/shared/impact-tools/jackson-annotations-2.11.0.jar b/shared/impact-tools/jackson-annotations-2.11.0.jar
new file mode 100644
index 00000000..2c345677
Binary files /dev/null and b/shared/impact-tools/jackson-annotations-2.11.0.jar differ
diff --git a/shared/impact-tools/jackson-core-2.11.0.jar b/shared/impact-tools/jackson-core-2.11.0.jar
new file mode 100644
index 00000000..6ed89ba8
Binary files /dev/null and b/shared/impact-tools/jackson-core-2.11.0.jar differ
diff --git a/shared/impact-tools/jackson-databind-2.11.0.jar b/shared/impact-tools/jackson-databind-2.11.0.jar
new file mode 100644
index 00000000..458e1d3f
Binary files /dev/null and b/shared/impact-tools/jackson-databind-2.11.0.jar differ
diff --git a/shared/impact-tools/jackson-dataformat-xml-2.11.0.jar b/shared/impact-tools/jackson-dataformat-xml-2.11.0.jar
new file mode 100644
index 00000000..5a6cbf20
Binary files /dev/null and b/shared/impact-tools/jackson-dataformat-xml-2.11.0.jar differ
diff --git a/shared/impact-tools/jackson-module-jaxb-annotations-2.11.0.jar b/shared/impact-tools/jackson-module-jaxb-annotations-2.11.0.jar
new file mode 100644
index 00000000..f3d81886
Binary files /dev/null and b/shared/impact-tools/jackson-module-jaxb-annotations-2.11.0.jar differ
diff --git a/shared/impact-tools/soot-3.2.0.jar b/shared/impact-tools/soot-4.3.0.jar
similarity index 61%
rename from shared/impact-tools/soot-3.2.0.jar
rename to shared/impact-tools/soot-4.3.0.jar
index 23264758..40b2ac6f 100644
Binary files a/shared/impact-tools/soot-3.2.0.jar and b/shared/impact-tools/soot-4.3.0.jar differ
diff --git a/shared/impact-tools/stax2-api-4.2.1.jar b/shared/impact-tools/stax2-api-4.2.1.jar
new file mode 100644
index 00000000..28c6a08f
Binary files /dev/null and b/shared/impact-tools/stax2-api-4.2.1.jar differ
diff --git a/shared/impact-tools/testrunner-core-plugin-1.2.1.jar b/shared/impact-tools/testrunner-core-plugin-1.2.1.jar
new file mode 100644
index 00000000..50949420
Binary files /dev/null and b/shared/impact-tools/testrunner-core-plugin-1.2.1.jar differ
diff --git a/shared/impact-tools/testrunner-maven-plugin-0.1-SNAPSHOT.jar b/shared/impact-tools/testrunner-maven-plugin-0.1-SNAPSHOT.jar
deleted file mode 100644
index de7786bc..00000000
Binary files a/shared/impact-tools/testrunner-maven-plugin-0.1-SNAPSHOT.jar and /dev/null differ
diff --git a/shared/impact-tools/testrunner-maven-plugin-1.2.1.jar b/shared/impact-tools/testrunner-maven-plugin-1.2.1.jar
new file mode 100644
index 00000000..aba80418
Binary files /dev/null and b/shared/impact-tools/testrunner-maven-plugin-1.2.1.jar differ
diff --git a/shared/impact-tools/testrunner-running-0.1-SNAPSHOT.jar b/shared/impact-tools/testrunner-running-0.1-SNAPSHOT.jar
deleted file mode 100644
index d01875ae..00000000
Binary files a/shared/impact-tools/testrunner-running-0.1-SNAPSHOT.jar and /dev/null differ
diff --git a/shared/impact-tools/testrunner-running-1.2.1.jar b/shared/impact-tools/testrunner-running-1.2.1.jar
new file mode 100644
index 00000000..f5ef5839
Binary files /dev/null and b/shared/impact-tools/testrunner-running-1.2.1.jar differ
diff --git a/shared/impact-tools/testrunner-testing-1.2.1.jar b/shared/impact-tools/testrunner-testing-1.2.1.jar
new file mode 100644
index 00000000..313ca503
Binary files /dev/null and b/shared/impact-tools/testrunner-testing-1.2.1.jar differ
diff --git a/shared/set-vars.sh b/shared/set-vars.sh
index ae9657cc..cbde1400 100644
--- a/shared/set-vars.sh
+++ b/shared/set-vars.sh
@@ -17,7 +17,7 @@ fi
export DT_SUBJ_SRC="$DT_SUBJ_ROOT"
export DT_SUBJ="$DT_SUBJ_ROOT/target"
if [[ ! -d "$DT_SUBJ" ]]; then
- echo "Path to DT_SUBJ does not exist. You must run mvn mvn install -DskipTests in $DT_SUBJ_ROOT first."
+ echo "Path to DT_SUBJ does not exist. You must run mvn mvn install -DskipTests in $DT_SUBJ first."
exit 1
fi
@@ -27,7 +27,8 @@ if [[ ! -d "$libs_dir" ]]; then
echo "Path to DT_LIBS does not exist. You must run mvn dependency:copy-dependencies in $DT_SUBJ_ROOT first."
exit 1
fi
-LIBS=$(find "$DT_SUBJ/dependency/" -name "*.jar" -not -name "junit*.jar")
+#LIBS=$(find "$DT_SUBJ/dependency/" -name "*.jar" -not -name "junit*.jar")
+LIBS=$(find "$DT_SUBJ/dependency/" -name "*.jar")
export DT_LIBS=$(echo $LIBS | sed -E "s/ /:/g")
# Compiled class files of the old subject
@@ -65,7 +66,8 @@ if [[ ! -d "$libs_dir" ]]; then
echo "Path to NEW_DT_LIBS does not exist. You must run mvn dependency:copy-dependencies in $NEW_DT_SUBJ_ROOT first."
exit 1
fi
-LIBS=$(find "$NEW_DT_SUBJ/dependency/" -name "*.jar" -not -name "junit*.jar")
+#LIBS=$(find "$NEW_DT_SUBJ/dependency/" -name "*.jar" -not -name "junit*.jar")
+LIBS=$(find "$DT_SUBJ/dependency/" -name "*.jar")
export NEW_DT_LIBS=$(echo $LIBS | sed -E "s/ /:/g")
# Compiled class files of the new subject
@@ -159,3 +161,60 @@ if [[ "$MACHINES" != "2" ]] && [[ "$MACHINES" != "4" ]] && [[ "$MACHINES" != "8"
fi
export medianTimes=1
+
+# ===========Get changed files
+cd $(dirname "$DT_SUBJ_ROOT")
+
+
+COMMIT1=2d62a3e9da726942a93cf16b6e91c0187e6c0136
+COMMIT2=f6600a6df2dce52b18cc985a1897a47f510547b6
+
+fullyQualifiedMethodNames=""
+
+changed_files=$(git diff $COMMIT1 $COMMIT2 --name-only | grep "Test.java")
+modified_methods=""
+
+for file in $changed_files; do
+ git_diff_output=$(git diff --unified=10000 $COMMIT1 $COMMIT2 -- $file)
+ package_name=$(echo "$git_diff_output" | grep -oP '(?<=package ).*?(?=;)')
+ class_name=$(basename "$file" .java)
+ method_name=""
+ brace_count=0
+ modified=0
+ inside_test_method=0
+
+ while read -r line; do
+ if [[ $line =~ "@Test" ]]; then
+ if [[ $inside_test_method -eq 1 && $modified -eq 1 ]]; then
+ modified_methods="${modified_methods},${package_name}.${class_name}.${method_name}"
+ modified=0
+ fi
+ inside_test_method=1
+ elif [[ $inside_test_method -eq 1 && $line =~ "public void" ]]; then
+ method_name=$(echo "$line" | grep -oP '(?<=public void ).*?(?=\()')
+ if [[ $line =~ "{" ]]; then
+ ((brace_count++))
+ fi
+ elif [[ $line =~ "{" ]] && [[ $inside_test_method -eq 1 ]]; then
+ ((brace_count++))
+ elif [[ $line =~ "}" ]] && [[ $inside_test_method -eq 1 ]]; then
+ ((brace_count--))
+ if [[ $brace_count -eq 0 ]]; then
+ inside_test_method=0
+ if [[ $modified -eq 1 ]]; then
+ modified_methods="${modified_methods},${package_name}.${class_name}.${method_name}"
+ modified=0
+ fi
+ fi
+ elif [[ $inside_test_method -eq 1 && ($line =~ ^[+-]) && (!($line =~ "public void")) && (!($line =~ "@Test")) ]]; then
+ modified=1
+ #echo "Changed line: $line for method: ${package_name}.${class_name}.${method_name}"
+ fi
+ done <<< "$(echo "$git_diff_output")"
+
+ echo ""
+done
+
+fullyQualifiedMethodNames=$(echo "$modified_methods" | sed 's/^,//')
+echo $fullyQualifiedMethodNames
+export fullyQualifiedMethodNames
\ No newline at end of file