{"id":16837603,"url":"https://github.com/johntitor/ctest2","last_synced_at":"2025-04-04T13:12:13.751Z","repository":{"id":40370676,"uuid":"246708390","full_name":"JohnTitor/ctest2","owner":"JohnTitor","description":"Automatic testing of FFI bindings for Rust","archived":false,"fork":false,"pushed_at":"2024-10-23T17:19:31.000Z","size":1108,"stargazers_count":22,"open_issues_count":7,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-25T04:46:04.185Z","etag":null,"topics":["c","ffi","hacktoberfest","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ctest2","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnTitor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2020-03-12T00:29:41.000Z","updated_at":"2024-10-23T17:19:36.000Z","dependencies_parsed_at":"2024-06-25T20:43:21.810Z","dependency_job_id":"7bea8565-4df3-45b4-aa33-11a54f0d46b8","html_url":"https://github.com/JohnTitor/ctest2","commit_stats":{"total_commits":256,"total_committers":40,"mean_commits":6.4,"dds":0.70703125,"last_synced_commit":"8b45e124f84333d09f4f7142bd45eda72b504bd0"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnTitor%2Fctest2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnTitor%2Fctest2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnTitor%2Fctest2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnTitor%2Fctest2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnTitor","download_url":"https://codeload.github.com/JohnTitor/ctest2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182401,"owners_count":20897381,"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","ffi","hacktoberfest","rust"],"created_at":"2024-10-13T12:18:00.466Z","updated_at":"2025-04-04T13:12:13.731Z","avatar_url":"https://github.com/JohnTitor.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ctest2\n\n[Documentation][dox]\n\n[dox]: https://docs.rs/ctest2\n\n**Note: This is a fork of [`ctest`], intended as a temporary replacement until maintenance of [`ctest`] resumes.**\n\n[`ctest`]: https://crates.io/crates/ctest\n\nAutomated testing of FFI bindings in Rust. This repository is intended to\nvalidate the `*-sys` crates that can be found on crates.io to ensure that the\nAPIs in Rust match the APIs defined in C.\n\n## MSRV (Minimum Supported Rust Version)\n\nThe MSRV is 1.63.0 because of the transitive dependencies.\nNote that MSRV may be changed anytime by dependencies.\n\n## Example\n\nUnfortunately the usage today is a little wonky, but to use this library, first,\ncreate a new Cargo project in your repo:\n\n```\n$ cargo new --bin systest\n```\n\nThen, edit `systest/Cargo.toml` to add these dependencies:\n\n```toml\n[package]\n# ...\nbuild = \"build.rs\"\n\n[dependencies]\nmylib-sys = { path = \"../mylib-sys\" }\nlibc = \"0.2\"\n\n[build-dependencies]\nctest2 = \"0.4\"\n```\n\nNext, add a build script to `systest/build.rs`:\n\n```rust\nfn main() {\n    let mut cfg = ctest2::TestGenerator::new();\n\n    // Include the header files where the C APIs are defined\n    cfg.header(\"foo.h\")\n       .header(\"bar.h\");\n\n    // Include the directory where the header files are defined\n    cfg.include(\"path/to/include\");\n\n    // Generate the tests, passing the path to the `*-sys` library as well as\n    // the module to generate.\n    cfg.generate(\"../mylib-sys/lib.rs\", \"all.rs\");\n}\n```\n\nNext, add this to `src/main.rs`\n\n```rust\n#![allow(bad_style)]\n\nuse libc::*;\nuse mylib_sys::*;\n\ninclude!(concat!(env!(\"OUT_DIR\"), \"/all.rs\"));\n```\n\nAnd you're good to go! To run the tests execute `cargo run` in the `systest`\ndirectory, and everything should be kicked into action!\n\n## How it works\n\nThis library will parse the `*-sys` crate to learn about all extern fn\ndefinitions within. It will then generate a test suite to ensure that all\nfunction function signatures, constant values, struct layout/alignment, type\nsize/alignment, etc, all match their C equivalent.\n\nThe generated tests come in two forms. One is a Rust file which contains the\n`main` function (hence the `include!` above), and another is a C file which is\ncompiled as part of the build script. The C file is what includes all headers\nand returns information about the C side of things (which is validated in Rust).\n\nA large amount of configuration can be applied to how the C file is generated,\nyou can browse [the documentation][dox].\n\n## Projects using ctest2\n\n- [libc](https://github.com/rust-lang/libc)\n- [libz-sys](https://github.com/rust-lang/libz-sys)\n\n## License\n\nThis project is licensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n  https://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or\n  https://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in ctest2 by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohntitor%2Fctest2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohntitor%2Fctest2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohntitor%2Fctest2/lists"}