Skip to content

Commit

Permalink
test: Fix tst.symbols.c
Browse files Browse the repository at this point in the history
Skip symbols (e.g., ftrace_trampoline) in module __builtin__ftrace
since we cannot load the module ELF.

Fix the check for duplicate symbols in the "lookup by name" test.
Specifically, we were checking for duplicates when dtrace_lookup_by_name()
failed.  Check for duplicates when that function succeeds.  This fix
is necessitated by commit 8151fb8 "htab reduction: symtab", which
makes it hard for us to know which duplicate will be chosen.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
  • Loading branch information
euloh committed Feb 2, 2022
1 parent 1abff1c commit 266560f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/unittest/consumer/tst.symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ int read_symbols() {
if (strcmp(modname, "bpf]") == 0)
continue;

if (strcmp(modname, "__builtin__ftrace]") == 0)
continue;

/*
* In libdtrace/dt_module.c function dt_modsym_update(),
* we skip a number of symbols. Do not test them. The
Expand Down Expand Up @@ -284,19 +287,10 @@ int check_lookup_by_name(dtrace_hdl_t *h, int specify_module) {
specify_module ? " and module" : "");
for (i = 0; i < nsymbols; i++) {
nchecks++;

if (dtrace_lookup_by_name(h,
specify_module ? symbols[i].modname : DTRACE_OBJ_KMODS,
symbols[i].symname, &sym, &si)) {

/*
* If the module has another symbol with this name,
* it is okay that the lookup failed.
*/
if (duplicate(i) >= 0) {
n_dupl++;
continue;
}

printf("ERROR: dtrace_lookup_by_name failed\n");
printf(" expect:");
print_symbol(i);
Expand All @@ -308,6 +302,11 @@ int check_lookup_by_name(dtrace_hdl_t *h, int specify_module) {
strcmp(symbols[i].symname, si.name) ||
strcmp(symbols[i].modname, si.object)) {

if (duplicate(i) >= 0) {
n_dupl++;
continue;
}

printf("ERROR: mismatch\n");
printf(" expect:");
print_symbol(i);
Expand Down

0 comments on commit 266560f

Please sign in to comment.