Skip to content

Commit f2b273f

Browse files
committed
Switch to ReTestItems.jl.
1 parent f3f2c5e commit f2b273f

22 files changed

+485
-458
lines changed

test/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
44
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
55
Metal_LLVM_Tools_jll = "0418c028-ff8c-56b8-a53e-0f9676ed36fc"
66
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
7+
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
78
SPIRV_LLVM_Translator_unified_jll = "85f0d8ed-5b39-5caa-b1ae-7472de402361"
89
SPIRV_Tools_jll = "6ac6d60f-d740-5983-97d7-a4482c0689f4"
910
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

test/bpf.jl renamed to test/bpf_tests.jl

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
@testset "eBPF" begin
2-
3-
include("definitions/bpf.jl")
1+
@testitem "BPF" setup=[BPF, Helpers] begin
42

53
############################################################################################
64

75
@testset "No-op" begin
86
kernel() = 0
97

10-
output = sprint(io->bpf_code_native(io, kernel, ()))
8+
output = sprint(io->BPF.code_native(io, kernel, ()))
119
@test occursin("\tr0 = 0\n\texit", output)
1210
end
1311
@testset "Return argument" begin
1412
kernel(x) = x
1513

16-
output = sprint(io->bpf_code_native(io, kernel, (UInt64,)))
14+
output = sprint(io->BPF.code_native(io, kernel, (UInt64,)))
1715
@test occursin("\tr0 = r1\n\texit", output)
1816
end
1917
@testset "Addition" begin
2018
kernel(x) = x+1
2119

22-
output = sprint(io->bpf_code_native(io, kernel, (UInt64,)))
20+
output = sprint(io->BPF.code_native(io, kernel, (UInt64,)))
2321
@test occursin("\tr0 = r1\n\tr0 += 1\n\texit", output)
2422
end
2523
@testset "Errors" begin
2624
kernel(x) = fakefunc(x)
2725

28-
@test_throws GPUCompiler.InvalidIRError bpf_code_execution(kernel, (UInt64,))
26+
@test_throws GPUCompiler.InvalidIRError BPF.code_execution(kernel, (UInt64,))
2927
end
3028
@testset "Function Pointers" begin
3129
@testset "valid" begin
3230
goodcall(x) = Base.llvmcall("%2 = call i64 inttoptr (i64 3 to i64 (i64)*)(i64 %0)\nret i64 %2", Int, Tuple{Int}, x)
3331
kernel(x) = goodcall(x)
3432

35-
output = sprint(io->bpf_code_native(io, kernel, (Int,)))
33+
output = sprint(io->BPF.code_native(io, kernel, (Int,)))
3634
@test occursin("\tcall 3\n\texit", output)
3735
end
3836
@testset "invalid" begin
3937
badcall(x) = Base.llvmcall("%2 = call i64 inttoptr (i64 3000 to i64 (i64)*)(i64 %0)\nret i64 %2", Int, Tuple{Int}, x)
4038
kernel(x) = badcall(x)
4139

42-
@test_throws GPUCompiler.InvalidIRError bpf_code_execution(kernel, (Int,))
40+
@test_throws GPUCompiler.InvalidIRError BPF.code_execution(kernel, (Int,))
4341
end
4442
end
4543

test/bpf_testsetup.jl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@testsetup module BPF
2+
3+
using GPUCompiler
4+
5+
6+
# create a native test compiler, and generate reflection methods for it
7+
8+
include("runtime.jl")
9+
struct CompilerParams <: AbstractCompilerParams end
10+
GPUCompiler.runtime_module(::CompilerJob{<:Any,CompilerParams}) = TestRuntime
11+
12+
function create_job(@nospecialize(func), @nospecialize(types);
13+
kernel::Bool=false, always_inline=false, kwargs...)
14+
source = methodinstance(typeof(func), Base.to_tuple_type(types), Base.get_world_counter())
15+
target = BPFCompilerTarget()
16+
params = CompilerParams()
17+
config = CompilerConfig(target, params; kernel, always_inline)
18+
CompilerJob(source, config), kwargs
19+
end
20+
21+
function code_llvm(io::IO, @nospecialize(func), @nospecialize(types); kwargs...)
22+
job, kwargs = create_job(func, types; kwargs...)
23+
GPUCompiler.code_llvm(io, job; kwargs...)
24+
end
25+
26+
function code_native(io::IO, @nospecialize(func), @nospecialize(types); kwargs...)
27+
job, kwargs = create_job(func, types; kwargs...)
28+
GPUCompiler.code_native(io, job; kwargs...)
29+
end
30+
31+
# simulates codegen for a kernel function: validates by default
32+
function code_execution(@nospecialize(func), @nospecialize(types); kwargs...)
33+
job, kwargs = create_job(func, types; kwargs...)
34+
JuliaContext() do ctx
35+
GPUCompiler.compile(:asm, job; kwargs...)
36+
end
37+
end
38+
39+
end

test/definitions/bpf.jl

-35
This file was deleted.

test/definitions/gcn.jl

-45
This file was deleted.

test/definitions/metal.jl

-45
This file was deleted.

test/definitions/spirv.jl

-46
This file was deleted.

test/examples.jl renamed to test/examples_tests.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "examples" begin
1+
@testitem "examples" begin
22

33
function find_sources(path::String, sources=String[])
44
if isdir(path)
@@ -11,13 +11,13 @@ function find_sources(path::String, sources=String[])
1111
sources
1212
end
1313

14-
examples_dir = joinpath(@__DIR__, "..", "examples")
15-
examples = find_sources(examples_dir)
16-
filter!(file -> readline(file) != "# EXCLUDE FROM TESTING", examples)
17-
filter!(file -> !occursin("Kaleidoscope", file), examples)
14+
dir = joinpath(@__DIR__, "..", "examples")
15+
files = find_sources(dir)
16+
filter!(file -> readline(file) != "# EXCLUDE FROM TESTING", files)
17+
filter!(file -> !occursin("Kaleidoscope", file), files)
1818

19-
cd(examples_dir) do
20-
examples = relpath.(examples, Ref(examples_dir))
19+
cd(dir) do
20+
examples = relpath.(files, Ref(dir))
2121
@testset for example in examples
2222
cmd = `$(Base.julia_cmd()) --project=$(Base.active_project())`
2323
@test success(pipeline(`$cmd $example`, stderr=stderr))

0 commit comments

Comments
 (0)