Skip to content

Commit

Permalink
test: Add tests for ldpath
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 Feb 26, 2023
1 parent 279196b commit 27a7d5f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/unittest/options/err.D_PRAGMA_OPTSET.ldpath.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.
*/

/*
* ASSERTION: Option ldpath cannot be used from within a D program.
*
* SECTION: Options and Tunables/Consumer Options
*/

#pragma D option ldpath=/nonexistent/directory

BEGIN
{
exit(0);
}
2 changes: 2 additions & 0 deletions test/unittest/options/err.D_PRAGMA_OPTSET.ldpath.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- @@stderr --
dtrace: failed to compile script test/unittest/options/err.D_PRAGMA_OPTSET.ldpath.d: [D_PRAGMA_OPTSET] line 14: failed to set option 'ldpath' to '/nonexistent/directory': Option cannot be used from within a D program
19 changes: 19 additions & 0 deletions test/unittest/options/err.ldpath.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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.
*/

/*
* ASSERTION: The ldpath option changes the ld path.
*
* SECTION: Options and Tunables/Consumer Options
*/

/* @@runtest-opts: -G -xldpath=/nonexistent/ld */

BEGIN
{
exit(0);
}
3 changes: 3 additions & 0 deletions test/unittest/options/err.ldpath.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- @@stderr --
sh: /nonexistent/ld: No such file or directory
dtrace: failed to link script test/unittest/options/err.ldpath: failed to link err.ldpath.o: /nonexistent/ld exited with status 127
10 changes: 10 additions & 0 deletions test/unittest/options/err.ldpath.r.p
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/gawk -f

/: \/nonexistent\/ld:/ {
print "sh: /nonexistent/ld: No such file or directory";
next;
}

{
print;
}
17 changes: 17 additions & 0 deletions test/unittest/options/tst.ldpath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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.
#

dtrace=$1

DIRNAME="$tmpdir/ldpath.$$.$RANDOM"
mkdir -p $DIRNAME
cd $DIRNAME

# ldpath=ld does nothing remarkable, but this test complements err.ldpath.d
$dtrace $dt_flags -G -xldpath=ld -n 'BEGIN {exit(0)}'
exit $?

0 comments on commit 27a7d5f

Please sign in to comment.