Skip to content

Is there anything like @Setup ,@State in linCheck If yes then I am not able to work with it getting the following error . #872

@jayrathi5

Description

@jayrathi5

I am attaching my code which I want to test but getting error .

package ch_3;

import org.jetbrains.kotlinx.lincheck.LinChecker;
import org.jetbrains.kotlinx.lincheck.annotations.Operation;
import org.jetbrains.kotlinx.lincheck.annotations.Setup;
import org.jetbrains.kotlinx.lincheck.annotations.State;
import org.jetbrains.kotlinx.lincheck.annotations.Validate;
import org.jetbrains.kotlinx.lincheck.strategy.stress.StressOptions;
import org.junit.Test;

import java.util.*;

@State
public class AGMStackRAStressTest {

private final AGMStack<Integer> stack = new AGMStack<>();


// Map Lincheck threads -> RA thread IDs
private static final Map<Long, String> threadNames = new HashMap<>();
private static int threadCounter = 0;

private static synchronized String getTid() {
    long id = Thread.currentThread().getId();
    return threadNames.computeIfAbsent(id, k -> "t" + (++threadCounter));
}

@Operation
public void push(int x) throws AGMStack.FullException {
    String tid = getTid();
    Object loc = stack;  // treat stack as shared location

    // --- RA write simulation ---
    raExec.performWrite(tid, loc, x);
    trace.add(new RAEvent(tid, "W", loc, x));

    stack.push(x);
}

@Operation
public Integer pop() throws AGMStack.EmptyException {
    String tid = getTid();
    Object loc = stack;

    Integer val = stack.pop();
    int v = (val == null) ? -1 : val;

    // --- RA read simulation ---
    raExec.performRead(tid, loc, v);
    trace.add(new RAEvent(tid, "R", loc, v));

    return val;
}

@Setup
public void resetState() {
  
}



@Test
public void stressCheckRA() {
    LinChecker.check(AGMStackRAStressTest.class,
            new StressOptions()
                    .threads(2)
                    .iterations(10));
}

}

jay@jay-Victus-by-HP-Gaming-Laptop-15-fa1xxx:~/IdeaProjects/linCheck$ ./gradlew clean test --tests "AGMStackRAStressTest"
Starting a Gradle Daemon, 4 stopped Daemons could not be reused, use --status for details

Task :compileJava
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Task :compileTestJava FAILED
/home/jay/IdeaProjects/linCheck/src/test/java/ch_3/AGMStackRAStressTest.java:5: error: cannot find symbol
import org.jetbrains.kotlinx.lincheck.annotations.Setup;
^
symbol: class Setup
location: package org.jetbrains.kotlinx.lincheck.annotations
/home/jay/IdeaProjects/linCheck/src/test/java/ch_3/AGMStackRAStressTest.java:6: error: cannot find symbol
import org.jetbrains.kotlinx.lincheck.annotations.State;
^
symbol: class State
location: package org.jetbrains.kotlinx.lincheck.annotations
/home/jay/IdeaProjects/linCheck/src/test/java/ch_3/AGMStackRAStressTest.java:14: error: cannot find symbol
@State
^
symbol: class State
/home/jay/IdeaProjects/linCheck/src/test/java/ch_3/AGMStackRAStressTest.java:61: error: cannot find symbol
@setup
^
symbol: class Setup
location: class AGMStackRAStressTest
Note: /home/jay/IdeaProjects/linCheck/src/test/java/ch_11/Stack5Test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

[Incubating] Problems report is available at: file:///home/jay/IdeaProjects/linCheck/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':compileTestJava'.

Compilation failed; see the compiler output below.
/home/jay/IdeaProjects/linCheck/src/test/java/ch_3/AGMStackRAStressTest.java:5: error: cannot find symbol
import org.jetbrains.kotlinx.lincheck.annotations.Setup;
^
symbol: class Setup
location: package org.jetbrains.kotlinx.lincheck.annotations
4 errors

  • Try:

Check your code and dependencies to fix the compilation error(s)
Run with --scan to get full insights.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 27s
4 actionable tasks: 4 executed

getting this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions