Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bytetostr():
"""
Test bytetostr function
"""
list_items = (
b'\xc5\xbe\xc3\xad\xc5\xbeala',
'texty',
)
item = b'p\xc5\x99\xc3\xad\xc5\xa1ern\xc4\x9b \xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd k\xc5\xaf\xc5\x88'
result = helpers.byte_to_string(item)
assert isinstance(result, str)
assert result == 'příšerně žluťoučký kůň'
result = helpers.byte_to_string(list_items)
assert isinstance(result, list)
assert result[0] == 'žížala'
def test_warnprint(capsys):
"""
Check we print stuff to stderr
"""
message = 'I am writing to stderr'
helpers.print_warning(message)
out, err = capsys.readouterr()
assert message not in out
assert message in err
def get_tested_spec_package(name):
filename = Path(name).name + '.spec'
pkg_path = list(get_tested_path(name).parent.glob(filename))[0]
return FakePkg(pkg_path)
def test_lto_archive_text(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('stripped-lto.a'), 'x.a')
out = output.print_results(output.results)
assert 'E: lto-no-text-in-archive' in out
assert 'E: static-library-without-debuginfo' in out
def test_unused_dependency_in_package_for_executable(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('appletviewer'), '/usr/bin/appletviewer')
assert not test.readelf_parser.parsing_failed_reason()
assert not test.ldd_parser.parsing_failed_reason
out = output.print_results(output.results)
assert 'W: unused-direct-shlib-dependency ' in out
def test_lto_archive_preinit_array(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('libclang_rt.asan-preinit-x86_64.a'), 'x.a')
assert 'E: lto-no-text-in-archive' not in output.print_results(output.results)
def test_stripped_archive(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('stripped-archive.a'), 'x.a')
out = output.print_results(output.results)
assert 'E: static-library-without-symtab' in out
def test_lto_archive_text_function_sections(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('function-sections.a'), 'x.a')
assert 'E: lto-no-text-in-archive' not in output.print_results(output.results)
def test_executable_stack(binariescheck):
output, test = binariescheck
test.run_elf_checks(FakePkg('fake'), get_full_path('executable-stack'), 'a.out')
assert 'E: executable-stack' in output.results[0]
def builddatecheck():
CONFIG.info = True
output = Filter(CONFIG)
test = BuildDateCheck(CONFIG, output)
return output, test