Skip to content

Commit

Permalink
Test execution of projects
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Oct 13, 2024
1 parent affc9de commit f6fc951
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ jobs:
with:
tool: bpf-linker,cargo-generate

- run: sudo apt update
- run: sudo apt install expect
- run: ./test.sh ${{ github.workspace }} ${{ matrix.program }}
30 changes: 27 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash

set -ex
set -eux

TEMPLATE_DIR=$1
if [ -z "${TEMPLATE_DIR}" ]; then echo "template dir required"; exit 1; fi
Expand Down Expand Up @@ -53,12 +53,36 @@ esac
cargo generate --path "${TEMPLATE_DIR}" -n test -d program_type="${PROG_TYPE}" "${ADDITIONAL_ARGS[@]}"
pushd test
cargo +nightly fmt --all -- --check

expect << EOF
set timeout 30 ;# Increase timeout if necessary
spawn cargo xtask run
expect {
-re "Waiting for Ctrl-C.*" {
send -- \003 ;# Send Ctrl-C
}
timeout {
puts "Error: Timed out waiting for 'Waiting for Ctrl-C...'"
exit 1
}
eof {
puts "Error: Process exited prematurely"
exit 1
}
}
expect {
-re "Exiting.*" { }
eof { }
}
EOF

cargo build --package test
cargo build --package test --release
# We cannot run clippy over the whole workspace at once due to feature unification. Since both test
# and test-ebpf depend on test-common and test activates test-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.
cargo clippy --exclude test-ebpf --all-targets --workspace -- --deny warnings
cargo clippy --package test-ebpf --all-targets -- --deny warnings

popd
exit 0

0 comments on commit f6fc951

Please sign in to comment.