Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions diktat-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,9 @@
- name: DEBUG_PRINT
enabled: true
ignoreAnnotated: [ LoggerImpl ]
- name: WRONG_NAME_OF_VARIABLE_INSIDE_ACCESSOR
enabled: false
- name: EMPTY_BLOCK_STRUCTURE_ERROR
enabled: false
- name: KDOC_NO_CLASS_BODY_PROPERTIES_IN_HEADER
enabled: false
268 changes: 0 additions & 268 deletions kotlinx.fuzz.api/src/main/kotlin/kotlinx/fuzz/KFuzzConfig.kt

This file was deleted.

48 changes: 26 additions & 22 deletions kotlinx.fuzz.api/src/main/kotlin/kotlinx/fuzz/KFuzzTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package kotlinx.fuzz

import kotlin.time.Duration
import kotlinx.fuzz.config.KFuzzConfig
import kotlinx.fuzz.config.KFuzzConfigBuilder
import kotlinx.fuzz.config.TargetConfig
import org.junit.platform.commons.annotation.Testable

/**
Expand All @@ -20,31 +23,32 @@ import org.junit.platform.commons.annotation.Testable
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.ANNOTATION_CLASS)
@Testable
annotation class KFuzzTest(
val keepGoing: Long = KFuzzConfigImpl.Companion.Defaults.KEEP_GOING,
val maxFuzzTime: String = KFuzzConfigImpl.Companion.Defaults.MAX_SINGLE_TARGET_FUZZ_TIME_STRING,
val keepGoing: Long = TargetConfig.Defaults.KEEP_GOING,
val maxFuzzTime: String = TargetConfig.Defaults.MAX_FUZZ_TIME_STRING,
val instrument: Array<String> = [],
val customHookExcludes: Array<String> = [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, we should move instrument and customHookExcludes from TargetConfig to GlobalConfig. I can't see reasons to instrument different classes depending on target (we could instrument only the code we execute, but it's a different thing). Same for customHookExcludes: if we want to exclude something, we most likely want to exclude it everywhere

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I fully agree with that. I think there might be reasons to want to instrument different parts of code for different targets. Because depending on what is instrumented, fuzzer will change its behaviour. So if I want a target to fuzz a specific part of the project, I would want to "communicate" that idea to the fuzzer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it makes more sense to have customHookINCLUDES for some targets and others not. But this is again a question about borrowing Jazzer naming. Will remove these two from @KFuzzTest arguments as well

val dumpCoverage: Boolean = KFuzzConfigImpl.Companion.Defaults.DUMP_COVERAGE,
val dumpCoverage: Boolean = TargetConfig.Defaults.DUMP_COVERAGE,
)

fun KFuzzConfig.addAnnotationParams(annotation: KFuzzTest): KFuzzConfig = KFuzzConfigImpl.fromAnotherConfig(this) {
keepGoing = newUnlessDefault(
old = this@addAnnotationParams.keepGoing,
new = annotation.keepGoing,
default = KFuzzConfigImpl.Companion.Defaults.KEEP_GOING,
)
maxSingleTargetFuzzTime = newUnlessDefault(
old = this@addAnnotationParams.maxSingleTargetFuzzTime,
new = Duration.parse(annotation.maxFuzzTime),
default = Duration.parse(KFuzzConfigImpl.Companion.Defaults.MAX_SINGLE_TARGET_FUZZ_TIME_STRING),
)
instrument = this@addAnnotationParams.instrument + annotation.instrument
customHookExcludes = this@addAnnotationParams.customHookExcludes + annotation.customHookExcludes
dumpCoverage = newUnlessDefault(
old = this@addAnnotationParams.dumpCoverage,
new = annotation.dumpCoverage,
default = KFuzzConfigImpl.Companion.Defaults.DUMP_COVERAGE,
)
}
fun KFuzzConfig.addAnnotationParams(annotation: KFuzzTest): KFuzzConfig = KFuzzConfigBuilder.fromAnotherConfig(this)
.editOverride {
target.keepGoing = newUnlessDefault(
old = this@addAnnotationParams.target.keepGoing,
new = annotation.keepGoing,
default = TargetConfig.Defaults.KEEP_GOING,
)
target.maxFuzzTime = newUnlessDefault(
old = this@addAnnotationParams.target.maxFuzzTime,
new = Duration.parse(annotation.maxFuzzTime),
default = Duration.parse(TargetConfig.Defaults.MAX_FUZZ_TIME_STRING),
)
global.instrument = this@addAnnotationParams.global.instrument + annotation.instrument
global.customHookExcludes = this@addAnnotationParams.global.customHookExcludes + annotation.customHookExcludes
target.dumpCoverage = newUnlessDefault(
old = this@addAnnotationParams.target.dumpCoverage,
new = annotation.dumpCoverage,
default = TargetConfig.Defaults.DUMP_COVERAGE,
)
}.build()

private fun <T> newUnlessDefault(old: T, new: T, default: T): T = if (new == default) old else new
24 changes: 0 additions & 24 deletions kotlinx.fuzz.api/src/main/kotlin/kotlinx/fuzz/SystemProperty.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package kotlinx.fuzz.config

private const val NAME_PREFIX = "coverage"

interface CoverageConfig {
val reportTypes: Set<CoverageReportType>
val includeDependencies: Set<String>
}

class CoverageConfigImpl internal constructor(builder: KFuzzConfigBuilder) : CoverageConfig {
override var reportTypes: Set<CoverageReportType> by builder.KFuzzPropProvider(
nameSuffix = "$NAME_PREFIX.reportTypes",
intoString = { it.joinToString(",") },
fromString = { it.split(",").map { CoverageReportType.valueOf(it) }.toSet() },
default = setOf(CoverageReportType.HTML),
)
override var includeDependencies: Set<String> by builder.KFuzzPropProvider(
nameSuffix = "$NAME_PREFIX.includeDependencies",
intoString = { it.joinToString(",") },
fromString = { it.split(",").toSet() },
default = emptySet(),
)
}

enum class CoverageReportType {
CSV, HTML, XML;
}
Loading
Loading