From 29cfa94dd85b4695673f860ee35256be44782b51 Mon Sep 17 00:00:00 2001 From: Denis Lochmelis Date: Sun, 7 Jul 2024 18:59:27 +0200 Subject: [PATCH] Fix 4 + fix bug in parsing jcstress results --- .github/workflows/run-litmus.yml | 2 +- cli/src/jvmMain/kotlin/org/jetbrains/litmuskt/CliJvm.kt | 6 +++++- .../main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-litmus.yml b/.github/workflows/run-litmus.yml index bb8923c..e1f5965 100644 --- a/.github/workflows/run-litmus.yml +++ b/.github/workflows/run-litmus.yml @@ -38,7 +38,7 @@ jobs: - name: Run litmus tests via CLI (x64 + release) run: ./cli/build/bin/macosX64/releaseExecutable/cli.kexe -r pthread ".*" - name: Run a single test with JCStress - run: ./gradlew :cli:jvmRun --args="-r jcstress -j '-m quick' .*" + run: ./gradlew :cli:jvmRun --args="-r jcstress -j '-m quick' StoreBuffering.Plain" - name: Assemble CLI binary (arm + release) run: ./gradlew cli:linkReleaseExecutableMacosArm64 - name: Run litmus tests via CLI (arm + release) diff --git a/cli/src/jvmMain/kotlin/org/jetbrains/litmuskt/CliJvm.kt b/cli/src/jvmMain/kotlin/org/jetbrains/litmuskt/CliJvm.kt index 3862138..1c16614 100644 --- a/cli/src/jvmMain/kotlin/org/jetbrains/litmuskt/CliJvm.kt +++ b/cli/src/jvmMain/kotlin/org/jetbrains/litmuskt/CliJvm.kt @@ -82,7 +82,11 @@ class CliJvm : CliCommon() { val results = jcsRunner.runTests(tests, jcsParams) echo() - (tests zip results).forEach { (test, result) -> + if (results.isEmpty()) { + echo("no tests were run, perhaps they are missing jcstress wrappers?", err = true) + return + } + results.forEach { (test, result) -> echo("results for ${test.alias}:") echo(result.generateTable() + "\n") } diff --git a/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt b/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt index 1c286b2..4395c7b 100644 --- a/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt +++ b/jcstress-wrapper/src/main/kotlin/org/jetbrains/litmuskt/JCStressRunner.kt @@ -41,7 +41,7 @@ class JCStressRunner( internal fun startTests( tests: List>, params: LitmusRunParams - ): () -> List { + ): () -> Map, LitmusResult> { val mvn = ProcessBuilder("mvn", "install", "verify", "-U") .directory(jcstressDirectory.toFile()) .redirectOutput(ProcessBuilder.Redirect.INHERIT) @@ -71,13 +71,13 @@ class JCStressRunner( return handle@{ jcs.waitFor() if (jcs.exitValue() != 0) error("jcstress exited with code ${jcs.exitValue()}") - return@handle tests.map { test -> parseJCStressResults(test) } + return@handle tests.associateWith { test -> parseJCStressResults(test) } } } override fun startTest(test: LitmusTest, params: LitmusRunParams): () -> LitmusResult { val handle = startTests(listOf(test), params) - return { handle().first() } + return { handle()[test] ?: error("test $test did not produce a result; perhaps its wrapper is missing?") } } /** @@ -142,7 +142,7 @@ class JCStressRunner( fun JCStressRunner.runTests( tests: List>, params: LitmusRunParams, -): List = startTests(tests, params).invoke() +): Map, LitmusResult> = startTests(tests, params).invoke() /** * Split a sequence into two: one with the first [size] elements and one with the rest.