Skip to content

Commit

Permalink
Fix compilation problems in C tests
Browse files Browse the repository at this point in the history
The tests that are C source files are not compiling.  Fix those
errors, including:

- augmenting test_incflags in runtest.sh
  (and improving readability while we are at it)

- remove xfail for some tests

- update names of dtrace_syminfo_t members

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Oct 8, 2021
1 parent 5f57f40 commit c80033d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
11 changes: 7 additions & 4 deletions runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# and generated intermediate representation.
#
# Oracle Linux DTrace.
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.

Expand Down Expand Up @@ -522,7 +522,7 @@ if [[ -z $USE_INSTALLED ]]; then
dtrace="$(pwd)/build*/dtrace"
test_libdir="$(pwd)/build/dlibs"
test_ldflags="-L$(pwd)/build"
test_incflags="-Iuts/common -DARCH_$arch"
test_incflags="-Iinclude -Iuts/common -Ibuild -Ilibdtrace -DARCH_$arch"

if [[ -z $(eval echo $dtrace) ]]; then
echo "No dtraces available." >&2
Expand Down Expand Up @@ -1139,8 +1139,11 @@ for dt in $dtrace; do
fi
CC="${CC:-gcc}"
log "Compiling $CC -std=gnu99 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $test_incflags $CFLAGS $test_ldflags $LDFLAGS -o $tmpdir/$base $_test $link\n"
if ! $CC $CFLAGS -std=gnu99 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $test_incflags $test_ldflags $LDFLAGS -o $tmpdir/$(basename $base) $_test $link >/dev/null 2>$tmpdir/cc.err; then
CCline="$CC -std=gnu99 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
CCline="$CCline $test_incflags $CFLAGS $test_ldflags $LDFLAGS"
CCline="$CCline -o $tmpdir/$(basename $base) $_test $link"
log "Compiling $CCline\n"
if ! $CCline >/dev/null 2>$tmpdir/cc.err; then
fail=t
failmsg="compilation failure"
fail "$xfail" "$xfailmsg" "compilation failure"
Expand Down
3 changes: 1 addition & 2 deletions test/unittest/consumer/addr2str-null.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
/* @@xfail: dtv2 */

/*
* Verify that a dtrace_addr2str() of the null pointer does not
Expand Down
3 changes: 1 addition & 2 deletions test/unittest/consumer/tst.merge_ranges_bug25767469.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
/* @@xfail: dtv2 */

/*
* 25767469 dtrace_update() does not merge address ranges properly
Expand Down
26 changes: 13 additions & 13 deletions test/unittest/consumer/tst.symbols.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -195,8 +195,8 @@ void match_at_addr(int i, GElf_Sym *symp, dtrace_syminfo_t *sip) {
printf(" actual: %16.16llx %8.8llx %32s %20s\n",
(long long)symp->st_value,
(long long)symp->st_size,
sip->dts_name,
sip->dts_object);
sip->name,
sip->object);
}

/*
Expand All @@ -205,19 +205,19 @@ void match_at_addr(int i, GElf_Sym *symp, dtrace_syminfo_t *sip) {
* some known symbol at this address.
*/

if (strcmp(symbols[i].symname, sip->dts_name) == 0)
if (strcmp(symbols[i].symname, sip->name) == 0)
match = i;

j = i - 1;
while (match < 0 && j >= 0 && symbols[j].addr == symbols[i].addr) {
if (strcmp(symbols[j].symname, sip->dts_name) == 0)
if (strcmp(symbols[j].symname, sip->name) == 0)
match = j;
j--;
}

j = i + 1;
while (match < 0 && j < nsymbols && symbols[j].addr == symbols[i].addr) {
if (strcmp(symbols[j].symname, sip->dts_name) == 0)
if (strcmp(symbols[j].symname, sip->name) == 0)
match = j;
j++;
}
Expand All @@ -229,16 +229,16 @@ void match_at_addr(int i, GElf_Sym *symp, dtrace_syminfo_t *sip) {

if (match < 0 ||
symbols[match].size != symp->st_size ||
strcmp(symbols[match].modname, sip->dts_object)) {
strcmp(symbols[match].modname, sip->object)) {
nerrors++;
printf("ERROR: no such reported symbol\n");
printf(" expect:");
print_symbol(i);
printf(" actual: %16.16llx %8.8llx %32s %20s\n",
(long long)symp->st_value,
(long long)symp->st_size,
sip->dts_name,
sip->dts_object);
sip->name,
sip->object);
}
}

Expand Down Expand Up @@ -305,17 +305,17 @@ int check_lookup_by_name(dtrace_hdl_t *h, int specify_module) {

if (symbols[i].addr != sym.st_value ||
symbols[i].size != sym.st_size ||
strcmp(symbols[i].symname, si.dts_name) ||
strcmp(symbols[i].modname, si.dts_object)) {
strcmp(symbols[i].symname, si.name) ||
strcmp(symbols[i].modname, si.object)) {

printf("ERROR: mismatch\n");
printf(" expect:");
print_symbol(i);
printf(" actual: %16.16llx %8.8llx %32s %20s\n",
(long long)sym.st_value,
(long long)sym.st_size,
si.dts_name,
si.dts_object);
si.name,
si.object);
nerrors++;
}
}
Expand Down

0 comments on commit c80033d

Please sign in to comment.