forked from JuliaGPU/CUDA.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.jl
35 lines (32 loc) · 1.05 KB
/
utils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@testset "test utilities" begin
mutable struct NoThrowTestSet <: Test.AbstractTestSet
results::Vector
NoThrowTestSet(desc) = new([])
end
Test.record(ts::NoThrowTestSet, t::Test.Result) = (push!(ts.results, t); t)
Test.finish(ts::NoThrowTestSet) = ts.results
fails = @testset NoThrowTestSet begin
# OK
@test_throws_cuerror CUDA.ERROR_UNKNOWN throw(CuError(CUDA.ERROR_UNKNOWN))
# Fail, wrong CuError
@test_throws_cuerror CUDA.ERROR_UNKNOWN throw(CuError(CUDA.ERROR_INVALID_VALUE))
# Fail, wrong Exception
@test_throws_cuerror CUDA.ERROR_UNKNOWN error()
end
@test isa(fails[1], Test.Pass)
@test isa(fails[2], Test.Fail)
@test isa(fails[3], Test.Fail)
end
@testset "@sync" begin
t = Base.@elapsed ret = CUDA.@sync begin
# TODO: do something that takes a while on the GPU
# (need to wrap clock64 for that)
42
end
@test t >= 0
@test ret == 42
CUDA.@sync blocking=false begin end
end
@testset "versioninfo" begin
CUDA.versioninfo(devnull)
end