Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add java testcases #537

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 package and different file (require import)
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();
}
}
}