Include JCStress for stress tests in our concurrent models. (#987)

This commit is contained in:
Articdive 2022-04-26 13:14:34 +02:00 committed by GitHub
parent 9ce5a79cc8
commit 6a7497f436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 1 deletions

View File

@ -36,7 +36,8 @@ jNoise = "b93008e35e"
# JMH
jmh = "1.35"
# JCStress
jcstress = "0.8"
[libraries]
@ -92,6 +93,9 @@ jNoise = { group = "com.github.Articdive.JNoise", name = "jnoise-pipeline", vers
jmh-core = { group = "org.openjdk.jmh", name = "jmh-core", version.ref = "jmh" }
jmh-annotationprocessor = { group = "org.openjdk.jmh", name = "jmh-generator-annprocess", version.ref = "jmh" }
# JCStress
jcstress-core = { group = "org.openjdk.jcstress", name = "jcstress-core", version.ref = "jcstress" }
[bundles]
kotlin = ["kotlin-stdlib-jdk8", "kotlin-reflect"]

View File

@ -0,0 +1,9 @@
plugins {
id("io.github.reyerizo.gradle.jcstress") version "0.8.13"
id("minestom.common-conventions")
}
dependencies {
jcstressImplementation(rootProject)
jcstress(libs.jcstress.core)
}

View File

@ -0,0 +1,49 @@
package net.minestom.server;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.I_Result;
import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE;
import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE_INTERESTING;
@JCStressTest
@Outcome(id = "-1", expect = ACCEPTABLE, desc = "Object has not been seen")
@Outcome(id = {"4", "5"}, expect = ACCEPTABLE_INTERESTING, desc = "Object only partially initialized")
@Outcome(id = "9", expect = ACCEPTABLE, desc = "Object fully initialized")
@State
public class ConstructorBasic {
private SimpleClass value;
@Actor
public void actor1() {
value = new SimpleClass();
}
@Actor
public void actor2(I_Result r) {
SimpleClass current = this.value;
if (current != null) {
r.r1 = current.getX() + current.getY();
} else {
r.r1 = -1;
}
}
public static class SimpleClass {
private int x;
private int y;
SimpleClass() {
x = 4;
y = 5;
}
int getX() {
return x;
}
int getY() {
return y;
}
}
}

View File

@ -19,4 +19,5 @@ pluginManagement {
rootProject.name = "Minestom"
include("code-generators")
include("jmh-benchmarks")
include("jcstress-tests")
include("demo")