Skip to content

Commit

Permalink
Make Java fuzzer fallback to null value when nothing else works
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMuravjov committed Jul 25, 2023
1 parent 051b293 commit 920d15a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.utbot.framework.util.graph
import org.utbot.framework.util.sootMethod
import org.utbot.fuzzer.*
import org.utbot.fuzzing.*
import org.utbot.fuzzing.providers.AnyDepthNullValueProvider
import org.utbot.fuzzing.utils.Trie
import org.utbot.instrumentation.ConcreteExecutor
import org.utbot.instrumentation.instrumentation.Instrumentation
Expand Down Expand Up @@ -392,6 +393,7 @@ class UtBotSymbolicEngine(
emit(UtError(e.message ?: "Failed to create ValueProvider", e))
return@flow
}.let(transform)
.withFallback(AnyDepthNullValueProvider)

val coverageToMinStateBeforeSize = mutableMapOf<Trie.Node<Instruction>, Int>()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ object NullValueProvider : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescript
}
}

/**
* Unlike [NullValueProvider] can generate `null` values at any depth.
*
* Intended to be used as a last fallback.
*/
object AnyDepthNullValueProvider : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescription> {

override fun accept(type: FuzzedType) = type.classId.isRefType

override fun generate(
description: FuzzedDescription,
type: FuzzedType
) = sequenceOf<Seed<FuzzedType, FuzzedValue>>(Seed.Simple(nullFuzzedValue(classClassId)))
}

/**
* Finds and create object from implementations of abstract classes or interfaces.
*/
Expand Down

0 comments on commit 920d15a

Please sign in to comment.