Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix strange behaviour
  • Loading branch information
sergeypospelov committed Jul 8, 2022
commit 3f01700e2594d0ac9f76dfe33d8a46a6851616e2
16 changes: 9 additions & 7 deletions utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3330,12 +3330,12 @@ class Traverser(
queuedSymbolicStateUpdates += mkNot(mkEq(symbolicResult.value.addr, nullObjectAddr)).asHardConstraint()
}

val state = environment.state.update(queuedSymbolicStateUpdates)
val memory = state.memory
val solver = state.solver
val symbolicState = environment.state.symbolicState + queuedSymbolicStateUpdates
val memory = symbolicState.memory
val solver = symbolicState.solver

//no need to respect soft constraints in NestedMethod
val holder = solver.check(respectSoft = !state.isInNestedMethod())
val holder = solver.check(respectSoft = !environment.state.isInNestedMethod())

if (holder !is UtSolverStatusSAT) {
logger.trace { "processResult<${environment.method.signature}> UNSAT" }
Expand All @@ -3344,7 +3344,7 @@ class Traverser(
val methodResult = MethodResult(symbolicResult)

//execution frame from level 2 or above
if (state.isInNestedMethod()) {
if (environment.state.isInNestedMethod()) {
// static fields substitution
// TODO: JIRA:1610 -- better way of working with statics
val updates = if (environment.method.name == STATIC_INITIALIZER && substituteStaticsWithSymbolicVariable) {
Expand All @@ -3355,15 +3355,17 @@ class Traverser(
} else {
MemoryUpdate() // all memory updates are already added in [environment.state]
}
val stateToOffer = state.pop(methodResult.copy(symbolicStateUpdate = updates.asUpdate()))
val methodResultWithUpdates = methodResult.copy(symbolicStateUpdate = queuedSymbolicStateUpdates + updates)
val stateToOffer = environment.state.pop(methodResultWithUpdates)
offerState(stateToOffer)

logger.trace { "processResult<${environment.method.signature}> return from nested method" }
return
}

//toplevel method
val terminalExecutionState = state.copy(
val terminalExecutionState = environment.state.copy(
symbolicState = symbolicState,
methodResult = methodResult, // the way to put SymbolicResult into terminal state
label = StateLabel.TERMINAL
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ class UtBotSymbolicEngine(
val solver = state.solver
val parameters = state.parameters.map { it.value }
val symbolicResult = requireNotNull(state.methodResult?.symbolicResult) { "The state must have symbolicResult" }
// it's free to make a check, because in the result is SAT, it should be already cached
val holder = requireNotNull(solver.check(respectSoft = true) as? UtSolverStatusSAT) { "The state must be SAT!" }
val holder = requireNotNull(solver.lastStatus as? UtSolverStatusSAT) { "The state must be SAT!" }

val predictedTestName = Predictors.testName.predict(state.path)
Predictors.testName.provide(state.path, predictedTestName, "")
Expand Down