8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures
authorshade
Wed, 04 May 2016 17:17:10 +0300
changeset 38234 06263a71233c
parent 38233 9f784c50b967
child 38235 b2cbc7dbebb6
8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures Reviewed-by: psandoz, vlivanov, simonis
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
hotspot/test/compiler/unsafe/generate-unsafe-tests.sh
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestBoolean {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -148,4 +149,3 @@
 
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestByte {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestChar {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -203,4 +204,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestDouble {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestFloat {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -185,4 +186,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestInt {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -251,22 +252,31 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2);
-            assertEquals(r, true, "weakCompareAndSwap int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSwap int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 2, "weakCompareAndSwap int value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1);
-            assertEquals(r, true, "weakCompareAndSwapAcquire int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 1, "weakCompareAndSwapAcquire int");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2);
-            assertEquals(r, true, "weakCompareAndSwapRelease int");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease int");
             int x = UNSAFE.getInt(base, offset);
             assertEquals(x, 2, "weakCompareAndSwapRelease int");
         }
@@ -286,7 +296,7 @@
             int o = UNSAFE.getAndAddInt(base, offset, 2);
             assertEquals(o, 1, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int");
+            assertEquals(x, 1 + 2, "getAndAdd int");
         }
     }
 
@@ -300,4 +310,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestLong {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -251,22 +252,31 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSwap long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSwap long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 2L, "weakCompareAndSwap long value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L);
-            assertEquals(r, true, "weakCompareAndSwapAcquire long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 1L, "weakCompareAndSwapAcquire long");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L);
-            assertEquals(r, true, "weakCompareAndSwapRelease long");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease long");
             long x = UNSAFE.getLong(base, offset);
             assertEquals(x, 2L, "weakCompareAndSwapRelease long");
         }
@@ -286,7 +296,7 @@
             long o = UNSAFE.getAndAddLong(base, offset, 2L);
             assertEquals(o, 1L, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long");
+            assertEquals(x, 1L + 2L, "getAndAdd long");
         }
     }
 
@@ -300,4 +310,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestObject {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -204,22 +205,31 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwap Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwap Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwap Object value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSwapAcquire Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "foo", "weakCompareAndSwapAcquire Object");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwapRelease Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwapRelease Object");
         }
@@ -236,4 +246,3 @@
 
 }
 
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestShort {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -203,4 +204,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestBoolean {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -131,9 +132,7 @@
 
 
 
-
     }
 
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestByte {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestChar {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestDouble {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestFloat {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestInt {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -165,7 +166,6 @@
 
 
 
-
         UNSAFE.putInt(base, offset, 1);
 
         // Compare
@@ -184,7 +184,6 @@
         }
 
 
-
         // Compare set and get
         {
             int o = UNSAFE.getAndSetInt(base, offset, 1);
@@ -200,7 +199,7 @@
             int o = UNSAFE.getAndAddInt(base, offset, 2);
             assertEquals(o, 1, "getAndAdd int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int");
+            assertEquals(x, 1 + 2, "getAndAdd int");
         }
     }
 
@@ -214,4 +213,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestLong {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -165,7 +166,6 @@
 
 
 
-
         UNSAFE.putLong(base, offset, 1L);
 
         // Compare
@@ -184,7 +184,6 @@
         }
 
 
-
         // Compare set and get
         {
             long o = UNSAFE.getAndSetLong(base, offset, 1L);
@@ -200,7 +199,7 @@
             long o = UNSAFE.getAndAddLong(base, offset, 2L);
             assertEquals(o, 1L, "getAndAdd long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long");
+            assertEquals(x, 1L + 2L, "getAndAdd long");
         }
     }
 
@@ -214,4 +213,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestObject {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -136,7 +137,6 @@
 
 
 
-
         UNSAFE.putObject(base, offset, "foo");
 
         // Compare
@@ -155,7 +155,6 @@
         }
 
 
-
         // Compare set and get
         {
             Object o = UNSAFE.getAndSetObject(base, offset, "foo");
@@ -168,4 +167,3 @@
 
 }
 
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class SunMiscUnsafeAccessTestShort {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final sun.misc.Unsafe UNSAFE;
 
@@ -160,7 +161,6 @@
 
 
 
-
     }
 
     static void testAccess(long address) {
@@ -173,4 +173,3 @@
     }
 }
 
-
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class $Qualifier$UnsafeAccessTest$Type$ {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final $package$.Unsafe UNSAFE;
 
@@ -273,22 +274,31 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSwap $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSwap $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value2$, "weakCompareAndSwap $type$ value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
-            assertEquals(r, true, "weakCompareAndSwapAcquire $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
-            assertEquals(r, true, "weakCompareAndSwapRelease $type$");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
             assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$");
         }
@@ -311,7 +321,7 @@
             $type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$);
             assertEquals(o, $value1$, "getAndAdd $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$ + $value2$, "weakCompareAndSwapRelease $type$");
+            assertEquals(x, $value1$ + $value2$, "getAndAdd $type$");
         }
 #end[AtomicAdd]
     }
--- a/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh	Tue May 03 20:36:17 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#!/bin/bash
-
-javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java
-
-SPP=build.tools.spp.Spp
-
-# Generates unsafe access tests for objects and all primitive types
-# $1 = package name to Unsafe, sun.misc | jdk.internal.misc
-# $2 = test class qualifier name, SunMisc | JdkInternalMisc
-function generate {
-    package=$1
-    Qualifier=$2
-
-    for type in boolean byte short char int long float double Object
-    do
-      Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}"
-      args="-K$type -Dtype=$type -DType=$Type"
-
-      case $type in
-        Object|int|long)
-          args="$args -KCAS -KOrdered"
-          ;;
-      esac
-
-      case $type in
-        int|long)
-          args="$args -KAtomicAdd"
-          ;;
-      esac
-
-      case $type in
-        short|char|int|long)
-          args="$args -KUnaligned"
-          ;;
-      esac
-
-      case $type in
-        boolean)
-          value1=true
-          value2=false
-          value3=false
-          ;;
-        byte)
-          value1=(byte)1
-          value2=(byte)2
-          value3=(byte)3
-          ;;
-        short)
-          value1=(short)1
-          value2=(short)2
-          value3=(short)3
-          ;;
-        char)
-          value1=\'a\'
-          value2=\'b\'
-          value3=\'c\'
-          ;;
-        int)
-          value1=1
-          value2=2
-          value3=3
-          ;;
-        long)
-          value1=1L
-          value2=2L
-          value3=3L
-          ;;
-        float)
-          value1=1.0f
-          value2=2.0f
-          value3=3.0f
-          ;;
-        double)
-          value1=1.0d
-          value2=2.0d
-          value3=3.0d
-          ;;
-        Object)
-          value1=\"foo\"
-          value2=\"bar\"
-          value3=\"baz\"
-          ;;
-      esac
-
-      args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3"
-
-      echo $args
-
-      java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier \
-          $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java
-    done
-}
-
-generate sun.misc SunMisc
-generate jdk.internal.misc JdkInternalMisc
-
-rm -fr build
\ No newline at end of file