Skip to content

Commit eb9f1ec

Browse files
committed
CI: add a standalone reuseport coverage test
1 parent 70e9d58 commit eb9f1ec

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,40 @@ jobs:
6464
name: lib-unit-test
6565
token: ${{ secrets.CODECOV_TOKEN }}
6666
verbose: false
67+
lib-reuseport:
68+
name: reuseport test
69+
runs-on: ubuntu-26.04
70+
steps:
71+
- name: Checkout sources
72+
uses: actions/checkout@v7
73+
with:
74+
submodules: true
75+
- name: Install rust toolchain
76+
uses: actions-rust-lang/setup-rust-toolchain@v1
77+
with:
78+
toolchain: stable
79+
components: llvm-tools
80+
- name: Install build dependencies
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install libbpf-dev linux-bpf-dev
84+
- name: Install binutils
85+
run: |
86+
cargo install cargo-binutils@0.3.6
87+
- name: run unit test
88+
run: |
89+
cargo clean
90+
./scripts/coverage/lib_reuseport.sh
91+
- name: Upload coverage data
92+
uses: codecov/codecov-action@v7
93+
with:
94+
fail_ci_if_error: true
95+
disable_search: true
96+
files: output.lcov
97+
flags: reuseport
98+
name: lib-reuseport
99+
token: ${{ secrets.CODECOV_TOKEN }}
100+
verbose: false
67101
vey-mkcert-test:
68102
name: vey-mkcert test
69103
runs-on: ubuntu-26.04

scripts/coverage/lib_reuseport.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
SCRIPTS_DIR=$(dirname "$0")
6+
PROJECT_DIR=$(realpath "${SCRIPTS_DIR}/../..")
7+
8+
9+
TEST_NAME="reuseport-test"
10+
. "${SCRIPTS_DIR}/enter.sh"
11+
12+
# build
13+
cargo build -p vey-reuseport
14+
15+
all_binaries=$(find target/debug/ -maxdepth 1 -type f -perm /111 | awk '{print "-object "$0}')
16+
17+
# run the tests
18+
sudo "${PROJECT_DIR}"/target/debug/udp_reuseport_test
19+
20+
all_objects=$(find target/debug/deps/ -type f -perm /111 -not -name "*.so" | awk '{print "-object "$0}')
21+
22+
23+
# get all profraw files generated in each test
24+
profraw_files=$(find . -type f -regex ".*/${TEST_NAME}.*\.profraw")
25+
26+
# get indexed profile data file
27+
cargo profdata -- merge -o "${PROF_DATA_FILE}" ${profraw_files}
28+
29+
# report to console
30+
31+
IGNORE_FLAGS="--ignore-filename-regex=.cargo \
32+
--ignore-filename-regex=rustc \
33+
--ignore-filename-regex=target/debug/build"
34+
35+
cargo cov -- report --use-color --instr-profile="${PROF_DATA_FILE}" ${IGNORE_FLAGS} ${all_binaries} ${all_objects}
36+
cargo cov -- export --format=lcov --instr-profile="${PROF_DATA_FILE}" ${IGNORE_FLAGS} ${all_binaries} ${all_objects} > output.lcov

0 commit comments

Comments
 (0)