Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for the general-purpose model checker #411

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dmitrii-artuhov
Copy link
Collaborator

No description provided.

@dmitrii-artuhov dmitrii-artuhov requested a review from eupp October 7, 2024 14:04
@dmitrii-artuhov dmitrii-artuhov self-assigned this Oct 7, 2024
@dmitrii-artuhov dmitrii-artuhov marked this pull request as draft October 7, 2024 14:04
@eupp
Copy link
Collaborator

eupp commented Oct 7, 2024

@dmitrii-artuhov thanks for the PR.
Could you please repair the CI before we start reviewing this.

@dmitrii-artuhov dmitrii-artuhov changed the title [Draft] Lincheck new API function Lincheck new API function Oct 17, 2024
@ndkoval ndkoval changed the title Lincheck new API function API for the general-purpose model checker Nov 25, 2024
),
emptyList(),
null
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use CustomScenarioDSL.kt instead.


val result = strategy.runInvocation()
val failure = strategy.verify(result, verifier)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many empty lines for just a few lines of code ?)

}

return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for this function.
For start, add few tests in representation sub-module and check that the trace is correctly collected.

private class ExecutionExceptionsVerifier(@Suppress("UNUSED_PARAMETER") sequentialSpecification: Class<*>) : Verifier {
override fun verifyResults(scenario: ExecutionScenario?, results: ExecutionResult?): Boolean {
if (results == null) return true
// User `check(...)`'s will fail and put their exceptions as an execution result, we must track that and disallow such outcomes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this explanation to the kdoc of ExecutionExceptionsVerifier.

* @param invocations number of different interleavings of code in the [block]
* that should be explored.
* @param block lambda which body will be a target for the interleavings exploration.
*/
Copy link
Collaborator

@eupp eupp Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
 * This method will explore different interleavings of the [block] body and all the threads created within it, searching for the first  raised exception.
 *
 * @param invocations number of different interleavings of code in the [block] that should be explored.
 * @param block lambda which body will be a target for the interleavings exploration.
 */

@@ -48,6 +48,8 @@ abstract class CTestConfiguration(
stateRepresentationMethod: Method?
): Strategy

fun createVerifier() = verifierClass.getConstructor(Class::class.java).newInstance(sequentialSpecification)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this an extension function, as it was before.

@JvmStatic
fun <R> verifyWithModelChecker(
invocations: Int = ManagedCTestConfiguration.DEFAULT_INVOCATIONS,
verifierClass: Class<out Verifier>? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not expose the verifier in the API of this function.

import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.atomic.AtomicReferenceArray

class AtomicReferencesNamesRunWithLambdaTests : BaseRunWithLambdaRepresentationTest("atomic_references_names_trace_run_with_lambda.txt") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please shorten the names of the .txt files

* Implement me and place the logic to check its trace.
*/
@Operation
abstract fun operation()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename to block. Also, you don't need @Operation annotation for this new API.

}
failure.checkLincheckOutput(outputFileName)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put all the new tests together into singe file RunWithLambdaRepresentationTests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants