mirror of https://github.com/aya-rs/aya
Extract integration-common for shared types
parent
c5172def75
commit
e0c4948e36
@ -1,12 +1,20 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# `-C panic=abort` because "unwinding panics are not supported without std";
|
set -eux
|
||||||
# integration-ebpf contains `#[no_std]` binaries.
|
|
||||||
#
|
# We cannot run clippy over the whole workspace at once due to feature unification. Since both
|
||||||
|
# integration-test and integration-ebpf depend on integration-common and integration-test activates
|
||||||
|
# integration-common's aya dependency, we end up trying to compile the panic handler twice: once
|
||||||
|
# from the bpf program, and again from std via aya.
|
||||||
|
#
|
||||||
|
# `-C panic=abort` because "unwinding panics are not supported without std"; integration-ebpf
|
||||||
|
# contains `#[no_std]` binaries.
|
||||||
|
#
|
||||||
# `-Zpanic_abort_tests` because "building tests with panic=abort is not supported without
|
# `-Zpanic_abort_tests` because "building tests with panic=abort is not supported without
|
||||||
# `-Zpanic_abort_tests`"; Cargo does this automatically when panic=abort is set via profile
|
# `-Zpanic_abort_tests`"; Cargo does this automatically when panic=abort is set via profile but we
|
||||||
# but we want to preserve unwinding at runtime - here we are just running clippy so we don't
|
# want to preserve unwinding at runtime - here we are just running clippy so we don't care about
|
||||||
# care about unwinding behavior.
|
# unwinding behavior.
|
||||||
#
|
#
|
||||||
# `+nightly` because "the option `Z` is only accepted on the nightly compiler".
|
# `+nightly` because "the option `Z` is only accepted on the nightly compiler".
|
||||||
exec cargo +nightly hack clippy "$@" --all-targets --feature-powerset --workspace -- --deny warnings -C panic=abort -Zpanic_abort_tests
|
cargo +nightly hack clippy "$@" --exclude integration-ebpf --all-targets --feature-powerset --workspace -- --deny warnings
|
||||||
|
cargo +nightly hack clippy "$@" --package integration-ebpf --all-targets --feature-powerset -- --deny warnings -C panic=abort -Zpanic_abort_tests
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
[package]
|
||||||
|
name = "integration-common"
|
||||||
|
version = "0.1.0"
|
||||||
|
publish = false
|
||||||
|
authors.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
aya = { path = "../../aya", optional = true }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
user = ["aya"]
|
@ -0,0 +1,53 @@
|
|||||||
|
#![no_std]
|
||||||
|
|
||||||
|
pub mod bpf_probe_read {
|
||||||
|
pub const RESULT_BUF_LEN: usize = 1024;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct TestResult {
|
||||||
|
pub buf: [u8; RESULT_BUF_LEN],
|
||||||
|
pub len: Option<Result<usize, i64>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "user")]
|
||||||
|
unsafe impl aya::Pod for TestResult {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod ring_buf {
|
||||||
|
// This structure's definition is duplicated in the probe.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)]
|
||||||
|
pub struct Registers {
|
||||||
|
pub dropped: u64,
|
||||||
|
pub rejected: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::ops::Add for Registers {
|
||||||
|
type Output = Self;
|
||||||
|
fn add(self, rhs: Self) -> Self::Output {
|
||||||
|
Self {
|
||||||
|
dropped: self.dropped + rhs.dropped,
|
||||||
|
rejected: self.rejected + rhs.rejected,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> core::iter::Sum<&'a Registers> for Registers {
|
||||||
|
fn sum<I: Iterator<Item = &'a Registers>>(iter: I) -> Self {
|
||||||
|
iter.fold(Default::default(), |a, b| a + *b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "user")]
|
||||||
|
unsafe impl aya::Pod for Registers {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod strncmp {
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct TestResult(pub core::cmp::Ordering);
|
||||||
|
|
||||||
|
#[cfg(feature = "user")]
|
||||||
|
unsafe impl aya::Pod for TestResult {}
|
||||||
|
}
|
Loading…
Reference in New Issue