changeset 106:da7c2d740be7

Migrate locks.barriers.* test descriptions to new API.
author shade
date Fri, 14 Mar 2014 02:42:51 +0400
parents a68df4d2111e
children c0600aa1b85f
files tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier0Test.java tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier1Test.java tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier2Test.java tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier3Test.java tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier4Test.java
diffstat 5 files changed, 76 insertions(+), 164 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier0Test.java	Fri Mar 14 02:38:19 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier0Test.java	Fri Mar 14 02:42:51 2014 +0400
@@ -24,36 +24,29 @@
  */
 package org.openjdk.jcstress.tests.locks.barriers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
-public class SyncBarrier0Test implements Actor2_Test<SyncBarrier0Test.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class SyncBarrier0Test {
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 2;
-        s.b = 1;
+    int a;
+    int b;
+
+    @Actor
+    public void actor1() {
+        a = 2;
+        b = 1;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.b;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
+    @Actor
+    public void actor2(IntResult2 r) {
+        r.r1 = b;
+        r.r2 = a;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier1Test.java	Fri Mar 14 02:38:19 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier1Test.java	Fri Mar 14 02:42:51 2014 +0400
@@ -24,44 +24,37 @@
  */
 package org.openjdk.jcstress.tests.locks.barriers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
-public class SyncBarrier1Test implements Actor2_Test<SyncBarrier1Test.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class SyncBarrier1Test {
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 2;
-        synchronized (State.locks.get()) {}
-        s.b = 1;
+    public static ThreadLocal<Object> locks = new ThreadLocal<Object>() {
+        @Override
+        protected Object initialValue() {
+            return new Object();
+        }
+    };
+
+    int a;
+    int b;
+
+    @Actor
+    public void actor1(IntResult2 r) {
+        a = 2;
+        synchronized (locks.get()) {}
+        b = 1;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.b;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
-
-        public static ThreadLocal<Object> locks = new ThreadLocal<Object>() {
-            @Override
-            protected Object initialValue() {
-                return new Object();
-            }
-        };
+    @Actor
+    public void actor2(IntResult2 r) {
+        r.r1 = b;
+        r.r2 = a;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier2Test.java	Fri Mar 14 02:38:19 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier2Test.java	Fri Mar 14 02:42:51 2014 +0400
@@ -24,37 +24,30 @@
  */
 package org.openjdk.jcstress.tests.locks.barriers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
-public class SyncBarrier2Test implements Actor2_Test<SyncBarrier2Test.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class SyncBarrier2Test {
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 2;
+    int a;
+    int b;
+
+    @Actor
+    public void actor1() {
+        a = 2;
         synchronized (new Object()) {}
-        s.b = 1;
+        b = 1;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.b;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
+    @Actor
+    public void actor2(IntResult2 r) {
+        r.r1 = b;
+        r.r2 = a;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier3Test.java	Fri Mar 14 02:38:19 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier3Test.java	Fri Mar 14 02:42:51 2014 +0400
@@ -24,37 +24,30 @@
  */
 package org.openjdk.jcstress.tests.locks.barriers;
 
+import org.openjdk.jcstress.infra.annotations.Actor;
+import org.openjdk.jcstress.infra.annotations.ConcurrencyStressTest;
+import org.openjdk.jcstress.infra.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult2;
 import org.openjdk.jcstress.tests.Actor2_Test;
 
-public class SyncBarrier3Test implements Actor2_Test<SyncBarrier3Test.State, IntResult2> {
+@ConcurrencyStressTest
+@State
+public class SyncBarrier3Test {
 
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 2;
+    int a;
+    int b;
+
+    @Actor
+    public void actor1() {
+        a = 2;
         synchronized (this) {}
-        s.b = 1;
+        b = 1;
     }
 
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.b;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
+    @Actor
+    public void actor2(IntResult2 r) {
+        r.r1 = b;
+        r.r2 = a;
     }
 
 }
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/locks/barriers/SyncBarrier4Test.java	Fri Mar 14 02:38:19 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.jcstress.tests.locks.barriers;
-
-import org.openjdk.jcstress.infra.results.IntResult2;
-import org.openjdk.jcstress.tests.Actor2_Test;
-
-public class SyncBarrier4Test implements Actor2_Test<SyncBarrier4Test.State, IntResult2> {
-
-    @Override
-    public void actor1(State s, IntResult2 r) {
-        s.a = 2;
-        synchronized (s) {}
-        s.b = 1;
-    }
-
-    @Override
-    public void actor2(State s, IntResult2 r) {
-        r.r1 = s.b;
-        r.r2 = s.a;
-    }
-
-    @Override
-    public State newState() {
-        return new State();
-    }
-
-    @Override
-    public IntResult2 newResult() {
-        return new IntResult2();
-    }
-
-    public static class State {
-        public int a;
-        public int b;
-    }
-
-}