{"id":25090793,"url":"https://github.com/san7o/valfuzz","last_synced_at":"2025-04-01T19:34:14.371Z","repository":{"id":257278798,"uuid":"857780746","full_name":"San7o/valFuzz","owner":"San7o","description":"valFuzz (or val-di-Fuzz) is a modern cross-platform, multi-threaded testing, fuzzing and benchmarking library for C++23.","archived":false,"fork":false,"pushed_at":"2024-10-16T06:23:21.000Z","size":178,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-17T20:48:50.515Z","etag":null,"topics":["fuzzer","modern-cpp","testing"],"latest_commit_sha":null,"homepage":"https://san7o.github.io/brenta-engine-documentation/valfuzz/v1.0/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/San7o.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-15T15:42:14.000Z","updated_at":"2024-10-16T05:54:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"5972a954-4ed7-4324-831f-5fda0af04bee","html_url":"https://github.com/San7o/valFuzz","commit_stats":null,"previous_names":["san7o/valfuzz"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/San7o%2FvalFuzz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/San7o%2FvalFuzz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/San7o%2FvalFuzz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/San7o%2FvalFuzz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/San7o","download_url":"https://codeload.github.com/San7o/valFuzz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246701144,"owners_count":20820004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fuzzer","modern-cpp","testing"],"created_at":"2025-02-07T12:32:03.844Z","updated_at":"2025-04-01T19:34:14.351Z","avatar_url":"https://github.com/San7o.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n             _ _____\n __   ____ _| |  ___|   _ ________\n \\ \\ / / _` | | |_ | | | |_  /_  /\n  \\ V / (_| | |  _|| |_| |/ / / /\n   \\_/ \\__,_|_|_|   \\__,_/___/___|\n\nA modern testing \u0026 fuzzing library for C++\nSettings:\n - Multithreaded: true\n - Max threads: 4\n - Verbose: true\n - Reporter: default\n\nSeed: 1726579491\nRunning 1337 tests...\n```\n\nvalFuzz (or val-di-Fuzz) is a modern cross-platform testing,\nfuzzing and benchmarking library for C++17/20/23.\nCheck out [tests](./tests) for some examples on how to use\nthis library, or read the online documentation\n[here](https://san7o.github.io/brenta-engine-documentation/valfuzz/v1.0/).\n\n\u003e valFuzz is the official testing library for [Brenta Engine](https://github.com/San7o/Brenta-Engine).\n\n# Usage\n```\nUsage: valfuzz [options]\nOptions:\n\n TESTS\n  --test \u003cname\u003e: run a specific test\n  --no-multithread: run tests in a single thread\n  --max-threads \u003cnum\u003e: set the maximum number of threads\n\n FUZZING\n  --fuzz: run fuzz tests\n  --fuzz-one \u003cname\u003e: run a specific fuzz test\n\n BENCHMARK\n  --benchmark: run benchmarks\n  --num-iterations \u003cnum\u003e: set the number of iterations for benchmarks\n  --run-one-benchmark \u003cname\u003e: run a specific benchmark\n  --report \u003cfile\u003e: save benchmark results to a file\n  --reporter \u003cname\u003e: use a custom reporter, currently supported\n                     are default, csv, none\n\n GENERAL\n  --verbose: print test names\n  --no-header: do not print the header at the start\n  --seed \u003cseed\u003e: set the seed for PRNG\n  --help: print this help message\n```\n\n## Compile shared library\n\n### cmake\n\n```bash\ncmake -Bbuild -DCMAKE_BUILD_TYPE=Release\ncmake --build build -j 4\n```\n\n### bazel\n```\nbazel build //:libvalfuzz\n```\n\n### cpm\nYou can easily use [cpm](https://github.com/cpm-cmake/CPM.cmake) to include\nthe library in your project.\n```\nCPMAddPackage(\n    NAME valfuzz\n    GITHUB_REPOSITORY San7o/valFuzz\n    GIT_TAG v1.1.0\n    DOWNLOAD_ONLY True\n)\n```\n\n### meson\n```\n[wrap-git]\nurl = https://github.com/San7o/valFuzz\nrevision = v1.1.0\ndepth = 1\n```\n\n# Documentation\nYou can read a comprehensive documentation\n[here](https://san7o.github.io/brenta-engine-documentation/valfuzz/v1.0/).\nHere is presented a quick guide to showcase the library's api.\n\n## Run tests\nYou can run a test by defining it with the `TEST` macro:\n```c++\n#include \"valfuzz/valfuzz.hpp\"\n\nTEST(simple, \"Simple Assertion\") {\n    ASSERT(1 == 2);\n}\n```\n```\ntest: Simple Assertion, line: 3, Assertion failed: 1 != 2\n```\n\nThe library already contains a main so you just need to\ndefine the tests with `TEST`, the first argument is the\ntest name, the second one is the name that will be\ndisplayed in the output when an assertion on the test\nfails.\n\n## Run a single test\n\nIf you want, you can run a specific test by passing\nIts name to `--test` argument:\n```bash\n./build/asserts_test --test \"Simple Assertion\"\n```\n\n## Execute before and after all\nYou can set a function to be executed either before or after\nall the tests with the macro `BEFORE()` and `AFTER()`:\n```c++\nBEFORE() {\n    std::cout \u003c\u003c \"Before test\" \u003c\u003c std::endl;\n}\n\nAFTER() {\n    std::cout \u003c\u003c \"After test\" \u003c\u003c std::endl;\n}\n\nTEST(a_test, \"Another simple test\") {\n    ASSERT_EQ(1, 1);\n}\n```\n\n## Fuzzing\nYou can set up a fuzz test using the `FUZZME` macro, specifying\nan unique fuzz name and a string name:\n```c++\nFUZZME(simple_fuzzing, \"Simple fuzzing\")\n{\n    int a = valfuzz::get_random\u003cint\u003e();\n    int b = valfuzz::get_random\u003cint\u003e();\n    int ret = sum_int(a, b);\n    ASSERT_EQ(ret, a + b);\n}\n```\nand use the `get_random\u003cT\u003e()` function to get a random\nvalue of `T` type. Fuzz tests are executed continuously\nin a multithreaded environment (unless you specify \n`--no-multithread`) until you stop the program.\n\nYou can run with fuzzing by specifying `--fuzz`:\n```bash\n./build/asserts_test --fuzz\n```\n\nYou can also specify a specific fuzz test to fuzz:\n```bash\n./build/asserts_test --fuzz-one \"Simple fuzzing\"\n```\n```\nRunning fuzz test: Simple fuzzing\nIterations: 1000000\nIterations: 2000000\nIterations: 3000000\n...\n```\n\n## Benchmarks\n\nYou can define a benchmark function with the macro `BENCHMARK`.\nInside the benchmark, you can do any setup / cleanup and run\nan expression to be benchmarked with `BENCHMARK_RUN(space, expr)`.\nThe first argument is gonna be the space complecity, this will be used to \nproduce a report, the second argument is the expression that will\nbe evaluated. You can specify a reporter or provide one your\nown since It very easy. Yon can save the reports in a file via\n`--report \u003cfile\u003e`. If you didn't specify a report file, you\ncan set any value in the first argument.\n\n\u003e currently, the cache will be reset between benchmarks only on linux\n\nFor example:\n```c++\nint sum_slow(int a, int b)\n{\n    int sum = 0;\n    for (int i = 0; i \u003c a; i++)\n    {\n        sum += b;\n    }\n    return sum;\n}\n\nBENCHMARK(bench_sum_slow, \"Sum slow\")\n{\n    int a = 1000;\n    int b = 2000;\n    RUN_BENCHMARK(1, sum_slow(a, b));\n}\n```\n\nCompile and run with `--benchmark` flag:\n```bash\n./build/valfuzz --benchmark --verbose\n```\n```\nRunning benchmark: Sum slow\nbenchmark: \"Sum slow\"\n - space: 10000\n - min: 1.7114e-05s\n - max: 2.9317e-05s\n - mean: 1.94025e-05s\n - standard deviation: 1.63826e-06\n - Q1: 1.8365e-05s\n - Q3: 2.0794e-05s\n```\n\nThe benchmark will be run 10000 times by default. You\ncan set the number of iterations using the `--num-iterations` flag.\nIf you specified `--reporter csv`, a csv output will be generated\nwith the following structure:\n```\nbenchmark_name,space_complexity,min_time,max_time,mean,standard_deviation,quantile1,quantile3\n```\nYou can quickly generate a graph with python by following the instructions\nin [plotting/README.md](plotting/README.md).\n\n![image](https://github.com/user-attachments/assets/0cae5078-2bf3-481d-a2e8-b822f2918bfb)\n\n\n# License\n\nThis library falls under [MIT](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsan7o%2Fvalfuzz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsan7o%2Fvalfuzz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsan7o%2Fvalfuzz/lists"}