Skip to content

Commit 712f59a

Browse files
committed
ci: minimal CI testing setup
Add static and shared build and runtime testing.
1 parent 6b242f8 commit 712f59a

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

.github/workflows/test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: USDT CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install prerequisites
18+
run: |
19+
curl -L -o bpftrace https://github.com/bpftrace/bpftrace/releases/download/v0.21.2/bpftrace
20+
chmod +x bpftrace
21+
./bpftrace --version
22+
23+
- name: Build (static)
24+
run: make SHARED=0 -C tests -j$(nproc) build
25+
26+
- name: Build (shared)
27+
run: make SHARED=1 -C tests -j$(nproc) build
28+
29+
- name: Test (static)
30+
run: make V=1 BPFTRACE=$(realpath bpftrace) BPFTRACE_TIMEOUT=300 SHARED=0 -C tests test
31+
32+
- name: Test (shared)
33+
run: make V=1 BPFTRACE=$(realpath bpftrace) BPFTRACE_TIMEOUT=300 SHARED=1 -C tests test

tests/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ endif
3434
NONTESTS = tester common
3535

3636
TESTS := $(filter-out $(NONTESTS), \
37-
$(shell ls *.{c,cpp} 2>/dev/null | grep -v '^lib' | \
38-
${AWK} '{split($$0, p, /[^A-Za-z_]+/); print p[1]}' | \
37+
$(shell ls *.c *.cpp 2>/dev/null | grep -v '^lib' | \
38+
${AWK} '{split($$0, p, /[^A-Za-z_]+/); print p[1]}' | \
3939
sort | uniq \
4040
) \
4141
)
4242
LIBS := $(filter-out $(NONTESTS), \
43-
$(shell ls lib*.{c,cpp} 2>/dev/null | \
43+
$(shell ls lib*.c lib*.cpp 2>/dev/null | \
4444
${AWK} '{split($$0, p, /[^A-Za-z_]+/); print substr(p[1], 4)}' | \
4545
sort | uniq \
4646
) \
@@ -59,6 +59,7 @@ clean:
5959

6060
.PHONY: list
6161
list:
62+
$(call msg,TESTS,$@)
6263
$(Q)$(foreach test,$(TESTS), $(info $(test)))
6364

6465
.PHONY: build

tests/prepare-bt-script.awk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
# Emit corresponding bpftrace probe spec:
4141
# U:./test:group:name { printf("%s: some %s fmt %d spec %d\n", probe, str(arg0), (int)arg1, arg2 - 10); }
42-
printf("U:%s:%s:%s { printf(\"%s%s:%s: %s\\n\"%s); }\n",
42+
printf("usdt:%s:%s:%s { printf(\"%s%s:%s: %s\\n\"%s); }\n",
4343
path, group, name,
4444
probe[1] == "lib" ? "lib:" : "", group, name,
4545
fmt, args == "" ? "" : ", " args);

tests/run_test.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ if [ "${V:-0}" -eq 1 ]; then
77
set -x
88
fi
99

10-
TIMEOUT=10
11-
10+
bpftrace_timeout=${BPFTRACE_TIMEOUT:-30}
1211
awk=${AWK:-awk}
1312
readelf=${READELF:-readelf}
1413
bpftrace=${BPFTRACE:-bpftrace}
@@ -75,7 +74,7 @@ if [ -s "$TEST_BTSCRIPT" ]; then
7574
bt_elapsed=$(( $(date +%s) - bt_start ))
7675
if grep -q "STARTED!" "$TEST_BTOUT_RAW"; then
7776
break
78-
elif [ "$bt_elapsed" -ge "$TIMEOUT" ]; then
77+
elif [ "$bt_elapsed" -ge "$bpftrace_timeout" ]; then
7978
sudo kill -KILL -$bt_pgid 2>/dev/null
8079
echo "BPFTRACE STARTUP TIMEOUT!"
8180
echo "BPFTRACE SCRIPT:"
@@ -91,15 +90,22 @@ if [ -s "$TEST_BTSCRIPT" ]; then
9190
cat "$TEST_BTOUT_RAW"
9291
exit 1
9392
else
94-
sleep 0.2
93+
sleep 1
9594
fi
95+
echo "ITER"
9696
done
9797

98+
echo "DONE 1"
99+
98100
# get test output while bpftrace is attached
99101
$TEST_BIN &>"$TEST_OUT"
100102

103+
echo "DONE 2"
104+
101105
sudo kill -INT -$bt_pgid 2>/dev/null
102106

107+
echo "DONE 3"
108+
103109
$awk '/STARTED!/ {flag=1; next} /DONE!/ {flag=0} flag' $TEST_BTOUT_RAW > $TEST_BTOUT
104110
if ! $awk -f check-match.awk $TEST_BTOUT_SPEC $TEST_BTOUT; then
105111
echo "BPFTRACE OUTPUT MISMTACH:"

0 commit comments

Comments
 (0)