[DTrace-devel] [PATCH] test: split tst.str_comparison-basic.d into with and without NULL testing

Kris Van Hees kris.van.hees at oracle.com
Tue Oct 11 21:40:20 UTC 2022


Since NULL strings are not supported yet, the tst.str_comparison-basic.d
test is fialing even though the non-NULL case should PASS without any
problem.  The test is now written as two tests: one that exercises the
case of NULL strings and one that does not.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 .../tst.str_comparison-basic-with-NULL.d      | 75 +++++++++++++++++++
 .../operators/tst.str_comparison-basic.d      | 23 ------
 2 files changed, 75 insertions(+), 23 deletions(-)
 create mode 100644 test/unittest/operators/tst.str_comparison-basic-with-NULL.d

diff --git a/test/unittest/operators/tst.str_comparison-basic-with-NULL.d b/test/unittest/operators/tst.str_comparison-basic-with-NULL.d
new file mode 100644
index 00000000..64bb0579
--- /dev/null
+++ b/test/unittest/operators/tst.str_comparison-basic-with-NULL.d
@@ -0,0 +1,75 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 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.
+ */
+/* @@xfail: No support for NULL strings yet */
+
+/*
+ * ASSERTION: String comparisons work.
+ *
+ * SECTION:  Operators
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+	nerrors = 0;
+
+	s1 = "abcdefghi";
+	s2 = "jklmnopqr";
+	s3 = "stuvwxyz!";
+
+	nerrors += (s1 <= s2 ? 0 : 1);
+	nerrors += (s1 <  s2 ? 0 : 1);
+	nerrors += (s1 == s2 ? 1 : 0);
+	nerrors += (s1 != s2 ? 0 : 1);
+	nerrors += (s1 >= s2 ? 1 : 0);
+	nerrors += (s1 >  s2 ? 1 : 0);
+
+	nerrors += (s2 <= s2 ? 0 : 1);
+	nerrors += (s2 <  s2 ? 1 : 0);
+	nerrors += (s2 == s2 ? 0 : 1);
+	nerrors += (s2 != s2 ? 1 : 0);
+	nerrors += (s2 >= s2 ? 0 : 1);
+	nerrors += (s2 >  s2 ? 1 : 0);
+
+	nerrors += (s3 <= s2 ? 1 : 0);
+	nerrors += (s3 <  s2 ? 1 : 0);
+	nerrors += (s3 == s2 ? 1 : 0);
+	nerrors += (s3 != s2 ? 0 : 1);
+	nerrors += (s3 >= s2 ? 0 : 1);
+	nerrors += (s3 >  s2 ? 0 : 1);
+
+	s2 = NULL;
+	nerrors += (s3 <= s2 ? 1 : 0);
+	nerrors += (s3 <  s2 ? 1 : 0);
+	nerrors += (s3 == s2 ? 1 : 0);
+	nerrors += (s3 != s2 ? 0 : 1);
+	nerrors += (s3 >= s2 ? 0 : 0);
+	nerrors += (s3 >  s2 ? 0 : 0);
+
+	nerrors += (s2 <= s3 ? 0 : 1);
+	nerrors += (s2 <  s3 ? 0 : 1);
+	nerrors += (s2 == s3 ? 1 : 0);
+	nerrors += (s2 != s3 ? 0 : 1);
+	nerrors += (s2 >= s3 ? 1 : 0);
+	nerrors += (s2 >  s3 ? 1 : 0);
+
+	s3 = NULL;
+	nerrors += (s2 <= s3 ? 0 : 1);
+	nerrors += (s2 <  s3 ? 1 : 0);
+	nerrors += (s2 == s3 ? 0 : 1);
+	nerrors += (s2 != s3 ? 1 : 0);
+	nerrors += (s2 >= s3 ? 0 : 1);
+	nerrors += (s2 >  s3 ? 1 : 0);
+
+	printf("%d errors\n", nerrors);
+	exit(nerrors == 0 ? 0 : 1);
+}
+ERROR
+{
+	exit(1);
+}
diff --git a/test/unittest/operators/tst.str_comparison-basic.d b/test/unittest/operators/tst.str_comparison-basic.d
index 344a2cf0..1e13c70f 100644
--- a/test/unittest/operators/tst.str_comparison-basic.d
+++ b/test/unittest/operators/tst.str_comparison-basic.d
@@ -42,29 +42,6 @@ BEGIN
 	nerrors += (s3 >= s2 ? 0 : 1);
 	nerrors += (s3 >  s2 ? 0 : 1);
 
-	s2 = NULL;
-	nerrors += (s3 <= s2 ? 1 : 0);
-	nerrors += (s3 <  s2 ? 1 : 0);
-	nerrors += (s3 == s2 ? 1 : 0);
-	nerrors += (s3 != s2 ? 0 : 1);
-	nerrors += (s3 >= s2 ? 0 : 0);
-	nerrors += (s3 >  s2 ? 0 : 0);
-
-	nerrors += (s2 <= s3 ? 0 : 1);
-	nerrors += (s2 <  s3 ? 0 : 1);
-	nerrors += (s2 == s3 ? 1 : 0);
-	nerrors += (s2 != s3 ? 0 : 1);
-	nerrors += (s2 >= s3 ? 1 : 0);
-	nerrors += (s2 >  s3 ? 1 : 0);
-
-	s3 = NULL;
-	nerrors += (s2 <= s3 ? 0 : 1);
-	nerrors += (s2 <  s3 ? 1 : 0);
-	nerrors += (s2 == s3 ? 0 : 1);
-	nerrors += (s2 != s3 ? 1 : 0);
-	nerrors += (s2 >= s3 ? 0 : 1);
-	nerrors += (s2 >  s3 ? 1 : 0);
-
 	printf("%d errors\n", nerrors);
 	exit(nerrors == 0 ? 0 : 1);
 }
-- 
2.37.2




More information about the DTrace-devel mailing list