Skip to content

Commit

Permalink
Create base test cases for Java integration
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan committed Oct 5, 2022
1 parent bd8a8f8 commit e4254c5
Show file tree
Hide file tree
Showing 12 changed files with 257 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/java/test1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The simple one class java fuzzer
22 changes: 22 additions & 0 deletions tests/java/test1/TestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class TestFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
return;
}
}
1 change: 1 addition & 0 deletions tests/java/test2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test case with reachable and unreachable methods in same class
44 changes: 44 additions & 0 deletions tests/java/test2/TestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class TestFuzzer {
private void function1() {
return;
}

private static void function2() {
return;
}

void functionPublicDead() {
return;
}

private void functionPrivateDead() {
return;
}

public static void fuzzerTestOneInput(FuzzedDataProvider data) {
int choice = data.consumeInt(0,1);
if (choice == 0) {
TestFuzzer tf = new TestFuzzer();
tf.function1();
} else {
TestFuzzer.function2();
}
}
}
1 change: 1 addition & 0 deletions tests/java/test3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test case with reachable and unreachable methods in different class
49 changes: 49 additions & 0 deletions tests/java/test3/TestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

class FunctionTest {
protected void function1() {
return;
}

protected static void function2() {
return;
}

protected void functionPublicDead() {
return;
}

private void functionPrivateDead() {
return;
}

}

public class TestFuzzer {

public static void fuzzerTestOneInput(FuzzedDataProvider data) {
int choice = data.consumeInt(0,1);

if (choice == 0) {
FunctionTest ft = new FunctionTest();
ft.function1();
} else {
FunctionTest.function2();
}
}
}
37 changes: 37 additions & 0 deletions tests/java/test4/FunctionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

package Fuzz;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class FunctionTest {
protected void function1() {
return;
}

protected static void function2() {
return;
}

protected void functionPublicDead() {
return;
}

private void functionPrivateDead() {
return;
}

}
1 change: 1 addition & 0 deletions tests/java/test4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test case with reachable and unreachable methods in different class in same package but different java file
31 changes: 31 additions & 0 deletions tests/java/test4/TestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

package Fuzz;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class TestFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
int choice = data.consumeInt(0,1);

if (choice == 0) {
FunctionTest ft = new FunctionTest();
ft.function1();
} else {
FunctionTest.function2();
}
}
}
37 changes: 37 additions & 0 deletions tests/java/test5/FunctionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

package Function;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class FunctionTest {
public void function1() {
return;
}

public static void function2() {
return;
}

public void functionPublicDead() {
return;
}

private void functionPrivateDead() {
return;
}

}
1 change: 1 addition & 0 deletions tests/java/test5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Test case with reachable and unreachable methods in different class in different
32 changes: 32 additions & 0 deletions tests/java/test5/TestFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Fuzz Introspector Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

package Fuzz;

import Function.FunctionTest;
import com.code_intelligence.jazzer.api.FuzzedDataProvider;

public class TestFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
int choice = data.consumeInt(0,1);

if (choice == 0) {
FunctionTest ft = new FunctionTest();
ft.function1();
} else {
FunctionTest.function2();
}
}
}

0 comments on commit e4254c5

Please sign in to comment.