[DTrace-devel] [PATCH 4/4] Formatted printa() is broken

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Jan 6 17:39:13 PST 2021


From: Eugene Loh <eugene.loh at oracle.com>

A few tests were failing due simply to this bug.  Their XFAIL
annotations should be removed.  Add stddev and llquantize to
tst.basics.d so that all aggregation functions are tested;  each
function causes a specific callback to be used.

https://github.com/oracle/dtrace-utils/issues/5
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_printf.c               | 8 ++++----
 test/unittest/aggs/tst.clearavg2.d  | 1 -
 test/unittest/aggs/tst.multiaggs3.d | 1 -
 test/unittest/printa/tst.basics.d   | 6 +++++-
 test/unittest/printa/tst.basics.r   | 7 +++++++
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/libdtrace/dt_printf.c b/libdtrace/dt_printf.c
index d6803cc8..617baf04 100644
--- a/libdtrace/dt_printf.c
+++ b/libdtrace/dt_printf.c
@@ -1,6 +1,6 @@
 /*
  * Oracle Linux DTrace.
- * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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.
  */
@@ -1390,9 +1390,10 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
 				curagg++;
 
 			rec = &agg->dtagd_recs[aggrec];
-			addr = aggdata->dtada_data + rec->dtrd_offset;
+			addr = aggdata->dtada_data;
 			limit = addr + aggdata->dtada_size;
 			normal = aggdata->dtada_normal;
+			size = agg->dtagd_size;
 			sig = agg->dtagd_sig;
 			flags = DTRACE_BUFDATA_AGGVAL;
 		} else {
@@ -1417,11 +1418,10 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE *fp, const dt_pfargv_t *pfv,
 			addr = (caddr_t)buf + rec->dtrd_offset;
 			limit = lim;
 			normal = 1;
+			size = rec->dtrd_size;
 			sig = 0;
 		}
 
-		size = rec->dtrd_size;
-
 		if (addr + size > limit) {
 			dt_dprintf("bad size: addr=%p size=0x%x lim=%p\n",
 			    (void *)addr, rec->dtrd_size, (void *)lim);
diff --git a/test/unittest/aggs/tst.clearavg2.d b/test/unittest/aggs/tst.clearavg2.d
index 5b02f32d..d03e61e4 100644
--- a/test/unittest/aggs/tst.clearavg2.d
+++ b/test/unittest/aggs/tst.clearavg2.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 */
 
 /*
  * ASSERTION:
diff --git a/test/unittest/aggs/tst.multiaggs3.d b/test/unittest/aggs/tst.multiaggs3.d
index c2ccbee3..2459233f 100644
--- a/test/unittest/aggs/tst.multiaggs3.d
+++ b/test/unittest/aggs/tst.multiaggs3.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 */
 
 /*
  * ASSERTION:
diff --git a/test/unittest/printa/tst.basics.d b/test/unittest/printa/tst.basics.d
index 68068589..28ec0db0 100644
--- a/test/unittest/printa/tst.basics.d
+++ b/test/unittest/printa/tst.basics.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 */
 
 /*
  * ASSERTION:
@@ -25,6 +24,9 @@ BEGIN
 	@e = min(1);
 	@f = sum(1);
 	@g = quantize(1);
+	@h = llquantize(320, 10, 0, 5, 5, 8);
+	@i = stddev(10);
+	@i = stddev(20);
 
 	printa("@a = %@u\n", @a);
 	printa("@b = %@u\n", @b);
@@ -33,6 +35,8 @@ BEGIN
 	printa("@e = %@u\n", @e);
 	printa("@f = %@u\n", @f);
 	printa("@g = %@d\n", @g);
+	printa("@h = %@d\n", @h);
+	printa("@i = %@d\n", @i);
 
 	exit(0);
 }
diff --git a/test/unittest/printa/tst.basics.r b/test/unittest/printa/tst.basics.r
index a3d46a98..124c2bcf 100644
--- a/test/unittest/printa/tst.basics.r
+++ b/test/unittest/printa/tst.basics.r
@@ -15,4 +15,11 @@
                1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1        
                2 |                                         0        
 
+ at h = 
+           value  ------------- Distribution ------------- count    
+             100 |                                         0        
+             200 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8        
+             400 |                                         0        
+
+ at i = 5
 
-- 
2.18.4




More information about the DTrace-devel mailing list