[DTrace-devel] [PATCH 4/7] tests: fix tst.errno2.d to work with openat and skip aarch64

eugene.loh at oracle.com eugene.loh at oracle.com
Fri Aug 14 10:43:21 PDT 2020


From: "David P. McLean" <david.mclean at oracle.com>

tst.errno2.d previously was tagged unstable, because there were failures
due to using this->fn instead of self->fn.  This commit changes to self->fn
and removes the unstable tag.

Another problem solved is the test was written to only work with the 'open'
function call and some systems now have 'openat' instead.  The test now
works with both functions.

The test has not worked with the aarch64 implementation, because the test
makes use of copyinstr() which is unavailable on aarch64.  This commit
provides for skipping tst.errno2.d on aarch64 via the addition of the file
tst.errno2.aarch64.x

A minor modification has also been made to tst.errno2.r to match the
modified output.

Signed-off-by: David Mc Lean <david.mclean at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 test/unittest/builtinvar/tst.errno2.aarch64.x |  2 ++
 test/unittest/builtinvar/tst.errno2.d         | 19 +++++++++++++------
 test/unittest/builtinvar/tst.errno2.r         |  2 +-
 3 files changed, 16 insertions(+), 7 deletions(-)
 create mode 100755 test/unittest/builtinvar/tst.errno2.aarch64.x

diff --git a/test/unittest/builtinvar/tst.errno2.aarch64.x b/test/unittest/builtinvar/tst.errno2.aarch64.x
new file mode 100755
index 00000000..5c66540d
--- /dev/null
+++ b/test/unittest/builtinvar/tst.errno2.aarch64.x
@@ -0,0 +1,2 @@
+#!/bin/sh
+exit 2
diff --git a/test/unittest/builtinvar/tst.errno2.d b/test/unittest/builtinvar/tst.errno2.d
index 2b70f4cf..1f41be33 100644
--- a/test/unittest/builtinvar/tst.errno2.d
+++ b/test/unittest/builtinvar/tst.errno2.d
@@ -14,8 +14,6 @@
  * SECTION: Variables/Built-in Variables
  */
 
-/* @@tags: unstable */
-
 #pragma D option quiet
 #pragma D option destructive
 
@@ -25,15 +23,24 @@ BEGIN
 	system("cat /non/existant/file");
 }
 
+/*
+ * Use one clause for syscall::openat:entry and one for syscall::open:entry.
+ * Record file name pointer arg1 for the 'openat' function and arg0 for 'open'.
+ */
 syscall::open:entry
 {
-	this->fn = copyinstr(arg0);
+	self->fn = arg0;  /* 'open' arg0 holds a pointer to the file name */
+}
+
+syscall::openat:entry
+{
+	self->fn = arg1;  /* 'openat' arg1 holds a pointer to the file name */
 }
 
-syscall::open:return
-/this->fn == "/non/existant/file" && errno != 0/
+syscall::open*:return
+/copyinstr(self->fn) == "/non/existant/file" && errno != 0/
 {
-	printf("OPEN FAILED with errno %d for %s\n", errno, this->fn);
+	printf("OPEN FAILED with errno %d\n", errno);
 }
 
 proc:::exit
diff --git a/test/unittest/builtinvar/tst.errno2.r b/test/unittest/builtinvar/tst.errno2.r
index 449e9bed..e2782825 100644
--- a/test/unittest/builtinvar/tst.errno2.r
+++ b/test/unittest/builtinvar/tst.errno2.r
@@ -1,4 +1,4 @@
-OPEN FAILED with errno 2 for /non/existant/file
+OPEN FAILED with errno 2
 At exit, errno = 0
 
 -- @@stderr --
-- 
2.18.4




More information about the DTrace-devel mailing list