Skip to content

Commit 8fb0ee6

Browse files
committed
Fix various problems with fuzzing in ContestEstimator
1 parent ec720a7 commit 8fb0ee6

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
@@ -881,6 +881,8 @@ val Type.classId: ClassId
881881
else -> error("Unknown type $this")
882882
}
883883

884+
private val logger = KotlinLogging.logger {}
885+
884886
/**
885887
* Class id. Contains name, not a full qualified name.
886888
*
@@ -905,7 +907,9 @@ open class ClassId @JvmOverloads constructor(
905907
get() = jClass.modifiers
906908

907909
open val canonicalName: String
908-
get() = jClass.canonicalName ?: error("ClassId $name does not have canonical name")
910+
get() = jClass.canonicalName ?: name.also {
911+
logger.error("ClassId $name does not have canonical name")
912+
}
909913

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

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)