-
Notifications
You must be signed in to change notification settings - Fork 10
Revamp Testing Infrastructure and run Multi-Kernel Tests in CI #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
08ed72d
Fix invalid enum relocation
rhysre 30b9336
Improve error logging on JSON unmarshal failure
rhysre d922958
Fix broken probe_set_features logic
rhysre 8ffa182
Rework multi-kernel-tester and run in CI
rhysre de17e6d
Add debug build target
rhysre 70a8a37
Clarify format / test-format targets, format code
rhysre 8da3d76
Disable fail-fast in multikernel test action
rhysre e08ca4f
Clarify and cleanup formatting/build CI workflow
rhysre dbbfe32
Dump contents of tracefs trace file on test fail
rhysre 12a88fc
Fix typo in README.md
rhysre 225e700
Fix test failures on Linux 5.11/aarch64
rhysre 9a34c68
Fix broken build-debug target in Makefile
rhysre f4b33b2
Remove -DENABLE_BPF_PRINTK from CI builds
rhysre 956a1c9
Improve logging on test failure
rhysre a514d6a
Fix BPF tramp detection, add multi-kernel tests
rhysre c6ec037
Document unintuitive API
rhysre 06dd84f
Add comment to TestFeaturesCorrect RE: x86
rhysre 18e4888
Dockerize code formatting Makefile target
rhysre 535532a
Fix incorrect docker tag s/_TAG/_PULL_TAG/g
rhysre b433dfd
Fix clang-format not running in a container
rhysre a0bf227
Fix incorrect script args in comment
rhysre 21240ac
Remove time estimate in README
rhysre 7748bfc
Cleanup run_tests.sh arguments
rhysre 7c879ff
Add note about debootstrap to builder script
rhysre 46481d6
Fix improper getopts usage
rhysre 006d4a3
Fix incorrect variable name
rhysre 48df98b
Fix faulty bash list logic
rhysre 45a6b6b
Change BPFTOOL_VERSION to LINUX_TOOLS_VERSION
rhysre aef8f9e
Add gen_initramfs.sh script, update debug docs
rhysre ccf065e
Greatly clean up bash scripts
rhysre c2294c9
Fix caching logic in GH actions workflow
rhysre 74eefae
Fix inspecific restore key
rhysre 0bbb901
Remove reduntant apt-get update
rhysre 6344e6c
Cleanup Makefile
rhysre 266e30a
Fix broken test-format target
rhysre 936b063
Add section to README.md on userspace debugging
rhysre 7264703
Add missing arg to gen_initramfs.sh help
rhysre 21a043c
Remove KVM section from README.md
rhysre e87370f
Fixups to scripts/invoke_qemu.sh
rhysre 4e10c93
Add missing -o to find invocation in Makefile
rhysre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: Formatting and Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| formatting-and-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Test code formatting | ||
| run: make test-format | ||
| - name: Cache hash | ||
| run: echo "GITHUB_CACHE_HASH=$(md5sum Makefile docker/Dockerfile.builder | md5sum | awk '{print $1}')" >> $GITHUB_ENV | ||
| - name: Setup docker cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ~/.cache/docker | ||
| key: ${{ env.GITHUB_CACHE_HASH }}-v0 | ||
| restore-keys: | | ||
| ${{ env.GITHUB_CACHE_HASH }}-v0 | ||
| - name: Configure Docker | ||
| run: | | ||
| sudo systemctl stop docker | ||
| sudo rm -rf /var/lib/docker | ||
| sudo mkdir -p /var/lib/docker | ||
| sudo mkdir -p ~/.cache/docker | ||
| sudo chown -fR root:root ~/.cache/docker | ||
| sudo mount --rbind ~/.cache/docker /var/lib/docker | ||
| sudo systemctl start docker | ||
| - name: Test build | ||
| run: make build | ||
| - name: Test for source differences post-build | ||
| run: git diff --exit-code | ||
| - name: Test container image build | ||
| run: make container | ||
| - name: Fix permissions (last step) | ||
| run: | | ||
| docker system prune -f | ||
| sudo systemctl stop docker | ||
| sudo umount /var/lib/docker | ||
| sudo chown -R $USER:$USER ~/.cache/docker | ||
| sudo rm -rf ~/.cache/docker/volumes/backingFsBlockDev | ||
| sudo find ~/.cache/docker -name work | sudo xargs chmod -R 700 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| name: Multi Kernel Testing | ||
| on: [ pull_request ] | ||
|
|
||
| jobs: | ||
| multikernel_tester: | ||
| strategy: | ||
| # If a failure occurs, run the other arches/distros to the end. It's useful to see if it | ||
| # occurs on other kernels as well | ||
| fail-fast: false | ||
| matrix: | ||
| kernel_flavor: [ mainline ] | ||
| arch: [ x86_64, aarch64 ] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
| - name: Build eBPF probes and userspace components | ||
| run: make build ARCH=${{ matrix.arch }} | ||
| - name: Auth GCP | ||
| uses: 'google-github-actions/auth@v0' | ||
| with: | ||
| credentials_json: '${{ secrets.ACTIONS_GCP_JSON_CREDENTIALS }}' | ||
| - name: 'Setup gcloud' | ||
| uses: 'google-github-actions/setup-gcloud@v0' | ||
| - name: Create kernel images directory | ||
| run: | | ||
| sudo mkdir -p /kernel-images | ||
| sudo chown -fR $USER:$USER /kernel-images | ||
| - name: Get current timestamp for GCS cache key | ||
| run: echo "TIMESTAMP=$(date +%s)" >> $GITHUB_ENV | ||
| - name: Setup GCS cache | ||
| id: cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: /kernel-images | ||
| key: gcs-cache-${{ matrix.kernel_flavor }}-${{ matrix.arch }}-${{ env.TIMESTAMP }} | ||
| restore-keys: gcs-cache-${{ matrix.kernel_flavor }}-${{ matrix.arch }} | ||
| - name: Rsync kernel images from GCS | ||
| run: gsutil -m rsync -d -r gs://ebpf-ci-kernel-images/${{ matrix.kernel_flavor }}/${{ matrix.arch }}/images /kernel-images/ | ||
| - name: Install packages needed for testing | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y --no-install-recommends \ | ||
| gcc-aarch64-linux-gnu \ | ||
| libc6-dev-arm64-cross \ | ||
| parallel \ | ||
| qemu-system-x86 \ | ||
| qemu-system-arm | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| - name: Install Go | ||
| uses: actions/setup-go@v3 | ||
| with: | ||
| go-version: '1.17' | ||
| - name: Install Bluebox | ||
| run: go install github.com/florianl/bluebox@b8590fb1850f56df6e6d7786931fcabdc1e9173d | ||
| - name: Run tests | ||
| working-directory: testing | ||
| run: | | ||
| ./run_tests.sh \ | ||
| ${{ matrix.arch }} \ | ||
| ../artifacts-${{ matrix.arch }}/non-GPL/EventsTrace/EventsTrace \ | ||
| /kernel-images/* | ||
| - name: Archive test summary | ||
| if: always() | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: run-summary-${{ matrix.kernel_flavor }}-${{ matrix.arch }}.txt | ||
| path: testing/bpf-check-summary.txt | ||
| - name: Archive individual test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: results-${{ matrix.kernel_flavor }}-${{ matrix.arch }} | ||
| path: testing/results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,79 @@ | ||
| ARCH ?= $(shell arch) | ||
| BUILD_DIR ?= artifacts-${ARCH} | ||
| SUDO ?= | ||
| PWD ?= $(shell pwd) | ||
| CONTAINER_RUNTIME ?= docker | ||
| DOCKER_IMG_UBUNTU_VERSION ?= jammy | ||
| BUILDER_PULL_TAG ?= us-docker.pkg.dev/elastic-security-dev/ebpf-public/builder:20220620-0715 | ||
| BUILDER_TAG ?= us-docker.pkg.dev/elastic-security-dev/ebpf-public/builder:${USER}-latest | ||
| C_INCLUDE_PATH ?= | ||
| DOCKER_CACHE ?= | ||
|
|
||
| DOCKER_IMAGE = us-docker.pkg.dev/elastic-security-dev/ebpf-public/builder | ||
| DOCKER_PULL_TAG = 20220711-1742 | ||
| DOCKER_LOCAL_TAG = ${USER}-latest | ||
| CURRENT_DATE_TAG = $(shell date +%Y%m%d-%H%M) | ||
|
|
||
| .PHONY = build build-local clean container fix-permissions format test-format | ||
| PWD = $(shell pwd) | ||
| BUILD_DIR = artifacts-${ARCH} | ||
| CMAKE_FLAGS = -DARCH=${ARCH} -DBUILD_STATIC_EVENTSTRACE=True -DUSE_BUILTIN_VMLINUX=True -B${BUILD_DIR} -S${PWD} | ||
lrishi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| container: | ||
| ${CONTAINER_RUNTIME} build ${DOCKER_CACHE} -t ${BUILDER_TAG} --build-arg PULL_TAG=${DOCKER_IMG_UBUNTU_VERSION} -f docker/Dockerfile.builder . | ||
| # Directories to search recursively for c/cpp source files to clang-format | ||
| FORMAT_DIRS = GPL/ non-GPL/ testing/test_bins | ||
|
|
||
| .PHONY = build build-debug _internal-build clean container format test-format | ||
|
|
||
| # Kludge to get around a missing header. If we don't do this, we'll get the following error when | ||
| # building: | ||
| # | ||
| # In file included from /home/vagrant/ebpf/contrib/libbpf/include/uapi/linux/bpf.h:11: | ||
| # In file included from /home/vagrant/ebpf/contrib/libbpf/include/linux/types.h:8: | ||
| # In file included from /usr/lib/llvm-14/lib/clang/14.0.0/include/stdint.h:52: | ||
| # /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found | ||
| # include <bits/libc-header-start.h> | ||
| # ^~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| # | ||
| # The HostIsolation probes include linux/bpf.h (copied into the libbpf repo) which includes | ||
| # linux/types.h (also copied into the libbpf repo) which includes stdint.h. The clang stdint.h | ||
| # includes bits/libc-header-start.h which is not in our include path. The correct one to use | ||
| # depends on which arch we're compiling for. | ||
| ifeq ($(ARCH),x86_64) | ||
| export C_INCLUDE_PATH = /usr/include/x86_64-linux-gnu | ||
| else | ||
| export C_INCLUDE_PATH = /usr/aarch64-linux-gnu/include | ||
| endif | ||
|
|
||
| build-local: | ||
| mkdir -p ${BUILD_DIR} | ||
| C_INCLUDE_PATH=${C_INCLUDE_PATH} cmake -DUSE_BUILTIN_VMLINUX=True -B${BUILD_DIR} -S${PWD} | ||
| C_INCLUDE_PATH=${C_INCLUDE_PATH} make -C${BUILD_DIR} | ||
| export CC=${ARCH}-linux-gnu-gcc | ||
| export CXX=${ARCH}-linux-gnu-g++ | ||
| export AR=${ARCH}-linux-gnu-ar | ||
| export LD=${ARCH}-linux-gnu-ld | ||
|
|
||
| build: | ||
| docker run --rm -v${PWD}:${PWD} -w${PWD} ${BUILDER_PULL_TAG} | ||
| docker run --rm -v${PWD}:${PWD} -w${PWD} ${DOCKER_IMAGE}:${DOCKER_PULL_TAG} \ | ||
| /usr/bin/env make _internal-build ARCH=${ARCH} EXTRA_CMAKE_FLAGS=${EXTRA_CMAKE_FLAGS} | ||
| sudo chown -fR ${USER}:${USER} ${BUILD_DIR} | ||
| @echo "\n++ Build Successful at `date` ++\n" | ||
|
|
||
| fix-permissions: | ||
| # Convenience target to pass -DCMAKE_BUILD_TYPE=Debug and -DCMAKE_C_FLAGS="-g -O0" | ||
| build-debug: | ||
| docker run --rm -v${PWD}:${PWD} -w${PWD} ${DOCKER_IMAGE}:${DOCKER_PULL_TAG} \ | ||
| /usr/bin/env make _internal-build ARCH=${ARCH} EXTRA_CMAKE_FLAGS='-DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-g -O0"' | ||
| sudo chown -fR ${USER}:${USER} ${BUILD_DIR} | ||
| @echo "\n++ Build Successful at `date` ++\n" | ||
|
|
||
| _internal-build: | ||
| mkdir -p ${BUILD_DIR}/ | ||
| cmake ${EXTRA_CMAKE_FLAGS} ${CMAKE_FLAGS} | ||
| make -C${BUILD_DIR} -j$(shell nproc) | ||
|
|
||
| container: | ||
| docker build -t ${DOCKER_LOCAL_TAG} -f docker/Dockerfile.builder . | ||
|
|
||
| tag-container: | ||
| docker tag ${DOCKER_IMAGE}:${DOCKER_LOCAL_TAG} ${DOCKER_IMAGE}:$CURRENT_DATE_TAG | ||
| @echo "\n++ Tagged image as ${DOCKER_IMAGE}:${CURRENT_DATE_TAG} ++\n" | ||
|
|
||
| # We dockerize code formatting because differences in clang-format versions can | ||
| # lead to different formatting decisions. This way, everyone is using | ||
| # clang-format 14 (default in the Ubuntu jammy repos). | ||
| format: | ||
| find . \( -path ./contrib -o -path ./artifacts* \) -prune \ | ||
| -o -name "*.c" -o -name "*.cpp" -o -name "*.h" -print | xargs /usr/bin/env clang-format -i | ||
| docker run --rm -v${PWD}:${PWD} -w${PWD} ${DOCKER_IMAGE}:${DOCKER_PULL_TAG} \ | ||
| sh -c 'find ${FORMAT_DIRS} -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.cpp" | xargs /usr/bin/env clang-format -i' | ||
|
|
||
| test-format: | ||
| find . \( -path ./contrib -o -path ./artifacts* \) -prune \ | ||
| -o -name "*.c" -o -name "*.cpp" -o -name "*.h" -print | xargs /usr/bin/env clang-format --dry-run -Werror | ||
| docker run --rm -v${PWD}:${PWD} -w${PWD} ${DOCKER_IMAGE}:${DOCKER_PULL_TAG} \ | ||
| sh -c 'find ${FORMAT_DIRS} -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.cpp" | xargs /usr/bin/env clang-format -i --dry-run -Werror' | ||
|
|
||
| clean: | ||
| ${SUDO} rm -rf artifacts-* | ||
| sudo rm -rf artifacts-* | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.