diff --git a/test/ccall.jl b/test/ccall.jl index 7fa42a736e986..4cdc59b1ad999 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -2,15 +2,16 @@ import Base.copy, Base.== const verbose = false -ccall((:set_verbose, "./libccalltest"), Void, (Int32,), verbose) +const libccalltest = joinpath(dirname(@__FILE__), "libccalltest") +ccall((:set_verbose, libccalltest), Void, (Int32,), verbose) # Test for proper argument register truncation -ccall_test_func(x) = ccall((:testUcharX, "./libccalltest"), Int32, (UInt8,), x % UInt8) +ccall_test_func(x) = ccall((:testUcharX, libccalltest), Int32, (UInt8,), x % UInt8) @test ccall_test_func(3) == 1 @test ccall_test_func(259) == 1 # Test for proper round-trip of Ref{T} type -ccall_echo_func{T,U}(x, ::Type{T}, ::Type{U}) = ccall((:test_echo_p, "./libccalltest"), T, (U,), x) +ccall_echo_func{T,U}(x, ::Type{T}, ::Type{U}) = ccall((:test_echo_p, libccalltest), T, (U,), x) # Make sure object x is still valid (rooted as argument) # when loading the pointer. This works as long as we still keep the argument # rooted but might fail if we are smarter about eliminating dead root. @@ -41,38 +42,38 @@ end # Tests for passing and returning structs ci = 20+51im -b = ccall((:ctest, "./libccalltest"), Complex{Int}, (Complex{Int},), ci) +b = ccall((:ctest, libccalltest), Complex{Int}, (Complex{Int},), ci) @test b == ci + 1 - 2im ci_ary = [ci] # Make sure the array is alive during unsafe_load -b = unsafe_load(ccall((:cptest, "./libccalltest"), Ptr{Complex{Int}}, +b = unsafe_load(ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), ci_ary)) @test b == ci + 1 - 2im @test ci == 20+51im -b = ccall((:cptest_static, "./libccalltest"), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), &ci) +b = ccall((:cptest_static, libccalltest), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), &ci) @test unsafe_load(b) == ci Libc.free(convert(Ptr{Void},b)) cf64 = 2.84+5.2im -b = ccall((:cgtest, "./libccalltest"), Complex128, (Complex128,), cf64) +b = ccall((:cgtest, libccalltest), Complex128, (Complex128,), cf64) @test b == cf64 + 1 - 2im cf64_ary = [cf64] # Make sure the array is alive during unsafe_load -b = unsafe_load(ccall((:cgptest, "./libccalltest"), Ptr{Complex128}, (Ptr{Complex128},), cf64_ary)) +b = unsafe_load(ccall((:cgptest, libccalltest), Ptr{Complex128}, (Ptr{Complex128},), cf64_ary)) @test b == cf64 + 1 - 2im @test cf64 == 2.84+5.2im cf32 = 3.34f0+53.2f0im -b = ccall((:cftest, "./libccalltest"), Complex64, (Complex64,), cf32) +b = ccall((:cftest, libccalltest), Complex64, (Complex64,), cf32) @test b == cf32 + 1 - 2im cf32_ary = [cf32] # Make sure the array is alive during unsafe_load -b = unsafe_load(ccall((:cfptest, "./libccalltest"), Ptr{Complex64}, (Ptr{Complex64},), cf32_ary)) +b = unsafe_load(ccall((:cfptest, libccalltest), Ptr{Complex64}, (Ptr{Complex64},), cf32_ary)) @test b == cf32 + 1 - 2im @test cf32 == 3.34f0+53.2f0im # Tests for native Julia data types -@test_throws MethodError ccall((:cptest, "./libccalltest"), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), cf32) -@test_throws ErrorException ccall((:cptest, "./libccalltest"), Ptr{Complex{Int}}, (Complex{Int},), &cf32) #compile-time error +@test_throws MethodError ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Ptr{Complex{Int}},), cf32) +@test_throws ErrorException ccall((:cptest, libccalltest), Ptr{Complex{Int}}, (Complex{Int},), &cf32) #compile-time error # Tests for various sized data types (ByVal) type Struct1 @@ -83,7 +84,7 @@ end copy(a::Struct1) = Struct1(a.x, a.y) s1 = Struct1(352.39422f23, 19.287577) a = copy(s1) -b = ccall((:test_1, "./libccalltest"), Struct1, (Struct1,), a) +b = ccall((:test_1, libccalltest), Struct1, (Struct1,), a) @test a.x == s1.x && a.y == s1.y @test !(a === b) @test b.x == s1.x + 1 && b.y == s1.y - 2 @@ -95,21 +96,21 @@ function foos1(s::Struct1) end ci32 = Complex{Int32}(Int32(10),Int32(31)) -ba = ccall((:test_2a, "./libccalltest"), Complex{Int32}, (Complex{Int32},), ci32) -bb = ccall((:test_2b, "./libccalltest"), Complex{Int32}, (Complex{Int32},), ci32) +ba = ccall((:test_2a, libccalltest), Complex{Int32}, (Complex{Int32},), ci32) +bb = ccall((:test_2b, libccalltest), Complex{Int32}, (Complex{Int32},), ci32) @test ba == bb == ci32 + 1 - 2im @test ci32 == Complex{Int32}(Int32(10),Int32(31)) ci64 = Complex{Int64}(Int64(20),Int64(51)) -ba = ccall((:test_3a, "./libccalltest"), Complex{Int64}, (Complex{Int64},), ci64) -bb = ccall((:test_3b, "./libccalltest"), Complex{Int64}, (Complex{Int64},), ci64) -bc = ccall((:test_128, "./libccalltest"), Complex{Int64}, (Complex{Int64},), ci64) +ba = ccall((:test_3a, libccalltest), Complex{Int64}, (Complex{Int64},), ci64) +bb = ccall((:test_3b, libccalltest), Complex{Int64}, (Complex{Int64},), ci64) +bc = ccall((:test_128, libccalltest), Complex{Int64}, (Complex{Int64},), ci64) @test ba == bb == ci64 + 1 - 2im @test bc == ci64 + 1 @test ci64 == Complex{Int64}(Int64(20),Int64(51)) i128 = Int128(0x7f00123456789abc)<<64 + typemax(UInt64) -b = ccall((:test_128, "./libccalltest"), Int128, (Int128,), i128) +b = ccall((:test_128, libccalltest), Int128, (Int128,), i128) @test b == i128 + 1 @test i128 == Int128(0x7f00123456789abc)<<64 + typemax(UInt64) @@ -123,7 +124,7 @@ copy(a::Struct_Big) = Struct_Big(a.x, a.y, a.z) sbig = Struct_Big(424,-5,Int8('Z')) a = copy(sbig) -b = ccall((:test_big, "./libccalltest"), Struct_Big, (Struct_Big,), a) +b = ccall((:test_big, libccalltest), Struct_Big, (Struct_Big,), a) @test a.x == sbig.x && a.y == sbig.y && a.z == sbig.z @test b.x == sbig.x + 1 @test b.y == sbig.y - 2 diff --git a/test/libdl.jl b/test/libdl.jl index bc06724c9c35a..5a1cdfb761b06 100644 --- a/test/libdl.jl +++ b/test/libdl.jl @@ -20,6 +20,8 @@ end @test_throws ArgumentError Libdl.dlsym(C_NULL, :foo) @test_throws ArgumentError Libdl.dlsym_e(C_NULL, :foo) +cd(dirname(@__FILE__)) do + # @test !isempty(Libdl.find_library(["libccalltest"], [dirname(@__FILE__)])) # dlopen should be able to handle absolute and relative paths, with and without dlext @@ -162,3 +164,5 @@ let dl = C_NULL Libdl.dlclose(dl) end end + +end diff --git a/test/lineedit.jl b/test/lineedit.jl index bbb79530cc6a0..212c849c610bf 100644 --- a/test/lineedit.jl +++ b/test/lineedit.jl @@ -1,6 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license using Base.LineEdit +isdefined(:TestHelpers) || include(joinpath(dirname(@__FILE__), "TestHelpers.jl")) using TestHelpers a_foo = 0 diff --git a/test/repl.jl b/test/repl.jl index 85f85f7547023..8b961693889cd 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -1,6 +1,7 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license # REPL tests +isdefined(:TestHelpers) || include(joinpath(dirname(@__FILE__), "TestHelpers.jl")) using TestHelpers import Base: REPL, LineEdit