From 20bf97b789bbbf4148694320fb244f890eb18ff5 Mon Sep 17 00:00:00 2001
From: Zentrik <Zentrik@users.noreply.github.com>
Date: Fri, 26 Apr 2024 14:17:23 +0100
Subject: [PATCH] Add execution test for perf integration

---
 test/ExecutionTests.jl | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/ExecutionTests.jl b/test/ExecutionTests.jl
index 98a7e18c..f528aa5c 100644
--- a/test/ExecutionTests.jl
+++ b/test/ExecutionTests.jl
@@ -3,6 +3,7 @@ module ExecutionTests
 using BenchmarkTools
 using Profile
 using Test
+using LinuxPerf
 
 seteq(a, b) = length(a) == length(b) == length(intersect(a, b))
 
@@ -383,4 +384,24 @@ b = x = nothing
 GC.gc()
 @test x_finalized
 
+##################################
+# Linux Perf Integration #
+##################################
+
+b = @benchmarkable sin(42.)
+results = run(b, seconds=1, enable_linux_perf=true)
+@test results.linux_perf_stats !== nothing
+@test any(reults.linux_perf_stats.threads) do thread
+    clock = LinuxPerf.scaledcount(thread["task-clock"])
+    !isnan(clock) && clock > 0
+end
+
+b = @benchmarkable sin(42.)
+results = run(b, seconds=1, enable_linux_perf=false)
+@test results.linux_perf_stats === nothing
+
+b = @benchmarkable sin(42.)
+results = run(b, seconds=1)
+@test results.linux_perf_stats === nothing
+
 end # module