24
24
25
25
import inspect
26
26
import os
27
- import platform
28
27
import re
29
28
import shutil
30
29
import sys
@@ -196,8 +195,8 @@ def change_net_config_space_bin(test_fc_session_root_path):
196
195
yield change_net_config_space_bin
197
196
198
197
199
- @pytest .fixture ( scope = "session" )
200
- def bin_seccomp_paths (test_fc_session_root_path ):
198
+ @pytest .fixture
199
+ def bin_seccomp_paths ():
201
200
"""Build jailers and jailed binaries to test seccomp.
202
201
203
202
They currently consist of:
@@ -206,48 +205,20 @@ def bin_seccomp_paths(test_fc_session_root_path):
206
205
* a jailed binary that follows the seccomp rules;
207
206
* a jailed binary that breaks the seccomp rules.
208
207
"""
209
- seccomp_build_path = (
210
- Path (test_fc_session_root_path ) / build_tools .CARGO_RELEASE_REL_PATH
211
- )
212
- release_binaries_path = seccomp_build_path / build_tools .RELEASE_BINARIES_REL_PATH
213
-
214
- seccomp_examples = ["jailer" , "harmless" , "malicious" , "panic" ]
215
-
216
- demos = {}
217
-
218
- for example in seccomp_examples :
219
- build_tools .cargo_build (
220
- seccomp_build_path ,
221
- f"--release --target { platform .machine ()} -unknown-linux-musl --example seccomp_{ example } " ,
222
- )
223
-
224
- demos [f"demo_{ example } " ] = release_binaries_path / f"examples/seccomp_{ example } "
225
-
208
+ demos = {
209
+ f"demo_{ example } " : build_tools .get_example (f"seccomp_{ example } " )
210
+ for example in ["jailer" , "harmless" , "malicious" , "panic" ]
211
+ }
226
212
yield demos
227
213
228
214
229
- @pytest .fixture ( scope = "session" )
230
- def uffd_handler_paths (test_fc_session_root_path ):
215
+ @pytest .fixture
216
+ def uffd_handler_paths ():
231
217
"""Build UFFD handler binaries."""
232
- uffd_build_path = (
233
- Path (test_fc_session_root_path ) / build_tools .CARGO_RELEASE_REL_PATH
234
- )
235
- release_binaries_path = uffd_build_path / build_tools .RELEASE_BINARIES_REL_PATH
236
-
237
- uffd_handlers = ["malicious" , "valid" ]
238
-
239
- handlers = {}
240
-
241
- for handler in uffd_handlers :
242
- build_tools .cargo_build (
243
- uffd_build_path ,
244
- f"--release --target { platform .machine ()} -unknown-linux-musl --example uffd_{ handler } _handler" ,
245
- )
246
-
247
- handlers [f"{ handler } _handler" ] = (
248
- release_binaries_path / f"examples/uffd_{ handler } _handler"
249
- )
250
-
218
+ handlers = {
219
+ f"{ handler } _handler" : build_tools .get_example (f"uffd_{ handler } _handler" )
220
+ for handler in ["malicious" , "valid" ]
221
+ }
251
222
yield handlers
252
223
253
224
0 commit comments