[DTrace-devel] [PATCH 5/5] test: fix probe* builtin variable tests

Kris Van Hees kris.van.hees at oracle.com
Wed Sep 7 01:36:13 UTC 2022


Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 test/unittest/variables/bvar/tst.probefunc.d | 32 +++++++++++++++++---
 test/unittest/variables/bvar/tst.probemod.d  | 26 +++++++++++++---
 test/unittest/variables/bvar/tst.probename.d | 20 +++++++++---
 test/unittest/variables/bvar/tst.probeprov.d | 20 +++++++++---
 4 files changed, 78 insertions(+), 20 deletions(-)

diff --git a/test/unittest/variables/bvar/tst.probefunc.d b/test/unittest/variables/bvar/tst.probefunc.d
index 45839b29..6e936a47 100644
--- a/test/unittest/variables/bvar/tst.probefunc.d
+++ b/test/unittest/variables/bvar/tst.probefunc.d
@@ -1,22 +1,44 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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: dtv2 */
 
 /*
- * ASSERTION: The 'probefunc' variable can be accessed and is not -1.
+ * ASSERTION: The 'probefunc' variable returns the correct value.
  *
  * SECTION: Variables/Built-in Variables/probefunc
  */
 
 #pragma D option quiet
+#pragma D option destructive
 
-BEGIN {
+BEGIN
+{
+	system("sleep 1ms");
+}
+
+syscall::*sleep:entry
+{
 	trace(probefunc);
-	exit(probefunc != -1 ? 0 : 1);
+}
+
+syscall::*sleep:entry
+/probefunc == "clock_nanosleep"/
+{
+	exit(0);
+}
+
+syscall::*sleep:entry
+/probefunc == "nanosleep"/
+{
+	exit(0);
+}
+
+syscall::*sleep:entry
+{
+	exit(1);
 }
 
 ERROR {
diff --git a/test/unittest/variables/bvar/tst.probemod.d b/test/unittest/variables/bvar/tst.probemod.d
index a114e434..bb9d86a9 100644
--- a/test/unittest/variables/bvar/tst.probemod.d
+++ b/test/unittest/variables/bvar/tst.probemod.d
@@ -1,22 +1,38 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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: dtv2 */
 
 /*
- * ASSERTION: The 'probemod' variable can be accessed and is not -1.
+ * ASSERTION: The 'probemod' variable returns the correct value.
  *
  * SECTION: Variables/Built-in Variables/probemod
  */
 
 #pragma D option quiet
+#pragma D option destructive
 
-BEGIN {
+BEGIN
+{
+	system("sleep 1ms");
+}
+
+syscall::*sleep:entry
+{
 	trace(probemod);
-	exit(probemod != -1 ? 0 : 1);
+}
+
+syscall::*sleep:entry
+/probemod == "vmlinux"/
+{
+	exit(0);
+}
+
+syscall::*sleep:entry
+{
+	exit(1);
 }
 
 ERROR {
diff --git a/test/unittest/variables/bvar/tst.probename.d b/test/unittest/variables/bvar/tst.probename.d
index e379765e..7f2bde35 100644
--- a/test/unittest/variables/bvar/tst.probename.d
+++ b/test/unittest/variables/bvar/tst.probename.d
@@ -1,22 +1,32 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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: dtv2 */
 
 /*
- * ASSERTION: The 'probename' variable can be accessed and is not -1.
+ * ASSERTION: The 'probename' variable returns the correct value.
  *
  * SECTION: Variables/Built-in Variables/probename
  */
 
 #pragma D option quiet
 
-BEGIN {
+BEGIN
+{
 	trace(probename);
-	exit(probename != -1 ? 0 : 1);
+}
+
+BEGIN
+/probename == "BEGIN"/
+{
+	exit(0);
+}
+
+BEGIN
+{
+	exit(1);
 }
 
 ERROR {
diff --git a/test/unittest/variables/bvar/tst.probeprov.d b/test/unittest/variables/bvar/tst.probeprov.d
index 7f979104..e5f843ec 100644
--- a/test/unittest/variables/bvar/tst.probeprov.d
+++ b/test/unittest/variables/bvar/tst.probeprov.d
@@ -1,22 +1,32 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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: dtv2 */
 
 /*
- * ASSERTION: The 'probeprov' variable can be accessed and is not -1.
+ * ASSERTION: The 'probeprov' variable returns the correct value.
  *
  * SECTION: Variables/Built-in Variables/probeprov
  */
 
 #pragma D option quiet
 
-BEGIN {
+BEGIN
+{
 	trace(probeprov);
-	exit(probeprov != -1 ? 0 : 1);
+}
+
+BEGIN
+/probeprov == "dtrace"/
+{
+	exit(0);
+}
+
+BEGIN
+{
+	exit(1);
 }
 
 ERROR {
-- 
2.34.1




More information about the DTrace-devel mailing list