From f62a1528a4ea0cac756c0ffad6f28f73718cfb6b Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Sat, 23 Mar 2024 14:38:18 +0100 Subject: [PATCH] Fixed integration tests --- integration/build.gradle.kts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/integration/build.gradle.kts b/integration/build.gradle.kts index dd4e668..867d4f0 100644 --- a/integration/build.gradle.kts +++ b/integration/build.gradle.kts @@ -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") @@ -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") } @@ -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"