mirror of
https://github.com/eunomia-bpf/bpf-developer-tutorial.git
synced 2026-03-20 20:05:56 +08:00
Fix Rust uprobe tutorial and add CI tests in dedicated workflow (#197)
* Initial plan * Fix issue #173: Update Rust uprobe documentation to use debug build and correct function symbol Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Add CI tests for Rust uprobe tutorial (issue #173) Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Update src/37-uprobe-rust/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: 云微 <1067852565@qq.com> * Update src/37-uprobe-rust/README.zh.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: 云微 <1067852565@qq.com> * Use wildcard patterns for Rust symbol matching in bpftrace examples Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Add CI test to verify bpftrace can attach to Rust uprobe Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> * Separate bpftrace tests into new test-bpftrace.yml workflow Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> --------- Signed-off-by: 云微 <1067852565@qq.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yunwei37 <34985212+yunwei37@users.noreply.github.com> Co-authored-by: 云微 <1067852565@qq.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
57
.github/workflows/test-bpftrace.yml
vendored
Normal file
57
.github/workflows/test-bpftrace.yml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Test bpftrace examples
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: test 37 uprobe-rust helloworld
|
||||
run: |
|
||||
cd src/37-uprobe-rust/helloworld
|
||||
cargo build
|
||||
# Verify the hello function symbol exists in debug build
|
||||
nm target/debug/helloworld | grep "_ZN10helloworld5hello" || (echo "Error: hello function symbol not found in debug build" && exit 1)
|
||||
echo "✓ helloworld debug build has correct hello symbol"
|
||||
|
||||
- name: test 37 uprobe-rust args
|
||||
run: |
|
||||
cd src/37-uprobe-rust/args
|
||||
cargo build
|
||||
# Verify the hello function symbol exists in debug build
|
||||
nm target/debug/helloworld | grep "_ZN10helloworld5hello" || (echo "Error: hello function symbol not found in debug build" && exit 1)
|
||||
echo "✓ args debug build has correct hello symbol"
|
||||
# Run the binary to ensure it works
|
||||
./target/debug/helloworld 1 2 3 | grep -q "Hello, world!" || (echo "Error: binary execution failed" && exit 1)
|
||||
echo "✓ args binary runs successfully"
|
||||
|
||||
- name: test 37 uprobe-rust bpftrace attach
|
||||
run: |
|
||||
cd src/37-uprobe-rust/args
|
||||
# Test that bpftrace can attach to the hello function with wildcard pattern
|
||||
# Run bpftrace with the binary and verify it can trace the function
|
||||
sudo timeout 3 bpftrace -e 'uprobe:target/debug/helloworld:_ZN10helloworld5hello* { printf("traced\n"); exit(); }' -c "./target/debug/helloworld 1" > /tmp/bpftrace_output.txt 2>&1 || true
|
||||
# Check if bpftrace successfully attached and traced the function
|
||||
if grep -q "traced" /tmp/bpftrace_output.txt && grep -q "Attaching 1 probe" /tmp/bpftrace_output.txt; then
|
||||
echo "✓ bpftrace successfully attached to hello function with wildcard pattern"
|
||||
else
|
||||
echo "Error: bpftrace failed to attach or trace the hello function"
|
||||
cat /tmp/bpftrace_output.txt
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user