From 42d2547e809050dea08e650ead49bc51311b9c08 Mon Sep 17 00:00:00 2001 From: Shivam7-1 <55046031+Shivam7-1@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:02:24 +0530 Subject: [PATCH] fuzz: Initial fuzz_target.c (#1273) * Initial fuzz_target.c * Update Fuzz/fuzz_target.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update Fuzz/fuzz_target.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- Fuzz/fuzz_target.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Fuzz/fuzz_target.c diff --git a/Fuzz/fuzz_target.c b/Fuzz/fuzz_target.c new file mode 100644 index 0000000000..121a431320 --- /dev/null +++ b/Fuzz/fuzz_target.c @@ -0,0 +1,39 @@ +#include +#include +#include "pavl.h" +#include "sort.h" +#include "local_proto.h" +#include "test_simulation.cpp" +#include "test_treatments.cpp" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + if (size < sizeof(int)) + return 0; + + int input = *(int *)data; + + // fuzz test for pavl_create function from pavl.h + struct pavl_table *table = pavl_create(NULL, NULL, NULL); + if (table) { + pavl_destroy(table, NULL); + } + + // fuzz test for Mergesort_increasing_smallest_azimuth function from sort.h + struct node head; + struct node tail; + Mergesort_increasing_smallest_azimuth(&head, &tail); + + // Fuzz test for functions from local_proto.h + float result = f_and(input, input, E); + result += f_or(input, input, E); + result += f_not(input, E); + + // Fuzz test for test_simulation.cpp + ret += test_calling_all_functions(); + + // Fuzz test for test_treatments.cpp + ret += test_steering(); + + return 0; +}