-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental: add test-to-harness conversion logic (#495)
Adds a fuzz harness heuristic that relies on converting existing tests. At this stage, it's done without relying on FI, we simply (1) find tests files in the target project; (2) read them; (3) for each test file we use a simple prompt to convert it into a harness. At this stage, it already out-performs on some existing projects, e.g: https://github.com/jkuhlmann/cgltf/blob/master/test/main.c In this case, we have a harness generated that looks quite nice: ```c // Heuristic: TestConverterPrompt :: Target: #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <string.h> #define CGLTF_IMPLEMENTATION #include "cgltf.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { if (size < 1) { return 0; } cgltf_options options; memset(&options, 0, sizeof(cgltf_options)); cgltf_data* parsed_data = NULL; cgltf_result result; // Parse input data result = cgltf_parse(&options, data, size, &parsed_data); if (result == cgltf_result_success) { result = cgltf_validate(parsed_data); } if (result == cgltf_result_success) { // Use the parsed data in some way // For example, print file type and mesh count printf("Type: %u\n", parsed_data->file_type); printf("Meshes: %u\n", (unsigned)parsed_data->meshes_count); } cgltf_free(parsed_data); return 0; } ``` Ref: #494 --------- Signed-off-by: David Korczynski <[email protected]>
- Loading branch information
1 parent
4e3798e
commit 4309def
Showing
1 changed file
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters