Integration tests should only run when compiled via the xtask command.
To achieve this, we introduce a custom `cfg` that removes the `test`
attribute when the code is compiled via regular `cargo test`.
The `no_std` and `no_main` attributes are only needed when we compile
the eBPF kernels for the "bpf" architecture. By feature-gating them on
the target architecture, we ensure the kernels compile just fine on a
host-architecture like x64. They won't be able to do anything
meaningfully but it is useful within the context of the larger workspace
they are embedded in as it allows `cargo build --workspace` and `cargo
test --workspace` to just work.
We have previously tried to import traits anonymously where possible but
enforcing this manually was hard.
Since Rust 1.83 clippy can now enforce this for us.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
The init module contains a small init system for running our integration
tests against a kernel. While we don't need a full-blown linux distro,
we do need some utilities.
Once such utility is `modprobe` which allows us to load kernel modules.
Rather than create a new module for this utility, I've instead
refactored `init` into `test-distro` which is a module that contains
multiple binaries.
The xtask code has been adjusted to ensure these binaries are inserted
into the correct places in our cpio archive, as well as bringing in the
kernel modules.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Rather than emitting a warning, assert the inverse of the condition when
the current kernel version is lower than required. This strengthens the
assertions made by our tests (provided we run them over kernel versions
before and after the listed version, which is not yet the case).
Limit of map names in eBPF is 16 bytes and they have to be NULL
terminated.
Before this change, long names were truncated to 16 bytes.
`MAP_WITH_LOOOONG_NAAAAAAAAME` would become `MAP_WITH_LOOOONG`, which
doesn't contain the NULL byte.
This change fixes that by truncating the name to 15 bytes, ensuring
that the 16th byte is NULL. `MAP_WITH_LOOOONG_NAAAAAAAAME` is truncated
to `MAP_WITH_LOOOON\0`.
In practice this will forbid unused dependencies because we run clippy
with `--deny warnings`.
Workspace lints is a nice place to ratchet up lints through the codebase
all at once and consistently.
Merging via comment isn't possible. We could merge this automatically on
green, however we'd prefer to use @dependabot merge or merge manually.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
- Document the need for external rustfmt invocation.
- Remove reexports.
- Remove `write_to_file`.
- Avoid allocating strings when using bindgen to write bindings.
Turns out this was actually being used through magic.
Remove mips since it is a tier 3 target that is only supported on
nightly and dtolnay/rust-toolchain doesn't seem to handle installing
targets without std.
Exclude xtask since it depends on `ring` which doesn't build on all
targets.
Fix compilation on armv7 which had rotted.
This reverts commit d92fc95c39.
This can be done externally. Do so in CI.
This is an attempt to resolve the inconsistency between CI and local
rustfmt in the generated bindings.
Restore running CI on generated branches; the presence of a PR is
apparently not enough.
Change FromRawTracepointArgs::arg to return T rather than *const T which
seems to have been returning a dangling pointer.
Arguably this is not strictly necessary; edition 2024 seems to be
focused on increased strictness around unsafe code which doesn't unlock
new functionality for our users. That said, this work revealed an
apparent bug (see above) that we wouldn't otherwise catch due to
allow-by-default lints.