Lines 2-7
Link Here
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
3 |
|
4 |
import platform |
4 |
import platform |
|
|
5 |
import resource |
5 |
|
6 |
|
6 |
import pytest |
7 |
import pytest |
7 |
|
8 |
|
Lines 12-18
from portage.const import BASH_BINARY
Link Here
|
12 |
@pytest.mark.skipif(platform.system() != "Linux", reason="not Linux") |
13 |
@pytest.mark.skipif(platform.system() != "Linux", reason="not Linux") |
13 |
def test_spawnE2big(capsys, tmp_path): |
14 |
def test_spawnE2big(capsys, tmp_path): |
14 |
env = dict() |
15 |
env = dict() |
15 |
env["VERY_LARGE_ENV_VAR"] = "X" * 1024 * 256 |
16 |
# Kernel MAX_ARG_STRLEN is defined as 32 * PAGE_SIZE |
|
|
17 |
max_arg_strlen_bytes = 1024 * 32 * resource.getpagesize() |
18 |
env["VERY_LARGE_ENV_VAR"] = "X" * max_arg_strlen_bytes |
16 |
|
19 |
|
17 |
logfile = tmp_path / "logfile" |
20 |
logfile = tmp_path / "logfile" |
18 |
echo_output = "Should never appear" |
21 |
echo_output = "Should never appear" |
Lines 24-30
def test_spawnE2big(capsys, tmp_path):
Link Here
|
24 |
with open(logfile) as f: |
27 |
with open(logfile) as f: |
25 |
logfile_content = f.read() |
28 |
logfile_content = f.read() |
26 |
assert ( |
29 |
assert ( |
27 |
"Largest environment variable: VERY_LARGE_ENV_VAR (262164 bytes)" |
30 |
f"Largest environment variable: VERY_LARGE_ENV_VAR ({max_arg_strlen_bytes + 20} bytes)" |
28 |
in logfile_content |
31 |
in logfile_content |
29 |
) |
32 |
) |
30 |
assert retval == 1 |
33 |
assert retval == 1 |