Skip to content

Commit 3b68f40

Browse files
committed
improved checks for taints
1 parent f8bce0d commit 3b68f40

6 files changed

Lines changed: 25 additions & 8 deletions

File tree

core/src/main/kotlin/org/evomaster/core/problem/enterprise/EnterpriseIndividual.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ abstract class EnterpriseIndividual(
180180
*/
181181
fun ensureFlattenedStructure() : Boolean{
182182

183+
Lazy.assert { verifyValidity(); true }
184+
183185
val before = seeAllActions().size
184186

185187
val issues = doFlattenStructure()

core/src/main/kotlin/org/evomaster/core/problem/rest/data/RestIndividual.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ class RestIndividual(
154154
.sortBy { if ((it as SqlAction).representExistingData) 0 else 1 }
155155
}
156156

157+
/*
158+
Can't do this, as it can change how the test behave when there are bounded tainted values
159+
*/
160+
//seeAllActions().forEach { it.forceNewTaints() }
161+
157162
/*
158163
if we move any environment action to the beginning of the individual, it might impact the fitness
159164
*/

core/src/main/kotlin/org/evomaster/core/problem/rest/service/RestIndividualBuilder.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class RestIndividualBuilder {
103103
other.resetLocalIdRecursively()
104104

105105
//avoid possible taint id conflicts
106+
base.seeAllActions().forEach { it.forceNewTaints() }
106107
other.seeAllActions().forEach { it.forceNewTaints() }
107108

108109
val duplicates = base.addInitializingActions(other.seeInitializingActions())
@@ -122,7 +123,7 @@ class RestIndividualBuilder {
122123
//merge shouldn't lose any actions
123124
assert(before == (after+duplicates)) { "$after+$duplicates!=$before" }
124125

125-
base.verifyValidity()
126+
base.verifyValidity(true)
126127

127128
return base
128129
}

core/src/main/kotlin/org/evomaster/core/search/Individual.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ abstract class Individual(
180180
* All invariants should always be satisfied after any modification of the individual.
181181
* If not, this is a bug.
182182
*/
183-
fun verifyValidity(){
183+
fun verifyValidity(checkForTaints: Boolean = false){
184184

185185
groupsView()?.verifyGroups()
186186

@@ -202,9 +202,18 @@ abstract class Individual(
202202
throw IllegalStateException("There are invalid local ids:\n" + localIdErrors.joinToString("\n"))
203203
}
204204

205-
val taintIdErrors = verifyTaintIds()
206-
if(taintIdErrors.isNotEmpty()){
207-
throw IllegalStateException("There are invalid taint ids:\n" + taintIdErrors.joinToString("\n"))
205+
/*
206+
We cannot really verify it all the time.
207+
Duplicates might exist due to bounded genes.
208+
But flattening (done at minimization, for example) removes the binding, leading
209+
this check to fail.
210+
further problem, many phases (eg security) are done _after_ minimization...
211+
*/
212+
if(checkForTaints) {
213+
val taintIdErrors = verifyTaintIds()
214+
if (taintIdErrors.isNotEmpty()) {
215+
throw IllegalStateException("There are invalid taint ids:\n" + taintIdErrors.joinToString("\n"))
216+
}
208217
}
209218
}
210219

core/src/main/kotlin/org/evomaster/core/search/service/Sampler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ abstract class Sampler<T> : TrackOperator where T : Individual {
9999

100100
samplePostProcessing(ind)
101101

102-
org.evomaster.core.Lazy.assert { ind.verifyValidity(); true }
102+
org.evomaster.core.Lazy.assert { ind.verifyValidity(true); true }
103103
return ind
104104
}
105105

core/src/main/kotlin/org/evomaster/core/search/service/mutator/Mutator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ abstract class Mutator<T> : TrackOperator where T : Individual {
159159
log.trace("now it is {}th, do addInitializingActions ends", i)
160160
}
161161

162-
Lazy.assert{current.individual.verifyValidity(); true}
162+
Lazy.assert{current.individual.verifyValidity(true); true}
163163

164164
// skip to mutate the individual if any new harvested external actions are added
165165
val mutatedInd = if (!anyHarvestedExternalServiceActions)
@@ -171,7 +171,7 @@ abstract class Mutator<T> : TrackOperator where T : Individual {
171171

172172
sampler.applyDerivedParamModifications(mutatedInd)
173173

174-
Lazy.assert{mutatedInd.verifyValidity(); true}
174+
Lazy.assert{mutatedInd.verifyValidity(true); true}
175175

176176
//FIXME: why setOf()??? are we skipping coverage collection here???
177177
// or always added non-covered from archive? if so, name "targets" is confusing

0 commit comments

Comments
 (0)