changeset 186:8d289a23c8c8

Migrate singleton.* tests to annotation API.
author shade
date Wed, 13 Aug 2014 00:02:25 +0400
parents 8761a67b7fc9
children 181e2e7a6cb5
files tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/FinalWrapperSingletonTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/HolderSingletonTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/SafeDCLSingletonTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeDCLSingletonTest.java tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeLocalDCLSingletonTest.java tests-custom/src/main/resources/org/openjdk/jcstress/desc/singletons.xml
diffstat 6 files changed, 35 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/FinalWrapperSingletonTest.java	Tue Aug 12 14:59:45 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/FinalWrapperSingletonTest.java	Wed Aug 13 00:02:25 2014 +0400
@@ -25,7 +25,10 @@
 package org.openjdk.jcstress.tests.singletons;
 
 import org.openjdk.jcstress.annotations.Actor;
+import org.openjdk.jcstress.annotations.Description;
+import org.openjdk.jcstress.annotations.Expect;
 import org.openjdk.jcstress.annotations.JCStressTest;
+import org.openjdk.jcstress.annotations.Outcome;
 import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult1;
 
@@ -35,6 +38,10 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 @JCStressTest
+@Description("Tests the final wrapper case.")
+@Outcome(id = "[0]",  expect = Expect.FORBIDDEN,  desc = "Factory returned null singleton. This is the major correctness issue.")
+@Outcome(id = "[1]",  expect = Expect.FORBIDDEN,  desc = "The reference field in singleton is null. This is forbidden by JMM.")
+@Outcome(id = "[42]", expect = Expect.ACCEPTABLE, desc = "The singleton is observed in fully-constructed way.")
 public class FinalWrapperSingletonTest {
 
     @Actor
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/HolderSingletonTest.java	Tue Aug 12 14:59:45 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/HolderSingletonTest.java	Wed Aug 13 00:02:25 2014 +0400
@@ -25,7 +25,10 @@
 package org.openjdk.jcstress.tests.singletons;
 
 import org.openjdk.jcstress.annotations.Actor;
+import org.openjdk.jcstress.annotations.Description;
+import org.openjdk.jcstress.annotations.Expect;
 import org.openjdk.jcstress.annotations.JCStressTest;
+import org.openjdk.jcstress.annotations.Outcome;
 import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult1;
 
@@ -35,6 +38,10 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 @JCStressTest
+@Description("Tests the static holder case.")
+@Outcome(id = "[0]",  expect = Expect.FORBIDDEN,  desc = "Factory returned null singleton. This is the major correctness issue.")
+@Outcome(id = "[1]",  expect = Expect.FORBIDDEN,  desc = "The reference field in singleton is null. This is forbidden by JMM.")
+@Outcome(id = "[42]", expect = Expect.ACCEPTABLE, desc = "The singleton is observed in fully-constructed way.")
 public class HolderSingletonTest {
 
     @Actor
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/SafeDCLSingletonTest.java	Tue Aug 12 14:59:45 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/SafeDCLSingletonTest.java	Wed Aug 13 00:02:25 2014 +0400
@@ -25,7 +25,10 @@
 package org.openjdk.jcstress.tests.singletons;
 
 import org.openjdk.jcstress.annotations.Actor;
+import org.openjdk.jcstress.annotations.Description;
+import org.openjdk.jcstress.annotations.Expect;
 import org.openjdk.jcstress.annotations.JCStressTest;
+import org.openjdk.jcstress.annotations.Outcome;
 import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult1;
 
@@ -35,6 +38,10 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 @JCStressTest
+@Description("Tests the safe volatile case.")
+@Outcome(id = "[0]",  expect = Expect.FORBIDDEN,  desc = "Factory returned null singleton. This is the major correctness issue.")
+@Outcome(id = "[1]",  expect = Expect.FORBIDDEN,  desc = "The reference field in singleton is null. This is forbidden by JMM.")
+@Outcome(id = "[42]", expect = Expect.ACCEPTABLE, desc = "The singleton is observed in fully-constructed way.")
 public class SafeDCLSingletonTest {
 
     @Actor
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeDCLSingletonTest.java	Tue Aug 12 14:59:45 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeDCLSingletonTest.java	Wed Aug 13 00:02:25 2014 +0400
@@ -25,7 +25,10 @@
 package org.openjdk.jcstress.tests.singletons;
 
 import org.openjdk.jcstress.annotations.Actor;
+import org.openjdk.jcstress.annotations.Description;
+import org.openjdk.jcstress.annotations.Expect;
 import org.openjdk.jcstress.annotations.JCStressTest;
+import org.openjdk.jcstress.annotations.Outcome;
 import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult1;
 
@@ -35,6 +38,10 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 @JCStressTest
+@Description("Tests the unsafe publishing case.")
+@Outcome(id = "[0]",  expect = Expect.ACCEPTABLE_INTERESTING, desc = "Singleton return the null instance. This is counter-intuitive, but there is the race on $instance, and second read in the return can indeed return the null reference.")
+@Outcome(id = "[1]",  expect = Expect.ACCEPTABLE_INTERESTING, desc = "The reference field in singleton is null. This is the violation of singleton contract, but legal JMM behavior.")
+@Outcome(id = "[42]", expect = Expect.ACCEPTABLE, desc = "The singleton is observed in fully-constructed way.")
 public class UnsafeDCLSingletonTest {
 
     @Actor
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeLocalDCLSingletonTest.java	Tue Aug 12 14:59:45 2014 +0400
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/singletons/UnsafeLocalDCLSingletonTest.java	Wed Aug 13 00:02:25 2014 +0400
@@ -25,7 +25,10 @@
 package org.openjdk.jcstress.tests.singletons;
 
 import org.openjdk.jcstress.annotations.Actor;
+import org.openjdk.jcstress.annotations.Description;
+import org.openjdk.jcstress.annotations.Expect;
 import org.openjdk.jcstress.annotations.JCStressTest;
+import org.openjdk.jcstress.annotations.Outcome;
 import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.results.IntResult1;
 
@@ -35,6 +38,10 @@
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
 @JCStressTest
+@Description("Tests the unsafe publishing case.")
+@Outcome(id = "[0]",  expect = Expect.ACCEPTABLE_INTERESTING, desc = "Singleton return the null instance. This is counter-intuitive, but there is the race on $instance, and second read in the return can indeed return the null reference.")
+@Outcome(id = "[1]",  expect = Expect.ACCEPTABLE_INTERESTING, desc = "The reference field in singleton is null. This is the violation of singleton contract, but legal JMM behavior.")
+@Outcome(id = "[42]", expect = Expect.ACCEPTABLE, desc = "The singleton is observed in fully-constructed way.")
 public class UnsafeLocalDCLSingletonTest {
 
     @Actor
--- a/tests-custom/src/main/resources/org/openjdk/jcstress/desc/singletons.xml	Tue Aug 12 14:59:45 2014 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +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.
-
--->
-<testsuite>
-
-    <template name="singleton">
-        <contributed-by>Aleksey Shipilev (aleksey.shipilev@oracle.com)</contributed-by>
-        <description>
-            Default description
-        </description>
-        <case>
-            <match>[0]</match>
-            <expect>FORBIDDEN</expect>
-            <description>
-                Factory returned null singleton. This is the major correctness issue.
-            </description>
-        </case>
-        <case>
-            <match>[1]</match>
-            <expect>FORBIDDEN</expect>
-            <description>
-                The reference field in singleton is null.
-                This is forbidden by JMM.
-            </description>
-        </case>
-        <case>
-            <match>[42]</match>
-            <expect>ACCEPTABLE</expect>
-            <description>
-                The singleton is observed in fully-constructed way.
-            </description>
-        </case>
-        <unmatched>
-            <expect>ACCEPTABLE_INTERESTING</expect>
-            <description>
-                This should be under-uninitialized case. This is a correct JMM behavior.
-            </description>
-        </unmatched>
-    </template>
-
-    <test template="singleton" name="org.openjdk.jcstress.tests.singletons.UnsafeDCLSingletonTest">
-        <description>Tests the broken DCL-style singleton.</description>
-        <case>
-            <match>[1]</match>
-            <expect>ACCEPTABLE_INTERESTING</expect>
-            <description>
-                The reference field in singleton is null.
-                This is the violation of singleton contract, but legal JMM behavior.
-            </description>
-        </case>
-        <case>
-            <match>[0]</match>
-            <expect>ACCEPTABLE_INTERESTING</expect>
-            <description>
-                Singleton return the null instance. This is counter-intuitive, but there is the race on $instance,
-                and second read in the return can indeed return the null reference.
-            </description>
-        </case>
-    </test>
-
-    <test template="singleton" name="org.openjdk.jcstress.tests.singletons.UnsafeLocalDCLSingletonTest">
-        <description>Tests the broken DCL-style singleton.</description>
-        <case>
-            <match>[1]</match>
-            <expect>ACCEPTABLE_INTERESTING</expect>
-            <description>
-                The reference field in singleton is null.
-                This is the violation of singleton contract, but legal JMM behavior.
-            </description>
-        </case>
-    </test>
-
-    <test template="singleton" name="org.openjdk.jcstress.tests.singletons.SafeDCLSingletonTest">
-        <description>Tests the safe DCL-style singleton.</description>
-    </test>
-
-    <test template="singleton" name="org.openjdk.jcstress.tests.singletons.HolderSingletonTest">
-        <description>Tests the Holder-idiom singleton.</description>
-    </test>
-
-    <test template="singleton"  name="org.openjdk.jcstress.tests.singletons.FinalWrapperSingletonTest">
-        <description>Tests the final wrapper case.</description>
-    </test>
-
-</testsuite>