|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
| 3 | +import json |
3 | 4 | import os
|
4 | 5 | import platform
|
5 | 6 | import random
|
|
18 | 19 |
|
19 | 20 | # for these tests we use manylinux2014 images, because they're available on
|
20 | 21 | # multi architectures and include python3.8
|
| 22 | +DEFAULT_IMAGE_TEMPLATE = "quay.io/pypa/manylinux2014_{machine}:2023-09-04-0828984" |
21 | 23 | pm = platform.machine()
|
22 |
| -if pm == "x86_64": |
23 |
| - DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_x86_64:2020-05-17-2f8ac3b" |
| 24 | +if pm in {"x86_64", "ppc64le", "s390x"}: |
| 25 | + DEFAULT_IMAGE = DEFAULT_IMAGE_TEMPLATE.format(machine=pm) |
24 | 26 | elif pm in {"aarch64", "arm64"}:
|
25 |
| - DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_aarch64:2020-05-17-2f8ac3b" |
26 |
| -elif pm == "ppc64le": |
27 |
| - DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_ppc64le:2020-05-17-2f8ac3b" |
28 |
| -elif pm == "s390x": |
29 |
| - DEFAULT_IMAGE = "quay.io/pypa/manylinux2014_s390x:2020-05-17-2f8ac3b" |
| 27 | + DEFAULT_IMAGE = DEFAULT_IMAGE_TEMPLATE.format(machine="aarch64") |
30 | 28 | else:
|
31 | 29 | DEFAULT_IMAGE = ""
|
32 | 30 |
|
@@ -378,3 +376,24 @@ def test_parse_engine_config(config, name, create_args):
|
378 | 376 | engine_config = OCIContainerEngineConfig.from_config_string(config)
|
379 | 377 | assert engine_config.name == name
|
380 | 378 | assert engine_config.create_args == create_args
|
| 379 | + |
| 380 | + |
| 381 | +@pytest.mark.skipif(pm != "x86_64", reason="Only runs on x86_64") |
| 382 | +@pytest.mark.parametrize( |
| 383 | + ("image", "shell_args"), |
| 384 | + [ |
| 385 | + (DEFAULT_IMAGE_TEMPLATE.format(machine="i686"), ["/bin/bash"]), |
| 386 | + (DEFAULT_IMAGE_TEMPLATE.format(machine="x86_64"), ["linux32", "/bin/bash"]), |
| 387 | + ], |
| 388 | +) |
| 389 | +def test_enforce_32_bit(container_engine, image, shell_args): |
| 390 | + with OCIContainer(engine=container_engine, image=image, enforce_32_bit=True) as container: |
| 391 | + assert container.call(["uname", "-m"], capture_output=True).strip() == "i686" |
| 392 | + container_args = subprocess.run( |
| 393 | + f"{container.engine.name} inspect -f '{{{{json .Args }}}}' {container.name}", |
| 394 | + shell=True, |
| 395 | + check=True, |
| 396 | + stdout=subprocess.PIPE, |
| 397 | + text=True, |
| 398 | + ).stdout |
| 399 | + assert json.loads(container_args) == shell_args |
0 commit comments