package
0.0.0-20240824050318-b1dc25b147ec
Repository: https://github.com/vkumbhar94/golang.git
Documentation: pkg.go.dev

# README

Fuzz Testing

Introduction

Fuzz testing helps to run the program with random inputs to find the bugs in the program. It is also known as fuzzing. Fuzz testing is a software testing technique that provides invalid, unexpected, or random data to the inputs of a computer program. The program is then monitored for exceptions such as crashes, failing built-in code assertions, or potential memory leaks. Fuzz testing is commonly used to test for security problems in software or computer systems.

Fuzz Testing in Go

Go has a built-in package testing/fuzz that provides a framework for fuzz testing. The testing/fuzz package provides a way to generate random data for testing. The fuzz package provides a Fuzz function that takes a function as an argument and generates random data to test the function. The Fuzz function generates random data and calls the function with the generated data. The Fuzz function is used to test the function with random data.

two types of fuzz testing

  • Fuzzing a single function: In this type of fuzz testing, we test a single function with random data. We provide a function to the Fuzz function, and the Fuzz function generates random data and calls the function with the generated data.
  • Fuzzing a package: In this type of fuzz testing, we test a package with random data. We provide a package to the Fuzz function, and the Fuzz function generates random data and calls the exported functions of the package with the generated data.
  • Fuzzing a package with a custom fuzzer: In this type of fuzz testing, we test a package with random data generated by a custom fuzzer. We provide a package and a custom fuzzer to the Fuzz function, and the Fuzz function calls the exported functions of the package with the generated data.

Two areas where fuzz testing is useful

Differencial fuzzing

Differential fuzzing is a fuzz testing technique that compares the output of two different implementations of the same function. Differential fuzzing is useful for finding bugs in the implementation of a function. Differential fuzzing is used to compare the output of two different implementations of the same function and find the differences between the outputs. Differential fuzzing is useful for finding bugs in the implementation of a function.

Round trip fuzzing

Round trip fuzzing is a fuzz testing technique that tests the serialization and deserialization of data. Round trip fuzzing is useful for finding bugs in the serialization and deserialization of data. Round trip fuzzing is used to test the serialization and deserialization of data and find bugs in the implementation of the serialization and deserialization functions.

References