You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new MinimizationPostProcessor runs at the end of minimization and
attempts to add certain features - which are deemed useful for future
code mutations - back to the program as long as they don't alter the
interesting behaviour. For example, it attempts to add return statements
at the end of functions and add arguments to function calls.
Copy file name to clipboardExpand all lines: Sources/Fuzzilli/Minimization/MinimizationHelper.swift
+43-14Lines changed: 43 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -12,23 +12,23 @@
12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
-
/// A ReductionTester tests whether a reducton is valid and doesn't alter the important aspects of a program.
16
-
classReductionTester{
15
+
/// The MinimizationHelper provides functions for testing whether a code change alters the programs interesting behaviour. It also provides access to the fuzzer instance for executing programs or other tasks.
16
+
classMinimizationHelper{
17
17
vartotalReductions=0
18
18
varfailedReductions=0
19
19
vardidReduce=false
20
20
21
+
/// Fuzzer instance to schedule execution of programs on.
22
+
letfuzzer:Fuzzer
23
+
21
24
/// The aspects of the program to preserve during minimization.
22
25
privateletaspects:ProgramAspects
23
26
24
-
/// Fuzzer instance to schedule execution of programs on.
25
-
privateletfuzzer:Fuzzer
26
-
27
27
/// Whether we are running on the fuzzer queue (synchronous minimization) or not (asynchronous minimization).
28
28
privateletrunningOnFuzzerQueue:Bool
29
29
30
30
/// The minimizer can select instructions that should be kept regardless of whether they are important or not. This set tracks those instructions.
31
-
privateletinstructionsToKeep:Set<Int>
31
+
privatevarinstructionsToKeep:Set<Int>
32
32
33
33
init(for aspects:ProgramAspects, of fuzzer:Fuzzer, keeping instructionsToKeep:Set<Int>, runningOnFuzzerQueue:Bool){
34
34
self.aspects = aspects
@@ -37,6 +37,18 @@ class ReductionTester {
37
37
self.runningOnFuzzerQueue = runningOnFuzzerQueue
38
38
}
39
39
40
+
func performOnFuzzerQueue(_ task:()->Void){
41
+
if runningOnFuzzerQueue {
42
+
returntask()
43
+
}else{
44
+
return fuzzer.sync(do: task)
45
+
}
46
+
}
47
+
48
+
func clearInstructionsToKeep(){
49
+
instructionsToKeep.removeAll()
50
+
}
51
+
40
52
/// Test a reduction and return true if the reduction was Ok, false otherwise.
41
53
func test(_ code:Code)->Bool{
42
54
// Reducers are allowed to nop instructions without verifying whether their outputs are used.
@@ -49,15 +61,10 @@ class ReductionTester {
49
61
50
62
// Run the modified program and see if the patch changed its behaviour
0 commit comments