Skip to content
Open
16 changes: 13 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
<version>2.12.6</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.6</version>
<groupId>org.xmlunit</groupId>
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated
<artifactId>xmlunit-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>edu.illinois.cs</groupId>
Expand All @@ -98,6 +98,16 @@
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.5.0-SNAPSHOT</version>
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.2</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
2 changes: 2 additions & 0 deletions testrunner-running/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0
Premain-Class: edu.illinois.cs.diaper.agent.MainAgent
26 changes: 24 additions & 2 deletions testrunner-running/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@
<artifactId>scala-library</artifactId>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -118,6 +126,20 @@
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
<argLine>-Xmx4096m</argLine>
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<!--<manifest>
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>-->
<manifestFile>MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package edu.illinois.cs.diaper;
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated

import com.thoughtworks.xstream.converters.collections.MapConverter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.io.ExtendedHierarchicalStreamWriterHelper;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;

import java.util.Iterator;
import java.util.Map;

public class CustomMapConverter extends MapConverter {

public CustomMapConverter(Mapper mapper) {
super(mapper);
}

// Logic mostly copied from writeItem
protected void writeItemWithName(String name, Object item, MarshallingContext context, HierarchicalStreamWriter writer) {
if (item == null) {
writeNullItem(context, writer);
} else {
String clazz = mapper().serializedClass(item.getClass());
// String clazz = item.getClass().getName();
ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, item.getClass());
writer.addAttribute("class", clazz); // Map the class as an attribute to the node
writeBareItem(item, context, writer);
writer.endNode();
}
}

@Override
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
Map map = (Map) source;
String entryName = mapper().serializedClass(Map.Entry.class);
for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
ExtendedHierarchicalStreamWriterHelper.startNode(writer, entryName, entry.getClass());

// Give consistent name to elements (their types will be encoded as attribute)
writeItemWithName("key", entry.getKey(), context, writer);
writeItemWithName("value", entry.getValue(), context, writer);

writer.endNode();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package edu.illinois.cs.diaper;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class DiaperLogger {
Comment thread
ChopinLi-cp marked this conversation as resolved.
Outdated
public enum Task { SERIALIZATION, STATE_CAPTURE, DIFF };
private static double serializationTime;
private static double stateCaptureTime;
private static double diffTime;
private String projName;
private long startTime;
private long endTime;
private String pathToLogFile;


public DiaperLogger(String projName, String pathToLogFile) {
this.projName = projName;
this.pathToLogFile = pathToLogFile;
createHeader();
}

private void writeToFile(String fn, String content, boolean append) {
try {
File f = new File(fn);
if (!f.exists()) {
f.createNewFile();
}
BufferedWriter w = new BufferedWriter(new FileWriter(f.getAbsoluteFile(), append));
w.write(content);
w.close();
} catch (IOException e) {
e.printStackTrace();
}
}

public double getSerializationTime() {
return serializationTime;
}

public double getStateCaptureTime() {
return stateCaptureTime;
}
public void startTimer() {
startTime = System.currentTimeMillis();
}

public void stopTimeAndUpdate(Task task) {
endTime = System.currentTimeMillis();
double duration_sec = (double)(endTime - startTime)/1000;
if ( task == Task.SERIALIZATION) {
serializationTime += duration_sec;
}
else if (task == Task.STATE_CAPTURE) {
stateCaptureTime += duration_sec;
}
else if (task == Task.DIFF) {
diffTime += duration_sec;
}

// reset the times
startTime = 0;
endTime = 0;
}

public void saveToFileAndReset() {

// save the entry: projName, stateCaptureTime, serializationTime, diffTime
String entry = String.format("%s,%.3f,%.3f,%.3f\n", projName, stateCaptureTime,
serializationTime, diffTime);
writeToFile(pathToLogFile, entry, true);

// reset the times
serializationTime = 0;
stateCaptureTime = 0;
diffTime = 0;
}
private void createHeader() {
String header = "projName,stateCaptureTime, serializationTime, diffTime\n";
writeToFile(pathToLogFile, header, false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package edu.illinois.cs.diaper;

public interface IStateCapture {

public void runCapture();
}
Loading