diff --git a/.gitignore b/.gitignore index c3483a0..5eaa214 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ temp/ *.hprof gitignored/ +local.properties diff --git a/cli/build.gradle.kts b/cli/build.gradle.kts new file mode 100644 index 0000000..5cef217 --- /dev/null +++ b/cli/build.gradle.kts @@ -0,0 +1,51 @@ +plugins { + kotlin("multiplatform") +} + +kotlin { + val nativeTargets = listOf( + linuxX64(), +// linuxArm64(), // 1) no machine currently available 2) CLI library does not support + macosX64(), + macosArm64(), + ) + nativeTargets.forEach { target -> + target.binaries { + executable { + entryPoint = "main" + } + } + } + jvm { + withJava() + } + + sourceSets { + commonMain { + dependencies { + implementation(project(":core")) + implementation("com.github.ajalt.clikt:clikt:4.2.1") + } + } + jvmMain { + dependencies { + implementation(project(":jcstress-wrapper")) + } + } + } +} + +val jcsDir: File get() = File(System.getenv("JCS_DIR") ?: error("JCS_DIR envvar is not set")) + +//tasks.named("jvmRun") { +// dependsOn(":core:copyLibToJCStress") +// dependsOn(":jcstress-wrapper:copyLibToJCStress") +//} + +// code above does not sync +tasks.whenTaskAdded { + if (name == "jvmRun") { + dependsOn(":core:copyLibToJCStress") + dependsOn(":jcstress-wrapper:run") + } +} diff --git a/litmus/src/commonMain/kotlin/komem/litmus/CliCommon.kt b/cli/src/commonMain/kotlin/komem/litmus/CliCommon.kt similarity index 97% rename from litmus/src/commonMain/kotlin/komem/litmus/CliCommon.kt rename to cli/src/commonMain/kotlin/komem/litmus/CliCommon.kt index 7a37b98..0ec8b15 100644 --- a/litmus/src/commonMain/kotlin/komem/litmus/CliCommon.kt +++ b/cli/src/commonMain/kotlin/komem/litmus/CliCommon.kt @@ -12,7 +12,8 @@ import komem.litmus.generated.LitmusTestRegistry import kotlin.time.Duration abstract class CliCommon : CliktCommand( - name = "litmuskt" + name = "litmuskt", + printHelpOnEmptyArgs = true, ) { companion object { const val DEFAULT_BATCH_SIZE = 1_000_000 @@ -56,6 +57,8 @@ abstract class CliCommon : CliktCommand( protected abstract val barrierProducer: BarrierProducer // TODO: we don't talk about memshuffler for now + // TODO: dry run = simply list tests + override fun run() { echo("selected tests: \n" + tests.joinToString("\n") { " - " + LitmusTestRegistry.resolveName(it) }) echo("in total: ${tests.size} tests") diff --git a/litmus/src/jvmMain/kotlin/JvmMain.kt b/cli/src/jvmMain/kotlin/JvmMain.kt similarity index 100% rename from litmus/src/jvmMain/kotlin/JvmMain.kt rename to cli/src/jvmMain/kotlin/JvmMain.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/CliJvm.kt b/cli/src/jvmMain/kotlin/komem/litmus/CliJvm.kt similarity index 80% rename from litmus/src/jvmMain/kotlin/komem/litmus/CliJvm.kt rename to cli/src/jvmMain/kotlin/komem/litmus/CliJvm.kt index 961535c..68a6346 100644 --- a/litmus/src/jvmMain/kotlin/komem/litmus/CliJvm.kt +++ b/cli/src/jvmMain/kotlin/komem/litmus/CliJvm.kt @@ -1,10 +1,8 @@ package komem.litmus -import com.github.ajalt.clikt.parameters.options.flag -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required +import com.github.ajalt.clikt.parameters.options.* import com.github.ajalt.clikt.parameters.types.choice -import com.github.ajalt.clikt.parameters.types.path +import jcstressDirectory import komem.litmus.barriers.JvmSpinBarrier import komem.litmus.jcstress.JCStressRunner @@ -15,15 +13,17 @@ class CliJvm : CliCommon() { override val barrierProducer = ::JvmSpinBarrier override val affinityMapSchedule = listOf(null) - private val jcstressDirectory by option("-j", "--jcsdir") - .path(canBeFile = false) private val allowJCStressReruns by option("--allow-jcs-reruns") .flag() - // TODO: freeJCStressArgs + private val jcstressFreeArgs by option("-j", "--jcsargs") + .convert { it.split(" ") } + .default(emptyList()) override fun run() = if (runner == JCStressRunner) jcstressRun() else super.run() private fun jcstressRun() { + println("haha: $jcstressFreeArgs") + val paramsList = variateRunParams( batchSizeSchedule = batchSizeSchedule, affinityMapSchedule = affinityMapSchedule, @@ -54,7 +54,12 @@ class CliJvm : CliCommon() { params.batchSize == DEFAULT_BATCH_SIZE && params.syncPeriod == DEFAULT_SYNC_EVERY ) null else params // jcstress defaults are different - JCStressRunner.runJCStress(nonDefaultParams, tests, jcstressDirectory) + JCStressRunner.runJCStress( + nonDefaultParams, + tests, + jcstressDirectory, + jcstressFreeArgs, + ) } } } diff --git a/litmus/src/nativeMain/kotlin/NativeMain.kt b/cli/src/nativeMain/kotlin/NativeMain.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/NativeMain.kt rename to cli/src/nativeMain/kotlin/NativeMain.kt diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/CliNative.kt b/cli/src/nativeMain/kotlin/komem/litmus/CliNative.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/CliNative.kt rename to cli/src/nativeMain/kotlin/komem/litmus/CliNative.kt diff --git a/litmus/build.gradle.kts b/core/build.gradle.kts similarity index 81% rename from litmus/build.gradle.kts rename to core/build.gradle.kts index 486246b..5d9f432 100644 --- a/litmus/build.gradle.kts +++ b/core/build.gradle.kts @@ -18,7 +18,7 @@ kotlin { ) jvm { - withSourcesJar() + withJava() jvmToolchain(8) } @@ -56,7 +56,6 @@ kotlin { commonMain { dependencies { implementation("org.jetbrains.kotlinx:atomicfu:0.20.2") - implementation("com.github.ajalt.clikt:clikt:4.2.1") } kotlin.srcDir(layout.buildDirectory.dir("generated/ksp/metadata/commonMain/kotlin/")) // ksp } @@ -82,22 +81,6 @@ kotlin { } } -//val setupCinterop by tasks.register("setupCinterop") { -// group = "interop" -// doFirst { -// val interopFolder = project.projectDir.resolve("src/nativeInterop") -// if (!interopFolder.resolve("kaffinity.def").exists()) { -// exec { -// executable = interopFolder.resolve("setup.sh").absolutePath -// args = listOf(interopFolder.absolutePath) -// } -// } -// } -//} -// -//tasks.matching { it.name.contains("cinterop") && it.name.contains("Linux") } -// .forEach { it.dependsOn(setupCinterop) } - val bitcodeInternal by tasks.register("bitcodeInternal") { val tempDir = projectDir.resolve("temp/bitcode") doLast { @@ -135,8 +118,11 @@ tasks.whenTaskAdded { } } +val jcsDir: File get() = File(System.getenv("JCS_DIR") ?: error("JCS_DIR envvar is not set")) + tasks.register("copyLibToJCStress") { dependsOn("jvmJar") - from(layout.buildDirectory.file("libs/litmus-jvm-$version.jar")) - into(projectDir.resolve("../jcstress/libs/")) + from(layout.buildDirectory.file("libs/core-jvm-$version.jar")) + rename { "litmusktJvm-1.0.jar" } + into(jcsDir.resolve("libs/komem/litmus/litmusktJvm/1.0/")) } diff --git a/litmus/src/commonMain/kotlin/komem/litmus/AffinityMap.kt b/core/src/commonMain/kotlin/komem/litmus/AffinityMap.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/AffinityMap.kt rename to core/src/commonMain/kotlin/komem/litmus/AffinityMap.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusAutoOutcome.kt b/core/src/commonMain/kotlin/komem/litmus/LitmusAutoOutcome.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/LitmusAutoOutcome.kt rename to core/src/commonMain/kotlin/komem/litmus/LitmusAutoOutcome.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusOutcomeStats.kt b/core/src/commonMain/kotlin/komem/litmus/LitmusOutcomeStats.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/LitmusOutcomeStats.kt rename to core/src/commonMain/kotlin/komem/litmus/LitmusOutcomeStats.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusRunParams.kt b/core/src/commonMain/kotlin/komem/litmus/LitmusRunParams.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/LitmusRunParams.kt rename to core/src/commonMain/kotlin/komem/litmus/LitmusRunParams.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusRunner.kt b/core/src/commonMain/kotlin/komem/litmus/LitmusRunner.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/LitmusRunner.kt rename to core/src/commonMain/kotlin/komem/litmus/LitmusRunner.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt b/core/src/commonMain/kotlin/komem/litmus/LitmusTest.kt similarity index 90% rename from litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt rename to core/src/commonMain/kotlin/komem/litmus/LitmusTest.kt index 7f8bad3..866160e 100644 --- a/litmus/src/commonMain/kotlin/komem/litmus/LitmusTest.kt +++ b/core/src/commonMain/kotlin/komem/litmus/LitmusTest.kt @@ -1,5 +1,7 @@ package komem.litmus +import komem.litmus.generated.LitmusTestRegistry + data class LitmusTest( val stateProducer: () -> S, val threadFunctions: List Unit>, @@ -47,3 +49,6 @@ class LitmusTestScope( fun litmusTest(stateProducer: () -> S, setup: LitmusTestScope.() -> Unit) = LitmusTestScope(stateProducer).apply(setup).build() + +val LitmusTest<*>.name get() = LitmusTestRegistry.resolveName(this) +val LitmusTest<*>.javaClassName get() = name.replace('.', '_') diff --git a/litmus/src/commonMain/kotlin/komem/litmus/Utils.kt b/core/src/commonMain/kotlin/komem/litmus/Utils.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/Utils.kt rename to core/src/commonMain/kotlin/komem/litmus/Utils.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/barriers/Barrier.kt b/core/src/commonMain/kotlin/komem/litmus/barriers/Barrier.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/barriers/Barrier.kt rename to core/src/commonMain/kotlin/komem/litmus/barriers/Barrier.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/testsuite/ClassicTests.kt b/core/src/commonMain/kotlin/komem/litmus/testsuite/ClassicTests.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/testsuite/ClassicTests.kt rename to core/src/commonMain/kotlin/komem/litmus/testsuite/ClassicTests.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/testsuite/CustomTests.kt b/core/src/commonMain/kotlin/komem/litmus/testsuite/CustomTests.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/testsuite/CustomTests.kt rename to core/src/commonMain/kotlin/komem/litmus/testsuite/CustomTests.kt diff --git a/litmus/src/commonMain/kotlin/komem/litmus/testsuite/UPUBExtraTests.kt b/core/src/commonMain/kotlin/komem/litmus/testsuite/UPUBExtraTests.kt similarity index 100% rename from litmus/src/commonMain/kotlin/komem/litmus/testsuite/UPUBExtraTests.kt rename to core/src/commonMain/kotlin/komem/litmus/testsuite/UPUBExtraTests.kt diff --git a/litmus/src/commonTest/kotlin/komem.litmus/LitmusOutcomeTest.kt b/core/src/commonTest/kotlin/komem.litmus/LitmusOutcomeTest.kt similarity index 100% rename from litmus/src/commonTest/kotlin/komem.litmus/LitmusOutcomeTest.kt rename to core/src/commonTest/kotlin/komem.litmus/LitmusOutcomeTest.kt diff --git a/litmus/src/commonTest/kotlin/komem.litmus/infra/TestDefaults.kt b/core/src/commonTest/kotlin/komem.litmus/infra/TestDefaults.kt similarity index 100% rename from litmus/src/commonTest/kotlin/komem.litmus/infra/TestDefaults.kt rename to core/src/commonTest/kotlin/komem.litmus/infra/TestDefaults.kt diff --git a/litmus/src/commonTest/kotlin/komem.litmus/testsuite/ClassicTests.kt b/core/src/commonTest/kotlin/komem.litmus/testsuite/ClassicTests.kt similarity index 100% rename from litmus/src/commonTest/kotlin/komem.litmus/testsuite/ClassicTests.kt rename to core/src/commonTest/kotlin/komem.litmus/testsuite/ClassicTests.kt diff --git a/litmus/src/commonTest/kotlin/komem.litmus/testsuite/CustomTests.kt b/core/src/commonTest/kotlin/komem.litmus/testsuite/CustomTests.kt similarity index 100% rename from litmus/src/commonTest/kotlin/komem.litmus/testsuite/CustomTests.kt rename to core/src/commonTest/kotlin/komem.litmus/testsuite/CustomTests.kt diff --git a/litmus/src/commonTest/kotlin/komem.litmus/testsuite/UPUBExtraTests.kt b/core/src/commonTest/kotlin/komem.litmus/testsuite/UPUBExtraTests.kt similarity index 100% rename from litmus/src/commonTest/kotlin/komem.litmus/testsuite/UPUBExtraTests.kt rename to core/src/commonTest/kotlin/komem.litmus/testsuite/UPUBExtraTests.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/JvmThreadRunner.kt b/core/src/jvmMain/kotlin/komem/litmus/JvmThreadRunner.kt similarity index 100% rename from litmus/src/jvmMain/kotlin/komem/litmus/JvmThreadRunner.kt rename to core/src/jvmMain/kotlin/komem/litmus/JvmThreadRunner.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/JvmUtils.kt b/core/src/jvmMain/kotlin/komem/litmus/JvmUtils.kt similarity index 100% rename from litmus/src/jvmMain/kotlin/komem/litmus/JvmUtils.kt rename to core/src/jvmMain/kotlin/komem/litmus/JvmUtils.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/barriers/JvmCyclicBarrier.kt b/core/src/jvmMain/kotlin/komem/litmus/barriers/JvmCyclicBarrier.kt similarity index 100% rename from litmus/src/jvmMain/kotlin/komem/litmus/barriers/JvmCyclicBarrier.kt rename to core/src/jvmMain/kotlin/komem/litmus/barriers/JvmCyclicBarrier.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/barriers/JvmSpinBarrier.kt b/core/src/jvmMain/kotlin/komem/litmus/barriers/JvmSpinBarrier.kt similarity index 100% rename from litmus/src/jvmMain/kotlin/komem/litmus/barriers/JvmSpinBarrier.kt rename to core/src/jvmMain/kotlin/komem/litmus/barriers/JvmSpinBarrier.kt diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt b/core/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt similarity index 76% rename from litmus/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt rename to core/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt index ba28f8c..50e329f 100644 --- a/litmus/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt +++ b/core/src/jvmMain/kotlin/komem/litmus/jcstress/JCStressRunner.kt @@ -1,11 +1,7 @@ package komem.litmus.jcstress -import komem.litmus.LitmusResult -import komem.litmus.LitmusRunParams -import komem.litmus.LitmusRunner -import komem.litmus.LitmusTest +import komem.litmus.* import java.nio.file.Path -import kotlin.io.path.Path import kotlin.system.exitProcess /** @@ -18,12 +14,11 @@ object JCStressRunner : LitmusRunner() { fun runJCStress( params: LitmusRunParams?, tests: Collection>, - jcsDirectory: Path? = null + jcstressDirectory: Path, + jcstressFreeArgs: List, ) { - val jcstressDirectory = jcsDirectory ?: Path("../jcstress") - for (test in tests) generateWrapperFile(test, jcstressDirectory) - val mvn = ProcessBuilder("mvn", "verify") + val mvn = ProcessBuilder("mvn", "install", "verify") .directory(jcstressDirectory.toFile()) .redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectError(ProcessBuilder.Redirect.INHERIT) @@ -40,7 +35,7 @@ object JCStressRunner : LitmusRunner() { "java", "-jar", "target/jcstress.jar", - *jcsParams, + *(jcsParams + jcstressFreeArgs), "-t", tests.joinToString("|") { it.javaClassName }, ) diff --git a/litmus/src/jvmTest/kotlin/komem/litmus/infra/TestDefaults.jvm.kt b/core/src/jvmTest/kotlin/komem/litmus/infra/TestDefaults.jvm.kt similarity index 100% rename from litmus/src/jvmTest/kotlin/komem/litmus/infra/TestDefaults.jvm.kt rename to core/src/jvmTest/kotlin/komem/litmus/infra/TestDefaults.jvm.kt diff --git a/litmus/src/linuxMain/kotlin/komem/litmus/AffinityBindingsImplPosix.kt b/core/src/linuxMain/kotlin/komem/litmus/AffinityBindingsImplPosix.kt similarity index 100% rename from litmus/src/linuxMain/kotlin/komem/litmus/AffinityBindingsImplPosix.kt rename to core/src/linuxMain/kotlin/komem/litmus/AffinityBindingsImplPosix.kt diff --git a/litmus/src/macosMain/kotlin/komem/litmus/AffinityBindingsImplNoop.kt b/core/src/macosMain/kotlin/komem/litmus/AffinityBindingsImplNoop.kt similarity index 100% rename from litmus/src/macosMain/kotlin/komem/litmus/AffinityBindingsImplNoop.kt rename to core/src/macosMain/kotlin/komem/litmus/AffinityBindingsImplNoop.kt diff --git a/litmus/src/nativeInterop/barrier.def b/core/src/nativeInterop/barrier.def similarity index 100% rename from litmus/src/nativeInterop/barrier.def rename to core/src/nativeInterop/barrier.def diff --git a/litmus/src/nativeInterop/barrier.h b/core/src/nativeInterop/barrier.h similarity index 100% rename from litmus/src/nativeInterop/barrier.h rename to core/src/nativeInterop/barrier.h diff --git a/litmus/src/nativeInterop/kaffinity.def b/core/src/nativeInterop/kaffinity.def similarity index 100% rename from litmus/src/nativeInterop/kaffinity.def rename to core/src/nativeInterop/kaffinity.def diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/AffinityManager.kt b/core/src/nativeMain/kotlin/komem.litmus/AffinityManager.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/AffinityManager.kt rename to core/src/nativeMain/kotlin/komem.litmus/AffinityManager.kt diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/NativeUtils.kt b/core/src/nativeMain/kotlin/komem.litmus/NativeUtils.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/NativeUtils.kt rename to core/src/nativeMain/kotlin/komem.litmus/NativeUtils.kt diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/WorkerRunner.kt b/core/src/nativeMain/kotlin/komem.litmus/WorkerRunner.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/WorkerRunner.kt rename to core/src/nativeMain/kotlin/komem.litmus/WorkerRunner.kt diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/barriers/CinteropSpinBarrier.kt b/core/src/nativeMain/kotlin/komem.litmus/barriers/CinteropSpinBarrier.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/barriers/CinteropSpinBarrier.kt rename to core/src/nativeMain/kotlin/komem.litmus/barriers/CinteropSpinBarrier.kt diff --git a/litmus/src/nativeMain/kotlin/komem.litmus/barriers/KNativeSpinBarrier.kt b/core/src/nativeMain/kotlin/komem.litmus/barriers/KNativeSpinBarrier.kt similarity index 100% rename from litmus/src/nativeMain/kotlin/komem.litmus/barriers/KNativeSpinBarrier.kt rename to core/src/nativeMain/kotlin/komem.litmus/barriers/KNativeSpinBarrier.kt diff --git a/litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt b/core/src/nativeTest/kotlin/komem/litmus/NativeTest.kt similarity index 100% rename from litmus/src/nativeTest/kotlin/komem/litmus/NativeTest.kt rename to core/src/nativeTest/kotlin/komem/litmus/NativeTest.kt diff --git a/litmus/src/nativeTest/kotlin/komem/litmus/infra/TestDefaults.native.kt b/core/src/nativeTest/kotlin/komem/litmus/infra/TestDefaults.native.kt similarity index 100% rename from litmus/src/nativeTest/kotlin/komem/litmus/infra/TestDefaults.native.kt rename to core/src/nativeTest/kotlin/komem/litmus/infra/TestDefaults.native.kt diff --git a/jcstress-wrapper/build.gradle.kts b/jcstress-wrapper/build.gradle.kts new file mode 100644 index 0000000..c4a2b00 --- /dev/null +++ b/jcstress-wrapper/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + kotlin("jvm") + application +} + +application { + mainClass = "MainKt" +} + +dependencies { + implementation(project(":core")) + implementation(kotlin("reflect")) +} diff --git a/jcstress-wrapper/src/main/kotlin/Main.kt b/jcstress-wrapper/src/main/kotlin/Main.kt new file mode 100644 index 0000000..b85dc63 --- /dev/null +++ b/jcstress-wrapper/src/main/kotlin/Main.kt @@ -0,0 +1,18 @@ +import komem.litmus.generateWrapperFile +import komem.litmus.generated.LitmusTestRegistry +import kotlin.io.path.Path + +fun main() { + var successCnt = 0 + val allTests = LitmusTestRegistry.all() + for (test in allTests) { + val success = generateWrapperFile(test, jcstressDirectory) + if (success) successCnt++ + } + if (successCnt != allTests.size) { + System.err.println("WARNING: generated wrappers for $successCnt out of ${allTests.size} known tests") + } +} + +val jcstressDirectory + get() = Path(System.getenv("JCS_DIR") ?: error("JCS_DIR envvar is not set")) diff --git a/litmus/src/jvmMain/kotlin/komem/litmus/jcstress/Codegen.kt b/jcstress-wrapper/src/main/kotlin/komem/litmus/Codegen.kt similarity index 92% rename from litmus/src/jvmMain/kotlin/komem/litmus/jcstress/Codegen.kt rename to jcstress-wrapper/src/main/kotlin/komem/litmus/Codegen.kt index aafd533..4746833 100644 --- a/litmus/src/jvmMain/kotlin/komem/litmus/jcstress/Codegen.kt +++ b/jcstress-wrapper/src/main/kotlin/komem/litmus/Codegen.kt @@ -1,9 +1,5 @@ -package komem.litmus.jcstress +package komem.litmus -import komem.litmus.LitmusAutoOutcome -import komem.litmus.LitmusOutcomeType -import komem.litmus.LitmusTest -import komem.litmus.generated.LitmusTestRegistry import java.nio.file.Path import kotlin.io.path.createParentDirectories import kotlin.io.path.div @@ -12,14 +8,17 @@ import kotlin.reflect.full.allSuperclasses import kotlin.reflect.full.isSubclassOf import kotlin.reflect.full.superclasses -val LitmusTest<*>.name get() = LitmusTestRegistry.resolveName(this) -val LitmusTest<*>.javaClassName get() = name.replace('.', '_') - -fun generateWrapperFile(test: LitmusTest<*>, jcstressDirectory: Path) { +fun generateWrapperFile(test: LitmusTest<*>, jcstressDirectory: Path): Boolean { val targetFile = jcstressDirectory / "src/main/java/komem/litmus/${test.javaClassName}.java" targetFile.createParentDirectories() - val targetCode = generateWrapperCode(test) + val targetCode = try { + generateWrapperCode(test) + } catch (e: Throwable) { + System.err.println("WARNING: could not generate wrapper for ${test.name} because: ${e.message}") + return false + } targetFile.writeText(targetCode) + return true } private fun generateWrapperCode(test: LitmusTest<*>): String { @@ -137,4 +136,6 @@ public class ${test.javaClassName} { """.trimIndent() } +// TODO: arbiter padding is broken + private fun String.padded(padding: Int) = replace("\n", "\n" + " ".repeat(padding)) diff --git a/jcstress/pom.xml b/jcstress/pom.xml index db85c2b..adbc5c0 100644 --- a/jcstress/pom.xml +++ b/jcstress/pom.xml @@ -49,21 +49,36 @@ THE POSSIBILITY OF SUCH DAMAGE. 3.2 + + + libs + libs + + true + ignore + + + false + + file://${basedir}/libs + + + org.openjdk.jcstress jcstress-core ${jcstress.version} - - komem.litmus - litmuskt - 1.0 - org.jetbrains.kotlin kotlin-stdlib - 1.9.10 + 1.9.20 + + + komem.litmus + litmusktJvm + 1.0 @@ -122,33 +137,53 @@ THE POSSIBILITY OF SUCH DAMAGE. META-INF/TestList + + + * + + - - org.apache.maven.plugins - maven-install-plugin - 3.1.1 - - komem.litmus - litmuskt - 1.0 - jar - ${basedir}/libs/litmus-jvm-1.0-SNAPSHOT.jar - true - - - - install-jar-lib - - install-file - - validate - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/litmus-jcstress/build.gradle.kts b/litmus-jcstress/build.gradle.kts deleted file mode 100644 index 02d3099..0000000 --- a/litmus-jcstress/build.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - kotlin("jvm") -} - -dependencies { - implementation(project(":litmus")) -} diff --git a/litmus-jcstress/src/main/kotlin/komem/litmus/CodegenMain.kt b/litmus-jcstress/src/main/kotlin/komem/litmus/CodegenMain.kt deleted file mode 100644 index 0cef778..0000000 --- a/litmus-jcstress/src/main/kotlin/komem/litmus/CodegenMain.kt +++ /dev/null @@ -1,5 +0,0 @@ -package komem.litmus - -fun main() { - val t = litmusTest -} diff --git a/settings.gradle.kts b/settings.gradle.kts index df4c34b..d724a9f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,6 @@ rootProject.name = "litmuskt" -include(":litmus") +include(":core") include(":codegen") -include(":litmus-jcstress") +include(":jcstress-wrapper") +include(":cli")