Skip to content

Commit

Permalink
ci(workflows/bpf-test): add BPF test to cover route logic (#671)
Browse files Browse the repository at this point in the history
Co-authored-by: mzz <[email protected]>
  • Loading branch information
jschwinger233 and mzz2017 authored Oct 14, 2024
1 parent 3b77ddf commit 438c05c
Show file tree
Hide file tree
Showing 5 changed files with 1,401 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/bpf-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: BPF Test

on:
pull_request:
paths:
- "**/*.c"
- "**/*.h"
- "go.mod"
- "go.sum"
- ".github/workflows/bpf-test.yml"

permissions: read-all

jobs:
bpf_tests:
name: BPF Unit Test
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
persist-credentials: false
fetch-depth: 0
- name: Run BPF tests
run: |
git submodule update --init
sudo make ebpf-test || (echo "Run 'make ebpf-test' locally to investigate failures"; exit 1)
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ clean-ebpf:
rm -f control/bpf_bpf*.o
@rm -f trace/bpf_bpf*.go && \
rm -f trace/bpf_bpf*.o
@rm -f control/kern/tests/bpftest_bpf*.go && \
rm -f control/kern/tests/bpftest_bpf*.o
fmt:
go fmt ./...

Expand All @@ -99,4 +101,18 @@ ebpf: submodule clean-ebpf
ebpf-lint:
./scripts/checkpatch.pl --no-tree --strict --no-summary --show-types --color=always control/kern/tproxy.c --ignore COMMIT_COMMENT_SYMBOL,NOT_UNIFIED_DIFF,COMMIT_LOG_LONG_LINE,LONG_LINE_COMMENT,VOLATILE,ASSIGN_IN_IF,PREFER_DEFINED_ATTRIBUTE_MACRO,CAMELCASE,LEADING_SPACE,OPEN_ENDED_LINE,SPACING,BLOCK_COMMENT_STYLE

ebpf-test: export BPF_CLANG := $(CLANG)
ebpf-test: export BPF_STRIP_FLAG := $(STRIP_FLAG)
ebpf-test: export BPF_CFLAGS := $(CFLAGS)
ebpf-test: export BPF_TARGET := $(TARGET)
ebpf-test: export BPF_TRACE_TARGET := $(GOARCH)
ebpf-test: submodule clean-ebpf
@unset GOOS && \
unset GOARCH && \
unset GOARM && \
echo $(STRIP_FLAG) && \
go generate ./control/kern/tests/bpf_test.go && \
go clean -testcache && \
go test -v ./control/kern/tests/...

## End Ebpf
Loading

0 comments on commit 438c05c

Please sign in to comment.