From c5160dcc90336cf2b5ec165e574e65a572e52218 Mon Sep 17 00:00:00 2001 From: Denis Lochmelis Date: Wed, 18 Oct 2023 13:41:56 +0200 Subject: [PATCH] Manually connect and run a test with jcstress --- gradle/wrapper/gradle-wrapper.properties | 2 +- jcstress/.gitignore | 3 ++ jcstress/pom.xml | 8 +++- .../src/main/java/org/sample/AbaTest.java | 15 ------- .../src/main/java/org/sample/LitmusSB.java | 43 +++++++++++++++++++ litmus/build.gradle.kts | 2 +- 6 files changed, 55 insertions(+), 18 deletions(-) delete mode 100644 jcstress/src/main/java/org/sample/AbaTest.java create mode 100644 jcstress/src/main/java/org/sample/LitmusSB.java diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..e411586 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/jcstress/.gitignore b/jcstress/.gitignore index 4c72a9b..7fd277f 100644 --- a/jcstress/.gitignore +++ b/jcstress/.gitignore @@ -1,2 +1,5 @@ target/ libs/ +results/ +*.bin.gz +test.iml diff --git a/jcstress/pom.xml b/jcstress/pom.xml index 012c16e..db85c2b 100644 --- a/jcstress/pom.xml +++ b/jcstress/pom.xml @@ -60,6 +60,11 @@ THE POSSIBILITY OF SUCH DAMAGE. litmuskt 1.0 + + org.jetbrains.kotlin + kotlin-stdlib + 1.9.10 + @@ -112,7 +117,8 @@ THE POSSIBILITY OF SUCH DAMAGE. implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> org.openjdk.jcstress.Main - + META-INF/TestList diff --git a/jcstress/src/main/java/org/sample/AbaTest.java b/jcstress/src/main/java/org/sample/AbaTest.java deleted file mode 100644 index 6c05b03..0000000 --- a/jcstress/src/main/java/org/sample/AbaTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.sample; - -import komem.litmus.LitmusTest; - -public class AbaTest { - - private List> fs; - private Function1 arbiter; - - public AbaTest(LitmusTest test) { - fs = test.getThreadFunctions(); - arbiter = test.getOutcomeFinalizer(); - } - -} diff --git a/jcstress/src/main/java/org/sample/LitmusSB.java b/jcstress/src/main/java/org/sample/LitmusSB.java new file mode 100644 index 0000000..f467b4e --- /dev/null +++ b/jcstress/src/main/java/org/sample/LitmusSB.java @@ -0,0 +1,43 @@ +package org.sample; + +import komem.litmus.LitmusTest; +import kotlin.Unit; +import kotlin.jvm.functions.Function1; +import komem.litmus.testsuite.ClassicTestsKt; +import org.openjdk.jcstress.annotations.*; +import org.openjdk.jcstress.infra.results.II_Result; + +import java.util.List; + +@JCStressTest +@State +public class LitmusSB { + + private static final LitmusTest sb = (LitmusTest) ClassicTestsKt.getSB(); + private static final Function1 fT0 = sb.getThreadFunctions().get(0); + private static final Function1 fT1 = sb.getThreadFunctions().get(1); + private static final Function1 fA = sb.getOutcomeFinalizer(); + + public LitmusSB() { + } + + public Object state = sb.getStateProducer().invoke(); + + @Actor + public void t1() { + fT0.invoke(state); + } + + @Actor + public void t2() { + fT1.invoke(state); + } + + @Arbiter + public void a(II_Result r) { + List result = (List) fA.invoke(state); + r.r1 = result.get(0); + r.r2 = result.get(1); + } + +} diff --git a/litmus/build.gradle.kts b/litmus/build.gradle.kts index 0b1f60a..4f04948 100644 --- a/litmus/build.gradle.kts +++ b/litmus/build.gradle.kts @@ -36,7 +36,7 @@ kotlin { mainClass.set("JvmMainKt") } withSourcesJar() - withJava() + jvmToolchain(8) } val affinitySupported = hostOs == "Linux"