diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 20d367b9..b632e29b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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: @@ -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: ./ diff --git a/.github/workflows/test-cli.yml b/.github/workflows/test-cli.yml deleted file mode 100644 index e4cf7472..00000000 --- a/.github/workflows/test-cli.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Test whether CLI works properly - -on: - push: - branches: "master" - pull_request: - branches: "master" - -jobs: - build-runtime-cli-and-test-cli: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Install dependencies - run: | - 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 - - name: Build and install CLI - run: | - cd tools/cli-rs - RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target x86_64-unknown-linux-gnu - mkdir -p ~/.bpftime - cp ./target/x86_64-unknown-linux-gnu/release/bpftime ~/.bpftime - - uses: actions/upload-artifact@v3 - with: - name: bpftime-cli - path: ~/.bpftime/bpftime - - name: Build test assets - run: | - cd example/malloc - make -j - - name: Test CLI - attach by running - run: | - export PATH=$PATH:~/.bpftime - bpftime --help - cd example/malloc - timeout -s 2 15s bpftime load ./malloc || if [ $? = 124 ]; then exit 0; else exit $?; fi & - sleep 10s - ID1=$! - timeout -s 2 5s bpftime start ./victim || if [ $? = 124 ]; then exit 0; else exit $?; fi - fg $ID1 || true diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index f66e74b5..28e6d987 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/test-runtime.yml b/.github/workflows/test-runtime.yml index 904d49ff..a9985e9b 100644 --- a/.github/workflows/test-runtime.yml +++ b/.github/workflows/test-runtime.yml @@ -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 diff --git a/.github/workflows/test-vm.yml b/.github/workflows/test-vm.yml index 5fe49fff..72f1102a 100644 --- a/.github/workflows/test-vm.yml +++ b/.github/workflows/test-vm.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 96e07391..48925adf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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