changeset 328:01fb61958140

Runners: Fix ragged output for String tests with \0 symbols.
author shade
date Thu, 20 Oct 2016 15:22:13 +0200
parents 3b07f039cca7
children 9a849898ff24
files jcstress-core/src/main/java/org/openjdk/jcstress/util/StringUtils.java tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBufferTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBuilderTest.java
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/StringUtils.java	Thu Oct 20 10:08:42 2016 +0200
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/StringUtils.java	Thu Oct 20 15:22:13 2016 +0200
@@ -31,6 +31,7 @@
 public class StringUtils {
 
     public static String cutoff(String src, int len) {
+        src = src.replaceAll("\u0000", " ");
         while (src.contains("  ")) {
             src = src.replaceAll("  ", " ");
         }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBufferTest.java	Thu Oct 20 10:08:42 2016 +0200
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBufferTest.java	Thu Oct 20 15:22:13 2016 +0200
@@ -29,7 +29,7 @@
 
 @JCStressTest
 @Description("Tests the StringBuffers are working good under concurrent updates.")
-@Outcome(id = "b{20}", expect = Expect.ACCEPTABLE, desc = "All appends are visible")
+@Outcome(id = "b{4}", expect = Expect.ACCEPTABLE, desc = "All appends are visible")
 @State
 public class StringBufferTest {
 
@@ -37,14 +37,14 @@
 
     @Actor
     public void actor1() {
-        for (int i = 0; i < 10; ++i) {
+        for (int i = 0; i < 2; ++i) {
             sb.append('b');
         }
     }
 
     @Actor
     public void actor2() {
-        for (int i = 0; i < 10; ++i) {
+        for (int i = 0; i < 2; ++i) {
             sb.append('b');
         }
     }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBuilderTest.java	Thu Oct 20 10:08:42 2016 +0200
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/StringBuilderTest.java	Thu Oct 20 15:22:13 2016 +0200
@@ -29,7 +29,7 @@
 
 @JCStressTest
 @Description("Tests the StringBuilders are working good under concurrent updates.")
-@Outcome(id = "b{20}", expect = Expect.ACCEPTABLE, desc = "All appends are visible.")
+@Outcome(id = "b{4}", expect = Expect.ACCEPTABLE, desc = "All appends are visible.")
 @Outcome(expect = Expect.ACCEPTABLE_INTERESTING, desc = "Other values are expected, threads are messing with each other.")
 @State
 public class StringBuilderTest {
@@ -39,7 +39,7 @@
     @Actor
     public void actor1() {
         try {
-            for (int i = 0; i < 10; ++i) {
+            for (int i = 0; i < 2; ++i) {
                 sb.append('b');
             }
         } catch (Exception e) {
@@ -50,7 +50,7 @@
     @Actor
     public void actor2() {
         try {
-            for (int i = 0; i < 10; ++i) {
+            for (int i = 0; i < 2; ++i) {
                 sb.append('b');
             }
         } catch (Exception e) {