THRIFT-5855: Add FUZZING.md and test structures
This PR adds a basic readme describing the upcoming fuzzing support (it's forward looking, I have local commits that add support to all the languages that I'll re-test and submit once this merges).
It also adds 2 files with test structures - the main difference just being one is for languages with UUID support and one without.
diff --git a/FUZZING.md b/FUZZING.md
new file mode 100644
index 0000000..f0f0324
--- /dev/null
+++ b/FUZZING.md
@@ -0,0 +1,78 @@
+# Fuzzing Apache Thrift
+
+This document describes the fuzzing infrastructure and goals for Apache Thrift.
+
+We use [OSS-Fuzz](https://github.com/google/oss-fuzz) as our primary fuzzing platform to continuously test and improve the robustness of Thrift's hand-written and generated code.
+
+## Goals
+
+With fuzzing, we are focusing on testing the following key aspects across supported languages:
+
+1. Security - Testing how the generated code handles malformed/malicious input
+2. Serialization round-trip correctness - Ensuring that data stays identical if we serialize then deserialize it.
+
+## Supported Languages
+
+We currently maintain fuzzers for the following languages:
+
+- Go (needs improvement)
+
+We are working on adding fuzzers for the following languages:
+
+- c_glib
+- C++
+- Rust
+- Swift
+- Python
+- JavaScript
+- Java/JVM (and other JVM languages)
+- netstd
+
+## Fuzzer Types
+
+For each supported language, we implement at minimum:
+
+1. **Deserializer Fuzzer**
+ - Takes raw fuzzer input and attempts to deserialize it into Thrift structures
+ - Tests handling of malformed/unexpected input
+ - Implemented for each supported protocol (Binary, Compact, JSON where available)
+
+2. **Round-Trip Fuzzer**
+ - Deserializes fuzzer input, then re-serializes and verifies it matches
+ - Ensures data integrity through serialization cycles
+ - Tests both serialization and deserialization code paths
+
+## Building and Running the Fuzzers
+
+Each language has its own fuzzers under the `lib/<language>/test/fuzz` directory.
+The fuzzers are built when building the language-specific code (using the normal build system), as regular binaries (without fuzzing support enabled), to ensure that there are no build breakages.
+
+To ensure fuzzing can find issues as soon as possible, we will enable fuzzing support in CI once the fuzzers are stable.
+
+Currently the only convenient, formally supported build with fuzzing support enabled is the via the oss-fuzz workflow. For languages where local fuzzing is easy to do, documentation is provided along with the fuzzers.
+
+## OSS-Fuzz Integration
+
+Our fuzzers run continuously on OSS-Fuzz. To view build status:
+
+1. Visit the [OSS-Fuzz Status Dashboard](https://oss-fuzz-build-logs.storage.googleapis.com/index.html)
+2. Look for the "thrift" project
+
+The source code for the oss-fuzz build is [available upstream](https://github.com/google/oss-fuzz/tree/master/projects/thrift).
+
+We aim to improve the fuzzers through viewing the fuzz introspector reports, available [here](https://introspector.oss-fuzz.com/project-profile?project=thrift).
+
+*NB: The oss-fuzz integration will be significantly updated once all the language specific fuzzers are committed here.
+
+## Contributing to the fuzzers
+
+To contribute to the fuzzing effort - please look at https://issues.apache.org/jira/browse/THRIFT-5855 for the latest status and planned work. Once the ticket is closed,
+we would still appreciate contributions that:
+
+1. Add new fuzzers for unsupported languages
+2. Improve existing fuzzers
+3. Add test cases to corpus
+
+If you do add or change a fuzzer, please remember to make corresponding changes to the oss-fuzz build script in case they are needed.
+
+Please see CONTRIBUTING.md for general contribution guidelines.
\ No newline at end of file
diff --git a/test/FuzzTest.thrift b/test/FuzzTest.thrift
new file mode 100644
index 0000000..7a6da33
--- /dev/null
+++ b/test/FuzzTest.thrift
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+namespace cpp fuzz
+namespace java org.apache.thrift.fuzz
+namespace py fuzz
+namespace swift Fuzz
+
+// Test typedefs
+typedef i64 UserId
+typedef binary BinaryData
+
+// Test all primitive types in a compact struct
+struct BasicTypes {
+ 1: bool bool_field,
+ 2: i8 byte_field,
+ 3: i16 i16_field,
+ 4: i32 i32_field,
+ 5: i64 i64_field,
+ 6: double double_field,
+ 7: string string_field,
+ 8: binary binary_field,
+ 9: uuid uuid_field
+}
+
+// Test optional/required/default requiredness
+struct Requiredness {
+ 1: required i32 req_field,
+ 2: optional i32 opt_field,
+ 3: i32 default_field, // default requiredness
+ 4: optional string opt_with_default = "test",
+ 5: required bool req_with_default = true
+}
+
+// Test field ID edge cases
+struct FieldIDTest {
+ 1: i32 first,
+ 100: i32 gap,
+ 255: i32 medium_id,
+ 32767: i32 large_id,
+}
+
+// Test empty struct
+struct EmptyStruct {}
+
+// Test union
+union TestUnion {
+ 1: i32 int_field,
+ 2: string string_field,
+ 3: BasicTypes struct_field,
+ 4: binary binary_field
+}
+
+// Test containers (but not too deeply nested)
+struct Containers {
+ 1: list<i32> int_list,
+ 2: set<string> string_set,
+ 3: map<i32, string> int_string_map,
+ 4: list<BasicTypes> struct_list,
+ 5: map<string, list<i32>> nested_map,
+ 6: set<UserId> typedef_set,
+}
+
+// Test enum with various values
+enum TestEnum {
+ ZERO = 0,
+ ONE = 1,
+ TWO = 2,
+ NEGATIVE = -1,
+ LARGE = 32767,
+ HEX_VALUE = 0xFF
+}
+
+// Test recursive structure
+struct RecursiveStruct {
+ 1: optional RecursiveStruct & recurse,
+ 2: i32 data,
+ 3: optional list<RecursiveStruct> children
+}
+
+// Main test structure - kept minimal but comprehensive
+struct FuzzTest {
+ 1: required BasicTypes basic,
+ 2: required Requiredness required_test,
+ 3: required Containers containers,
+ 4: required TestUnion union_field,
+ 5: optional RecursiveStruct recursive,
+ 6: optional EmptyStruct empty,
+ 7: optional FieldIDTest field_ids,
+ 8: required TestEnum enum_field,
+ 9: optional map<TestEnum, string> enum_map,
+ 10: UserId user_id,
+ 11: BinaryData data,
+}
\ No newline at end of file
diff --git a/test/v0.16/FuzzTestNoUuid.thrift b/test/v0.16/FuzzTestNoUuid.thrift
new file mode 100644
index 0000000..bf87740
--- /dev/null
+++ b/test/v0.16/FuzzTestNoUuid.thrift
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+namespace cpp fuzz
+namespace java org.apache.thrift.fuzz
+namespace py fuzz
+namespace swift Fuzz
+
+// Test typedefs
+typedef i64 UserId
+typedef binary BinaryData
+
+// Test all primitive types in a compact struct
+struct BasicTypes {
+ 1: bool bool_field,
+ 2: i8 byte_field,
+ 3: i16 i16_field,
+ 4: i32 i32_field,
+ 5: i64 i64_field,
+ 6: double double_field,
+ 7: string string_field,
+ 8: binary binary_field,
+}
+
+// Test optional/required/default requiredness
+struct Requiredness {
+ 1: required i32 req_field,
+ 2: optional i32 opt_field,
+ 3: i32 default_field, // default requiredness
+ 4: optional string opt_with_default = "test",
+ 5: required bool req_with_default = true
+}
+
+// Test field ID edge cases
+struct FieldIDTest {
+ 1: i32 first,
+ 100: i32 gap,
+ 255: i32 medium_id,
+ 32767: i32 large_id,
+}
+
+// Test empty struct
+struct EmptyStruct {}
+
+// Test union
+union TestUnion {
+ 1: i32 int_field,
+ 2: string string_field,
+ 3: BasicTypes struct_field,
+ 4: binary binary_field
+}
+
+// Test containers (but not too deeply nested)
+struct Containers {
+ 1: list<i32> int_list,
+ 2: set<string> string_set,
+ 3: map<i32, string> int_string_map,
+ 4: list<BasicTypes> struct_list,
+ 5: map<string, list<i32>> nested_map,
+ 6: set<UserId> typedef_set,
+}
+
+// Test enum with various values
+enum TestEnum {
+ ZERO = 0,
+ ONE = 1,
+ TWO = 2,
+ NEGATIVE = -1,
+ LARGE = 32767,
+ HEX_VALUE = 0xFF
+}
+
+// Do not test recursive structures here, as not all languages (e.g. c_glib) support them.
+// struct RecursiveStruct {
+// 1: optional RecursiveStruct recurse,
+// 2: i32 data,
+// 3: optional list<RecursiveStruct> children
+// }
+
+// Main test structure - kept minimal but comprehensive
+struct FuzzTest {
+ 1: required BasicTypes basic,
+ 2: required Requiredness required_test,
+ 3: required Containers containers,
+ 4: required TestUnion union_field,
+// 5: optional RecursiveStruct recursive,
+ 6: optional EmptyStruct empty,
+ 7: optional FieldIDTest field_ids,
+ 8: required TestEnum enum_field,
+ 9: optional map<TestEnum, string> enum_map,
+ 10: UserId user_id,
+ 11: BinaryData data,
+}
\ No newline at end of file