1+ // Configure fuzz testing for codec modules using Jazzer
2+
3+ configure<SourceSetContainer > {
4+ val main by getting
5+ val test by getting
6+
7+ // Create a separate "fuzz" source set for fuzz tests
8+ create(" fuzz" ) {
9+ compileClasspath + = main.output + configurations[" testRuntimeClasspath" ] + configurations[" testCompileClasspath" ]
10+ runtimeClasspath + = output + compileClasspath + test.runtimeClasspath + test.output
11+ }
12+ }
13+
14+ // Add fuzz-test-harness dependency to the fuzz source set
15+ dependencies {
16+ " fuzzImplementation" (project(" :fuzz-test-harness" ))
17+ }
18+
19+ // Create the fuzz test task
20+ tasks.register<Test >(" fuzz" ) {
21+ description = " Run fuzz tests using Jazzer"
22+ group = " verification"
23+
24+ val fuzzSourceSet = project.the<SourceSetContainer >()[" fuzz" ]
25+ testClassesDirs = fuzzSourceSet.output.classesDirs
26+ classpath = fuzzSourceSet.runtimeClasspath
27+
28+ useJUnitPlatform()
29+
30+ // Fork for each test class to ensure isolation
31+ setForkEvery(1 )
32+
33+ // Memory settings
34+ maxHeapSize = " 2048m"
35+ minHeapSize = " 2048m"
36+
37+ // Enable Jazzer fuzzing mode
38+ environment(" JAZZER_FUZZ" , " 1" )
39+
40+ // Jazzer configuration
41+ systemProperty(" jazzer.valueprofile" , " 1" )
42+ systemProperty(" jazzer.coverage_report" , " ${project.layout.buildDirectory} /reports/jazzer" )
43+
44+ systemProperty(" jazzer.instrumentation_includes" , " software.amazon.smithy.java.**" )
45+
46+ val corpusDir = " ${project.projectDir} /src/fuzz/resources/corpus"
47+ if (file(corpusDir).exists()) {
48+ systemProperty(" jazzer.internal.arg.0" , corpusDir)
49+ }
50+
51+ val maxDuration = project.findProperty(" fuzz.maxDuration" ) ? : " 1h"
52+ systemProperty(" jazzer.max_duration" , maxDuration)
53+ }
0 commit comments