Git Product home page Git Product logo

ctest2's Introduction

ctest2

Documentation

Note: This is a fork of ctest, intended as a temporary replacement until maintenance of ctest resumes.

Automated testing of FFI bindings in Rust. This repository is intended to validate the *-sys crates that can be found on crates.io to ensure that the APIs in Rust match the APIs defined in C.

MSRV (Minimum Supported Rust Version)

The MSRV is 1.63.0 because of the transitive dependencies. Note that MSRV may be changed anytime by dependencies.

Example

Unfortunately the usage today is a little wonky, but to use this library, first, create a new Cargo project in your repo:

$ cargo new --bin systest

Then, edit systest/Cargo.toml to add these dependencies:

[package]
# ...
build = "build.rs"

[dependencies]
mylib-sys = { path = "../mylib-sys" }
libc = "0.2"

[build-dependencies]
ctest2 = "0.4"

Next, add a build script to systest/build.rs:

fn main() {
    let mut cfg = ctest2::TestGenerator::new();

    // Include the header files where the C APIs are defined
    cfg.header("foo.h")
       .header("bar.h");

    // Include the directory where the header files are defined
    cfg.include("path/to/include");

    // Generate the tests, passing the path to the `*-sys` library as well as
    // the module to generate.
    cfg.generate("../mylib-sys/lib.rs", "all.rs");
}

Next, add this to src/main.rs

#![allow(bad_style)]

use libc::*;
use mylib_sys::*;

include!(concat!(env!("OUT_DIR"), "/all.rs"));

And you're good to go! To run the tests execute cargo run in the systest directory, and everything should be kicked into action!

How it works

This library will parse the *-sys crate to learn about all extern fn definitions within. It will then generate a test suite to ensure that all function function signatures, constant values, struct layout/alignment, type size/alignment, etc, all match their C equivalent.

The generated tests come in two forms. One is a Rust file which contains the main function (hence the include! above), and another is a C file which is compiled as part of the build script. The C file is what includes all headers and returns information about the C side of things (which is validated in Rust).

A large amount of configuration can be applied to how the C file is generated, you can browse the documentation.

Projects using ctest2

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ctest2 by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

ctest2's People

Contributors

alexcrichton avatar bgermann avatar bzeq avatar cactorium avatar flba-eb avatar glandium avatar gnzlbg avatar guillaumegomez avatar jackpot51 avatar jessicah avatar jnqnfe avatar johnschug avatar johntitor avatar joshtriplett avatar lu-zero avatar malbarbo avatar mati865 avatar mneumann avatar nielx avatar petrochenkov avatar pfmooney avatar posborne avatar robinst avatar samkearney avatar semarie avatar sfackler avatar spl avatar tbu- avatar wesleywiser avatar zhaixiaojuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ctest2's Issues

offset_of assumes structure can be zero-initialized

The fix for #23 (in PR #24) calls mem::zeroed() to create a zero-initialized version of a structure. However, not all structures can be safely zero-initialized.

I discovered this when attempting to update libz-sys to ctest2 0.4.3 to get the fix for #23. One of the structures contained function pointers, which couldn't be zero-initialized, and this resulted in a pile of warnings as well as a runtime panic.

Rebuilding `ctest2` as part of GSoC Project Proposal.

I am interested in working on modernizing the libc crate as part of the projects from GSoC this year and it contained a point of either rebuilding the ctest2 crate or using an alternative like bindgen. I am intrigued by this particular aspect of the project and I'd like to include it in my project proposal as something to work on.
To do that though, I'll need to have at least a working knowledge of ctest2, its faults, and what can be improved upon. I have been able to read the code and understand it as well as the sparse documentation provided, but I'll still need some insight from you since you wrote it and @Amanieu mentioned you'll be the best point of contact on this subject matter.
I'd be glad if we could have a call to go through this as the deadline for the project proposal is this Friday.
Thanks.

GNU-related tests are failing

GNU-related tests are failing with the following failure:

 error: could not compile `testcrate` due to previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcCZ2hXI/symbols.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.18mywkt3d4h515zs.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1d1gbaxx4rg49vbk.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1eqyaoamn3jo7vfj.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1fykttgmx59ikokk.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1gcpr3z6afyqjs74.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1l5yp1g3jj2jy5bd.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1mrbqkn288cmc1qs.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1ok8qudrohhaqocm.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1qq6z3ra2x3ofnbs.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1siuajpq29jfuzag.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1tmnyahvbudtxhm2.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1x8hakvhijdyoyux.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.20xecbjcsh5n4mye.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.25875o6dgns5wb8m.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.25rkcvghnnv16bl9.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.28yymgfvgrg79atm.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2b4r2i7ix6609wcc.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2ikootra5g0es717.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2mxt07fas8rlm4xk.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2o3juxqfdu9f5skc.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2p14gd28q17o5z9p.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2si2alhnvwas6ieo.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2w5yqtptw93cbb8e.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2yv7p5xvrkcu53uw.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.2zgn3bxfcsw285f5.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.31c0uijjhg9lriyd.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.33tvwzho8e1xdpmw.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.34b27menq29pm5jn.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.37zg08vyp2sulaxk.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3hq5o6r4xmvltct8.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3ktwxretbab9d1qz.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3lm1d3bo9is5azjc.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3rgr1kczctpzh488.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3tx02yf27rjmhdub.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3vebnxab5oksbfgw.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3x4pn75xku4698fp.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.3z4gwj9gcylzxv0q.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.458hi8ke748ei3fy.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.46bkcyg3ykjuwjm4.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.497w46j5sh0lp7fs.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.49e8zp7ubffoeies.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4hue4fqjxro9h19.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4kp9y7bguyd2sqap.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4lqukl3r6q8liie2.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4mps9j6xiendwzta.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4wv110qn1rmh638i.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.4zye6syc16jbc2ha.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.50vcce4dmov1sxej.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.5303jys2xpe0csg6.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.53wbhdc90c69xpaf.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.53y8r5i7i9qpzlv5.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.58hxi5fqgl3966dm.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.5d2cwt4wuenm968x.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.5d7qvo2o6e1bv9ce.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.6zxmaas5abzp09t.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.9sn5maqusy2ca6b.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.9tsg2qhawlh6x2o.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.hzfvbtkbzmfl44a.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.k5f6lnxw98p08re.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.la8xafkmi0g8e1k.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.ozkhdh9hqykror2.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.tldz0j37d3f0p0p.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.zmevim0vejq98j3.rcgu.o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9.1owklwvnb2d52hiw.rcgu.o" "-Wl,--as-needed" "-L" "/home/runner/work/ctest2/ctest2/target/debug/deps" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/work/ctest2/ctest2/target/debug/build/testcrate-3de52bf284381420/out" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib" "/home/runner/work/ctest2/ctest2/target/debug/deps/liblibc-9f42add3d53c8284.rlib" "-Wl,--start-group" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5670385a2fe8b60b.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-fd56ba6dbf7aaecc.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-b8acf8e5c2e85baa.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-1706edefffdca0a2.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-f483302e0b13708e.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-725b0718fc18e1ed.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-de685fcf2157e6fb.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-f613ac3eda05b9ff.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-3de98a7d049af6a1.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-c12183655bdce152.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-0fc7beea925de7e3.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-8c34825485bf59dc.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-ba5f7e926e729d81.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-643de0950163a839.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-539ea2f72ef89687.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-871432094bb4c885.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-ef1a8ee61f2e39bf.rlib" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f1646747442c1c7b.rlib" "-Wl,--end-group" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ff283b4bf550fa1c.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/runner/work/ctest2/ctest2/target/debug/deps/t1-65d5a8236da74ce9" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:65: multiple definition of `T1_static_mut_u8'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:65: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:66: multiple definition of `T1_static_mut_fn_ptr'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:66: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:72: multiple definition of `T1_static_right2'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:72: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:77: multiple definition of `T1_fn_ptr_s'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:77: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:82: multiple definition of `T1_fn_ptr_s2'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:82: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:101: multiple definition of `T1_opt_fn2'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:101: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:102: multiple definition of `T1_opt_fn3'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:102: first defined here
          /usr/bin/ld: /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1gen.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:157: multiple definition of `T1_fn_ptr_vol'; /home/runner/work/ctest2/ctest2/target/debug/deps/libtestcrate-e0b72bb35e4f5015.rlib(t1.o):/home/runner/work/ctest2/ctest2/testcrate/src/t1.h:157: first defined here
          collect2: error: ld returned 1 exit status
          

error: could not compile `testcrate` due to previous error

I'm totally not sure what happens, but the issue could be on the testcrate itself as libc-test passes fine.
This happens since we updated CI image to ubuntu-22.04, so I suspect that a newer glibc is related.

Fails to parse `_` as a const identifier

  error: expected identifier, found `_`
     --> ../src/fixed_width_ints.rs:64:23
      |
  64  |                   const _: [(); $a] = [(); $b];

ctest2 needs to be using a parsing library that can handle newer Rust.

CTest uses syntex_syntax which doesn't support raw identifiers.

CTest fails on code that uses raw identifiers like r#type. Currently libc translation of structs that have a type field in c are translated as type_ because of that.

If CTest would support raw identifiers we could accurately use type as a field name in rust too.

"this is a fork repo" text is somewhat confusing on crates.io page

I discovered ctest2 on crates.io and I'm about to try it out. The readme text "Note: This is a fork repository and we intend to use this in libc-test only." is somewhat confusing appearing on the crates.io page.

  1. Firstly, from the crates.io perspective the page is not a repo so the sentence is not appropriate.
  2. Secondly, it's not really obvious who "we" is. Perhaps better to say "... and intended for use with libc-test ..."
  3. Thirdly, I failed to find anywhere what the purpose is of the existence of ctest2 over ctest. Although the text states only for libc-test, it's at the same time been published to crates.io with all the hallmarks of superseding the original (larger version number, '2' postfix to name). I'm sure that you can understand the confusion that causes; I'm looking into trying ctest/ctest2 for my own FFI crates and I'm left really not knowing which to actually use. Is the original broken currently and you were fed waiting for it to be fixed?

offset_of! triggers the deref_nullptr lint on nightly

error: dereferencing a null pointer
    --> /home/runner/work/rstack/rstack/target/aarch64-unknown-linux-gnu/debug/build/unwind-systest-b23fd082cb870172/out/all.rs:54:24
     |
54   |                     (&((*(0 as *const $ty)).$field)) as *const _ as u64
     |                        ^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed
...
2685 |                     same(offset_of!(unw_cursor_t, opaque),
     |                          -------------------------------- in this macro invocation
     |
     = note: `-D deref-nullptr` implied by `-D warnings`
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

https://github.com/sfackler/rstack/runs/2462078365?check_suite_focus=true

2018 edition support?

Hi, I'm attempting to use ctest2 with a -sys crate that uses edition = "2018", however it looks like that may be unsupported?

The proximate errors I'm seeing are:

error: expected identifier, found keyword crate

I suspect adding new edition support is non-trivial, but I figured I should ask. If adding it is too difficult, it may be worth documenting.

Can't parse macro-processed extern "C" block

Given a macro which processes extern C functions:

macro_rules! some_macro {
    (extern "C" { $($i:item)* }) => ( extern "C" { $($i)* });
}

And code invoking it:

some_macro! {
    extern "C" {
        pub fn func(arg: c_int) -> c_int;
    }
}

systest will fail to parse this, emitting an error like this:

  error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found `;`
     --> ../src/lib.rs:120:82
      |
  118 | / some_macro! {
  119 | |     extern "C" {
  120 | |         pub fn func(arg: c_int) -> c_int;
      | |                                         ^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` here

If I modify the macro and invocation to go inside the extern "C" block rather than outside it, I instead get an internal compiler error:

  error: internal compiler error: Error constructed but not emitted

  thread 'main' panicked at 'explicit panic', /path/to/.cargo/registry/src/github.com-1ecc6299db9ec823/garando_errors-0.1.0/src/diagnostic_builder.rs:190:13

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.