Skip to content

Commit

Permalink
keep black happy and assert static elf is not dynamic
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
  • Loading branch information
cmatsuoka committed Apr 7, 2019
1 parent 6e71442 commit 3e1289a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
47 changes: 41 additions & 6 deletions tests/fixture_setup/_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,66 @@ def _fake_elffile_extract(self, path):
glibc = elf.NeededLibrary(name="libc.so.6")
glibc.add_version("GLIBC_2.2.5")
glibc.add_version("GLIBC_2.26")
return (arch, "/lib64/ld-linux-x86-64.so.2", "", {glibc.name: glibc}, False, True)
return (
arch,
"/lib64/ld-linux-x86-64.so.2",
"",
{glibc.name: glibc},
False,
True,
)
elif name == "fake_elf-2.23":
glibc = elf.NeededLibrary(name="libc.so.6")
glibc.add_version("GLIBC_2.2.5")
glibc.add_version("GLIBC_2.23")
return (arch, "/lib64/ld-linux-x86-64.so.2", "", {glibc.name: glibc}, False, True)
return (
arch,
"/lib64/ld-linux-x86-64.so.2",
"",
{glibc.name: glibc},
False,
True,
)
elif name == "fake_elf-1.1":
glibc = elf.NeededLibrary(name="libc.so.6")
glibc.add_version("GLIBC_1.1")
glibc.add_version("GLIBC_0.1")
return (arch, "/lib64/ld-linux-x86-64.so.2", "", {glibc.name: glibc}, False, True)
return (
arch,
"/lib64/ld-linux-x86-64.so.2",
"",
{glibc.name: glibc},
False,
True,
)
elif name == "fake_elf-static":
return arch, "", "", {}, False, False
elif name == "fake_elf-shared-object":
openssl = elf.NeededLibrary(name="libssl.so.1.0.0")
openssl.add_version("OPENSSL_1.0.0")
return arch, "", "libfake_elf.so.0", {openssl.name: openssl}, False, True
return (arch, "", "libfake_elf.so.0", {openssl.name: openssl}, False, True)
elif name == "fake_elf-with-execstack":
glibc = elf.NeededLibrary(name="libc.so.6")
glibc.add_version("GLIBC_2.23")
return (arch, "/lib64/ld-linux-x86-64.so.2", "", {glibc.name: glibc}, True, True)
return (
arch,
"/lib64/ld-linux-x86-64.so.2",
"",
{glibc.name: glibc},
True,
True,
)
elif name == "fake_elf-with-bad-execstack":
glibc = elf.NeededLibrary(name="libc.so.6")
glibc.add_version("GLIBC_2.23")
return (arch, "/lib64/ld-linux-x86-64.so.2", "", {glibc.name: glibc}, True, True)
return (
arch,
"/lib64/ld-linux-x86-64.so.2",
"",
{glibc.name: glibc},
True,
True,
)
elif name == "libc.so.6":
return arch, "", "libc.so.6", {}, False, True
elif name == "libssl.so.1.0.0":
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ def test_skip_object_files(self):
def test_no_find_dependencies_statically_linked(self):
elf_files = elf.get_elf_files(self.fake_elf.root_path, {"fake_elf-static"})
self.assertThat(elf_files, Equals(set()))
elf_file = set(elf_files).pop()
self.assertThat(elf_file.is_dynamic, Equals(False))

def test_elf_with_execstack(self):
elf_files = elf.get_elf_files(
Expand Down

0 comments on commit 3e1289a

Please sign in to comment.