1
1
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Pytest fixtures and redefined-outer-name don't mix well. Disable it.
5
+ # pylint:disable=redefined-outer-name
6
+
3
7
"""Imported by pytest at the start of every test session.
4
8
5
9
# Fixture Goals
@@ -178,8 +182,6 @@ def dump(self, result):
178
182
179
183
def init_microvm (root_path , bin_cloner_path , fc_binary = None , jailer_binary = None ):
180
184
"""Auxiliary function for instantiating a microvm and setting it up."""
181
- # pylint: disable=redefined-outer-name
182
- # The fixture pattern causes a pylint false positive for that rule.
183
185
microvm_id = str (uuid .uuid4 ())
184
186
185
187
# Update permissions for custom binaries.
@@ -255,8 +257,6 @@ def test_fc_session_root_path():
255
257
@pytest .fixture
256
258
def test_session_tmp_path (test_fc_session_root_path ):
257
259
"""Yield a random temporary directory. Destroyed on teardown."""
258
- # pylint: disable=redefined-outer-name
259
- # The fixture pattern causes a pylint false positive for that rule.
260
260
261
261
tmp_path = tempfile .mkdtemp (prefix = test_fc_session_root_path )
262
262
yield tmp_path
@@ -285,8 +285,6 @@ def bin_cloner_path(test_fc_session_root_path):
285
285
It's necessary because Python doesn't interface well with the `clone()`
286
286
syscall directly.
287
287
"""
288
- # pylint: disable=redefined-outer-name
289
- # The fixture pattern causes a pylint false positive for that rule.
290
288
cloner_bin_path = os .path .join (test_fc_session_root_path , "newpid_cloner" )
291
289
_gcc_compile ("host_tools/newpid_cloner.c" , cloner_bin_path )
292
290
yield cloner_bin_path
@@ -295,8 +293,6 @@ def bin_cloner_path(test_fc_session_root_path):
295
293
@pytest .fixture (scope = "session" )
296
294
def bin_vsock_path (test_fc_session_root_path ):
297
295
"""Build a simple vsock client/server application."""
298
- # pylint: disable=redefined-outer-name
299
- # The fixture pattern causes a pylint false positive for that rule.
300
296
vsock_helper_bin_path = os .path .join (test_fc_session_root_path , "vsock_helper" )
301
297
_gcc_compile ("host_tools/vsock_helper.c" , vsock_helper_bin_path )
302
298
yield vsock_helper_bin_path
@@ -305,7 +301,6 @@ def bin_vsock_path(test_fc_session_root_path):
305
301
@pytest .fixture (scope = "session" )
306
302
def change_net_config_space_bin (test_fc_session_root_path ):
307
303
"""Build a binary that changes the MMIO config space."""
308
- # pylint: disable=redefined-outer-name
309
304
change_net_config_space_bin = os .path .join (
310
305
test_fc_session_root_path , "change_net_config_space"
311
306
)
@@ -327,8 +322,6 @@ def bin_seccomp_paths(test_fc_session_root_path):
327
322
* a jailed binary that follows the seccomp rules;
328
323
* a jailed binary that breaks the seccomp rules.
329
324
"""
330
- # pylint: disable=redefined-outer-name
331
- # The fixture pattern causes a pylint false positive for that rule.
332
325
seccomp_build_path = os .path .join (
333
326
test_fc_session_root_path , build_tools .CARGO_RELEASE_REL_PATH
334
327
)
@@ -367,8 +360,6 @@ def bin_seccomp_paths(test_fc_session_root_path):
367
360
@pytest .fixture (scope = "session" )
368
361
def uffd_handler_paths (test_fc_session_root_path ):
369
362
"""Build UFFD handler binaries."""
370
- # pylint: disable=redefined-outer-name
371
- # The fixture pattern causes a pylint false positive for that rule.
372
363
uffd_build_path = os .path .join (
373
364
test_fc_session_root_path , build_tools .CARGO_RELEASE_REL_PATH
374
365
)
@@ -402,9 +393,6 @@ def uffd_handler_paths(test_fc_session_root_path):
402
393
@pytest .fixture ()
403
394
def microvm (test_fc_session_root_path , bin_cloner_path ):
404
395
"""Instantiate a microvm."""
405
- # pylint: disable=redefined-outer-name
406
- # The fixture pattern causes a pylint false positive for that rule.
407
-
408
396
# Make sure the necessary binaries are there before instantiating the
409
397
# microvm.
410
398
vm = init_microvm (test_fc_session_root_path , bin_cloner_path )
@@ -455,8 +443,6 @@ def test_microvm_any(request, microvm):
455
443
test cases for each test that depends on this fixture, each receiving a
456
444
microvm instance with a different microvm image.
457
445
"""
458
- # pylint: disable=redefined-outer-name
459
- # The fixture pattern causes a pylint false positive for that rule.
460
446
461
447
MICROVM_S3_FETCHER .init_vm_resources (request .param , microvm )
462
448
yield microvm
@@ -471,8 +457,6 @@ def test_multiple_microvms(test_fc_session_root_path, context, bin_cloner_path):
471
457
of the guest image used to spawn a microvm and the number of microvms
472
458
to spawn.
473
459
"""
474
- # pylint: disable=redefined-outer-name
475
- # The fixture pattern causes a pylint false positive for that rule.
476
460
microvms = []
477
461
(microvm_resources , how_many ) = context
478
462
0 commit comments