summaryrefslogtreecommitdiff
path: root/chapter18/src/test/java/com/seaofnodes/simple/FuzzerWrap.java
blob: 1427c99d4d8d648c0402d9cc475177b7b0f319b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.seaofnodes.simple;

import com.seaofnodes.simple.fuzzer.Fuzzer;
import java.util.Random;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertTrue;

/**
 * Normal tests run only this chapter's fixed regression seeds. Open failures
 * and exploratory fuzzing are opt-in: run their methods directly in the IDE,
 * or temporarily remove the relevant Ignore annotation when investigating.
 * Seeds belong to this chapter's generator; do not copy them between chapters.
 */
public class FuzzerWrap {

    private static final long[] REGRESSION_SEEDS = {
    };

    private static final long[] OPEN_FAILING_SEEDS = {
        973358943756616234L, // Parser failure on nullable field access after dead code
    };

    @Test         public void fuzzPeepsRegression  () { fuzzPeepsSeeds(REGRESSION_SEEDS); }
    @Test @Ignore public void fuzzPeepsOpenFailures() { fuzzPeepsSeeds(OPEN_FAILING_SEEDS); }

    private static void fuzzPeepsSeeds(long... seeds) {
        var fuzzer = new Fuzzer();
        for (long seed : seeds)
            fuzzer.fuzzPeepsRegression(seed);
    }

    @Ignore
    @Test
    public void fuzzPeepsLarge() {
        var fuzzer = new Fuzzer();
        for (int i=0; i<1000000; i++)
            fuzzer.fuzzPeeps(i);
        assertTrue(fuzzer.noExceptions());
    }


    @Test @Ignore
    public void fuzzPeepsRandom() {
        Random R = new Random(System.currentTimeMillis());
        var fuzzer = new Fuzzer();
        for (int i=0; i<100; i++)
            fuzzer.fuzzPeeps( R.nextLong());
        assertTrue(fuzzer.noExceptions());
    }

    @Test
    @Ignore
    public void fuzzPeepTiming() {
        var fuzzer = new Fuzzer();
        int max_nid=0;
        for (int i=0; i<1000000; i++)
            max_nid = fuzzer.fuzzPeepTiming(i, max_nid);
    }
}