Skip to content

[FEATURE] Add CI to test bpftrace #1125

[FEATURE] Add CI to test bpftrace

[FEATURE] Add CI to test bpftrace #1125

Workflow file for this run

name: Build and run all integrated tests (examples)
on:
push:
branches: "*"
pull_request:
branches: "*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build-runtime:
strategy:
matrix:
enable_jit:
- true
- false
container:
- image: ubuntu-2204
name: ubuntu
- image: fedora-39
name: fedora
runs-on: ubuntu-22.04
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}"
options: --privileged
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build and install runtime (with llvm-jit)
if: ${{matrix.enable_jit}}
run: |
make release-with-llvm-jit -j
- name: Build and install runtime (without llvm-jit)
if: ${{!matrix.enable_jit}}
run: |
make release -j
- name: Upload build results (without jit)
uses: actions/upload-artifact@v3
if: ${{!matrix.enable_jit}}
with:
name: runtime-package-no-jit-${{matrix.container.name}}
path: |
~/.bpftime
- name: Upload build results (with jit)
uses: actions/upload-artifact@v3
if: ${{matrix.enable_jit}}
with:
name: runtime-package-jit-${{matrix.container.name}}
path: |
~/.bpftime
build-and-test:
runs-on: ubuntu-22.04
needs: [build-runtime]
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}"
options: --privileged -v /sys/kernel/debug/:/sys/kernel/debug:rw -v /sys/kernel/tracing:/sys/kernel/tracing:rw
strategy:
fail-fast: true
matrix:
container:
- image: ubuntu-2204
name: ubuntu
- image: fedora-39
name: fedora
enable_jit:
- true
- false
examples:
- path: libbpf-tools/opensnoop
executable: ./opensnoop
victim: ./victim
syscall_trace: true
expected_str: " 0 test.txt"
- path: libbpf-tools/statsnoop
executable: ./statsnoop
victim: ./victim
syscall_trace: true
expected_str: "victim 0 0 /sys"
- path: malloc
executable: ./malloc
victim: ./victim
syscall_trace: false
expected_str: "malloc calls: "
- path: minimal
executable: ./uprobe
victim: ./victim
syscall_trace: false
expected_str: ""
- path: opensnoop
executable: ./opensnoop
victim: ./victim
syscall_trace: true
expected_str: " 0 test.txt"
- path: sslsniff
executable: ./sslsniff
victim: /bin/wget https://www.google.com
syscall_trace: false
expected_str: "----- DATA -----"
- path: libbpf-tools/bashreadline
executable: ./readline
victim: /bin/bash
syscall_trace: false
expected_str: "info"
- path: libbpf-tools/syscount
executable: ./syscount
victim: /bin/bash
syscall_trace: false
expected_str: "info"
- path: libbpf-tools/funclatency
executable: ./funclatency -i 1 ./victim:plus
victim: ./victim
syscall_trace: false
expected_str: "|*"
- path: libbpf-tools/mountsnoop
executable: ./mountsnoop
victim: ./victim
syscall_trace: true
expected_str: mount(
- path: libbpf-tools/sigsnoop
executable: ./sigsnoop
victim: ./victim
syscall_trace: true
expected_str: "victim 0 -1 0"
- path: tailcall_minimal
executable: ./tailcall_minimal
victim: ./victim
syscall_trace: false
expected_str: "See /sys/kernel/debug/tracing/trace_pipe for output (15)"
- path: usdt_minimal
executable: ./usdt_minimal
victim: ./victim
syscall_trace: false
expected_str: "bpf:"
steps:
- name: Download prebuilt runtime (with jit)
if: ${{matrix.enable_jit}}
uses: actions/download-artifact@v3
with:
name: runtime-package-jit-${{matrix.container.name}}
path: ~/.bpftime
- name: Download prebuilt runtime (without jit)
if: ${{!matrix.enable_jit}}
uses: actions/download-artifact@v3
with:
name: runtime-package-no-jit-${{matrix.container.name}}
path: ~/.bpftime
- name: Install which(required by funclatency on fedora)
if: ${{matrix.container.name=='fedora' && matrix.examples.path=='libbpf-tools/funclatency'}}
run: |
yum install -y which
- name: Set permissions
run: |
chmod +x ~/.bpftime/*
- name: Show downloaded artifacts
run: |
ls ~/.bpftime
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build test assets
run: |
make -C example/${{matrix.examples.path}} -j
- name: Test CLI - show help
run: |
export PATH=$PATH:~/.bpftime
bpftime --help
- name: Test CLI - attach by running (syscall_trace)
if: matrix.examples.syscall_trace
shell: bash
run: |
ROOT=$(pwd)
cd example/${{matrix.examples.path}}
python3 $ROOT/.github/script/run_example.py "${{matrix.examples.executable}}" "${{matrix.examples.victim}}" "${{matrix.examples.expected_str}}" "/github/home/.bpftime/bpftime -i /github/home/.bpftime" 1
- name: Test CLI - attach by running (uprobe)
if: '!matrix.examples.syscall_trace'
shell: bash
run: |
ROOT=$(pwd)
cd example/${{matrix.examples.path}}
python3 $ROOT/.github/script/run_example.py "${{matrix.examples.executable}}" "${{matrix.examples.victim}}" "${{matrix.examples.expected_str}}" "/github/home/.bpftime/bpftime -i /github/home/.bpftime" 0