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

@ -35,7 +35,7 @@ jobs:
- name: Check C formatting - name: Check C formatting
run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror
- name: Check Markdown - name: Check Markdown
uses: DavidAnson/markdownlint-cli2-action@v14 uses: DavidAnson/markdownlint-cli2-action@v14
@ -111,6 +111,20 @@ jobs:
--exclude integration-test \ --exclude integration-test \
--workspace --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: build-test-aya-bpf:
strategy: strategy:
fail-fast: false fail-fast: false
@ -149,6 +163,17 @@ jobs:
--target ${{ matrix.target }} \ --target ${{ matrix.target }} \
-Z build-std=core -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: run-integration-test:
strategy: strategy:
fail-fast: false fail-fast: false

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

@ -25,9 +25,9 @@ use crate::{
/// static MAP: CpuMap = CpuMap::with_max_entries(8, 0); /// static MAP: CpuMap = CpuMap::with_max_entries(8, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 { /// fn xdp(_ctx: XdpContext) -> u32 {
/// // Redirect to CPU 7 or drop packet if no entry found. /// // 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)] #[repr(transparent)]

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

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

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

Loading…
Cancel
Save