-
-
Notifications
You must be signed in to change notification settings - Fork 84
295 lines (292 loc) · 10.7 KB
/
test-examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Build and run all integrated tests (examples)
on:
push:
branches: "*"
pull_request:
branches: "*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
build-runtime:
strategy:
matrix:
enable_jit:
- true
- false
container:
- image: ubuntu-2204
name: ubuntu
- image: fedora-39
name: fedora
runs-on: ubuntu-22.04
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}"
options: --privileged
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Install lcov (Ubuntu)
if: ${{matrix.container.name=='ubuntu'}}
run: |
apt-get install -y lcov tree
- name: Install lcov (Fedora)
if: ${{matrix.container.name =='fedora'}}
run: |
dnf install -y lcov tree
- name: Build and install runtime (with llvm-jit)
if: ${{matrix.enable_jit}}
run: |
cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DBPFTIME_LLVM_JIT=1 \
-DTEST_LCOV=YES \
-DBUILD_BPFTIME_DAEMON=1 \
-DCMAKE_CXX_FLAGS="-DDEFAULT_LOGGER_OUTPUT_PATH='\"console\"'"
cmake --build build --config RelWithDebInfo --target install -j
- name: Build and install runtime (without llvm-jit)
if: ${{!matrix.enable_jit}}
run: |
cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
-DBPFTIME_LLVM_JIT=0 \
-DTEST_LCOV=YES \
-DBUILD_BPFTIME_DAEMON=1 \
-DCMAKE_CXX_FLAGS="-DDEFAULT_LOGGER_OUTPUT_PATH='\"console\"'"
cmake --build build --config RelWithDebInfo --target install -j
- name: Build basic examples
run: |
make -C example -j
- name: Package gcno files
run: |
find . -type f -name "*.gcno" | tar --create --gzip --file=gcno_files.tar.gz --files-from=-
ls -la
pwd
tree .
- name: Upload gcno file
uses: actions/upload-artifact@v4
with:
name: gcno-files-${{matrix.enable_jit && 'jit' || 'no-jit'}}-${{matrix.container.name}}
include-hidden-files: true
path: |
./gcno_files.tar.gz
- name: Upload build results (without jit)
uses: actions/upload-artifact@v4
if: ${{!matrix.enable_jit}}
with:
name: runtime-package-no-jit-${{matrix.container.name}}
include-hidden-files: true
path: |
~/.bpftime
- name: Upload build results (with jit)
uses: actions/upload-artifact@v4
if: ${{matrix.enable_jit}}
with:
name: runtime-package-jit-${{matrix.container.name}}
include-hidden-files: true
path: |
~/.bpftime
build-and-test:
runs-on: ubuntu-22.04
needs: [build-runtime]
container:
image: "manjusakalza/bpftime-base-image:${{matrix.container.image}}"
options: " ${{matrix.privilege_options.options}}"
strategy:
fail-fast: true
matrix:
exclude:
- privilege_options:
enable: false
examples:
syscall_trace: true
- privilege_options:
enable: false
examples:
path: tailcall_minimal
- privilege_options:
enable: false
examples:
path: malloc
privilege_options:
- options: "--privileged -v /sys/kernel/debug/:/sys/kernel/debug:rw -v /sys/kernel/tracing:/sys/kernel/tracing:rw"
enable: true
- options: ""
enable: false
container:
- image: ubuntu-2204
name: ubuntu
- image: fedora-39
name: fedora
enable_jit:
- true
- false
examples:
- path: libbpf-tools/opensnoop
executable: ./opensnoop
victim: ./victim
syscall_trace: true
expected_str: " 0 test.txt"
name: opensnoop-libbpf-tools
- path: libbpf-tools/statsnoop
executable: ./statsnoop
victim: ./victim
syscall_trace: true
expected_str: "victim 0 0 /sys"
name: statsnoop
- path: malloc
executable: ./malloc
victim: ./victim
syscall_trace: false
expected_str: "malloc calls: "
name: malloc
- path: minimal
executable: ./uprobe
victim: ./victim
syscall_trace: false
expected_str: ""
name: minimal
- path: opensnoop
executable: ./opensnoop
victim: ./victim
syscall_trace: true
expected_str: " 0 test.txt"
name: opensnoop
- path: sslsniff
executable: ./sslsniff
victim: /bin/wget https://www.google.com
syscall_trace: false
expected_str: "----- DATA -----"
name: sslsniff
- path: libbpf-tools/bashreadline
executable: ./readline
victim: /bin/bash
syscall_trace: false
expected_str: "info"
name: bashreadline
- path: libbpf-tools/syscount
executable: ./syscount
victim: /bin/bash
syscall_trace: false
expected_str: "info"
name: syscount
- path: libbpf-tools/funclatency
executable: ./funclatency -i 1 ./victim:plus
victim: ./victim
syscall_trace: false
expected_str: "|*"
name: funclatency
- path: libbpf-tools/mountsnoop
executable: ./mountsnoop
victim: ./victim
syscall_trace: true
expected_str: mount(
name: mountsnoop
- path: libbpf-tools/sigsnoop
executable: ./sigsnoop
victim: ./victim
syscall_trace: true
expected_str: "victim 0 -1 0"
name: sigsnoop
- path: tailcall_minimal
executable: ./tailcall_minimal
victim: ./victim
syscall_trace: false
expected_str: "See /sys/kernel/debug/tracing/trace_pipe for output (15)"
name: tailcall_minimal
- path: usdt_minimal
executable: ./usdt_minimal
victim: ./victim
syscall_trace: false
expected_str: "bpf:"
name: usdt_minimal
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Download prebuilt runtime (with jit)
if: ${{matrix.enable_jit}}
uses: actions/download-artifact@v4
with:
name: runtime-package-jit-${{matrix.container.name}}
path: ~/.bpftime
- name: Download prebuilt runtime (without jit)
if: ${{!matrix.enable_jit}}
uses: actions/download-artifact@v4
with:
name: runtime-package-no-jit-${{matrix.container.name}}
path: ~/.bpftime
- name: Download gcno files
uses: actions/download-artifact@v4
with:
name: gcno-files-${{matrix.enable_jit && 'jit' || 'no-jit'}}-${{matrix.container.name}}
path: .
- name: Extract gcno files
run: |
ls -lah .
tar -zxvf gcno_files.tar.gz
pwd
- name: Install which(required by funclatency on fedora)
if: ${{matrix.container.name=='fedora' && matrix.examples.path=='libbpf-tools/funclatency'}}
run: |
yum install -y which
- name: Set permissions
run: |
chmod +x ~/.bpftime/*
- name: Show downloaded artifacts
run: |
ls ~/.bpftime
- name: Build test assets
run: |
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 (syscall_trace)
if: matrix.examples.syscall_trace
shell: bash
run: |
ROOT=$(pwd)
cd example/${{matrix.examples.path}}
python3 $ROOT/.github/script/run_example.py "${{matrix.examples.executable}}" "${{matrix.examples.victim}}" "${{matrix.examples.expected_str}}" "/github/home/.bpftime/bpftime -i /github/home/.bpftime" 1
- name: Test CLI - attach by running (uprobe)
if: '!matrix.examples.syscall_trace'
shell: bash
run: |
ROOT=$(pwd)
cd example/${{matrix.examples.path}}
python3 $ROOT/.github/script/run_example.py "${{matrix.examples.executable}}" "${{matrix.examples.victim}}" "${{matrix.examples.expected_str}}" "/github/home/.bpftime/bpftime -i /github/home/.bpftime" 0
- name: Generate example coverage (Ubuntu)
if: "matrix.container.image == 'ubuntu-2204'"
run: |
apt-get install -y gpg lcov
lcov --capture --directory . --directory .github --directory /github/home/.bpftime --output-file coverage-example.info --gcov-tool $(which gcov-12)
lcov --remove coverage-example.info '/usr/*' --output-file coverage-example.info
lcov --list coverage-example.info
- name: Generate example coverage (Fedora)
if: "matrix.container.image == 'fedora-39'"
run: |
dnf install -y lcov
lcov --capture --directory . --output-file coverage-example.info
lcov --remove coverage-example.info '/usr/*' --output-file coverage-example.info
lcov --list coverage-example.info
- name: Upload example coverage
uses: actions/upload-artifact@v4
with:
name: coverage-example-${{matrix.container.name}}-${{matrix.enable_jit}}-${{matrix.examples.name}}-${{matrix.privilege_options.enable}}
include-hidden-files: false
path: |
./coverage-example.info
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true # optional (default = false)
files: ./coverage-example.info
flags: coverage-example-${{matrix.container.name}}-${{matrix.enable_jit}}-${{matrix.examples.name}}-${{matrix.privilege_options.enable}}
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)
- name: Setup tmate session
# Setup SSH when manually triggered and failing, so we can debug CI more conveniently
if: "${{ failure() && github.event_name == 'workflow_dispatch' }}"
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: false