diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-30 16:07:02 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-04-12 13:53:32 -0400 |
commit | 8cbe0e73f4d57a8eb2d9578d93bf4207fcfb9c35 (patch) | |
tree | deaf0ae443c54dc18f38c0961de29dd71e84249d /tests/unittests | |
parent | 0689d8b3e10e969b7fed0af9ac906222858e4fb9 (diff) | |
download | sos-8cbe0e73f4d57a8eb2d9578d93bf4207fcfb9c35.tar.gz |
[Plugin] Don't tail binary files for `add_copy_spec()`
When a file collection will reach its sizelimit, don't tail the file if
it has binary content, as this will be useless collection.
Closes: #2851
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/plugin_tests.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/unittests/plugin_tests.py b/tests/unittests/plugin_tests.py index e469b78e..1d7cc96d 100644 --- a/tests/unittests/plugin_tests.py +++ b/tests/unittests/plugin_tests.py @@ -9,6 +9,7 @@ import unittest import os import tempfile import shutil +import random from io import StringIO @@ -16,6 +17,7 @@ from sos.report.plugins import Plugin, regex_findall, _mangle_command, PluginOpt from sos.archive import TarFileArchive from sos.policies.distros import LinuxPolicy from sos.policies.init_systems import InitSystem +from string import ascii_lowercase PATH = os.path.dirname(__file__) @@ -25,8 +27,10 @@ def j(filename): def create_file(size, dir=None): - f = tempfile.NamedTemporaryFile(delete=False, dir=dir) - f.write(b"*" * size * 1024 * 1024) + f = tempfile.NamedTemporaryFile(delete=False, dir=dir, mode='w') + fsize = size * 1024 * 1024 + content = ''.join(random.choice(ascii_lowercase) for x in range(fsize)) + f.write(content) f.flush() f.close() return f.name |