1
+ import Pkg
2
+
3
+ Pkg. add ([" JSON" ])
4
+
1
5
using Test
6
+ using JSON
2
7
3
8
@test length (ARGS ) == 1
4
9
bindir = dirname (ARGS [1 ])
@@ -24,28 +29,31 @@ let exe_suffix = splitext(Base.julia_exename())[2]
24
29
@test lines[2 ] == " Count of same vectors: 1"
25
30
26
31
# Test that the logging of entrypoints and types works correctly
27
- str = read (joinpath (bindir, " bindinginfo_libsimple.log" ), String)
28
- @test occursin (" copyto_and_sum(fromto::CVectorPair{Float32})::Float32" , str)
29
- @test occursin (
30
- """
31
- CVector{Float32}
32
- length::Int32[0]
33
- data::Ptr{Float32}[8]
34
- 16 bytes""" , str
35
- )
36
- @test occursin (
37
- """
38
- CVectorPair{Float32}
39
- from::CVector{Float32}[0]
40
- to::CVector{Float32}[16]
41
- 32 bytes""" , str
42
- )
43
- # ensure that there is a blank line between methods and types
44
- lines = split (str, ' \n ' ; keepempty= true )
45
- nblanks = 0
46
- for line in lines
47
- nblanks += isempty (line)
48
- occursin (" length" , line) && break
49
- end
50
- @test nblanks == 1
32
+ str = read (joinpath (bindir, " bindinginfo_libsimple.json" ), String)
33
+
34
+ # The log should parse as valid JSON
35
+ abi = JSON. Parser. parse (str)
36
+
37
+ # `copyto_and_sum` should have been exported
38
+ @test any (Bool[func[" symbol" ] == " copyto_and_sum" for func in abi[" functions" ]])
39
+
40
+ # `CVector{Float32}` should have been exported with the correct info
41
+ @test any (Bool[type[" name" ] == " CVector{Float32}" for type in abi[" types" ]])
42
+ CVector_Float32 = abi[" types" ][findfirst (type[" name" ] == " CVector{Float32}" for type in abi[" types" ])]
43
+ @test length (CVector_Float32[" fields" ]) == 2
44
+ @test CVector_Float32[" fields" ][1 ][" offset" ] == 0
45
+ @test CVector_Float32[" fields" ][2 ][" offset" ] == 8
46
+ @test abi[" types" ][CVector_Float32[" fields" ][1 ][" type" ]][" name" ] == " Int32"
47
+ @test abi[" types" ][CVector_Float32[" fields" ][2 ][" type" ]][" name" ] == " Ptr{Float32}"
48
+ @test CVector_Float32[" size" ] == 16
49
+
50
+ # `CVectorPair{Float32}` should have been exported with the correct info
51
+ @test any (Bool[type[" name" ] == " CVectorPair{Float32}" for type in abi[" types" ]])
52
+ CVectorPair_Float32 = abi[" types" ][findfirst (type[" name" ] == " CVectorPair{Float32}" for type in abi[" types" ])]
53
+ @test length (CVectorPair_Float32[" fields" ]) == 2
54
+ @test CVectorPair_Float32[" fields" ][1 ][" offset" ] == 0
55
+ @test CVectorPair_Float32[" fields" ][2 ][" offset" ] == 16
56
+ @test abi[" types" ][CVectorPair_Float32[" fields" ][1 ][" type" ]][" name" ] == " CVector{Float32}"
57
+ @test abi[" types" ][CVectorPair_Float32[" fields" ][2 ][" type" ]][" name" ] == " CVector{Float32}"
58
+ @test CVectorPair_Float32[" size" ] == 32
51
59
end
0 commit comments