Skip to content

Commit

Permalink
ci: Merge test-cli & test-example and Extend them to all examples (#54)
Browse files Browse the repository at this point in the history
* Update CI

* Update CI

* Update CI

* Fix CI

* update

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Update CI
  • Loading branch information
Officeyutong authored Oct 23, 2023
1 parent 4acb66f commit 451397a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 60 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: "master"
pull_request:
# Why wildcard? Because we want to see test results when examing prs from non-master branches..
branches: "master"

jobs:
Expand Down Expand Up @@ -36,7 +35,7 @@ jobs:
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v2
if: github.repository_owner == 'eunomia-bpf'
if: "github.repository_owner == 'eunomia-bpf' && !startsWith(github.ref, 'refs/pull/')"
with:
# relative path to the place where source code with Dockerfile is located
context: ./
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/test-cli.yml

This file was deleted.

59 changes: 49 additions & 10 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
name: Test examples
name: Build and run all integrated tests (examples)

on:
push:
branches: "master"
branches: "*"
pull_request:
branches: "master"
branches: "*"

jobs:
build-and-test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
examples:
- path: libbpf-tools/opensnoop
executable: opensnoop
victim: ./victim
syscall_trace: true
- path: libbpf-tools/statsnoop
executable: statsnoop
victim: ./victim
syscall_trace: true
- path: malloc
executable: malloc
victim: ./victim
syscall_trace: false
- path: opensnoop
executable: opensnoop
victim: ./victim
syscall_trace: false
- path: sslsniff
executable: sslsniff
victim: /bin/wget https://www.google.com
syscall_trace: false
- path: libbpf-tools/bashreadline
executable: readline
victim: /bin/bash
syscall_trace: false

steps:
- uses: actions/checkout@v2
with:
Expand All @@ -18,7 +47,7 @@ jobs:
sudo apt-get install binutils-dev libboost1.74-all-dev libelf-dev zlib1g-dev libyaml-cpp-dev gcc-12 g++-12 llvm
- name: Build and install runtime
run: |
CC=gcc-12 CXX=g++-12 make release
CC=gcc-12 CXX=g++-12 make release -j
- name: Build and install CLI
run: |
cd tools/cli-rs
Expand All @@ -27,18 +56,28 @@ jobs:
cp ./target/x86_64-unknown-linux-gnu/release/bpftime ~/.bpftime
- name: Build test assets
run: |
cd example/opensnoop
make -j
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
- name: Test CLI - attach by running (syscall_trace)
if: matrix.examples.syscall_trace
shell: "sudo /bin/bash -e {0}"
run: |
cd example/${{matrix.examples.path}}
timeout -s 2 30s sudo -E /home/runner/.bpftime/bpftime -i /home/runner/.bpftime load ./${{matrix.examples.executable}} || if [ $? = 124 ]; then exit 0; else exit $?; fi &
sleep 3s
ID1=$!
timeout -s 2 15s /home/runner/.bpftime/bpftime -i /home/runner/.bpftime start -s ${{matrix.examples.victim}} || if [ $? = 124 ]; then exit 0; else exit $?; fi
fg $ID1 || true
- name: Test CLI - attach by running (uprobe)
if: '!matrix.examples.syscall_trace'
shell: "sudo /bin/bash -e {0}"
run: |
cd example/opensnoop
timeout -s 2 30s sudo -E /home/runner/.bpftime/bpftime -i /home/runner/.bpftime load ./opensnoop || if [ $? = 124 ]; then exit 0; else exit $?; fi &
cd example/${{matrix.examples.path}}
timeout -s 2 30s sudo -E /home/runner/.bpftime/bpftime -i /home/runner/.bpftime load ./${{matrix.examples.executable}} || if [ $? = 124 ]; then exit 0; else exit $?; fi &
sleep 3s
ID1=$!
timeout -s 2 15s /home/runner/.bpftime/bpftime -i /home/runner/.bpftime start -s ./victim || if [ $? = 124 ]; then exit 0; else exit $?; fi
timeout -s 2 15s /home/runner/.bpftime/bpftime -i /home/runner/.bpftime start ${{matrix.examples.victim}} || if [ $? = 124 ]; then exit 0; else exit $?; fi
fg $ID1 || true
2 changes: 1 addition & 1 deletion .github/workflows/test-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
binutils-dev libyaml-cpp-dev gcc-12 g++-12 llvm
- name: build runtime
run: CC=gcc-12 CXX=g++-12 make build
run: CC=gcc-12 CXX=g++-12 make build -j

- name: test runtime
run: make unit-test
2 changes: 1 addition & 1 deletion .github/workflows/test-vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
sudo apt install python3-pytest
pip install -r vm/test/requirements.txt
# make build # or build-arm32 build-arm64
make -C vm test-vm
make -C vm test-vm -j
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ RUN git submodule update --init --recursive
ENV CXX=g++
ENV CC=gcc
ENV PATH="${PATH}:/root/.cargo/bin"
RUN make release && make install
RUN make release -j && make install -j

0 comments on commit 451397a

Please sign in to comment.