[DTrace-devel] [PATCH] test: fix the bitfield-offset fix
Nick Alcock
nick.alcock at oracle.com
Wed Mar 6 15:52:07 UTC 2024
Many systems on which CTF is too old for tst.bitfield-offset.d to pass will
also be too old for objdump --ctf=.ctf to work: in that case, we have no way
to tell how new the CTF is (and thus whether this bug is expected to be
fixed), so we have to skip it.
Even figuring out if this is the case is hard. We don't want to try to
objdump the entire kernel CTFA again in case it works (it's huge and takes
ages to dump: we're not exiting early on a version check here, after all).
But objdump returns with an exitcode of 1 both if an unrecognized option is
found *and* if the target contains no CTF at all -- so we must literally
grep for 'Unrecognized option' (under LANG=C) to be sure of spotting an
instance we must skip. (We also check for a zero exit code, because if our
random test executable *does* contain CTF and dumping it works there's no
need to grep the stderr for anything at all.)
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
test/unittest/bitfields/tst.bitfield-offset.x | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/test/unittest/bitfields/tst.bitfield-offset.x b/test/unittest/bitfields/tst.bitfield-offset.x
index 316c54a0d08f9..e49713af37830 100755
--- a/test/unittest/bitfields/tst.bitfield-offset.x
+++ b/test/unittest/bitfields/tst.bitfield-offset.x
@@ -7,11 +7,21 @@
# 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.
+# own: we must embed it into an ELF file ourselves. Worse yet,
+# objdump might be too old to read CTF at all: in this case, just
+# skip the test, since we can't possibly tell what it was
+# generated by.
+
+if ! objdump --ctf=.ctf --ctf-parent=shared_ctf /bin/true > /dev/null 2>&1 && \
+ LANG=C objdump --ctf=.ctf --ctf-parent=shared_ctf /bin/true 2>&1 | \
+ grep 'unrecognized option' > /dev/null 2>&1; then
+ exit 2
+fi
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; }'
--
2.43.0.272.gce700b77fd
More information about the DTrace-devel
mailing list