Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Prasetya, S.W.B. (Wishnu)
t3
Commits
38f38283
Commit
38f38283
authored
Jan 12, 2018
by
ISWB Prasetya
Browse files
adding modes to G2 to run without coverage guidance and without static info.
parent
8b6852fd
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2.java
View file @
38f38283
...
...
@@ -103,7 +103,7 @@ public class G2 {
*/
protected
G2
(
String
CUTname
,
G2Config
config
)
throws
Exception
{
this
.
config
=
config
;
g2sg
=
new
G2SuiteGen
(
CUTname
,
config
.
CUTrootDir
,
config
.
dirOfStaticInfo
)
;
g2sg
=
new
G2SuiteGen
(
CUTname
,
config
.
CUTrootDir
,
config
.
useCoverageGuidance
,
config
.
useStaticInfo
,
config
.
dirOfStaticInfo
)
;
g2sg
.
regressionMode
=
config
.
regressionMode
;
g2sg
.
injectOracles
=
config
.
injectOracles
;
...
...
@@ -198,9 +198,10 @@ public class G2 {
double
remaining
=
timebudgetTracker
.
check
()
;
t3log
.
info
(
"Start generating suites for: "
+
g2sg
.
scope
.
CUT
.
getName
());
while
(!
worklist
.
isEmpty
())
{
if
(
worklist
.
targets
.
isEmpty
()
)
{
if
(
worklist
.
targets
.
size
()
<
config
.
numberOfCPUcores
)
{
// the first time, this will generate the prefixes, upon the next iterations,
// this will refine the prefixes each time the targetlist is emptied.
// this will refine the prefixes each time the targetlist is emptied (more precisely, has less targets than
// the number of cores).
refinePrefixes
()
;
}
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2Config.java
View file @
38f38283
...
...
@@ -11,6 +11,18 @@ public class G2Config {
public
boolean
injectOracles
=
true
;
public
String
refinementHeuristic
=
"random"
;
/**
* If true (default) that will in principle only add new test sequences to the current suite if they improve
* coverage. If false, will refine suites with randomly generated new sequences, disregarding coverage.
*/
public
boolean
useCoverageGuidance
=
true
;
/**
* If true (default) will read a file containing lists of constants exctracted from the CUT.
* If false will ignore such a file.
*/
public
boolean
useStaticInfo
=
true
;
/**
* If not null, will determine the number of prefixes that will be generated for
* ADT testing. If it is left null, it will be calculated. The default is null.
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2SuiteGen.java
View file @
38f38283
...
...
@@ -61,6 +61,14 @@ public class G2SuiteGen {
// multi-core is currently not supported for this generator!
private
final
boolean
isSingleCore
=
true
;
// If true (default) that will in principle only add new test sequences to the current suite if they improve
// coverage. If false, will refine suites with randomly generated new sequences, disregarding coverage.
public
boolean
useCoverageGuidance
=
true
;
// If true (default) will read a file containing lists of constants exctracted from the CUT.
// If false will ignore such a file.
public
boolean
useStaticInfo
=
true
;
public
Pool
pool
;
private
G2ValueMG
gen2vmg
;
private
Generator
<
PARAM
,
STEP
>
valueMG
;
...
...
@@ -76,7 +84,7 @@ public class G2SuiteGen {
String
CUTrootDir
)
throws
Exception
{
this
(
CUTname
,
CUTrootDir
,
null
)
;
this
(
CUTname
,
CUTrootDir
,
true
,
true
,
null
)
;
}
/**
...
...
@@ -86,12 +94,16 @@ public class G2SuiteGen {
*/
public
G2SuiteGen
(
String
CUTname
,
String
CUTrootDir
,
boolean
useCoverageGuidance
,
boolean
useStaticInfo
,
String
staticInfoDir
)
throws
Exception
{
//t3log.info("** CUT = " + CUT.getName());
Class
CUT
;
if
(
CUTrootDir
!=
null
)
{
this
.
useCoverageGuidance
=
useCoverageGuidance
;
this
.
useStaticInfo
=
useStaticInfo
;
if
(
CUTrootDir
!=
null
&&
useCoverageGuidance
)
{
try
{
JacocoInstrumenter
ji
=
new
JacocoInstrumenter
(
CUTrootDir
,
CUTname
)
;
codeCoverage
=
new
CodeCoverage
(
ji
)
;
...
...
@@ -158,16 +170,20 @@ public class G2SuiteGen {
catch
(
Exception
e
)
{
t3log
.
warning
(
"Fail to read imap.txt in "
+
staticInfoDir
);
}
try
{
staticInfo
=
new
StaticInfo
(
scope
,
imap
,
staticInfoDir
)
;
t3log
.
info
(
"Staticinfo.txt read, #constants="
+
staticInfo
.
allConstants
.
length
+
", #instanceOfs="
+
staticInfo
.
allInstanceOfClasses
.
length
);
if
(
useStaticInfo
)
{
try
{
staticInfo
=
new
StaticInfo
(
scope
,
imap
,
staticInfoDir
)
;
t3log
.
info
(
"Staticinfo.txt read, #constants="
+
staticInfo
.
allConstants
.
length
+
", #instanceOfs="
+
staticInfo
.
allInstanceOfClasses
.
length
);
}
catch
(
IOException
e
)
{
t3log
.
warning
(
"Fail to read staticinfo.txt in "
+
staticInfoDir
);
}
}
catch
(
IOException
e
)
{
t3log
.
warning
(
"Fail to read staticinfo.txt in "
+
staticInfoDir
);
}
else
t3log
.
warning
(
"G2 is configured to ignore staticinfo.txt, so it does."
);
}
// setup value generator, and custom pool:
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/G2_forSBST2016.java
View file @
38f38283
...
...
@@ -39,7 +39,10 @@ public class G2_forSBST2016 {
String
worklisttype
,
String
refinementHeuristic
,
int
maxNumberOfTargetRefinements
,
int
numberOfcores
int
numberOfcores
,
boolean
turnOnCoverageGuidance
,
boolean
turnOnUseOfStaticInfo
)
throws
TimeBudgetException
,
InterruptedException
{
TimeOut
hardtimeOut
=
new
TimeOut
(
timebudget
+
10000
)
;
hardtimeOut
.
start
();
...
...
@@ -56,6 +59,8 @@ public class G2_forSBST2016 {
config
.
refinementHeuristic
=
refinementHeuristic
;
config
.
maxNumberOfRefinements_ofEachTarget
=
maxNumberOfTargetRefinements
;
config
.
numberOfCPUcores
=
numberOfcores
;
config
.
useCoverageGuidance
=
turnOnCoverageGuidance
;
config
.
useStaticInfo
=
turnOnUseOfStaticInfo
;
G2
.
generateSuites
(
CUTname
,
config
,
timebudget
)
;
System
.
exit
(-
1
);
}
...
...
@@ -81,14 +86,22 @@ public class G2_forSBST2016 {
* arg7 trace-refinement-heuristic: random/evo
* arg8 the maximum number of times each test-target will be refined
* arg9 number of CPU cores
* arg10 whether or not to use code-coverage guidance
* arg11 whether or not to use staticinfo.txt
*/
static
public
void
main
(
String
[]
args
)
throws
Throwable
{
if
(
args
[
0
].
equals
(
"generate"
))
{
if
(
args
.
length
!=
1
0
)
throw
new
IllegalArgumentException
()
;
if
(
args
.
length
!=
1
2
)
throw
new
IllegalArgumentException
()
;
long
timebudget
=
Integer
.
parseInt
(
args
[
5
])
;
int
maxNumberOfTargetRefinements
=
Integer
.
parseInt
(
args
[
8
])
;
int
numOfCores
=
Integer
.
parseInt
(
args
[
9
])
;
generate
(
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
timebudget
,
args
[
6
],
args
[
7
],
maxNumberOfTargetRefinements
,
numOfCores
)
;
boolean
useCoverageGuide
=
Boolean
.
parseBoolean
(
args
[
10
])
;
boolean
useStaticInfo
=
Boolean
.
parseBoolean
(
args
[
11
])
;
generate
(
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
],
timebudget
,
args
[
6
],
args
[
7
],
maxNumberOfTargetRefinements
,
numOfCores
,
useCoverageGuide
,
useStaticInfo
)
;
return
;
}
if
(
args
[
0
].
equals
(
"replayall"
))
{
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/StaticInfo.java
View file @
38f38283
...
...
@@ -24,16 +24,16 @@ public class StaticInfo {
TestingScope
scope
;
ImplementationMap
imap
;
private
List
<
String
>
allConstants_
=
new
LinkedList
<
String
>()
;
String
[]
allConstants
;
String
[]
allConstants
=
{}
;
private
List
<
String
>
constantsOfPrivateMethods_
=
new
LinkedList
<
String
>()
;
String
[]
constantsOfPrivateMethods
;
String
[]
constantsOfPrivateMethods
=
{}
;
private
Map
<
Object
,
List
<
String
>>
constants_
=
new
HashMap
<
Object
,
List
<
String
>>()
;
// mapping methods and constructors to constants
Map
<
Object
,
String
[]>
constants
=
new
HashMap
<
Object
,
String
[]>()
;
private
List
<
Class
>
allInstanceOfClasses_
=
new
LinkedList
<
Class
>()
;
Class
[]
allInstanceOfClasses
;
Class
[]
allInstanceOfClasses
=
{}
;
private
List
<
Class
>
instanceOfClassesOfPrivateMethods_
=
new
LinkedList
<
Class
>()
;
Class
[]
instanceOfClassesOfPrivateMethods
;
Class
[]
instanceOfClassesOfPrivateMethods
=
{}
;
private
Map
<
Object
,
List
<
Class
>>
instanceOfClasses_
=
new
HashMap
<
Object
,
List
<
Class
>>()
;
// mapping methods and constructors to instanceof-classes
Map
<
Object
,
Class
[]>
instanceOfClasses
=
new
HashMap
<
Object
,
Class
[]>()
;
...
...
@@ -51,6 +51,12 @@ public class StaticInfo {
readConstants
(
dir
)
;
}
//public StaticInfo(TestingScope scope, ImplementationMap imap) throws IOException {
// this.CUT = scope.CUT ;
// this.scope = scope ;
// this.imap = imap ;
//}
/**
* Read the constants info from an info-file.
* NOTE: the algorithm assumes the constants are arranged in lines; thus assuming
...
...
src/Sequenic/T3/DerivativeSuiteGens/Gen2/Test_G2SuiteGen_forCUTwith_constants.java
View file @
38f38283
...
...
@@ -9,7 +9,7 @@ public class Test_G2SuiteGen_forCUTwith_constants {
static
void
genWithG2
()
throws
Exception
{
String
staticInfoDir
=
"/Users/iswbprasetya/tmp/t3"
;
Class
CUT
=
Sequenic
.
T3
.
Examples
.
IncomeTax
.
class
;
G2SuiteGen
g2
=
new
G2SuiteGen
(
CUT
.
getName
(),
null
,
staticInfoDir
)
;
G2SuiteGen
g2
=
new
G2SuiteGen
(
CUT
.
getName
(),
null
,
true
,
true
,
staticInfoDir
)
;
g2
.
maxSuffixLength
=
0
;
g2
.
regressionMode
=
true
;
int
N0
=
Math
.
min
(
500
,
Math
.
max
(
10
,
g2
.
staticInfo
.
allConstants
.
length
*
20
))
;
...
...
src/Sequenic/T3/Sequence/Datatype/SUITE.java
View file @
38f38283
...
...
@@ -674,8 +674,8 @@ public class SUITE implements Serializable {
pw
.
write
(
" catch (Exception e) { } }\n"
)
;
pw
.
write
(
" } ;\n"
)
;
pw
.
write
(
" suiterunner.start() ;\n"
)
;
// wait
60 m
s -- hard wired here:
pw
.
write
(
" try { mainthread.sleep(
6
0000); log.warning(\"** JUnit's test suite execution has TIMED OUT.\"); }\n"
)
;
// wait
10
s -- hard wired here:
pw
.
write
(
" try { mainthread.sleep(
1
0000); log.warning(\"** JUnit's test suite execution has TIMED OUT.\"); }\n"
)
;
pw
.
write
(
" catch (Exception e) { log.warning(\"Test suite execution is done.\"); }"
)
;
pw
.
write
(
" }\n\n"
)
;
// test-1
...
...
@@ -683,7 +683,7 @@ public class SUITE implements Serializable {
pw
.
write
(
" public void test1() throws Exception {\n"
)
;
pw
.
write
(
" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \n"
);
pw
.
write
(
" boolean verdict = !info.seenCrash() ;\n"
);
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL
xxxxxxxxxxxx
\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n\n"
)
;
// test-2
...
...
@@ -691,7 +691,7 @@ public class SUITE implements Serializable {
pw
.
write
(
" public void testExceptionTypeOnly() throws Exception {\n"
)
;
pw
.
write
(
" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \n"
);
pw
.
write
(
" boolean verdict = info.inconsistentExc.isEmpty() ;\n"
);
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL
xxxxxxxxxxxx
\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n\n"
)
;
// test-3
...
...
@@ -699,7 +699,7 @@ public class SUITE implements Serializable {
pw
.
write
(
" public void testAllOracles() throws Exception {\n"
)
;
pw
.
write
(
" if (info==null) { log.info(\"NO VERDICT.\"); return ; } \n"
);
pw
.
write
(
" boolean verdict = info.violating.isEmpty() ;\n"
);
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" if (verdict) log.info(\"PASS\") ; else log.info(\"FAIL
xxxxxxxxxxxx
\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n"
)
;
pw
.
write
(
"}"
)
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment