Skip to content

Commit d922792

Browse files
committed
Fix various problems with fuzzing in ContestEstimator
1 parent 6e3c1c4 commit d922792

File tree

4 files changed

+13
-8
lines changed
  • utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api
  • utbot-fuzzing/src/main/kotlin/org/utbot/fuzzing
  • utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing

4 files changed

+13
-8
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ val Type.classId: ClassId
880880
else -> error("Unknown type $this")
881881
}
882882

883+
private val logger = KotlinLogging.logger {}
884+
883885
/**
884886
* Class id. Contains name, not a full qualified name.
885887
*
@@ -904,7 +906,9 @@ open class ClassId @JvmOverloads constructor(
904906
get() = jClass.modifiers
905907

906908
open val canonicalName: String
907-
get() = jClass.canonicalName ?: error("ClassId $name does not have canonical name")
909+
get() = jClass.canonicalName ?: name.also {
910+
logger.error("ClassId $name does not have canonical name")
911+
}
908912

909913
open val simpleName: String get() = jClass.simpleName
910914

utbot-fuzzing/src/main/kotlin/org/utbot/fuzzing/Api.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.utbot.fuzzing.seeds.KnownValue
77
import org.utbot.fuzzing.utils.MissedSeed
88
import org.utbot.fuzzing.utils.chooseOne
99
import org.utbot.fuzzing.utils.flipCoin
10+
import org.utbot.fuzzing.utils.transformIfNotEmpty
1011
import kotlin.random.Random
1112

1213
private val logger by lazy { KotlinLogging.logger {} }
@@ -515,11 +516,11 @@ private fun <TYPE, RESULT, DESCRIPTION : Description<TYPE>, FEEDBACK : Feedback<
515516
}
516517
),
517518
modify = task.modify
518-
// .toMutableList()
519-
// .transformIfNotEmpty {
520-
// shuffle(random)
521-
// take(random.nextInt(size + 1))
522-
// }
519+
.toMutableList()
520+
.transformIfNotEmpty {
521+
shuffle(random)
522+
take(configuration.maxNumberOfRecursiveSeedModifications)
523+
}
523524
.mapTo(arrayListOf()) { routine ->
524525
fuzz(
525526
routine.types,

utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/JavaLanguage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fun defaultValueProviders(idGenerator: IdentityPreservingIdGenerator<Int>) = lis
4444
StringValueProvider,
4545
NumberValueProvider,
4646
ObjectValueProvider(idGenerator).letIf(UtSettings.fuzzObjectWhenTheyCannotBeCreatedClean) { ovp ->
47-
ovp.withFallback(CreateObjectAnywayValueProvider(idGenerator, useMock = true))
47+
ovp.withFallback(CreateObjectAnywayValueProvider(idGenerator, useMock = false))
4848
},
4949
ArrayValueProvider(idGenerator),
5050
EnumValueProvider(idGenerator),

utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Objects.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ object NullValueProvider : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescript
134134

135135
class CreateObjectAnywayValueProvider(
136136
val idGenerator: IdGenerator<Int>,
137-
val useMock: Boolean = true,
137+
val useMock: Boolean = false,
138138
) : ValueProvider<FuzzedType, FuzzedValue, FuzzedDescription> {
139139

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

0 commit comments

Comments
 (0)