blob: 185344881166af431c9ce9c11f5a31481d4ff0d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
import platform
import tempfile
from pathlib import Path
import portage.process
from portage import shutil
from portage.tests import TestCase
class SpawnWarnLargeEnvTestCase(TestCase):
def testSpawnWarnLargeEnv(self):
if platform.system() != "Linux":
self.skipTest("not Linux")
env = dict()
env["LARGE_ENV_VAR"] = "X" * 1024 * 96
tmpdir = tempfile.mkdtemp()
previous_env_too_large_warnings = portage.process.env_too_large_warnings
try:
logfile = tmpdir / Path("logfile")
echo_output = "This is an echo process with a large env"
retval = portage.process.spawn(
["echo", echo_output],
env=env,
logfile=logfile,
warn_on_large_env=True,
)
with open(logfile) as f:
logfile_content = f.read()
self.assertIn(
echo_output,
logfile_content,
)
self.assertTrue(
portage.process.env_too_large_warnings > previous_env_too_large_warnings
)
self.assertEqual(retval, 0)
finally:
shutil.rmtree(tmpdir)
|