[DTrace-devel] [PATCH] Add test for option "linkmode"

eugene.loh at oracle.com eugene.loh at oracle.com
Fri Mar 10 19:35:11 UTC 2023


From: Eugene Loh <eugene.loh at oracle.com>

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 test/unittest/options/tst.linkmode.r  | 17 ++++++++++++
 test/unittest/options/tst.linkmode.sh | 39 +++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 test/unittest/options/tst.linkmode.r
 create mode 100755 test/unittest/options/tst.linkmode.sh

diff --git a/test/unittest/options/tst.linkmode.r b/test/unittest/options/tst.linkmode.r
new file mode 100644
index 00000000..4b453f56
--- /dev/null
+++ b/test/unittest/options/tst.linkmode.r
@@ -0,0 +1,17 @@
+try
+Linux version 
+
+try -xlinkmode=static
+Linux version 
+
+try -xlinkmode=kernel
+Linux version 
+
+try -xlinkmode=foo
+try -xlinkmode=dynamic
+try -xlinkmode=dynamic -xknodefs
+Linux version 
+
+-- @@stderr --
+dtrace: failed to set -x linkmode: Invalid value for specified option
+dtrace: invalid probe specifier BEGIN { trace((string)`linux_banner); exit(0); }: relocation remains against kernel symbol vmlinux`linux_banner (offset {ptr})
diff --git a/test/unittest/options/tst.linkmode.sh b/test/unittest/options/tst.linkmode.sh
new file mode 100755
index 00000000..4e28f8bd
--- /dev/null
+++ b/test/unittest/options/tst.linkmode.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2023, 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.
+#
+
+# @@nosort
+
+dtrace=$1
+
+function mytest() {
+	echo try $1
+	$dtrace $1 -qn 'BEGIN { trace((string)`linux_banner); exit(0); }' | cut -c-14
+}
+
+# Test different link modes.
+# - (default) should be the same as "kernel"
+# - "static" means that all symbols are static
+# - "dynamic" means that all symbols are dynamic
+# - "kernel" means that kernel symbols are static while user symbols are dynamic
+# - "foo" would be unrecognized
+
+# But no DTrace (even Solaris) supported userspace symbol resolving.
+# So (default), "static", and "kernel" should all be the same.
+# They should all work.
+mytest " "
+mytest "-xlinkmode=static"
+mytest "-xlinkmode=kernel"
+
+# These should not work.
+mytest "-xlinkmode=foo"
+mytest "-xlinkmode=dynamic"
+
+# This should work.
+mytest "-xlinkmode=dynamic -xknodefs"
+
+exit 0
-- 
2.18.4




More information about the DTrace-devel mailing list