Commit c88f7dad authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

G2 analytics; tweaking G2 so that it only saves test suite if it contains new traces.

parent 01bb5832
......@@ -31,6 +31,7 @@ import Sequenic.T3.CONSTANTS;
import Sequenic.T3.ImplementationMap;
import Sequenic.T3.Pool;
import Sequenic.T3.SimpleClassLoader;
import Sequenic.T3.DerivativeSuiteGens.Gen2.Worklist.TargetQuality;
import Sequenic.T3.Info.Analytics.Analytics;
import Sequenic.T3.Info.Analytics.DataTable;
import Sequenic.T3.Sequence.Datatype.*;
......@@ -268,15 +269,23 @@ public class G2 {
}
}
SingleTarget target = worklist.getNext(remaining/budget) ;
int sizeOld = 0 ;
if (target.suite != null && target.suite.suite != null) sizeOld = target.suite.suite.size() ;
target.refine() ;
boolean targetSolved = worklist.evaluateAndPutBack(target) ;
if (!targetSolved && target.isADT && target.target instanceof Method) {
int sizeNew = sizeOld ;
if (target.suite != null && target.suite.suite != null) sizeNew = target.suite.suite.size() ;
TargetQuality quality = worklist.evaluateAndPutBack(target) ;
if (quality == TargetQuality.TOBE_REFINED && target.isADT && target.target instanceof Method) {
// a method-ADT target cannot be solved. Signal need to generate more prefixes.
// Note that a constructor-target does not need prefix.
generateMorePrefix = true ;
}
target.saveSuite() ;
// only save if the new suite is larger:
if (sizeNew > sizeOld) target.saveSuite() ;
if (quality == TargetQuality.STAGNATE)
t3log.info("Refinement for " + target.getName() + " has STAGNATED; it will not be further refined.");
// save a minimized version of the test suite; however this seem to drop
// mutation kill rates in some situation; so I will just comment this out.
// Will later make it configurable.
......@@ -325,7 +334,7 @@ public class G2 {
return mkG2worker(CUTname,config,imap,classloader) ;
}
catch(Exception e) {
e.printStackTrace();
//e.printStackTrace();
t3log.warning("Fail to read imap.txt in " + config.dirOfStaticInfo);
return mkG2worker(CUTname,config,imap,ClassLoader.getSystemClassLoader()) ;
}
......
......@@ -50,15 +50,27 @@ public class Worklist {
return t1.getNumOfParams() < t2.getNumOfParams() ;
}
public static enum TargetQuality { GOOD_ENOUGH, STAGNATE, TOBE_REFINED }
/**
* Determine when a target's suite is considered to be good enough.
* If a suite is already good enough, the worklist will not put it
* back in the list. Override this method to define a different concept
* of "good enough".
*/
protected boolean isGoodEnough(SingleTarget target) {
return (target.numberOfIterations() >= target.maxNumberOfRefinement
|| target.getLastTargetCov() >= target.minimumCovTobeHappy) ;
protected TargetQuality checkQuality(SingleTarget target) {
// progressively lower the minimum-coverage requirement:
double progressiveMinimumCoverage = target.minimumCovTobeHappy ;
int Nmax = target.maxNumberOfRefinement ;
if (Nmax > 1) {
double loweringCorrection = Math.max(0,1.0 - progressiveMinimumCoverage)/(double)(Nmax - 1) ;
progressiveMinimumCoverage += 1d - (double) target.numberOfIterations()*loweringCorrection ;
}
if (target.getLastTargetCov() >= progressiveMinimumCoverage)
return TargetQuality.GOOD_ENOUGH ;
if (target.numberOfIterations() >= Nmax)
return TargetQuality.STAGNATE ;
return TargetQuality.TOBE_REFINED ;
}
/**
......@@ -72,11 +84,11 @@ public class Worklist {
* Check if the target is already good enough. If so, return true. If not,
* put it back in the waiting list, and return false.
*/
public boolean evaluateAndPutBack(SingleTarget target) {
if (isGoodEnough(target)) return true ;
waiting.add(target) ;
public TargetQuality evaluateAndPutBack(SingleTarget target) {
TargetQuality quality = checkQuality(target) ;
if (quality == TargetQuality.TOBE_REFINED) waiting.add(target) ;
//System.out.println(">>> putting back " + target.getName());
return false ;
return quality ;
}
public boolean isEmpty() { return targets.isEmpty() && waiting.isEmpty() ; }
......
......@@ -9,7 +9,7 @@ import java.util.LinkedList;
public class SimpleIntSortedList implements Serializable {
private LinkedList<Integer> s;
private Integer max;
private Integer max = null ;
/**
* This constructs an empty list.
......@@ -31,8 +31,14 @@ public class SimpleIntSortedList implements Serializable {
* This inserts a new element into the list.
*/
public void insert(Integer x) {
//if (x == null) {
// System.out.println("### insert(null)") ;
// assert x!=null : "PRE";
// throw new IllegalArgumentException() ;
//}
assert x!=null : "PRE";
int i = 0;
int i = 0;
for (Integer y : s) {
if (y > x) {
break;
......@@ -40,6 +46,8 @@ public class SimpleIntSortedList implements Serializable {
i++;
}
s.add(i, x);
//System.out.println(" ### insert " + x + ", max=" + max) ;
// deliberate error: should be x > max
if (max == null || x < max) {
......@@ -52,7 +60,7 @@ public class SimpleIntSortedList implements Serializable {
* not empty.
*/
public Integer get() {
assert !s.isEmpty() : "PRE";
//assert !s.isEmpty() : "PRE";
Integer x = max;
s.remove(max);
if (s.isEmpty()) {
......
......@@ -42,7 +42,7 @@ public class SimpleSortedList implements Serializable {
i++;
}
s.add(i, x);
// deliberate error:
if (max == null || x.compareTo(max) < 0) {
max = x;
......
......@@ -594,6 +594,7 @@ public class SUITE implements Serializable {
ObjectOutputStream oos = new ObjectOutputStream(buffer);
try {
oos.writeObject(this) ;
oos.flush();
Logger.getLogger(CONSTANTS.T3loggerName).info("** Saving a test-suite to " + fp + ", " + f.length()/1000 + " KB") ;
return fp.toString() ;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment