Skip to content

Commit

Permalink
test: Add test for option "linkmode"
Browse files Browse the repository at this point in the history
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 May 24, 2023
1 parent d2c5c87 commit dc7e695
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/unittest/options/tst.linkmode.r
Original file line number Diff line number Diff line change
@@ -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})
39 changes: 39 additions & 0 deletions test/unittest/options/tst.linkmode.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dc7e695

Please sign in to comment.