diff --git a/base/socket.jl b/base/socket.jl index ef976be07e385..5bbb7683ccaa5 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -546,6 +546,7 @@ const _sizeof_uv_interface_address = ccall(:jl_uv_sizeof_interface_address,Int32 function getipaddr() addr = Array(Ptr{Uint8},1) count = Array(Int32,1) + lo_present = false err = ccall(:jl_uv_interface_addresses,Int32,(Ptr{Ptr{Uint8}},Ptr{Int32}),addr,count) addr, count = addr[1],count[1] if err != 0 @@ -555,6 +556,7 @@ function getipaddr() for i = 0:(count-1) current_addr = addr + i*_sizeof_uv_interface_address if 1 == ccall(:jl_uv_interface_address_is_internal,Int32,(Ptr{Uint8},),current_addr) + lo_present = true continue end sockaddr = ccall(:jl_uv_interface_address_sockaddr,Ptr{Void},(Ptr{Uint8},),current_addr) @@ -568,7 +570,7 @@ function getipaddr() end end ccall(:uv_free_interface_addresses,Void,(Ptr{Uint8},Int32),addr,count) - return ip"127.0.0.1" + lo_present ? ip"127.0.0.1" : error("No networking interface available") end ## diff --git a/test/runtests.jl b/test/runtests.jl index 8b8fa3741730f..99f2fdd216036 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,12 +23,28 @@ if "linalg" in tests prepend!(tests, ["linalg1", "linalg2", "linalg3"]) end +net_required_for = ["socket", "parallel"] +net_on = true +try + ip = getipaddr() +catch + warn_str = "Networking unavailable: Skipping tests [$(net_required_for[1])" + for x in net_required_for[2:end] + warn_str = warn_str * ", $x" + end + warn_str = warn_str * "]" + warn(warn_str) + net_on = false +end -n = min(8, CPU_CORES, length(tests)) - -n > 1 && addprocs(n) - -blas_set_num_threads(1) +n = 1 +if net_on + n = min(8, CPU_CORES, length(tests)) + n > 1 && addprocs(n) + blas_set_num_threads(1) +else + filter!(x -> !(x in net_required_for), tests) +end @everywhere include("testdefs.jl")