From 6d06e2bf3a6d267589339743fef694763b5cc5af Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 13 Jul 2023 10:43:15 -0400 Subject: [PATCH] Include ~all crates in default members Several tests were not running due to being omitted from this list. --- .cargo/config.toml | 2 -- .github/workflows/build-aya-bpf.yml | 12 ++++++++---- Cargo.toml | 17 ++++++++++++++--- aya-log-common/src/lib.rs | 4 ++-- aya-log-parser/src/lib.rs | 3 +-- bpf/aya-bpf/src/programs/sk_buff.rs | 9 +++++++-- bpf/aya-bpf/src/programs/tc.rs | 9 +++++++-- 7 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 8f7da22a..0c1258f6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,7 +1,5 @@ [alias] xtask = "run --package xtask --" -build-bpfel = "build -Zbuild-std=core --target=bpfel-unknown-none" -build-bpfeb = "build -Zbuild-std=core --target=bpfeb-unknown-none" [target.armv7-unknown-linux-gnueabi] linker = "arm-linux-gnueabi-gcc" diff --git a/.github/workflows/build-aya-bpf.yml b/.github/workflows/build-aya-bpf.yml index 6820dd45..5388b95d 100644 --- a/.github/workflows/build-aya-bpf.yml +++ b/.github/workflows/build-aya-bpf.yml @@ -23,6 +23,9 @@ jobs: - aarch64 - arm - riscv64 + target: + - bpfel-unknown-none + - bpfeb-unknown-none runs-on: ubuntu-20.04 steps: @@ -38,11 +41,12 @@ jobs: - name: Prereqs run: cargo install bpf-linker + - uses: taiki-e/install-action@cargo-hack - name: Build env: CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }} run: | - cargo build-bpfel -p aya-bpf --verbose - cargo build-bpfeb -p aya-bpf --verbose - cargo build-bpfel -p aya-log-ebpf --verbose - cargo build-bpfeb -p aya-log-ebpf --verbose + cargo hack build --package aya-bpf --package aya-log-ebpf \ + --feature-powerset \ + --target ${{ matrix.target }} \ + -Z build-std=core diff --git a/Cargo.toml b/Cargo.toml index 03ac2810..10a438d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [workspace] members = [ "aya", - "aya-obj", - "aya-tool", "aya-log", "aya-log-common", "aya-log-parser", + "aya-obj", + "aya-tool", "test/integration-test", "xtask", @@ -19,15 +19,26 @@ members = [ "bpf/aya-log-ebpf", "test/integration-ebpf", ] + resolver = "2" default-members = [ "aya", + "aya-bpf-macros", + "aya-log", + "aya-log-common", + "aya-log-parser", "aya-obj", "aya-tool", - "aya-log", + # test/integration-test is omitted; it must be built with xtask. + "xtask", + "aya-bpf-macros", "aya-log-ebpf-macros", + + # ebpf crates are omitted; they must be built with: + # --target bpfe{b,l}-unknown-none + # CARGO_CFG_BPF_TARGET_ARCH={x86_64,aarch64,arm,riscv64} ] [profile.dev] diff --git a/aya-log-common/src/lib.rs b/aya-log-common/src/lib.rs index ec2cd2b3..0d789e3b 100644 --- a/aya-log-common/src/lib.rs +++ b/aya-log-common/src/lib.rs @@ -298,8 +298,8 @@ mod test { #[test] fn log_value_length_sufficient() { assert!( - LOG_BUF_CAPACITY >= LogValueLength::MAX.into(), - "{} < {}", + LOG_BUF_CAPACITY <= LogValueLength::MAX.into(), + "{} > {}", LOG_BUF_CAPACITY, LogValueLength::MAX ); diff --git a/aya-log-parser/src/lib.rs b/aya-log-parser/src/lib.rs index bedc92cc..8e4f30a7 100644 --- a/aya-log-parser/src/lib.rs +++ b/aya-log-parser/src/lib.rs @@ -163,8 +163,7 @@ mod test { Fragment::Parameter(Parameter { hint: DisplayHint::Ip }), - Fragment::Literal(" lmao ".into()), - Fragment::Literal(" {{}} {{something}}".into()), + Fragment::Literal(" lmao {} {something}".into()), ]) ); assert!(parse("foo {:}").is_err()); diff --git a/bpf/aya-bpf/src/programs/sk_buff.rs b/bpf/aya-bpf/src/programs/sk_buff.rs index 442ba97f..a7618ee2 100644 --- a/bpf/aya-bpf/src/programs/sk_buff.rs +++ b/bpf/aya-bpf/src/programs/sk_buff.rs @@ -404,8 +404,13 @@ impl SkBuffContext { /// # Examples /// /// ```no_run - /// mod bindings; - /// use bindings::{ethhdr, iphdr, udphdr}; + /// use aya_bpf::programs::SkBuffContext; + /// # #[allow(non_camel_case_types)] + /// # struct ethhdr {}; + /// # #[allow(non_camel_case_types)] + /// # struct iphdr {}; + /// # #[allow(non_camel_case_types)] + /// # struct udphdr {}; /// /// const ETH_HLEN: usize = core::mem::size_of::(); /// const IP_HLEN: usize = core::mem::size_of::(); diff --git a/bpf/aya-bpf/src/programs/tc.rs b/bpf/aya-bpf/src/programs/tc.rs index 5aa0a173..8eadfab7 100644 --- a/bpf/aya-bpf/src/programs/tc.rs +++ b/bpf/aya-bpf/src/programs/tc.rs @@ -161,8 +161,13 @@ impl TcContext { /// # Examples /// /// ```no_run - /// mod bindings; - /// use bindings::{ethhdr, iphdr, udphdr}; + /// use aya_bpf::programs::TcContext; + /// # #[allow(non_camel_case_types)] + /// # struct ethhdr {}; + /// # #[allow(non_camel_case_types)] + /// # struct iphdr {}; + /// # #[allow(non_camel_case_types)] + /// # struct udphdr {}; /// /// const ETH_HLEN: usize = core::mem::size_of::(); /// const IP_HLEN: usize = core::mem::size_of::();