Merge pull request #310 from dave-tucker/cross-ci

Enable CI for all supported architectures
pull/311/head
Dave Tucker 2 years ago committed by GitHub
commit bbb5d7124a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,14 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
arch:
- x86_64
- aarch64
- arm
# Disable riscv64 due to missing pt_regs handling in aya-bpf/args.rs
# - riscv64
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
@ -28,7 +36,17 @@ jobs:
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Build - name: Build
run: cargo build --manifest-path bpf/Cargo.toml --verbose env:
CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }}
run: |
pushd bpf
cargo build --workspace --exclude aya-bpf-macros --verbose
popd
- name: Run tests - name: Run tests
run: RUST_BACKTRACE=full cargo test --manifest-path bpf/Cargo.toml --verbose env:
CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }}
run: |
pushd bpf
cargo test --workspace --exclude aya-bpf-macros --verbose
popd

@ -15,16 +15,31 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
arch:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabi
- riscv64gc-unknown-none-elf
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1 - uses: Swatinem/rust-cache@v1
- name: Prereqs
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build - name: Build
run: cargo build --verbose run: cross build --verbose
- name: Run tests - name: Run test
run: RUST_BACKTRACE=full cargo test --verbose run: RUST_BACKTRACE=full cross test --verbose
- name: Build bpf macros
run: cross build --manifest-path ./bpf/Cargo.toml -p aya-bpf-macros --verbose
- name: Test bpf macros
run: RUST_BACKTRACE=full cross test --manifest-path ./bpf/Cargo.toml -p aya-bpf-macros --verbose
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

@ -1,7 +1,10 @@
use std::env; use std::env;
fn main() { fn main() {
if env::var("CARGO_CFG_BPF_TARGET_ARCH").is_err() { println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") {
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);
} else {
let arch = env::var("HOST").unwrap(); let arch = env::var("HOST").unwrap();
let arch = arch.split_once('-').map_or(&*arch, |x| x.0); let arch = arch.split_once('-').map_or(&*arch, |x| x.0);
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch); println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);

@ -1,7 +1,10 @@
use std::env; use std::env;
fn main() { fn main() {
if env::var("CARGO_CFG_BPF_TARGET_ARCH").is_err() { println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") {
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);
} else {
let arch = env::var("HOST").unwrap(); let arch = env::var("HOST").unwrap();
let arch = arch.split_once('-').map_or(&*arch, |x| x.0); let arch = arch.split_once('-').map_or(&*arch, |x| x.0);
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch); println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);

@ -1,7 +1,10 @@
use std::env; use std::env;
fn main() { fn main() {
if env::var("CARGO_CFG_BPF_TARGET_ARCH").is_err() { println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") {
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);
} else {
let arch = env::var("HOST").unwrap(); let arch = env::var("HOST").unwrap();
let arch = arch.split_once('-').map_or(&*arch, |x| x.0); let arch = arch.split_once('-').map_or(&*arch, |x| x.0);
println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch); println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch);

@ -116,18 +116,18 @@ impl<T> FromPtRegs for *const T {
} }
} }
#[cfg(bpf_target_arch = "armv7")] #[cfg(bpf_target_arch = "arm")]
impl<T> FromPtRegs for *const T { impl<T> FromPtRegs for *const T {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 6 { if n <= 6 {
Some(ctx.uregs.regs[n] as *const _) Some(ctx.uregs[n] as *const _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.uregs.regs[0] as *const _) Some(ctx.uregs[0] as *const _)
} }
} }
@ -135,14 +135,14 @@ impl<T> FromPtRegs for *const T {
impl<T> FromPtRegs for *const T { impl<T> FromPtRegs for *const T {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 7 { if n <= 7 {
Some(ctx.regs.regs[n] as *const _) Some(ctx.regs[n] as *const _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.regs.regs[0] as *const _) Some(ctx.regs[0] as *const _)
} }
} }
@ -165,18 +165,18 @@ impl<T> FromPtRegs for *mut T {
} }
} }
#[cfg(bpf_target_arch = "armv7")] #[cfg(bpf_target_arch = "arm")]
impl<T> FromPtRegs for *mut T { impl<T> FromPtRegs for *mut T {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 6 { if n <= 6 {
Some(ctx.uregs.regs[n] as *mut _) Some(ctx.uregs[n] as *mut _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.uregs.regs[0] as *mut _) Some(ctx.uregs[0] as *mut _)
} }
} }
@ -184,14 +184,14 @@ impl<T> FromPtRegs for *mut T {
impl<T> FromPtRegs for *mut T { impl<T> FromPtRegs for *mut T {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 7 { if n <= 7 {
Some(ctx.regs.regs[n] as *mut _) Some(ctx.regs[n] as *mut _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.regs.regs[0] as *mut _) Some(ctx.regs[0] as *mut _)
} }
} }
@ -217,18 +217,18 @@ macro_rules! impl_from_pt_regs {
} }
} }
#[cfg(bpf_target_arch = "armv7")] #[cfg(bpf_target_arch = "arm")]
impl FromPtRegs for $type { impl FromPtRegs for $type {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 6 { if n <= 6 {
Some(ctx.uregs.regs[n] as *const $type as _) Some(ctx.uregs[n] as *const $type as _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.uregs.regs[0] as *const $type as _) Some(ctx.uregs[0] as *const $type as _)
} }
} }
@ -236,14 +236,14 @@ macro_rules! impl_from_pt_regs {
impl FromPtRegs for $type { impl FromPtRegs for $type {
fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> { fn from_argument(ctx: &pt_regs, n: usize) -> Option<Self> {
if n <= 7 { if n <= 7 {
Some(ctx.regs.regs[n] as *const $type as _) Some(ctx.regs[n] as *const $type as _)
} else { } else {
None None
} }
} }
fn from_retval(ctx: &pt_regs) -> Option<Self> { fn from_retval(ctx: &pt_regs) -> Option<Self> {
Some(ctx.regs.regs[0] as *const $type as _) Some(ctx.regs[0] as *const $type as _)
} }
} }
}; };

Loading…
Cancel
Save