[DTrace-devel] [PATCH] Move freopen() and system() tests into unittest/actions/(freopen, system)
Kris Van Hees
kris.van.hees at oracle.com
Thu Apr 8 00:00:25 PDT 2021
The tst.freopen.sh test has been modified to not depend on string
support in D because that is not the purpose of the testcase.
The tst.badfreopen.sh test is marked XFAIL because it requires string
support (which is not available yet).
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
.../actions/freopen/err.D_FREOPEN_INVALID.d | 20 +++++++++++++++++
.../actions/freopen/err.D_FREOPEN_INVALID.r | 2 ++
.../freopen}/tst.badfreopen.sh | 0
.../freopen}/tst.freopen-single.r | 0
.../freopen}/tst.freopen-single.sh | 0
.../{funcs => actions/freopen}/tst.freopen.r | 0
.../{funcs => actions/freopen}/tst.freopen.sh | 6 ++---
.../system/tst.system-int.d} | 3 +--
.../system/tst.system-int.r} | 2 +-
test/unittest/actions/system/tst.system-str.d | 22 +++++++++++++++++++
test/unittest/actions/system/tst.system-str.r | 4 ++++
11 files changed, 53 insertions(+), 6 deletions(-)
create mode 100644 test/unittest/actions/freopen/err.D_FREOPEN_INVALID.d
create mode 100644 test/unittest/actions/freopen/err.D_FREOPEN_INVALID.r
rename test/unittest/{funcs => actions/freopen}/tst.badfreopen.sh (100%)
rename test/unittest/{funcs => actions/freopen}/tst.freopen-single.r (100%)
rename test/unittest/{funcs => actions/freopen}/tst.freopen-single.sh (100%)
rename test/unittest/{funcs => actions/freopen}/tst.freopen.r (100%)
rename test/unittest/{funcs => actions/freopen}/tst.freopen.sh (91%)
rename test/unittest/{funcs/tst.system.d => actions/system/tst.system-int.d} (85%)
rename test/unittest/{funcs/tst.system.r => actions/system/tst.system-int.r} (52%)
create mode 100644 test/unittest/actions/system/tst.system-str.d
create mode 100644 test/unittest/actions/system/tst.system-str.r
diff --git a/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.d b/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.d
new file mode 100644
index 00000000..8268d497
--- /dev/null
+++ b/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.d
@@ -0,0 +1,20 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2020, 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 freopen() action cannot have "." as first argument.
+ *
+ * SECTION: Actions and Subroutines/freopen()
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ freopen(".");
+ exit(0);
+}
diff --git a/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.r b/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.r
new file mode 100644
index 00000000..ac273257
--- /dev/null
+++ b/test/unittest/actions/freopen/err.D_FREOPEN_INVALID.r
@@ -0,0 +1,2 @@
+-- @@stderr --
+dtrace: failed to compile script test/unittest/actions/freopen/err.D_FREOPEN_INVALID.d: [D_FREOPEN_INVALID] line 18: freopen( ) argument #1 cannot be "."
diff --git a/test/unittest/funcs/tst.badfreopen.sh b/test/unittest/actions/freopen/tst.badfreopen.sh
similarity index 100%
rename from test/unittest/funcs/tst.badfreopen.sh
rename to test/unittest/actions/freopen/tst.badfreopen.sh
diff --git a/test/unittest/funcs/tst.freopen-single.r b/test/unittest/actions/freopen/tst.freopen-single.r
similarity index 100%
rename from test/unittest/funcs/tst.freopen-single.r
rename to test/unittest/actions/freopen/tst.freopen-single.r
diff --git a/test/unittest/funcs/tst.freopen-single.sh b/test/unittest/actions/freopen/tst.freopen-single.sh
similarity index 100%
rename from test/unittest/funcs/tst.freopen-single.sh
rename to test/unittest/actions/freopen/tst.freopen-single.sh
diff --git a/test/unittest/funcs/tst.freopen.r b/test/unittest/actions/freopen/tst.freopen.r
similarity index 100%
rename from test/unittest/funcs/tst.freopen.r
rename to test/unittest/actions/freopen/tst.freopen.r
diff --git a/test/unittest/funcs/tst.freopen.sh b/test/unittest/actions/freopen/tst.freopen.sh
similarity index 91%
rename from test/unittest/funcs/tst.freopen.sh
rename to test/unittest/actions/freopen/tst.freopen.sh
index 2345c5ec..b8fbec69 100755
--- a/test/unittest/funcs/tst.freopen.sh
+++ b/test/unittest/actions/freopen/tst.freopen.sh
@@ -5,10 +5,10 @@
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
#
-# @@xfail: dtv2
+
script()
{
- $dtrace $dt_flags -wq -o $tmpfile -s /dev/stdin $tmpfile <<EOF
+ $dtrace $dt_flags -wq -o $tmpfile -s /dev/stdin <<EOF
BEGIN
{
i = 0;
@@ -16,7 +16,7 @@ script()
tick-10ms
{
- freopen("%s.%d", \$\$1, i);
+ freopen("$tmpfile.%d", i);
printf("%d\n", i)
}
diff --git a/test/unittest/funcs/tst.system.d b/test/unittest/actions/system/tst.system-int.d
similarity index 85%
rename from test/unittest/funcs/tst.system.d
rename to test/unittest/actions/system/tst.system-int.d
index 46c1dc38..371981a7 100644
--- a/test/unittest/funcs/tst.system.d
+++ b/test/unittest/actions/system/tst.system-int.d
@@ -4,7 +4,6 @@
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
-/* @@xfail: dtv2 */
#pragma D option quiet
#pragma D option destructive
@@ -14,7 +13,7 @@ BEGIN
this->a = 9;
this->b = -2;
- system("echo %s %d %d", "foo", this->a, this->b);
+ system("echo %d %d", this->a, this->b);
system("echo %d", ++this->a);
system("echo %d", ++this->a);
system("echo %d", ++this->a);
diff --git a/test/unittest/funcs/tst.system.r b/test/unittest/actions/system/tst.system-int.r
similarity index 52%
rename from test/unittest/funcs/tst.system.r
rename to test/unittest/actions/system/tst.system-int.r
index 6c932409..d81ef3c0 100644
--- a/test/unittest/funcs/tst.system.r
+++ b/test/unittest/actions/system/tst.system-int.r
@@ -1,4 +1,4 @@
-foo 9 -2
+9 -2
10
11
12
diff --git a/test/unittest/actions/system/tst.system-str.d b/test/unittest/actions/system/tst.system-str.d
new file mode 100644
index 00000000..70b67e2a
--- /dev/null
+++ b/test/unittest/actions/system/tst.system-str.d
@@ -0,0 +1,22 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2006, 2020, 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: dtv2 */
+
+#pragma D option quiet
+#pragma D option destructive
+
+BEGIN
+{
+ this->s = "foo";
+ this->a = 9;
+ this->b = -2;
+
+ system("echo %s %d %d", this->s, this->a, this->b);
+ system("echo %s %d %d", "bar", this->a, this->b);
+ system("echo %s %d", probename, ++this->a);
+ exit(0);
+}
diff --git a/test/unittest/actions/system/tst.system-str.r b/test/unittest/actions/system/tst.system-str.r
new file mode 100644
index 00000000..adf95e0c
--- /dev/null
+++ b/test/unittest/actions/system/tst.system-str.r
@@ -0,0 +1,4 @@
+foo 9 -2
+bar 9 -2
+BEGIN 10
+
--
2.28.0
More information about the DTrace-devel
mailing list