Skip to content

Commit c351210

Browse files
HoyeonRheeyonghong-song
authored andcommitted
tests: add coverage for versioned SONAME resolution
Add tests for bcc_procutils_which_so{_in_process}() to verify correct behavior when resolving versioned SONAME fragments. Use library with long-stable SONAME version (libc.so.6), which have remained unchanged for over a decade and ensure deterministic results across systems. Signed-off-by: Hoyeon Lee <[email protected]>
1 parent beb1fe4 commit c351210

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/cc/test_c_api.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ TEST_CASE("shared object resolution using loaded libraries with the generalized
7070
free(libelf);
7171
}
7272

73+
TEST_CASE("versioned shared object resolution with the generalized function", "[c_api]") {
74+
char *libc = bcc_procutils_which_so("c.so.6", 0);
75+
REQUIRE(libc);
76+
REQUIRE(libc[0] == '/');
77+
REQUIRE(string(libc).find("libc.so.6") != string::npos);
78+
free(libc);
79+
}
80+
81+
TEST_CASE("versioned shared object resolution using loaded libraries", "[c_api]") {
82+
char *libc = bcc_procutils_which_so_in_process("c.so.6", getpid());
83+
REQUIRE(libc);
84+
REQUIRE(libc[0] == '/');
85+
REQUIRE(string(libc).find("libc.so.6") != string::npos);
86+
free(libc);
87+
}
88+
89+
TEST_CASE("versioned shared object resolution using loaded libraries with the generalized function", "[c_api]") {
90+
char *libc = bcc_procutils_which_so("c.so.6", getpid());
91+
REQUIRE(libc);
92+
REQUIRE(libc[0] == '/');
93+
REQUIRE(string(libc).find("libc.so.6") != string::npos);
94+
free(libc);
95+
}
96+
7397
TEST_CASE("binary resolution with `which`", "[c_api]") {
7498
char *ld = bcc_procutils_which("ld");
7599
REQUIRE(ld);

0 commit comments

Comments
 (0)