From 920d15ae0a7884a9d0144bd8f4dcad605eb17213 Mon Sep 17 00:00:00 2001 From: IlyaMuravjov Date: Tue, 25 Jul 2023 17:29:21 +0300 Subject: [PATCH] Make Java fuzzer fallback to `null` value when nothing else works --- .../org/utbot/engine/UtBotSymbolicEngine.kt | 2 ++ .../kotlin/org/utbot/fuzzing/providers/Objects.kt | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt index 46d16f234d..822896b447 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt @@ -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 @@ -392,6 +393,7 @@ class UtBotSymbolicEngine( emit(UtError(e.message ?: "Failed to create ValueProvider", e)) return@flow }.let(transform) + .withFallback(AnyDepthNullValueProvider) val coverageToMinStateBeforeSize = mutableMapOf, Int>() diff --git a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt index 77612897c9..528541cfd6 100644 --- a/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt +++ b/utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt @@ -132,6 +132,21 @@ object NullValueProvider : ValueProvider { + + override fun accept(type: FuzzedType) = type.classId.isRefType + + override fun generate( + description: FuzzedDescription, + type: FuzzedType + ) = sequenceOf>(Seed.Simple(nullFuzzedValue(classClassId))) +} + /** * Finds and create object from implementations of abstract classes or interfaces. */