From 518666e2f4ce8300f7fb63c0686e67bac4296b6e Mon Sep 17 00:00:00 2001 From: Christopher Krah Date: Tue, 14 May 2024 15:32:08 +0400 Subject: [PATCH] feat: add simple fuzz testing for parsers --- src/fuzz-testing/__init__.py | 0 src/fuzz-testing/nmea_fuzzer.py | 18 ++++++++++++++++++ src/fuzz-testing/rtcm_fuzzer.py | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/fuzz-testing/__init__.py create mode 100644 src/fuzz-testing/nmea_fuzzer.py create mode 100644 src/fuzz-testing/rtcm_fuzzer.py diff --git a/src/fuzz-testing/__init__.py b/src/fuzz-testing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/fuzz-testing/nmea_fuzzer.py b/src/fuzz-testing/nmea_fuzzer.py new file mode 100644 index 0000000..51d7a43 --- /dev/null +++ b/src/fuzz-testing/nmea_fuzzer.py @@ -0,0 +1,18 @@ +try: + import atheris +except ImportError: + raise ImportError("You need to install atheris to run this script.") +import sys + +with atheris.instrument_imports(): + from ..ntrip_client.nmea_parser import NMEAParser + + +def TestOneInput(data): + parser = NMEAParser() + parser.is_valid_sentence(data) + + +atheris.Setup(sys.argv, TestOneInput) +atheris.Fuzz() + diff --git a/src/fuzz-testing/rtcm_fuzzer.py b/src/fuzz-testing/rtcm_fuzzer.py new file mode 100644 index 0000000..540cd8c --- /dev/null +++ b/src/fuzz-testing/rtcm_fuzzer.py @@ -0,0 +1,18 @@ +try: + import atheris +except ImportError: + raise ImportError("You need to install atheris to run this script.") +import sys + +with atheris.instrument_imports(): + from ..ntrip_client.rtcm_parser import RTCMParser + + +def TestOneInput(data): + parser = RTCMParser() + parser.parse(data) + + +atheris.Setup(sys.argv, TestOneInput) +atheris.Fuzz() +