Skip to content

Commit

Permalink
Fixed integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhinkin committed Mar 23, 2024
1 parent c79e77b commit f62a152
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions integration/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.process.internal.ExecException
import java.io.ByteArrayOutputStream
import java.lang.IllegalStateException
import java.nio.charset.StandardCharsets

plugins {
id("java")
Expand All @@ -26,6 +27,19 @@ val hasXCtrace: Boolean by lazy {
}
}

val hasPMC: Boolean by lazy {
try {
val out = ByteArrayOutputStream()
val res = exec {
commandLine("sysctl", "-n", "hw.cpufamily")
standardOutput = out
}
res.exitValue == 0 && out.toByteArray().decodeToString().lineSequence().first() != "0"
} catch (e: ExecException) {
false
}
}

tasks {
create("runAsmProfWithDefaultArgs", JavaExec::class.java) {
onlyIf { hasXCtrace && !project.hasProperty("noPMU") }
Expand Down Expand Up @@ -89,17 +103,18 @@ tasks {
}
val kind = if (hasXCtrace) "supported" else "unsupported"
checkHasXCTraceAsmProfiler(filter(out.lineSequence()), kind)
checkHasXCTraceNormProfiler(filter(out.lineSequence()), kind)
val normKind = if (hasPMC) "supported" else "unsupported"
checkHasXCTraceNormProfiler(filter(out.lineSequence()), normKind)
}
}
create("runNormProfiler", JavaExec::class.java) {
onlyIf { hasXCtrace }
onlyIf { hasPMC }
dependsOn.add("jmhJar")
classpath += jmhJar.get().outputs.files
mainClass = "io.github.fzhinkin.XCTraceNormProfilerTest"
}
create("listPmuEvents", JavaExec::class.java) {
onlyIf { hasXCtrace }
onlyIf { hasPMC }
dependsOn.add("jmhJar")
classpath += jmhJar.get().outputs.files
mainClass = "io.github.fzhinkin.XCTraceNormProfilerListEventsTest"
Expand Down

0 comments on commit f62a152

Please sign in to comment.