Skip to content

Commit

Permalink
test: skip a test when CTF is built with dwarf2ctf
Browse files Browse the repository at this point in the history
Bitfields are somewhat broken in dwarf2ctf and unlikely ever to be fixed, so
skip a test that checks if they work.  This requires detecting, not whether
DTrace was built with libctf, but whether the CTF was built with the
toolchain CTF machinery.

We can reliably detect this by checking the CTF version number: 3
(CTF_VERSION_2) is libdtrace-ctf 1.0 / dwarf2ctf, while all versions of
binutils CTF in anything like current use are CTF_VERSION_3.  (Unreleased
versions of libdtrace-ctf can emit CTF_VERSION_3, but this is not in use to
build kernels anywhere I know of.)

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Mar 6, 2024
1 parent ffd89e0 commit b238cdf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/unittest/bitfields/tst.bitfield-offset.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
# This is expected to fail on systems where the CTF was built
# with dwarf2ctf. We can determine this with nothing more than
# objdump, because the CTF version number differs.
#
# Alas objdump cannot read vmlinux.ctfa of this vintage on its
# own: we must embed it into an ELF file ourselves.

ctfa=$tmpdir/vmlinux.ctfa
trap "rm -f $ctfa" EXIT ERR

objcopy --add-section=.ctf=/lib/modules/$(uname -r)/kernel/vmlinux.ctfa /bin/true $ctfa
objdump --ctf=.ctf --ctf-parent=shared_ctf $ctfa |\
awk '/Version: 3/ { exit 1; } /Version: / { exit 0; }'

0 comments on commit b238cdf

Please sign in to comment.