Skip to content

Commit 2390a76

Browse files
committed
Configure for maven testing...
1 parent 8f110d8 commit 2390a76

7 files changed

Lines changed: 139 additions & 54 deletions

File tree

Code/ChroniclerJ/pom.xml

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<groupId>edu.columbia.cs.psl.chroniclerj</groupId>
55
<artifactId>ChroniclerJ</artifactId>
66
<version>0.43-SNAPSHOT</version>
7+
<properties>
8+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
9+
</properties>
710
<build>
811
<plugins>
912
<plugin>
@@ -40,26 +43,19 @@
4043
<pattern>org.objectweb</pattern>
4144
<shadedPattern>edu.columbia.cs.psl.chroniclerj.org.objectweb</shadedPattern>
4245
</relocation>
43-
<!-- <relocation>
44-
<pattern>org.kxml2</pattern>
45-
<shadedPattern>edu.columbia.cs.psl.chroniclerj.org.kxml</shadedPattern>
46-
</relocation> -->
46+
<!-- <relocation> <pattern>org.kxml2</pattern> <shadedPattern>edu.columbia.cs.psl.chroniclerj.org.kxml</shadedPattern>
47+
</relocation> -->
4748
<relocation>
4849
<pattern>org.objenesis</pattern>
4950
<shadedPattern>edu.columbia.cs.psl.chroniclerj.org.objenesis</shadedPattern>
5051
</relocation>
51-
<!-- <relocation>
52-
<pattern>org.xmlpull</pattern>
53-
<shadedPattern>edu.columbia.cs.psl.chroniclerj.org.xmlpull</shadedPattern>
54-
</relocation>
55-
<relocation>
56-
<pattern>com.thoughtworks</pattern>
57-
<shadedPattern>edu.columbia.cs.psl.chroniclerj.com.thoughtworks</shadedPattern>
58-
</relocation> -->
52+
<!-- <relocation> <pattern>org.xmlpull</pattern> <shadedPattern>edu.columbia.cs.psl.chroniclerj.org.xmlpull</shadedPattern>
53+
</relocation> <relocation> <pattern>com.thoughtworks</pattern> <shadedPattern>edu.columbia.cs.psl.chroniclerj.com.thoughtworks</shadedPattern>
54+
</relocation> -->
5955
<relocation>
6056
<pattern>org.apache.log4j</pattern>
6157
<shadedPattern>edu.columbia.cs.psl.chroniclerj.org.apache.log4j</shadedPattern>
62-
</relocation>
58+
</relocation>
6359
</relocations>
6460
<minimizeJar>false</minimizeJar>
6561
</configuration>
@@ -72,23 +68,66 @@
7268
<version>2.19</version>
7369
<executions>
7470
<execution>
75-
<id>integration-test</id>
71+
<id>record-tests</id>
72+
<configuration>
73+
<runOrder>alphabetical</runOrder>
74+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
75+
<reportsDirectory>${project.build.directory}/failsafe-reports-record</reportsDirectory>
76+
<includes>
77+
<include>**/*ITCase.java</include>
78+
</includes>
79+
<argLine>
80+
-javaagent:${project.build.directory}/${project.build.finalName}.jar=failsafe,quiet,alwaysExport,whitelist=edu/columbia/cs/psl/test</argLine>
81+
<reuseForks>false</reuseForks>
82+
</configuration>
83+
<goals>
84+
<goal>integration-test</goal>
85+
<goal>verify</goal>
86+
</goals>
87+
</execution>
88+
<execution>
89+
<id>replay-tests</id>
7690
<configuration>
77-
<!-- <jvm>${project.build.directory}/jre-inst-int-untaggedwrappers/bin/java</jvm> -->
91+
<runOrder>alphabetical</runOrder>
92+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
93+
<reportsDirectory>${project.build.directory}/failsafe-reports-replay</reportsDirectory>
7894
<includes>
7995
<include>**/*ITCase.java</include>
8096
</includes>
81-
<argLine>-Xbootclasspath/p:${project.build.directory}/${project.build.finalName}.jar
82-
-javaagent:${project.build.directory}/${project.build.finalName}.jar=failsafe,alwaysExport</argLine>
83-
<reuseForks>false</reuseForks>
97+
<argLine>
98+
-javaagent:${project.build.directory}/${project.build.finalName}.jar=replay,failsafe,whitelist=edu/columbia/cs/psl/test</argLine>
99+
<reuseForks>false</reuseForks>
84100
</configuration>
85101
<goals>
86102
<goal>integration-test</goal>
87103
<goal>verify</goal>
88104
</goals>
89105
</execution>
90106
</executions>
107+
</plugin>
108+
<plugin>
109+
<groupId>net.jonbell.surefire</groupId>
110+
<artifactId>surefire-outputcomparison</artifactId>
111+
<executions>
112+
<execution>
113+
<id>examine-test-output</id>
114+
<phase>post-integration-test</phase>
115+
<goals>
116+
<goal>analyze</goal>
117+
</goals>
118+
</execution>
119+
</executions>
91120
<configuration>
121+
<testResultSources>
122+
<testResultSource>
123+
<name>chroniclerj-record</name>
124+
<directory>${project.build.directory}/failsafe-reports-record</directory>
125+
</testResultSource>
126+
<testResultSource>
127+
<name>chroniclerj-replay</name>
128+
<directory>${project.build.directory}/failsafe-reports-replay</directory>
129+
</testResultSource>
130+
</testResultSources>
92131
</configuration>
93132
</plugin>
94133
<plugin>
@@ -105,8 +144,12 @@
105144
</plugin>
106145
</plugins>
107146
</build>
108-
109147
<dependencies>
148+
<dependency>
149+
<groupId>net.jonbell.surefire</groupId>
150+
<artifactId>surefire-outputcomparison</artifactId>
151+
<version>1.0-SNAPSHOT</version>
152+
</dependency>
110153
<dependency>
111154
<groupId>junit</groupId>
112155
<artifactId>junit</artifactId>
@@ -139,11 +182,18 @@
139182
<version>1.2.16</version>
140183
</dependency>
141184
</dependencies>
185+
<repositories>
186+
<repository>
187+
<id>jb.snapshots</id>
188+
<name>jons snapshots</name>
189+
<url>https://maven.jonbell.net/repository/snapshots</url>
190+
</repository>
191+
</repositories>
142192
<distributionManagement>
143193
<snapshotRepository>
144-
<id>psl.internal</id>
145-
<name>PSL Internal Repository</name>
146-
<url>http://ase.cs.columbia.edu:8282/repository/snapshots</url>
194+
<id>jb.snapshots</id>
195+
<name>JB Snapshots Repository</name>
196+
<url>https://maven.jonbell.net/repository/snapshots</url>
147197
</snapshotRepository>
148198
</distributionManagement>
149199
</project>

Code/ChroniclerJ/src/main/java/edu/columbia/cs/psl/chroniclerj/ChroniclerJExportRunner.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public static void genTestCase(String name) {
105105
}
106106
zos.flush();
107107
zos.close();
108-
System.out.println("Chroniclerj exported a test case");
108+
if(!QUIET)
109+
System.out.println("Chroniclerj exported a test case");
109110
serializableLogs.clear();
110111
otherLogs.clear();
111112
} catch (IOException e) {
@@ -305,6 +306,8 @@ public static void _export() {
305306
private static boolean hasLoggedError = false;
306307
private static boolean hasRegisteredHook = false;
307308

309+
public static boolean QUIET;
310+
308311
public static void registerShutdownHook() {
309312
if(!hasRegisteredHook){
310313
hasRegisteredHook = true;

Code/ChroniclerJ/src/main/java/edu/columbia/cs/psl/chroniclerj/PreMain.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.objectweb.asm.util.TraceClassVisitor;
2121

2222
import edu.columbia.cs.psl.chroniclerj.replay.NonDeterministicReplayClassVisitor;
23+
import edu.columbia.cs.psl.chroniclerj.replay.ReplayRunner;
2324
import edu.columbia.cs.psl.chroniclerj.visitor.CallbackDuplicatingClassVisitor;
2425
import edu.columbia.cs.psl.chroniclerj.visitor.NonDeterministicLoggingClassVisitor;
2526

@@ -110,24 +111,40 @@ public byte[] transform(ClassLoader loader, String className, Class<?> classBein
110111
}
111112

112113
public static boolean isIgnoredClass(String className) {
114+
if (whiteList != null) {
115+
for (String s : whiteList)
116+
if (className.startsWith(s))
117+
return false;
118+
return true;
119+
}
113120
return className.startsWith("java") || className.startsWith("com/sun") || className.startsWith("sun/") || className.startsWith("edu/columbia/cs/psl/chroniclerj") || className.startsWith("com/rits/cloning") || className.startsWith("jdk")
114121
|| className.startsWith("com/thoughtworks") || className.startsWith("org/xmlpull") || className.startsWith("org/kxml2");
115122
}
116123

117124
static boolean DEBUG = false;
118-
125+
static String[] whiteList;
126+
119127
public static void premain(String _args, Instrumentation inst) {
120-
replay = _args != null && _args.equals("replay");
121128
if (_args != null) {
122129
String[] args = _args.split(",");
123130
for (String arg : args) {
124131
String[] d = arg.split("=");
125-
if (d[0].equals("logFile")) {
132+
if(d[0].equals("replay"))
133+
{
134+
replay = true;
135+
if (ChroniclerJExportRunner.nameOverride != null)
136+
ReplayRunner.setupLogs(new String[] { ChroniclerJExportRunner.nameOverride });
137+
}
138+
else if (d[0].equals("logFile")) {
126139
ChroniclerJExportRunner.nameOverride = d[1];
140+
if(replay)
141+
ReplayRunner.setupLogs(new String[] { ChroniclerJExportRunner.nameOverride });
127142
} else if (d[0].equals("alwaysExport")) {
128143
ChroniclerJExportRunner.registerShutdownHook();
129144
} else if (d[0].equals("debug"))
130145
DEBUG = true;
146+
else if(d[0].equals("quiet"))
147+
ChroniclerJExportRunner.QUIET = true;
131148
else if (d[0].equals("failsafe")) {
132149
try {
133150
// Read in the log file name based on the maven failsafe
@@ -146,7 +163,8 @@ else if (d[0].equals("failsafe")) {
146163
if (testClass == null)
147164
throw new IOException("Couldn't find test config");
148165
if (replay) {
149-
166+
ChroniclerJExportRunner.nameOverride = "target/"+testClass + ".crash";
167+
ReplayRunner.setupLogs(new String[]{ChroniclerJExportRunner.nameOverride});
150168
} else {
151169
System.out.println("Overriding test class: " + testClass);
152170
ChroniclerJExportRunner.nameOverride = "target/"+testClass + ".crash";
@@ -156,6 +174,10 @@ else if (d[0].equals("failsafe")) {
156174
System.err.println("Unable to load in failsafe config");
157175
}
158176
}
177+
else if(d[0].equals("whitelist"))
178+
{
179+
whiteList = d[1].split(";");
180+
}
159181
}
160182
}
161183
ClassFileTransformer transformer = new ChroniclerTransformer();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package edu.columbia.cs.psl.test.chroniclerj;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.io.ByteArrayInputStream;
6+
import java.util.Arrays;
7+
import java.util.Collections;
8+
import java.util.List;
9+
10+
import org.junit.Test;
11+
12+
public class ArraysParamITCase {
13+
14+
@Test
15+
public void testShuffle() throws Exception {
16+
Integer[] array = { 7, 5, 9, 3, 6, 0, 2, 4 };
17+
18+
byte[] ar = new byte[100];
19+
Arrays.fill(ar, (byte) 5);
20+
ByteArrayInputStream bis = new ByteArrayInputStream(ar);
21+
byte b[] = new byte[100];
22+
bis.read(b, 0, 100);
23+
bis.close();
24+
assertEquals(5, b[0]);
25+
26+
}
27+
public static void main(String[] args) throws Throwable{
28+
new ArraysParamITCase().testShuffle();
29+
}
30+
}

Code/ChroniclerJ/src/test/java/edu/columbia/cs/psl/test/chroniclerj/ArraysSortTestCase.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

Code/ChroniclerJ/src/test/java/edu/columbia/cs/psl/test/chroniclerj/RandomITCase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
public class RandomITCase {
66

7-
public static void main(String[] args) {
8-
System.out.println(Math.random());
7+
@Test
8+
public void testTwo() throws Exception {
9+
System.err.println("Test two ran??");
10+
System.out.println("Two");
911
}
10-
12+
1113
@Test
1214
public void testRandom() throws Exception {
1315
System.out.println(Math.random());
14-
throw new NullPointerException();
15-
1616
}
1717
}

Code/ChroniclerJ/src/test/java/edu/columbia/cs/psl/test/chroniclerj/ScannerTestCase.java renamed to Code/ChroniclerJ/src/test/java/edu/columbia/cs/psl/test/chroniclerj/ScannerITCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import java.util.List;
44
import java.util.Scanner;
55

6-
public class ScannerTestCase {
6+
public class ScannerITCase {
77
static List<Integer> list;
88

9+
910
public static void main(String[] args) {
1011

1112
Scanner in = new Scanner(System.in);

0 commit comments

Comments
 (0)