[DTrace-devel] [PATCH 2/4] test: Skip trace() of a 1-byte struct
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue Mar 25 22:25:19 UTC 2025
From: Eugene Loh <eugene.loh at oracle.com>
With commit 3a551bfd ("trace: fix char-array handling"), this test
started to FAIL. Meanwhile, the behavior of trace() on a 1-byte
struct is poorly defined. Users wishing clear semantics should use
print() or other actions.
Skip the test.
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
.../actions/trace/tst.struct-1-byte.d | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/test/unittest/actions/trace/tst.struct-1-byte.d b/test/unittest/actions/trace/tst.struct-1-byte.d
index 36de485f8..8bfcbdd53 100644
--- a/test/unittest/actions/trace/tst.struct-1-byte.d
+++ b/test/unittest/actions/trace/tst.struct-1-byte.d
@@ -5,6 +5,30 @@
* http://oss.oracle.com/licenses/upl.
*/
+/*
+ * With Solaris or legacy DTrace on Linux, the script gives
+ * 52
+ * That is, contents are dumped as an integer because the trace()
+ * argument is 1, 2, 4, or 8 bytes -- specifically, it is 1 byte.
+ *
+ * Before commit 3a551bfd ("trace: fix char-array handling"), we got
+ * 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
+ * 0: 34 4
+ * That is, contents were dumped as raw bytes.
+ *
+ * With that patch, we get:
+ * 4
+ * That is, contents are dumped as the string "4" since the contents
+ * are a printable char followed optionally by NUL bytes.
+ *
+ * The truth is that the semantics of trace() are poorly defined.
+ * So we are hard-pressed to say what is correct. The test has
+ * little value. Skip it.
+ *
+ * Users who want type-aware printing can use the print() action.
+ */
+/* @@skip: poorly defined semantics */
+
/*
* ASSERTION: The trace() action prints a struct { int8_t } correctly.
*
--
2.43.5
More information about the DTrace-devel
mailing list