Skip to contentSkip to conversation

test: Clean up tst.errno2.d

PATCH In review [email protected] 2 participants 2 messages Dec 4, 2024 – Dec 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Clean up tst.errno2.d

From: Eugene Loh <[email protected]>

Check only on the process of interest -- that is, /progenyof(parent)/.

Check that self->fn has been set before applying copyinstr() to it.

Add option zdefs in case open() is deprecated, so that the test will run on aarch64.

---
 test/unittest/builtinvar/tst.errno2.aarch64.x | 2 --
 test/unittest/builtinvar/tst.errno2.d         | 6 +++++-
 2 files changed, 5 insertions(+), 3 deletions(-)
 delete mode 100755 test/unittest/builtinvar/tst.errno2.aarch64.x
test/unittest/builtinvar/tst.errno2.aarch64.x deleted +0 -2
deleted file mode 100755
index 5c66540d1..000000000
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 2
test/unittest/builtinvar/tst.errno2.d +5 -1
index 22fe8b4a2..939f4c7d7 100644
@@ -15,6 +15,7 @@
 
 #pragma D option quiet
 #pragma D option destructive
+#pragma D option zdefs
 
 BEGIN
 {
@@ -27,19 +28,22 @@ BEGIN
  * Record file name pointer arg1 for the 'openat' function and arg0 for 'open'.
  */
 syscall::open:entry
+/progenyof(parent)/
 {
 	self->fn = arg0;  /* 'open' arg0 holds a pointer to the file name */
 }
 
 syscall::openat:entry
+/progenyof(parent)/
 {
 	self->fn = arg1;  /* 'openat' arg1 holds a pointer to the file name */
 }
 
 syscall::open*:return
-/copyinstr(self->fn) == "/non/existant/file" && errno != 0/
+/self->fn && copyinstr(self->fn) == "/non/existant/file" && errno != 0/
 {
 	printf("OPEN FAILED with errno %d\n", errno);
+	self->fn = 0;
 }
 
 proc:::exit
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Wed, Dec 04, 2024 at 01:51:52AM -0500, [email protected] wrote:

From: Eugene Loh <[email protected]>

Check only on the process of interest -- that is, /progenyof(parent)/.

Check that self->fn has been set before applying copyinstr() to it.

Add option zdefs in case open() is deprecated, so that the test will run on aarch64.

Quoted 53 lines
---
 test/unittest/builtinvar/tst.errno2.aarch64.x | 2 --
 test/unittest/builtinvar/tst.errno2.d         | 6 +++++-
 2 files changed, 5 insertions(+), 3 deletions(-)
 delete mode 100755 test/unittest/builtinvar/tst.errno2.aarch64.x
test/unittest/builtinvar/tst.errno2.aarch64.x deleted +0 -2
deleted file mode 100755
index 5c66540d1..000000000
@@ -1,2 +0,0 @@
-#!/bin/sh
-exit 2
test/unittest/builtinvar/tst.errno2.d +5 -1
index 22fe8b4a2..939f4c7d7 100644
@@ -15,6 +15,7 @@
 
 #pragma D option quiet
 #pragma D option destructive
+#pragma D option zdefs
 
 BEGIN
 {
@@ -27,19 +28,22 @@ BEGIN
  * Record file name pointer arg1 for the 'openat' function and arg0 for 'open'.
  */
 syscall::open:entry
+/progenyof(parent)/
 {
 	self->fn = arg0;  /* 'open' arg0 holds a pointer to the file name */
 }
 
 syscall::openat:entry
+/progenyof(parent)/
 {
 	self->fn = arg1;  /* 'openat' arg1 holds a pointer to the file name */
 }
 
 syscall::open*:return
-/copyinstr(self->fn) == "/non/existant/file" && errno != 0/
+/self->fn && copyinstr(self->fn) == "/non/existant/file" && errno != 0/
 {
 	printf("OPEN FAILED with errno %d\n", errno);
+	self->fn = 0;
 }
 
 proc:::exit
Signature · 1 line
2.43.5