libbpf-rs icon indicating copy to clipboard operation
libbpf-rs copied to clipboard

Can't build libbpf-cargo with tests in distributions because vmlinux crate is not published

Open michel-slm opened this issue 1 year ago • 2 comments

This commit removes the bundled vmlinux.h and moves some code from src/test.rs to a standalone crate - but that crate is never published.

https://github.com/libbpf/libbpf-rs/commit/44292ae585617ac5fedd54fe6753420a99344a34

Even disabling tests does not work as the test code would just fail to compile - and deleting the test file also does not work cleanly because there is a reference to the test module from src/lib.rs

error[E0433]: failed to resolve: use of undeclared crate or module `vmlinux`                                               
   --> src/test.rs:125:20
    |                                                                     
125 |         .write_all(vmlinux::VMLINUX)                   
    |                    ^^^^^^^ use of undeclared crate or module `vmlinux`                  
                                                                                                                                                     
For more information about this error, try `rustc --explain E0433`.
error: could not compile `libbpf-cargo` (lib test) due to 1 previous error 

michel-slm avatar May 20 '24 12:05 michel-slm

That commit still reverts cleanly, though I had to disable one test (test::test_btf_dump_definition_struct_ops_mixed)

https://src.fedoraproject.org/rpms/rust-libbpf-cargo/c/a440b56238bce2589c3d92939037cd3fc51e21d1?branch=rawhide

michel-slm avatar May 20 '24 12:05 michel-slm

Yeah, if you want to run the tests you should check out the source code. There is no guarantee that published bundles can be tested. Is that a requirement for you @michel-slm ?

danielocfb avatar May 20 '24 16:05 danielocfb

We're OK skipping tests that require unshipped fixtures - but a module import is harder to deal with. I guess worst case I'll ship a snapshot of the vmlinux folder though

Per the separate conversation we have for a different crate, generally in distributions we do want to run tests because we compile on architectures that upstreams often don't test for, and potentially different optimization flags and dependency versions.

michel-slm avatar Sep 13 '24 21:09 michel-slm

Yeah, but as I mentioned in that separate conversation crates.io published packages are not guaranteed to be testable. If you want to run the test suite then check out the source code and do it there.

I am not aware of any official guidance, but from a brief glance, here are a bunch of references seemingly coming to this conclusion or implying the same: [0] [1] [2] [3]

d-e-s-o avatar Sep 16 '24 19:09 d-e-s-o