{"id":20512635,"url":"https://github.com/db7/mockoto","last_synced_at":"2026-04-21T19:05:27.951Z","repository":{"id":213264596,"uuid":"712776287","full_name":"db7/mockoto","owner":"db7","description":"Simple C mock generator with Racket bindings","archived":false,"fork":false,"pushed_at":"2024-04-26T17:54:35.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T18:53:27.077Z","etag":null,"topics":["c-language","mock","racket-lang","testing"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/db7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2023-11-01T07:01:45.000Z","updated_at":"2024-04-26T17:54:40.000Z","dependencies_parsed_at":"2023-12-22T10:25:12.572Z","dependency_job_id":"d0fc9cc2-7037-4deb-a39e-6a53a3492f65","html_url":"https://github.com/db7/mockoto","commit_stats":null,"previous_names":["db7/mockoto"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/db7%2Fmockoto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/db7%2Fmockoto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/db7%2Fmockoto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/db7%2Fmockoto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/db7","download_url":"https://codeload.github.com/db7/mockoto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242117657,"owners_count":20074435,"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":["c-language","mock","racket-lang","testing"],"created_at":"2024-11-15T20:42:12.683Z","updated_at":"2026-04-21T19:05:27.942Z","avatar_url":"https://github.com/db7.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mockoto - C mock and FFI binding generator\n\nMockoto is a tool help the testing of C code with [Racket][] or\n[Chibi Scheme][].\n\nMockoto generates simple mock functions for C prototypes.\nThese mock functions do not do anything by default, but can be ajusted\nconforming the desired test case.\nMockoto also generates Racket and Chibi Scheme bindings to all related types\nand hook functions. In this way, one can write test cases and mock code in\nRacket or Chibi Scheme for C code.\n\n[Racket]: https://racket-lang.org\n[Chibi Scheme]: https://github.com/ashinn/chibi-scheme\n\n## Building\n\nEnsure your system have these packages installed:\n- cmake\n- clang\n- libclang-dev\n- xxd\n\nThat should be sufficient to compile Mockoto, but if you want to write test\ncases in Racket you, of course, also need Racket installed.\n\nTo build Mockoto run:\n\n\tcd mockoto\n\tcmake -S . -B build\n\tmake -j\n\nYou should now have the executable `build/mockoto`, which can be installed in\nyour `PATH`.\n\n## Usage\n\n    mockoto --mode C header.h another.h \u003e mock_code.c\n    mockoto --mode H header.h another.h \u003e mock_code.h\n    mockoto --mode rkt header.h another.h \u003e bindings.rkt\n    mockoto --mode chibi header.h another.h \u003e bindings.stub\n    mockoto -V\n    mockoto --include-static --mode chibi header.h \u003e bindings-with-static.stub\n\nYour test case can be compiled with `mock_code.c`.  If you want to adapt the\nmock code from C, you can include `mock_code.h` and use the respective\nfunctions.\n\nFor a function `foo` declared in the given header file, the following functions\nare available:\n\n    // This is the mock foo function, which does nothing by default.\n    // The return value is a 0-ed value of the return type.\n    retType foo(paramType ...);\n\n    // Returns the number of times foo was called.\n    // The counter resets once this function is called.\n    int mockoto_foo_called(void);\n\n    // Sets a different return value for foo in case foo has a return type\n    void mockoto_foo_returns(retType r);\n\n    // Sets a callback with the same signature as foo.\n    // Whenever foo is called, the callback will be called and its return value will be used\n    // instead of the default value of the mock.\n    void mockoto_foo_hook(mockoto_foo_f cb);\n\n\nWith `bindings.rkt` you have access to the mock from Racket. Here is the `foo`\nexample:\n\n    #lang racket\n    (require rackunit\n             \"bindings.rkt\")\n    (load-lib \"libmock_code.so\")\n    (mock foo\n      (lambda (param0 param1 ...)\n        ;; do something\n        ;; return the desired value\n        some-value))\n    (check-equal? (call foo ...) some-value)\n\nSee [example](example) for a running example.\n\nFor `--mode chibi`, the generated `.stub` can be compiled with `chibi-ffi`:\n\n    chibi-ffi -c bindings.stub\n\nBy default, static functions are skipped. Use `--include-static` to include\nthem in generated output.\n\n## Mockoto Limitations\n\n- no support for varargs\n- assumes enums and structs have unique names\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdb7%2Fmockoto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdb7%2Fmockoto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdb7%2Fmockoto/lists"}