I'm new to JCStress and I'm trying to run the "hello world" for JCStress but facing some problems. I think there is some obvious thing that I'm missing.
I'm following this link to learn. And the samples that I'm trying are here.
I started with the template project created from the following public maven archetype:
mvn archetype:generate "-DinteractiveMode=false" "-DarchetypeGroupId=org.openjdk.jcstress" "-DarchetypeArtifactId=jcstress-java-test-archetype" "-DarchetypeVersion=0.4" "-DgroupId=org.sample" "-DartifactId=test" "-Dversion=1.0"
I did a mvn clean install
and got the .\target\jcstress.jar
. I added MyConcurrencyTest
which has the following code in package org.sample
package org.sample;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.I_Result;
@JCStressTest
@Outcome(id = "1", expect = Expect.ACCEPTABLE_INTERESTING, desc = "One update lost: atomicity failure.")
@Outcome(id = "2", expect = Expect.ACCEPTABLE, desc = "Actors updated independently.")
@State
public class MyConcurrencyTest {
int v;
@Actor
public void actor1() {
v++;
}
@Actor
public void actor2() {
v++;
}
@Arbiter
public void arbiter(I_Result r) {
r.r1 = v;
}
}
The following is my project structure:
Now I'm trying to run this using this command (my current directory is the project root directory when I execute this command)
java -cp ".\target\classes" -jar .\target\jcstress.jar -v -t org.sample.MyConcurrencyTest
But the org.sample.MyConcurrencyTest
don't get executed.
(I understand that if we don't specify the tests using -t <testname>
the tests from jcstress.jar/META-INF/TestList
are picked up.)
I think I'm missing something very obvious. Can someone please help?
(It will be great if someone could share a good starter tutorial on JCStress explaining it's capabilities and functionalities that it has)