{"id":21066374,"url":"https://github.com/code-disaster/fips-munit","last_synced_at":"2025-12-29T21:39:03.646Z","repository":{"id":80772520,"uuid":"110805662","full_name":"code-disaster/fips-munit","owner":"code-disaster","description":"fipsified µunit (https://github.com/nemequ/munit)","archived":false,"fork":false,"pushed_at":"2019-02-07T21:20:07.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T21:13:53.251Z","etag":null,"topics":["fips"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-disaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-11-15T08:26:32.000Z","updated_at":"2019-02-07T21:20:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b7d9e0d-e2e8-40b4-a72b-bdbe38ad5b73","html_url":"https://github.com/code-disaster/fips-munit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-disaster%2Ffips-munit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-disaster%2Ffips-munit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-disaster%2Ffips-munit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-disaster%2Ffips-munit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-disaster","download_url":"https://codeload.github.com/code-disaster/fips-munit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243510121,"owners_count":20302294,"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":["fips"],"created_at":"2024-11-19T17:59:29.436Z","updated_at":"2025-12-29T21:38:58.627Z","avatar_url":"https://github.com/code-disaster.png","language":"Python","readme":"fips-munit\n==========\n\nA fipsified version of **µunit** (https://github.com/nemequ/munit), a unit testing framework for C.\n\nfips build system: https://github.com/floooh/fips\n\n## Basic use\n\nTo use µunit directly, just include `\u003cmunit/munit.h\u003e`. Refer to the [µunit documentation](https://nemequ.github.io/munit/) for more information.\n\n## Code generation\n\nfips-munit defines a small set of CMake and C macros, which utilize fips' code generation facilities for easier integration of unit tests into your code base.\n\nIn the following example, assume that we want to run some unit tests defined in `my_code.c`, in a command line app `my_app`, with a test runner we call `my_tests`.\n\n\u003e Note: *work in progress*! Doesn't use some of µunits advanced features, like parameterized tests. Also, API might still change.\n\n### Source code\n\nFirst, implement unit tests in some of your source files.\n\n`my_code.c`:\n```\n/* also includes \u003cmunit/munit.h\u003e */\n#include \u003cmunit_macros.h\u003e\n\nstatic int some_func()\n{\n    /* ... test-worthy code ... */\n    return ...;\n}\n\n/* define some test */\nMUNIT_TEST(some_func_returns_one)\n{\n    munit_assert_int(some_func(), == , 1);\n}\n```\n\nThen, you just need to include and call the to-be-generated test runner somewhere in your application code.\n\n`my_app.c`:\n```\n/* auto-generated test runner (see below) */\n#include \"my_tests_runner.h\"\n\n/* entry function to run all tests */\nint main(int argc, char* argv[])\n{\n    return my_tests_main(argc, argv);\n}\n```\n\n### CMake\n\n```\nfips_begin_app(my_app cmdline)\n\n  fips_files(my_code.c my_app.c)\n\n  # define our test runner\n  fips_munit_begin(my_tests)\n    # files to parse for generating tests\n    fips_munit_files(my_code.c)\n  fips_munit_end()\n\n  # link static library\n  fips_deps(munit)\n\nfips_end_app()\n\n# optional: run my_app as post-build step\nfips_munit_run(my_app)\n```\n\n\u003e `fips_munit_begin(my_tests)`\n\nThis defines a new test runner, `my_tests`. Must be called inside a `fips_begin_*()/fips_end_*()` block, and must be followed by `fips_munit_end()`.\n\n\u003e `fips_munit_files([files]...)`\n\nAdds a set of source files to the test runner. These source files are scanned for `MUNIT_TEST()` macros to auto-generate unit tests from. Each of these source files defines one µunit test suite.\n\n\u003e `fips_munit_end()`\n\nThis macro finalizes the test runner started with `fips_munit_begin()`. It auto-generates a `my_tests_main()` function accessible through `my_tests_runner.h`, which by itself runs all known test suites.\n\n\u003e `fips_munit_run(my_app[, args...])`\n\nThis macro is just for convenience, and must be called *after* `fips_end_app()`. It adds a custom command to run `my_app` as a post-build step. You need to make sure yourself that `my_app`'s main() function then calls `my_tests_main()`.\n\n### Output\n\nIf used as described above, the following files will be generated:\n\n- `my_code_suite.c` with the auto-generated µunit test suite with all tests found in `my_code.c`\n- `my_code_suite.yml` which is used internally as input to generate the test runner\n- `my_tests_runner.c` and `my_tests_runner.h` with entry code to run all suites, one after another\n- `my_tests.yml` which is currently empty, but touched by each generated suite to trigger a recompile of the test runner\n\nThe post-build step output will look like this:\n\n```\n  Running test suite with seed 0x15534978...\n  /my_code/some_func_returns_one      [ OK    ] [ 0.000 / 0.000 CPU ]\n  1 of 1 (100%) tests successful, 0 (0%) test skipped.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-disaster%2Ffips-munit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-disaster%2Ffips-munit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-disaster%2Ffips-munit/lists"}