[DTrace-devel] [PATCH] test: Add test for libdir
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue Jan 31 22:22:00 UTC 2023
From: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
test/unittest/options/tst.libdir.r | 3 +++
test/unittest/options/tst.libdir.sh | 31 +++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100644 test/unittest/options/tst.libdir.r
create mode 100755 test/unittest/options/tst.libdir.sh
diff --git a/test/unittest/options/tst.libdir.r b/test/unittest/options/tst.libdir.r
new file mode 100644
index 00000000..718bb99b
--- /dev/null
+++ b/test/unittest/options/tst.libdir.r
@@ -0,0 +1,3 @@
+DTrace found the faulty D program in the specified subdirectory
+-- @@stderr --
+dtrace: invalid probe specifier BEGIN {exit(0)}: "subdirectory/faulty_D_program.d", line 2: undefined function name: nonexistent_action
diff --git a/test/unittest/options/tst.libdir.sh b/test/unittest/options/tst.libdir.sh
new file mode 100755
index 00000000..bf56f6b3
--- /dev/null
+++ b/test/unittest/options/tst.libdir.sh
@@ -0,0 +1,31 @@
+#!/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/libdir.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# place a faulty D program in a subdirectory
+mkdir subdirectory
+cat << EOF > subdirectory/faulty_D_program.d
+BEGIN {
+ nonexistent_action();
+}
+EOF
+
+# check that the subdirectory (and its faulty program) is found
+$dtrace $dt_flags -xlibdir=subdirectory -n 'BEGIN {exit(0)}'
+if [ $? -eq 0 ]; then
+ echo ERROR: DTrace should have failed due to faulty D program
+ exit 1
+else
+ echo DTrace found the faulty D program in the specified subdirectory
+ exit 0
+fi
--
2.18.4
More information about the DTrace-devel
mailing list