• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 Code Intelligence GmbH
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.example;
16 
17 import java.time.Instant;
18 
19 public class CrashResistantCoverageTarget {
fuzzerTestOneInput(byte[] data)20   public static void fuzzerTestOneInput(byte[] data) {
21     if (data.length < 10) {
22       // Crash immediately on the empty and the first seed input so that we can verify that the
23       // crash-resistant merge strategy actually works.
24       throw new IllegalStateException("Crash");
25     }
26     if (data.length < 100) {
27       someFunction();
28     }
29   }
30 
someFunction()31   public static void someFunction() {
32     // A non-trivial condition that always evaluates to true.
33     if (Instant.now().getNano() >= 0) {
34       System.out.println("Hello, world!");
35     }
36   }
37 }
38