Skip to content

Commit

Permalink
elf: add tests for shlibs required analysis
Browse files Browse the repository at this point in the history
the libtest2fbsd.so.1 was created like this:
cc empty.c -o libtest2fbsd.so.1 -Wl,-soname=libtest2fbsd.so.1 -Wl,--rpath='$ORIGIN' -l foo -L . -shared
libfoo.so.1 was created like this:
cc empty -o libfoo.so.1 -Wl,-soname=libfoo.so.1 -shared
  • Loading branch information
bapt committed Nov 21, 2024
1 parent d00e8cd commit aca44db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Binary file added tests/frontend/libfoo.so.1
Binary file not shown.
Binary file added tests/frontend/libtest2fbsd.so.1
Binary file not shown.
12 changes: 11 additions & 1 deletion tests/lib/pkg_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,27 @@ ATF_TC_BODY(analyse_elf, tc)
ATF_REQUIRE_EQ(EPKG_OK, pkg_new(&p, PKG_INSTALLED));
ATF_REQUIRE(p != NULL);

ATF_REQUIRE_EQ(tll_length(p->shlibs_required), 0);
ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 0);
ATF_REQUIRE_EQ(pkg_analyse_elf(false, p, binpath), EPKG_OK);
ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 1);
ATF_REQUIRE_STREQ(tll_front(p->shlibs_provided), "libtestfbsd.so.1");

free(binpath);

xasprintf(&binpath, "%s/Makefile.autosetup", atf_tc_get_config_var(tc, "srcdir"));
ATF_REQUIRE_EQ(pkg_analyse_elf(false, p, binpath), EPKG_END);
ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 1);
free(binpath);

ATF_REQUIRE_EQ(tll_length(p->shlibs_required), 0);
xasprintf(&binpath, "%s/frontend/libtest2fbsd.so.1", atf_tc_get_config_var(tc, "srcdir"));
ATF_REQUIRE_EQ(pkg_analyse_elf(false, p, binpath), EPKG_OK);
ATF_REQUIRE_EQ(tll_length(p->shlibs_provided), 2);
ATF_REQUIRE_STREQ(tll_back(p->shlibs_provided), "libtest2fbsd.so.1");
ATF_REQUIRE_EQ(tll_length(p->shlibs_required), 1);
ATF_REQUIRE_STREQ(tll_front(p->shlibs_required), "libfoo.so.1");
free(binpath);

}

ATF_TP_ADD_TCS(tp)
Expand Down

0 comments on commit aca44db

Please sign in to comment.