[DTrace-devel] [PATCH 07/12] Add tests for various options and tunables
Kris Van Hees
kris.van.hees at oracle.com
Wed Jul 13 19:17:49 UTC 2022
Tests added for:
-xargref
-xbufsize
-xcore
-xcppargs
-xcpphdrs
-xcpppath
-xctypes
-xbufsize (and -b)
-xdebug
-xdefaultargs
-xdefine (and -D)
-xdestructive (and -w)
-xdtypes
-xempty
-xerrtags
-xflowindent (and -F)
-xkdefs
-xknodefs
-xundef (and -U)
-xzdefs (and -Z)
Tests moved for:
-xbpglog
-xbpglogsize
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
test/unittest/options/err.D_ASRELO.kdefs.d | 19 +++++++
test/unittest/options/err.D_ASRELO.kdefs.r | 2 +
test/unittest/options/err.D_EMPTY.errtags.d | 14 ++++++
test/unittest/options/err.D_EMPTY.errtags.r | 2 +
test/unittest/options/err.D_EMPTY.no-empty.d | 12 +++++
.../err.D_MACRO_UNDEF.no-defaultargs.d | 22 ++++++++
.../err.D_MACRO_UNDEF.no-defaultargs.r | 2 +
.../err.D_MACRO_UNDEF.no-defaultargs2.d | 27 ++++++++++
.../err.D_MACRO_UNDEF.no-defaultargs2.r | 2 +
.../options/err.D_MACRO_UNUSED.no-argref.d | 24 +++++++++
.../options/err.D_PRAGCTL_INVAL.no-cpp.d | 1 -
test/unittest/options/err.b-too-low.d | 34 +++++++++++++
test/unittest/options/err.b-too-low.r | 3 ++
test/unittest/options/err.bufsize-too-low.d | 34 +++++++++++++
test/unittest/options/err.bufsize-too-low.r | 3 ++
test/unittest/options/err.empty.d | 14 ++++++
test/unittest/options/err.empty.r | 3 ++
test/unittest/options/err.no-errtags.d | 12 +++++
test/unittest/options/err.no-errtags.r | 2 +
test/unittest/options/tst.D.d | 24 +++++++++
test/unittest/options/tst.F.d | 50 +++++++++++++++++++
test/unittest/options/tst.F.r | 44 ++++++++++++++++
test/unittest/options/tst.U.d | 28 +++++++++++
test/unittest/options/tst.Z.d | 20 ++++++++
test/unittest/options/tst.argref.d | 24 +++++++++
test/unittest/options/tst.b.d | 34 +++++++++++++
.../{misc => options}/tst.bpflog-cmdline.sh | 0
.../{misc => options}/tst.bpflog-pragma.sh | 0
.../tst.bpflogsize-cmdline.sh | 0
.../tst.bpflogsize-pragma.sh | 0
test/unittest/options/tst.bufsize.d | 34 +++++++++++++
test/unittest/options/tst.core.sh | 19 +++++++
test/unittest/options/tst.cpp.d | 1 -
test/unittest/options/tst.cppargs.sh | 24 +++++++++
test/unittest/options/tst.cpphdrs.sh | 23 +++++++++
test/unittest/options/tst.cpppath.r | 4 ++
test/unittest/options/tst.cpppath.sh | 31 ++++++++++++
test/unittest/options/tst.ctypes.sh | 31 ++++++++++++
test/unittest/options/tst.debug.sh | 23 +++++++++
test/unittest/options/tst.defaultargs.d | 24 +++++++++
test/unittest/options/tst.defaultargs2.d | 27 ++++++++++
test/unittest/options/tst.define.d | 24 +++++++++
test/unittest/options/tst.destructive.d | 20 ++++++++
test/unittest/options/tst.dtypes.sh | 31 ++++++++++++
test/unittest/options/tst.flowindent.d | 50 +++++++++++++++++++
test/unittest/options/tst.flowindent.r | 44 ++++++++++++++++
test/unittest/options/tst.knodefs.sh | 27 ++++++++++
test/unittest/options/tst.undef.d | 28 +++++++++++
test/unittest/options/tst.w.d | 20 ++++++++
test/unittest/options/tst.zdefs.d | 20 ++++++++
50 files changed, 959 insertions(+), 2 deletions(-)
create mode 100644 test/unittest/options/err.D_ASRELO.kdefs.d
create mode 100644 test/unittest/options/err.D_ASRELO.kdefs.r
create mode 100644 test/unittest/options/err.D_EMPTY.errtags.d
create mode 100644 test/unittest/options/err.D_EMPTY.errtags.r
create mode 100644 test/unittest/options/err.D_EMPTY.no-empty.d
create mode 100644 test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d
create mode 100644 test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.r
create mode 100644 test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d
create mode 100644 test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.r
create mode 100644 test/unittest/options/err.D_MACRO_UNUSED.no-argref.d
create mode 100644 test/unittest/options/err.b-too-low.d
create mode 100644 test/unittest/options/err.b-too-low.r
create mode 100644 test/unittest/options/err.bufsize-too-low.d
create mode 100644 test/unittest/options/err.bufsize-too-low.r
create mode 100644 test/unittest/options/err.empty.d
create mode 100644 test/unittest/options/err.empty.r
create mode 100644 test/unittest/options/err.no-errtags.d
create mode 100644 test/unittest/options/err.no-errtags.r
create mode 100644 test/unittest/options/tst.D.d
create mode 100644 test/unittest/options/tst.F.d
create mode 100644 test/unittest/options/tst.F.r
create mode 100644 test/unittest/options/tst.U.d
create mode 100644 test/unittest/options/tst.Z.d
create mode 100644 test/unittest/options/tst.argref.d
create mode 100644 test/unittest/options/tst.b.d
rename test/unittest/{misc => options}/tst.bpflog-cmdline.sh (100%)
rename test/unittest/{misc => options}/tst.bpflog-pragma.sh (100%)
rename test/unittest/{misc => options}/tst.bpflogsize-cmdline.sh (100%)
rename test/unittest/{misc => options}/tst.bpflogsize-pragma.sh (100%)
create mode 100644 test/unittest/options/tst.bufsize.d
create mode 100755 test/unittest/options/tst.core.sh
create mode 100755 test/unittest/options/tst.cppargs.sh
create mode 100755 test/unittest/options/tst.cpphdrs.sh
create mode 100644 test/unittest/options/tst.cpppath.r
create mode 100755 test/unittest/options/tst.cpppath.sh
create mode 100755 test/unittest/options/tst.ctypes.sh
create mode 100755 test/unittest/options/tst.debug.sh
create mode 100644 test/unittest/options/tst.defaultargs.d
create mode 100644 test/unittest/options/tst.defaultargs2.d
create mode 100644 test/unittest/options/tst.define.d
create mode 100644 test/unittest/options/tst.destructive.d
create mode 100755 test/unittest/options/tst.dtypes.sh
create mode 100644 test/unittest/options/tst.flowindent.d
create mode 100644 test/unittest/options/tst.flowindent.r
create mode 100755 test/unittest/options/tst.knodefs.sh
create mode 100644 test/unittest/options/tst.undef.d
create mode 100644 test/unittest/options/tst.w.d
create mode 100644 test/unittest/options/tst.zdefs.d
diff --git a/test/unittest/options/err.D_ASRELO.kdefs.d b/test/unittest/options/err.D_ASRELO.kdefs.d
new file mode 100644
index 00000000..0a42fc6e
--- /dev/null
+++ b/test/unittest/options/err.D_ASRELO.kdefs.d
@@ -0,0 +1,19 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xkdefs option prohibits unresolved kernel symbols.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xerrtags -xlinkmode=dynamic -xknodefs -xkdefs */
+
+BEGIN {
+ trace((string)`linux_banner);
+ exit(0);
+}
diff --git a/test/unittest/options/err.D_ASRELO.kdefs.r b/test/unittest/options/err.D_ASRELO.kdefs.r
new file mode 100644
index 00000000..4dc5bfd8
--- /dev/null
+++ b/test/unittest/options/err.D_ASRELO.kdefs.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/options/err.D_ASRELO.kdefs.d: [D_ASRELO] line 17: relocation remains against kernel symbol vmlinux`linux_banner (offset {ptr})
diff --git a/test/unittest/options/err.D_EMPTY.errtags.d b/test/unittest/options/err.D_EMPTY.errtags.d
new file mode 100644
index 00000000..814b279c
--- /dev/null
+++ b/test/unittest/options/err.D_EMPTY.errtags.d
@@ -0,0 +1,14 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xerrtags option enables printing error tags.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xerrtags */
diff --git a/test/unittest/options/err.D_EMPTY.errtags.r b/test/unittest/options/err.D_EMPTY.errtags.r
new file mode 100644
index 00000000..b050312b
--- /dev/null
+++ b/test/unittest/options/err.D_EMPTY.errtags.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/options/err.D_EMPTY.errtags.d: [D_EMPTY] line 15: empty D program translation unit
diff --git a/test/unittest/options/err.D_EMPTY.no-empty.d b/test/unittest/options/err.D_EMPTY.no-empty.d
new file mode 100644
index 00000000..768ef87b
--- /dev/null
+++ b/test/unittest/options/err.D_EMPTY.no-empty.d
@@ -0,0 +1,12 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: No -xempty option with empty source files flags an error
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
diff --git a/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d
new file mode 100644
index 00000000..81b61d29
--- /dev/null
+++ b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d
@@ -0,0 +1,22 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: With no -xdefaultargs option, missing arguments cause an error.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+BEGIN
+{
+ exit($1 ? 1 : 0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.r b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.r
new file mode 100644
index 00000000..888b8e3f
--- /dev/null
+++ b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d: [D_MACRO_UNDEF] line 16: macro argument $1 is not defined
diff --git a/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d
new file mode 100644
index 00000000..dee7bdd2
--- /dev/null
+++ b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d
@@ -0,0 +1,27 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: With no -xdefaultargs option, missing arguments cause an error.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: 2 1 */
+
+BEGIN
+{
+ trace($1);
+ trace($2);
+ trace($3);
+ exit($3 ? 1 : 0);
+}
+
+ERROR
+{
+ exit(0);
+}
diff --git a/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.r b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.r
new file mode 100644
index 00000000..04356d40
--- /dev/null
+++ b/test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d: [D_MACRO_UNDEF] line 20: macro argument $3 is not defined
diff --git a/test/unittest/options/err.D_MACRO_UNUSED.no-argref.d b/test/unittest/options/err.D_MACRO_UNUSED.no-argref.d
new file mode 100644
index 00000000..a6c6345e
--- /dev/null
+++ b/test/unittest/options/err.D_MACRO_UNUSED.no-argref.d
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: With no -xargref option, extraneous argument(s) cause an error.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: 1234 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/err.D_PRAGCTL_INVAL.no-cpp.d b/test/unittest/options/err.D_PRAGCTL_INVAL.no-cpp.d
index 7dd2b516..719b4fc6 100644
--- a/test/unittest/options/err.D_PRAGCTL_INVAL.no-cpp.d
+++ b/test/unittest/options/err.D_PRAGCTL_INVAL.no-cpp.d
@@ -6,7 +6,6 @@
*/
/*
- *
* ASSERTION: With no -xcpp option the input file is not pre-processed.
*
* SECTION: Options and Tunables/Consumer Options
diff --git a/test/unittest/options/err.b-too-low.d b/test/unittest/options/err.b-too-low.d
new file mode 100644
index 00000000..bb77e37c
--- /dev/null
+++ b/test/unittest/options/err.b-too-low.d
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -b option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/*
+ * We use a buffer size of 59 because that should be just too small to hold the
+ * trace records generated in this script:
+ * - perf_event_header (40 bytes)
+ * - size (4 bytes)
+ * - gap (4 bytes)
+ * - EPID (4 bytes)
+ * - tag (4 bytes)
+ * - exit value (4 bytes)
+ */
+/* @@runtest-opts: -b59 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/err.b-too-low.r b/test/unittest/options/err.b-too-low.r
new file mode 100644
index 00000000..ba473ab8
--- /dev/null
+++ b/test/unittest/options/err.b-too-low.r
@@ -0,0 +1,3 @@
+-- @@stderr --
+dtrace: script 'test/unittest/options/err.b-too-low.d' matched 2 probes
+dtrace: could not enable tracing: Enabling exceeds size of buffer
diff --git a/test/unittest/options/err.bufsize-too-low.d b/test/unittest/options/err.bufsize-too-low.d
new file mode 100644
index 00000000..bbbdb5c5
--- /dev/null
+++ b/test/unittest/options/err.bufsize-too-low.d
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xbufsize option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/*
+ * We use a buffer size of 59 because that should be just too small to hold the
+ * trace records generated in this script:
+ * - perf_event_header (40 bytes)
+ * - size (4 bytes)
+ * - gap (4 bytes)
+ * - EPID (4 bytes)
+ * - tag (4 bytes)
+ * - exit value (4 bytes)
+ */
+/* @@runtest-opts: -xbufsize=59 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/err.bufsize-too-low.r b/test/unittest/options/err.bufsize-too-low.r
new file mode 100644
index 00000000..0b89080c
--- /dev/null
+++ b/test/unittest/options/err.bufsize-too-low.r
@@ -0,0 +1,3 @@
+-- @@stderr --
+dtrace: script 'test/unittest/options/err.bufsize-too-low.d' matched 2 probes
+dtrace: could not enable tracing: Enabling exceeds size of buffer
diff --git a/test/unittest/options/err.empty.d b/test/unittest/options/err.empty.d
new file mode 100644
index 00000000..d747def7
--- /dev/null
+++ b/test/unittest/options/err.empty.d
@@ -0,0 +1,14 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xempty option can be used to allow empty source files
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xempty */
diff --git a/test/unittest/options/err.empty.r b/test/unittest/options/err.empty.r
new file mode 100644
index 00000000..ec4aaa43
--- /dev/null
+++ b/test/unittest/options/err.empty.r
@@ -0,0 +1,3 @@
+-- @@stderr --
+dtrace: script 'test/unittest/options/err.empty.d' matched 0 probes
+dtrace: no probes matched
diff --git a/test/unittest/options/err.no-errtags.d b/test/unittest/options/err.no-errtags.d
new file mode 100644
index 00000000..2a7e859e
--- /dev/null
+++ b/test/unittest/options/err.no-errtags.d
@@ -0,0 +1,12 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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: Without the -xerrtags option, errors are printed with tag.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
diff --git a/test/unittest/options/err.no-errtags.r b/test/unittest/options/err.no-errtags.r
new file mode 100644
index 00000000..32b52173
--- /dev/null
+++ b/test/unittest/options/err.no-errtags.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/options/err.no-errtags.d: line 13: empty D program translation unit
diff --git a/test/unittest/options/tst.D.d b/test/unittest/options/tst.D.d
new file mode 100644
index 00000000..8b1ab4f4
--- /dev/null
+++ b/test/unittest/options/tst.D.d
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -D option can be used to define macros (requires -C).
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -Dprobe=BEGIN -C */
+
+probe
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.F.d b/test/unittest/options/tst.F.d
new file mode 100644
index 00000000..34c0c475
--- /dev/null
+++ b/test/unittest/options/tst.F.d
@@ -0,0 +1,50 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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.
+ */
+/* @@xfail: flowindent is broken */
+
+/*
+ * ASSERTION: The -F option enables entry/return matching output.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -FZ */
+/* @@timeout: 15 */
+/* @@trigger: readwholedir */
+
+BEGIN
+{
+ i = 0;
+ j = 0;
+ k = 0;
+}
+
+syscall::read:
+/i < 10/
+{
+ printf("syscall: %d\n", i++);
+}
+
+fbt:vmlinux:SyS_read:,
+fbt:vmlinux:__arm64_sys_read:,
+fbt:vmlinux:__x64_sys_read:
+/j < 10/
+{
+ printf("fbt: %d\n", j++);
+}
+
+profile:::tick-1sec
+/k < 4/
+{
+ printf("profile: %d\n", k++);
+}
+
+profile:::tick-10sec
+/i > 9 && j > 9 && k > 3/
+{
+ exit(0);
+}
diff --git a/test/unittest/options/tst.F.r b/test/unittest/options/tst.F.r
new file mode 100644
index 00000000..aae92b2e
--- /dev/null
+++ b/test/unittest/options/tst.F.r
@@ -0,0 +1,44 @@
+FUNCTION
+ => read syscall: 0
+
+ -> __x64_sys_read fbt: 0
+
+ <- __x64_sys_read fbt: 1
+
+ <= read syscall: 1
+
+ => read syscall: 2
+
+ -> __x64_sys_read fbt: 2
+
+ <- __x64_sys_read fbt: 3
+
+ <= read syscall: 3
+
+ => read syscall: 4
+
+ -> __x64_sys_read fbt: 4
+
+ <- __x64_sys_read fbt: 5
+
+ <= read syscall: 5
+
+ => read syscall: 6
+
+ -> __x64_sys_read fbt: 6
+
+ <- __x64_sys_read fbt: 7
+
+ <= read syscall: 7
+
+ => read syscall: 8
+
+ -> __x64_sys_read fbt: 8
+
+ <- __x64_sys_read fbt: 9
+
+ <= read syscall: 9
+
+
+-- @@stderr --
+dtrace: script 'test/unittest/options/tst.flowindent.d' matched 7 probes
diff --git a/test/unittest/options/tst.U.d b/test/unittest/options/tst.U.d
new file mode 100644
index 00000000..c2bcffbb
--- /dev/null
+++ b/test/unittest/options/tst.U.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -U option can be used to undefine macros (requires -C).
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -U__linux -C */
+
+BEGIN
+{
+#ifdef __linux
+ exit(1);
+#else
+ exit(0);
+#endif
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.Z.d b/test/unittest/options/tst.Z.d
new file mode 100644
index 00000000..0bc6bb6d
--- /dev/null
+++ b/test/unittest/options/tst.Z.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -Z option allows probe definitions that match no probes.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -Z */
+
+BEGIN,
+oracle
+{
+ exit(0);
+}
diff --git a/test/unittest/options/tst.argref.d b/test/unittest/options/tst.argref.d
new file mode 100644
index 00000000..5f400c58
--- /dev/null
+++ b/test/unittest/options/tst.argref.d
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xargref option surpresses the 'extraneous argument' error.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xargref 1234 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.b.d b/test/unittest/options/tst.b.d
new file mode 100644
index 00000000..57fa030d
--- /dev/null
+++ b/test/unittest/options/tst.b.d
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -b option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/*
+ * We use a buffer size of 60 because that should be the exact size necessary
+ * to hold the trace records generated in this script:
+ * - perf_event_header (40 bytes)
+ * - size (4 bytes)
+ * - gap (4 bytes)
+ * - EPID (4 bytes)
+ * - tag (4 bytes)
+ * - exit value (4 bytes)
+ */
+/* @@runtest-opts: -b60 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/misc/tst.bpflog-cmdline.sh b/test/unittest/options/tst.bpflog-cmdline.sh
similarity index 100%
rename from test/unittest/misc/tst.bpflog-cmdline.sh
rename to test/unittest/options/tst.bpflog-cmdline.sh
diff --git a/test/unittest/misc/tst.bpflog-pragma.sh b/test/unittest/options/tst.bpflog-pragma.sh
similarity index 100%
rename from test/unittest/misc/tst.bpflog-pragma.sh
rename to test/unittest/options/tst.bpflog-pragma.sh
diff --git a/test/unittest/misc/tst.bpflogsize-cmdline.sh b/test/unittest/options/tst.bpflogsize-cmdline.sh
similarity index 100%
rename from test/unittest/misc/tst.bpflogsize-cmdline.sh
rename to test/unittest/options/tst.bpflogsize-cmdline.sh
diff --git a/test/unittest/misc/tst.bpflogsize-pragma.sh b/test/unittest/options/tst.bpflogsize-pragma.sh
similarity index 100%
rename from test/unittest/misc/tst.bpflogsize-pragma.sh
rename to test/unittest/options/tst.bpflogsize-pragma.sh
diff --git a/test/unittest/options/tst.bufsize.d b/test/unittest/options/tst.bufsize.d
new file mode 100644
index 00000000..96b0f1b8
--- /dev/null
+++ b/test/unittest/options/tst.bufsize.d
@@ -0,0 +1,34 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xbufsize option sets the trace buffer size.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/*
+ * We use a buffer size of 60 because that should be the exact size necessary
+ * to hold the trace records generated in this script:
+ * - perf_event_header (40 bytes)
+ * - size (4 bytes)
+ * - gap (4 bytes)
+ * - EPID (4 bytes)
+ * - tag (4 bytes)
+ * - exit value (4 bytes)
+ */
+/* @@runtest-opts: -xbufsize=60 */
+
+BEGIN
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.core.sh b/test/unittest/options/tst.core.sh
new file mode 100755
index 00000000..48a58508
--- /dev/null
+++ b/test/unittest/options/tst.core.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xcore -n 'BEGIN { exit(0); }'
+file core | tee /dev/stderr | \
+ awk 'BEGIN { rc = 1; }
+ /ELF/ && /core file/ && /dtrace/ { rc = 0; next; }
+ END { exit(rc); }'
+rc=$?
+rm -f core
+
+exit $rcc
diff --git a/test/unittest/options/tst.cpp.d b/test/unittest/options/tst.cpp.d
index 02015755..f9b1a9cd 100644
--- a/test/unittest/options/tst.cpp.d
+++ b/test/unittest/options/tst.cpp.d
@@ -6,7 +6,6 @@
*/
/*
- *
* ASSERTION: The -xcpp option enables pre-processing of the input file.
*
* SECTION: Options and Tunables/Consumer Options
diff --git a/test/unittest/options/tst.cppargs.sh b/test/unittest/options/tst.cppargs.sh
new file mode 100755
index 00000000..9f60b162
--- /dev/null
+++ b/test/unittest/options/tst.cppargs.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xcppargs='-H -dM' -Cs /dev/stdin << EOT 2>&1 | \
+ awk '/^\.+/ && /\.h$/ { cnt++; }
+ /invalid control directive: #define/ { cnt = -cnt; }
+ { print; }
+ END { exit(cnt < 0 ? 0 : 1); }'
+#include <linux/posix_types.h>
+
+BEGIN
+{
+ exit(0);
+}
+EOT
+
+exit $?
diff --git a/test/unittest/options/tst.cpphdrs.sh b/test/unittest/options/tst.cpphdrs.sh
new file mode 100755
index 00000000..b3362c74
--- /dev/null
+++ b/test/unittest/options/tst.cpphdrs.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xcpphdrs -Cs /dev/stdin << EOT 2>&1 | \
+ awk '/^\.+/ && /\.h$/ { cnt++; }
+ { print; }
+ END { exit(cnt > 0 ? 0 : 1); }'
+#include <linux/posix_types.h>
+
+BEGIN
+{
+ exit(0);
+}
+EOT
+
+exit $?
diff --git a/test/unittest/options/tst.cpppath.r b/test/unittest/options/tst.cpppath.r
new file mode 100644
index 00000000..91d336b2
--- /dev/null
+++ b/test/unittest/options/tst.cpppath.r
@@ -0,0 +1,4 @@
+-- @@stderr --
+cat: invalid option -- 'D'
+Try 'cat --help' for more information.
+dtrace: failed to compile script /dev/stdin: Preprocessor failed to process input program
diff --git a/test/unittest/options/tst.cpppath.sh b/test/unittest/options/tst.cpppath.sh
new file mode 100755
index 00000000..f51b9a1e
--- /dev/null
+++ b/test/unittest/options/tst.cpppath.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+#
+# We test whether the -xcpppath option works by replacing the pre-processor
+# executable to be used with 'cat'. This will trigger an error due to the
+# default options passed to the pre-processor which conclusively shows that
+# the cpppath option took effect.
+#
+$dtrace $dt_flags -xcpppath=/bin/cat -Cs /dev/stdin << EOT
+#if 1
+BEGIN
+{
+ exit(0);
+}
+#endif
+EOT
+
+# We expect an error to be reported.
+if [ $? -eq 0 ]; then
+ exit 1
+else
+ exit 0
+fi
diff --git a/test/unittest/options/tst.ctypes.sh b/test/unittest/options/tst.ctypes.sh
new file mode 100755
index 00000000..ef7517be
--- /dev/null
+++ b/test/unittest/options/tst.ctypes.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xctypes=ctypes.ctf -n 'BEGIN { exit(0); }'
+if [ ! -r ctypes.ctf ]; then
+ echo "ERROR: No ctypes.ctf generated"
+ exit 1
+fi
+
+if ! objcopy --add-section=.ctf=ctypes.ctf /bin/true ctypes.o; then
+ echo "ERROR: Failed to create ELF object from ctypes.ctf"
+ exit 1
+fi
+
+objdump --ctf=.ctf ctypes.o | \
+ awk '/CTF_VERSION/ { vers = 1; next; }
+ vers && $1 ~ /0x[0-9A-Fa-f]+:/ { cnt++; next; }
+ END { print "C CTF data" (vers ? " " : " NOT ") "found";
+ exit(cnt > 0 ? 0 : 1); }'
+rc=$?
+
+rm -f ctypes.*
+
+exit $rc
diff --git a/test/unittest/options/tst.debug.sh b/test/unittest/options/tst.debug.sh
new file mode 100755
index 00000000..0af09155
--- /dev/null
+++ b/test/unittest/options/tst.debug.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xdebug -n 'BEGIN { exit(0); }' 2>&1 | \
+ awk '$2 == "DEBUG" && int($3) > 0 {
+ cnt[$1]++;
+ }
+ END {
+ for (lib in cnt) {
+ printf "%16s %8d debug messages\n", lib, cnt[lib];
+ sum += cnt[lib];
+ }
+ exit(sum > 0 ? 0 : 1);
+ }'
+
+exit $?
diff --git a/test/unittest/options/tst.defaultargs.d b/test/unittest/options/tst.defaultargs.d
new file mode 100644
index 00000000..3c1bad05
--- /dev/null
+++ b/test/unittest/options/tst.defaultargs.d
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xdefaultargs option ensures that undefined arguments are 0.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xdefaultargs */
+
+BEGIN
+{
+ exit($1);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.defaultargs2.d b/test/unittest/options/tst.defaultargs2.d
new file mode 100644
index 00000000..bdf96904
--- /dev/null
+++ b/test/unittest/options/tst.defaultargs2.d
@@ -0,0 +1,27 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xdefaultargs option ensures that undefined arguments are 0.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xdefaultargs 2 1 */
+
+BEGIN
+{
+ trace($1);
+ trace($2);
+ trace($3);
+ exit($3);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.define.d b/test/unittest/options/tst.define.d
new file mode 100644
index 00000000..2a1c589d
--- /dev/null
+++ b/test/unittest/options/tst.define.d
@@ -0,0 +1,24 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xdefine option can be used to define macros (requires -C).
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xdefine=probe=BEGIN -C */
+
+probe
+{
+ exit(0);
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.destructive.d b/test/unittest/options/tst.destructive.d
new file mode 100644
index 00000000..8bebca8c
--- /dev/null
+++ b/test/unittest/options/tst.destructive.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xdestructive option enables allowing destructive operations.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xdestructive */
+
+BEGIN
+{
+ system("echo ok");
+ exit(0);
+}
diff --git a/test/unittest/options/tst.dtypes.sh b/test/unittest/options/tst.dtypes.sh
new file mode 100755
index 00000000..80188880
--- /dev/null
+++ b/test/unittest/options/tst.dtypes.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xdtypes=dtypes.ctf -n 'BEGIN { exit(0); }'
+if [ ! -r dtypes.ctf ]; then
+ echo "ERROR: No dtypes.ctf generated"
+ exit 1
+fi
+
+if ! objcopy --add-section=.ctf=dtypes.ctf /bin/true dtypes.o; then
+ echo "ERROR: Failed to create ELF object from dtypes.ctf"
+ exit 1
+fi
+
+objdump --ctf=.ctf dtypes.o | \
+ awk '/CTF_VERSION/ { vers = 1; next; }
+ vers && $1 ~ /0x[0-9A-Fa-f]+:/ { cnt++; next; }
+ END { print "D CTF data" (vers ? " " : " NOT ") "found";
+ exit(cnt > 0 ? 0 : 1); }'
+rc=$?
+
+rm -f dtypes.*
+
+exit $rc
diff --git a/test/unittest/options/tst.flowindent.d b/test/unittest/options/tst.flowindent.d
new file mode 100644
index 00000000..8f8c2102
--- /dev/null
+++ b/test/unittest/options/tst.flowindent.d
@@ -0,0 +1,50 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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.
+ */
+/* @@xfail: flowindent is broken */
+
+/*
+ * ASSERTION: The -xflowindent option enables entry/return matching output.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xflowindent -Z */
+/* @@timeout: 15 */
+/* @@trigger: readwholedir */
+
+BEGIN
+{
+ i = 0;
+ j = 0;
+ k = 0;
+}
+
+syscall::read:
+/i < 10/
+{
+ printf("syscall: %d\n", i++);
+}
+
+fbt:vmlinux:SyS_read:,
+fbt:vmlinux:__arm64_sys_read:,
+fbt:vmlinux:__x64_sys_read:
+/j < 10/
+{
+ printf("fbt: %d\n", j++);
+}
+
+profile:::tick-1sec
+/k < 4/
+{
+ printf("profile: %d\n", k++);
+}
+
+profile:::tick-10sec
+/i > 9 && j > 9 && k > 3/
+{
+ exit(0);
+}
diff --git a/test/unittest/options/tst.flowindent.r b/test/unittest/options/tst.flowindent.r
new file mode 100644
index 00000000..aae92b2e
--- /dev/null
+++ b/test/unittest/options/tst.flowindent.r
@@ -0,0 +1,44 @@
+FUNCTION
+ => read syscall: 0
+
+ -> __x64_sys_read fbt: 0
+
+ <- __x64_sys_read fbt: 1
+
+ <= read syscall: 1
+
+ => read syscall: 2
+
+ -> __x64_sys_read fbt: 2
+
+ <- __x64_sys_read fbt: 3
+
+ <= read syscall: 3
+
+ => read syscall: 4
+
+ -> __x64_sys_read fbt: 4
+
+ <- __x64_sys_read fbt: 5
+
+ <= read syscall: 5
+
+ => read syscall: 6
+
+ -> __x64_sys_read fbt: 6
+
+ <- __x64_sys_read fbt: 7
+
+ <= read syscall: 7
+
+ => read syscall: 8
+
+ -> __x64_sys_read fbt: 8
+
+ <- __x64_sys_read fbt: 9
+
+ <= read syscall: 9
+
+
+-- @@stderr --
+dtrace: script 'test/unittest/options/tst.flowindent.d' matched 7 probes
diff --git a/test/unittest/options/tst.knodefs.sh b/test/unittest/options/tst.knodefs.sh
new file mode 100755
index 00000000..532d7eca
--- /dev/null
+++ b/test/unittest/options/tst.knodefs.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2022, 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
+
+$dtrace $dt_flags -xlinkmode=dynamic -xknodefs \
+ -Sn 'BEGIN { trace((string)`linux_banner); exit(0); }' 2>&1 | \
+ awk '/^KREL/ {
+ print;
+ while (getline == 1) {
+ if (NF == 0)
+ break;
+ print;
+ if ($1 == "R_BPF_INSN_64" && $4 == "linux_banner")
+ cnt++;
+ }
+ }
+ END {
+ exit(cnt == 1 ? 0 : 1);
+ }'
+
+exit $?
diff --git a/test/unittest/options/tst.undef.d b/test/unittest/options/tst.undef.d
new file mode 100644
index 00000000..9913cc1f
--- /dev/null
+++ b/test/unittest/options/tst.undef.d
@@ -0,0 +1,28 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xundef option can be used to undefine macros (requires -C).
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xundef=__linux -C */
+
+BEGIN
+{
+#ifdef __linux
+ exit(1);
+#else
+ exit(0);
+#endif
+}
+
+ERROR
+{
+ exit(1);
+}
diff --git a/test/unittest/options/tst.w.d b/test/unittest/options/tst.w.d
new file mode 100644
index 00000000..850bb3c8
--- /dev/null
+++ b/test/unittest/options/tst.w.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -w option enables allowing destructive operations.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -w */
+
+BEGIN
+{
+ system("echo ok");
+ exit(0);
+}
diff --git a/test/unittest/options/tst.zdefs.d b/test/unittest/options/tst.zdefs.d
new file mode 100644
index 00000000..575d3b82
--- /dev/null
+++ b/test/unittest/options/tst.zdefs.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, 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 -xzdefs option allows probe definitions that match no probes.
+ *
+ * SECTION: Options and Tunables/Consumer Options
+ */
+
+/* @@runtest-opts: -xzdefs */
+
+BEGIN,
+oracle
+{
+ exit(0);
+}
--
2.34.1
More information about the DTrace-devel
mailing list