forked from aya-rs/aya
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract integration-common for shared types
- Loading branch information
1 parent
c5172de
commit e0c4948
Showing
12 changed files
with
97 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
#!/usr/bin/env sh | ||
|
||
# `-C panic=abort` because "unwinding panics are not supported without std"; | ||
# integration-ebpf contains `#[no_std]` binaries. | ||
# | ||
set -eux | ||
|
||
# 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`"; Cargo does this automatically when panic=abort is set via profile | ||
# but we want to preserve unwinding at runtime - here we are just running clippy so we don't | ||
# care about unwinding behavior. | ||
# | ||
# `-Zpanic_abort_tests`"; Cargo does this automatically when panic=abort is set via profile but we | ||
# want to preserve unwinding at runtime - here we are just running clippy so we don't care about | ||
# unwinding behavior. | ||
# | ||
# `+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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters