[DTrace-devel] [PATCH v2] tst.alignring.d writes excessive output to test log

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Oct 13 07:43:08 PDT 2021


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

Orabug: 31927901
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 test/unittest/buffering/tst.alignring.d  |  64 ---------
 test/unittest/buffering/tst.alignring.sh | 172 +++++++++++++++++++++++
 2 files changed, 172 insertions(+), 64 deletions(-)
 delete mode 100644 test/unittest/buffering/tst.alignring.d
 create mode 100755 test/unittest/buffering/tst.alignring.sh

diff --git a/test/unittest/buffering/tst.alignring.d b/test/unittest/buffering/tst.alignring.d
deleted file mode 100644
index a2f9d549..00000000
--- a/test/unittest/buffering/tst.alignring.d
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 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.
- */
-
-/*
- * ASSERTION:
- *   Positive test for ring buffer policy.
- *
- * SECTION: Buffers and Buffering/ring Policy;
- *	Buffers and Buffering/Buffer Sizes;
- *	Options and Tunables/bufsize;
- *	Options and Tunables/bufpolicy
- */
-
-/* Incurs swapping, so
- *  @@timeout: 15
- */
-
-#pragma D option bufpolicy=ring
-#pragma D option bufsize=4k
-
-profile:::profile-1009hz
-{
-	printf("%x %x\n", (int)0xaaaa, (int)0xbbbb);
-}
-
-profile:::profile-1237hz
-{
-	printf("%x %x %x %x %x %x\n",
-	    (int)0xcccc,
-	    (int)0xdddd,
-	    (int)0xeeee,
-	    (int)0xffff,
-	    (int)0xabab,
-	    (int)0xacac);
-	printf("%x %x\n",
-	    (uint64_t)0xaabbaabbaabbaabb,
-	    (int)0xadad);
-}
-
-profile:::profile-1789hz
-{
-	printf("%x %x %x %x %x\n",
-	    (int)0xaeae,
-	    (int)0xafaf,
-	    (unsigned char)0xaa,
-	    (int)0xbcbc,
-	    (int)0xbdbd);
-}
-
-profile-1543hz
-{}
-
-profile-1361hz
-{}
-
-tick-1sec
-/i++ >= 10/
-{
-	exit(0);
-}
diff --git a/test/unittest/buffering/tst.alignring.sh b/test/unittest/buffering/tst.alignring.sh
new file mode 100755
index 00000000..999e67da
--- /dev/null
+++ b/test/unittest/buffering/tst.alignring.sh
@@ -0,0 +1,172 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2006, 2021, 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.
+#
+# ASSERTION:
+#   Positive test for ring buffer policy.
+#
+# SECTION: Buffers and Buffering/ring Policy;
+#	Buffers and Buffering/Buffer Sizes;
+#	Options and Tunables/bufsize;
+#	Options and Tunables/bufpolicy
+#
+# Incurs swapping, so
+#  @@timeout: 15
+
+dtrace=$1
+
+DIRNAME="$tmpdir/buffering-alignring.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# run DTrace
+
+$dtrace $dt_flags -o out.txt -n '
+#pragma D option bufpolicy=ring
+#pragma D option bufsize=4k
+
+profile:::profile-1009hz
+{
+	printf("%x %x\n", (int)0xaaaa, (int)0xbbbb);
+}
+
+profile:::profile-1237hz
+{
+	printf("%x %x %x %x %x %x\n",
+	    (int)0xcccc,
+	    (int)0xdddd,
+	    (int)0xeeee,
+	    (int)0xffff,
+	    (int)0xabab,
+	    (int)0xacac);
+	printf("%x %x\n",
+	    (uint64_t)0xaabbaabbaabbaabb,
+	    (int)0xadad);
+}
+
+profile:::profile-1789hz
+{
+	printf("%x %x %x %x %x\n",
+	    (int)0xaeae,
+	    (int)0xafaf,
+	    (unsigned char)0xaa,
+	    (int)0xbcbc,
+	    (int)0xbdbd);
+}
+
+profile-1543hz
+{}
+
+profile-1361hz
+{}
+
+tick-1sec
+/i++ >= 10/
+{
+	exit(0);
+}'
+if [ $? -ne 0 ]; then
+	echo "DTrace failed to run"
+	cat out.txt
+	exit 1
+fi
+
+# check output with awk
+
+NPROC=`getconf _NPROCESSORS_ONLN`
+
+awk -v NPROC=$NPROC '
+BEGIN {
+	# estimate final counts
+	n1009 = 10 * 1009 * NPROC;
+	n1237 = 10 * 1237 * NPROC;
+	n1361 = 10 * 1361 * NPROC;
+	n1543 = 10 * 1543 * NPROC;
+	n1789 = 10 * 1789 * NPROC;
+	nblank = n1009 + n1237 + n1789;
+
+	# initialize number of errors
+	nERRORs = 0;
+
+	# initialize numbers of lines found
+	iblank = iFUNC_NAME = iunexpected = 0;
+	i1237a = i1237b = i1361 = i1543 = i1789 = itick = 0;
+}
+
+# count lines
+NF == 0 { iblank++; next }
+/^ *FUNCTION:NAME$/ { iFUNC_NAME++; next }
+/^ *:profile-1009hz aaaa bbbb$/ { i1009++; next }
+/^ *:profile-1237hz cccc dddd eeee ffff abab acac$/ { i1237a++; next }
+/^aabbaabbaabbaabb adad$/ { i1237b++; next }
+/^ *:profile-1361hz $/ { i1361++; next }
+/^ *:profile-1543hz $/ { i1543++; next }
+/^ *:profile-1789hz aeae afaf aa bcbc bdbd$/ { i1789++; next }
+/^ *:tick-1sec $/ { itick++; next }
+{ iunexpected++; next }
+
+# done
+function check(xexpect, xactual, label) {
+	# allow a very big margin for underfiring
+	if (xactual < (10 * xexpect / 50) ||
+	    xactual > (51 * xexpect / 50)) {
+		print "ERROR:", label, "expect", xexpect, "actual", xactual;
+		nERRORS++;
+	}
+}
+END {
+	# print some diagnostic output
+	print NPROC, " procs"
+	print ":profile-1009hz expect", n1009, "actual", i1009
+	print ":profile-1237hz expect", n1237, "actual", i1237a, i1237b
+	print ":profile-1361hz expect", n1361, "actual", i1361
+	print ":profile-1543hz expect", n1543, "actual", i1543
+	print ":profile-1789hz expect", n1789, "actual", i1789
+	print iblank, "blank lines"
+
+	# check values
+	if (iunexpected != 0) {
+		print "ERROR: got", iunexpected, "unexpected lines";
+		nERRORS++;
+	}
+	if (iFUNC_NAME != 1) {
+		print "ERROR: FUNCTION:NAME expected once; got", iFUNC_NAME;
+		nERRORS++;
+	}
+	if (itick != 1) {
+		print "ERROR: tick-1sec expected once; got", itick;
+		nERRORS++;
+	}
+	if (i1237a != i1237b) {
+		print "ERROR: :profile-1237 continuation lines expect", i1237a, "actual", i1237b;
+		nERRORS++;
+	}
+	check(nblank, iblank, "blank lines");
+	check(n1009, i1009, ":profile-1009hz");
+	check(n1237, i1237a, ":profile-1237hz");
+	check(n1237, i1237b, ":profile-1237hz (continuation line)");
+	check(n1361, i1361, ":profile-1361hz");
+	check(n1543, i1543, ":profile-1543hz");
+	check(n1789, i1789, ":profile-1789hz");
+
+	# summarize and exit
+	if (nERRORS > 0) {
+		print "FAIL";
+		exit 1
+	} else {
+		print "SUCCESS";
+		exit 0
+	}
+}
+' out.txt
+if [ $? -ne 0 ]; then
+	echo "awk reports error"
+	cat out.txt
+	exit 1
+fi
+
+echo SUCCESS
+exit 0
-- 
2.18.4




More information about the DTrace-devel mailing list