@@ -143,8 +143,10 @@ def test_images_s3_bucket():
143143MICROVM_S3_FETCHER = MicrovmImageS3Fetcher (test_images_s3_bucket ())
144144
145145
146- def init_microvm (root_path , aux_binary_paths , features = '' ):
146+ def init_microvm (root_path , bin_cloner_path , features = '' ):
147147 """Auxiliary function for instantiating a microvm and setting it up."""
148+ # pylint: disable=redefined-outer-name
149+ # The fixture pattern causes a pylint false positive for that rule.
148150 microvm_id = str (uuid .uuid4 ())
149151 fc_binary , jailer_binary = build_tools .get_firecracker_binaries (
150152 root_path ,
@@ -156,7 +158,7 @@ def init_microvm(root_path, aux_binary_paths, features=''):
156158 jailer_binary_path = jailer_binary ,
157159 build_feature = features ,
158160 microvm_id = microvm_id ,
159- aux_bin_paths = aux_binary_paths
161+ bin_cloner_path = bin_cloner_path
160162 )
161163 vm .setup ()
162164 return vm
@@ -211,16 +213,11 @@ def _gcc_compile(src_file, output_file):
211213
212214
213215@pytest .fixture (scope = 'session' )
214- def aux_bin_paths (test_session_root_path ):
215- """Build external tools.
216-
217- They currently consist of:
216+ def bin_cloner_path (test_session_root_path ):
217+ """Build a binary that `clone`s into the jailer.
218218
219- * a binary that can properly use the `clone()` syscall;
220- * a jailer with a simple syscall whitelist;
221- * a jailer with a (syscall, arguments) advanced whitelist;
222- * a jailed binary that follows the seccomp rules;
223- * a jailed binary that breaks the seccomp rules.
219+ It's necessary because Python doesn't interface well with the `clone()`
220+ syscall directly.
224221 """
225222 # pylint: disable=redefined-outer-name
226223 # The fixture pattern causes a pylint false positive for that rule.
@@ -229,7 +226,14 @@ def aux_bin_paths(test_session_root_path):
229226 'host_tools/newpid_cloner.c' ,
230227 cloner_bin_path
231228 )
229+ yield cloner_bin_path
230+
232231
232+ @pytest .fixture (scope = 'session' )
233+ def bin_vsock_path (test_session_root_path ):
234+ """Build a simple vsock client/server application."""
235+ # pylint: disable=redefined-outer-name
236+ # The fixture pattern causes a pylint false positive for that rule.
233237 vsock_helper_bin_path = os .path .join (
234238 test_session_root_path ,
235239 'vsock_helper'
@@ -238,7 +242,22 @@ def aux_bin_paths(test_session_root_path):
238242 'host_tools/vsock_helper.c' ,
239243 vsock_helper_bin_path
240244 )
245+ yield vsock_helper_bin_path
246+
241247
248+ @pytest .fixture (scope = 'session' )
249+ def bin_seccomp_paths (test_session_root_path ):
250+ """Build jailers and jailed binaries to test seccomp.
251+
252+ They currently consist of:
253+
254+ * a jailer with a simple syscall whitelist;
255+ * a jailer with a (syscall, arguments) advanced whitelist;
256+ * a jailed binary that follows the seccomp rules;
257+ * a jailed binary that breaks the seccomp rules.
258+ """
259+ # pylint: disable=redefined-outer-name
260+ # The fixture pattern causes a pylint false positive for that rule.
242261 seccomp_build_path = os .path .join (
243262 test_session_root_path ,
244263 build_tools .CARGO_RELEASE_REL_PATH
@@ -282,17 +301,15 @@ def aux_bin_paths(test_session_root_path):
282301 )
283302
284303 yield {
285- 'cloner' : cloner_bin_path ,
286- 'vsock_helper' : vsock_helper_bin_path ,
287304 'demo_basic_jailer' : demo_basic_jailer ,
288305 'demo_advanced_jailer' : demo_advanced_jailer ,
289306 'demo_harmless' : demo_harmless ,
290307 'demo_malicious' : demo_malicious
291308 }
292309
293310
294- @pytest .fixture
295- def microvm (test_session_root_path , aux_bin_paths ):
311+ @pytest .fixture ()
312+ def microvm (test_session_root_path , bin_cloner_path ):
296313 """Instantiate a microvm."""
297314 # pylint: disable=redefined-outer-name
298315 # The fixture pattern causes a pylint false positive for that rule.
@@ -301,7 +318,7 @@ def microvm(test_session_root_path, aux_bin_paths):
301318 # microvm.
302319 vm = init_microvm (
303320 test_session_root_path ,
304- aux_bin_paths ,
321+ bin_cloner_path ,
305322 features = ''
306323 )
307324 yield vm
@@ -345,7 +362,7 @@ def test_microvm_any(request, microvm):
345362def test_multiple_microvms (
346363 test_session_root_path ,
347364 context ,
348- aux_bin_paths
365+ bin_cloner_path
349366):
350367 """Yield one or more microvms based on the context provided.
351368
@@ -361,7 +378,7 @@ def test_multiple_microvms(
361378
362379 # When the context specifies multiple microvms, we use the first vm to
363380 # populate the other ones by hardlinking its resources.
364- first_vm = init_microvm (test_session_root_path , aux_bin_paths )
381+ first_vm = init_microvm (test_session_root_path , bin_cloner_path )
365382 MICROVM_S3_FETCHER .init_vm_resources (
366383 microvm_resources ,
367384 first_vm
@@ -372,7 +389,7 @@ def test_multiple_microvms(
372389 # asserts that the `how_many` parameter is always positive
373390 # (i.e strictly greater than 0).
374391 for _ in range (how_many - 1 ):
375- vm = init_microvm (test_session_root_path , aux_bin_paths )
392+ vm = init_microvm (test_session_root_path , bin_cloner_path )
376393 MICROVM_S3_FETCHER .hardlink_vm_resources (
377394 microvm_resources ,
378395 first_vm ,
0 commit comments