Merge pull request #858 from dave-tucker/ringbuf-doctests

Fix docs build
pull/861/head
Dave Tucker 9 months ago committed by GitHub
commit 13f21dce1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -111,6 +111,20 @@ jobs:
--exclude integration-test \
--workspace
- name: Doctests
env:
RUST_BACKTRACE: full
run: |
set -euxo pipefail
cargo hack test --doc --feature-powerset \
--exclude aya-bpf \
--exclude aya-bpf-bindings \
--exclude aya-log-ebpf \
--exclude init \
--exclude integration-ebpf \
--exclude integration-test \
--workspace
build-test-aya-bpf:
strategy:
fail-fast: false
@ -149,6 +163,17 @@ jobs:
--target ${{ matrix.target }} \
-Z build-std=core
- name: Test
env:
CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }}
RUST_BACKTRACE: full
run: |
set -euxo pipefail
cargo hack test --doc \
--package aya-bpf \
--package aya-log-ebpf \
--feature-powerset
run-integration-test:
strategy:
fail-fast: false

@ -68,15 +68,15 @@ use crate::{
/// # }
/// # fn clear_ready(&mut self) {}
/// # }
/// # let bpf = aya::Bpf::load(&[])?;
/// # let mut bpf = aya::Bpf::load(&[])?;
/// use aya::maps::RingBuf;
/// use std::convert::TryFrom;
///
/// let ring_buf = RingBuf::try_from(bpf.map_mut("ARRAY")?)?;
/// let poll = poll_fd(ring_buf);
/// let ring_buf = RingBuf::try_from(bpf.map_mut("ARRAY").unwrap()).unwrap();
/// let mut poll = poll_fd(ring_buf);
/// loop {
/// let mut guard = poll.readable()?;
/// let ring_buf = guard.inner_mut()
/// let mut guard = poll.readable();
/// let ring_buf = guard.inner_mut();
/// while let Some(item) = ring_buf.next() {
/// println!("Received: {:?}", item);
/// }

@ -25,9 +25,9 @@ use crate::{
/// static MAP: CpuMap = CpuMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// fn xdp(_ctx: XdpContext) -> u32 {
/// // Redirect to CPU 7 or drop packet if no entry found.
/// MAP.redirect(7, xdp_action::XDP_DROP as u64)
/// MAP.redirect(7, xdp_action::XDP_DROP as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]

@ -27,8 +27,8 @@ use crate::{
/// static MAP: DevMap = DevMap::with_max_entries(1, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// MAP.redirect(0, xdp_action::XDP_PASS as u64)
/// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(0, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]
@ -100,7 +100,7 @@ impl DevMap {
/// #[map]
/// static MAP: DevMap = DevMap::with_max_entries(1, 0);
///
/// let target_if_index = MAP.get(0).target_if_index;
/// let target_if_index = MAP.get(0).unwrap().if_index;
///
/// // redirect to if_index
/// ```

@ -29,8 +29,8 @@ use crate::{
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// MAP.redirect(42, xdp_action::XDP_PASS as u64)
/// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(42, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]
@ -102,7 +102,7 @@ impl DevMapHash {
/// #[map]
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0);
///
/// let target_if_index = MAP.get(42).target_if_index;
/// let target_if_index = MAP.get(42).unwrap().if_index;
///
/// // redirect to ifindex
/// ```

@ -28,9 +28,9 @@ use crate::{
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(ctx, XdpContext) -> i32 {
/// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index };
/// MAP.redirect(queue_id, xdp_action::XDP_DROP as u64)
/// SOCKS.redirect(queue_id, xdp_action::XDP_DROP as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
///
@ -68,7 +68,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap};
///
/// #[map]
/// static SOCKS: XskMap::with_max_entries(8, 0);
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
/// ```
pub const fn with_max_entries(max_entries: u32, flags: u32) -> XskMap {
XskMap {
@ -93,7 +93,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap};
///
/// #[map]
/// static SOCKS: XskMap::pinned(8, 0);
/// static SOCKS: XskMap = XskMap::pinned(8, 0);
/// ```
pub const fn pinned(max_entries: u32, flags: u32) -> XskMap {
XskMap {
@ -151,9 +151,9 @@ impl XskMap {
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(ctx, XdpContext) -> u32 {
/// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index };
/// MAP.redirect(queue_id, 0).unwrap_or(xdp_action::XDP_DROP)
/// SOCKS.redirect(queue_id, 0).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[inline(always)]

Loading…
Cancel
Save