-
Notifications
You must be signed in to change notification settings - Fork 46
Implement state initialization by fuzzing #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting questions
I think it is a good idea to write a doc about what is going on or at least a brief description in the PR. It is not obvious what is happening and I didn't completely get it
utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt
Outdated
Show resolved
Hide resolved
utbot-framework/src/main/kotlin/org/utbot/engine/mvisitors/ConstraintModelVisitor.kt
Outdated
Show resolved
Hide resolved
2e0e8d4
to
a1db2de
Compare
a1db2de
to
90e85f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I think we need to address the problem when fuzzer can generate very many inputs
|
||
// create new state initialized by fuzzing if it is the last identity stmt for parameter | ||
val initializedStateByFuzzing = if ( | ||
UtSettings.useFuzzingInitialization && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract these variables into separate variables with meaningful names?
constraints += mkNot(mkEq(value.addr, nullObjectAddr)) | ||
val arrayLength = traverser.memory.findArrayLength(value.addr) | ||
constraints += mkEq(arrayLength.align(), model.length.primitiveToSymbolic()) | ||
val type = model.classId.toType() as ArrayType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same about finding a soot class and then .arrayType
} | ||
|
||
override fun visitAssemble(model: UtAssembleModel): List<UtBoolExpression> { | ||
// TODO: not supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will it be supported?
val constraints = mutableListOf<UtBoolExpression>() | ||
val type = model.classId.toType() as RefType | ||
val typeStorage = traverser.typeResolver.constructTypeStorage(type, useConcreteType = true) | ||
constraints += traverser.typeRegistry.typeConstraint(value.addr, typeStorage).isConstraint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need a correctness constraint?
* Call check of SMT Solver with [initialConstraints]. Used to initialize SMT Solver by fuzzing. | ||
*/ | ||
fun checkWithInitialConstraints(initialConstraints: List<UtBoolExpression>): UtSolverStatus { | ||
check(respectSoft = false).let { statusHolder -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we ignore soft constraints by default here? Wouldn't it be better to check with them?
} | ||
} | ||
val translatedConstraints = initialConstraints.translate() | ||
val statusHolder = when (val status = check(translatedConstraints, mutableMapOf())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emptyMap?
val ordinal = traverser.memory.findOrdinal(model.classId.toSoot().type, value.addr) | ||
listOf(mkEq(ordinal.expr, model.value.ordinal.primitiveToLiteral())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this one constraint is enough? I guess we need to use the name
field too to avoid two constructed enums with different ordinal but the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fuzzing part looks good to me
Description
Closes #217
Idea was described in issue. Briefly we use fuzzing as seed for SMT Solver to avoid bad initialization.
Implementation details
Now this feature is turning off. To turn on look at UtSettings::useFuzzingInitialization.
Type of Change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Autotesting
All CI tests passed with this feature turning on.
Manual Scenario
I tested it using IDEA plugin on guava project. Generate tests several times with turning on this feature and without it then compare results (coverage).
Checklist (remove irrelevant options):