Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate stress tests out and run them on node 1 #28270

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function choosetests(choices = [])
"euler", "show",
"errorshow", "sets", "goto", "llvmcall", "llvmcall2", "grisu",
"some", "meta", "stacktraces", "docs",
"misc", "threads",
"misc", "threads", "stress",
"enums", "cmdlineargs", "int",
"checked", "bitset", "floatfuncs", "precompile", "inline",
"boundscheck", "error", "ambiguous", "cartesian", "osutils",
Expand Down
12 changes: 0 additions & 12 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2436,18 +2436,6 @@ let x = [1,2,3]
@test (ccall(:jl_new_bits, Any, (Any,Ptr{Cvoid},), Tuple{Int16,Tuple{Cvoid},Int8,Tuple{},Int,Cvoid,Int}, x)::Tuple)[[2,4,5,6,7]] === ((nothing,),(),2,nothing,3)
end

# sig 2 is SIGINT per the POSIX.1-1990 standard
if !Sys.iswindows()
ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 0)
@test_throws InterruptException begin
ccall(:kill, Cvoid, (Cint, Cint,), getpid(), 2)
for i in 1:10
Libc.systemsleep(0.1)
ccall(:jl_gc_safepoint, Cvoid, ()) # wait for SIGINT to arrive
end
end
ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 1)
end
let
# Exception frame automatically restores sigatomic counter.
Base.sigatomic_begin()
Expand Down
67 changes: 0 additions & 67 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1029,71 +1029,4 @@ let n = tempname()
rm(n)
end

# issue 13559
if !Sys.iswindows()
function test_13559()
fn = tempname()
run(`mkfifo $fn`)
# use subprocess to write 127 bytes to FIFO
writer_cmds = """
using Test
x = open($(repr(fn)), "w")
for i in 1:120
write(x, 0xaa)
end
flush(x)
Test.@test read(stdin, Int8) == 31
for i in 1:7
write(x, 0xaa)
end
close(x)
"""
p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=stderr), "w")
# quickly read FIFO, draining it and blocking but not failing with EOFError yet
r = open(fn, "r")
# 15 proper reads
for i in 1:15
@test read(r, UInt64) === 0xaaaaaaaaaaaaaaaa
end
write(p, 0x1f)
# last read should throw EOFError when FIFO closes, since there are only 7 bytes (or less) available.
@test_throws EOFError read(r, UInt64)
close(r)
@test success(p)
rm(fn)
end
test_13559()
end
@test_throws ArgumentError mkpath("fakepath", mode = -1)

# issue #22566
# issue #24037 (disabling on FreeBSD)
if !Sys.iswindows() && !(Sys.isbsd() && !Sys.isapple())
function test_22566()
fn = tempname()
run(`mkfifo $fn`)

script = """
using Test
x = open($(repr(fn)), "w")
write(x, 0x42)
flush(x)
Test.@test read(stdin, Int8) == 21
close(x)
"""
cmd = `$(Base.julia_cmd()) --startup-file=no -e $script`
p = open(pipeline(cmd, stderr=stderr), "w")

r = open(fn, "r")
@test read(r, Int8) == 66
write(p, 0x15)
close(r)
@test success(p)
rm(fn)
end

# repeat opening/closing fifo file, ensure no EINTR popped out
for i ∈ 1:50
test_22566()
end
end # !Sys.iswindows
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ end
# Base.compilecache only works from node 1, so precompile test is handled specially
move_to_node1("precompile")
move_to_node1("SharedArrays")
# Ensure things like consuming all kernel pipe memory doesn't interfere with other tests
move_to_node1("stress")

# In a constrained memory environment, run the "distributed" test after all other tests
# since it starts a lot of workers and can easily exceed the maximum memory
Expand Down
25 changes: 0 additions & 25 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,31 +451,6 @@ end
@test_throws ArgumentError reduce(&, Base.Cmd[])
@test reduce(&, [`$echocmd abc`, `$echocmd def`, `$echocmd hij`]) == `$echocmd abc` & `$echocmd def` & `$echocmd hij`

# test for proper handling of FD exhaustion
if Sys.isunix()
let ps = Pipe[]
ulimit_n = tryparse(Int, readchomp(`sh -c 'ulimit -n'`))
try
for i = 1 : 100 * something(ulimit_n, 1000)
p = Pipe()
Base.link_pipe!(p)
push!(ps, p)
end
if ulimit_n === nothing
@warn "`ulimit -n` is set to unlimited, fd exhaustion cannot be tested"
@test_broken false
else
@test false
end
catch ex
isa(ex, Base.UVError) || rethrow(ex)
@test ex.code in (Base.UV_EMFILE, Base.UV_ENFILE)
finally
foreach(close, ps)
end
end
end

# readlines(::Cmd), accidentally broken in #20203
@test sort(readlines(`$lscmd -A`)) == sort(readdir())

Expand Down
107 changes: 107 additions & 0 deletions test/stress.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# test for proper handling of FD exhaustion
if Sys.isunix()
let ps = Pipe[]
ulimit_n = tryparse(Int, readchomp(`sh -c 'ulimit -n'`))
try
for i = 1:100*something(ulimit_n, 1000)
p = Pipe()
Base.link_pipe!(p)
push!(ps, p)
end
if ulimit_n === nothing
@warn "`ulimit -n` is set to unlimited, fd exhaustion cannot be tested"
@test_broken false
else
@test false
end
catch ex
isa(ex, Base.UVError) || rethrow(ex)
@test ex.code in (Base.UV_EMFILE, Base.UV_ENFILE)
finally
foreach(close, ps)
end
end
end

# issue 13559
if !Sys.iswindows()
function test_13559()
fn = tempname()
run(`mkfifo $fn`)
# use subprocess to write 127 bytes to FIFO
writer_cmds = """
using Test
x = open($(repr(fn)), "w")
for i in 1:120
write(x, 0xaa)
end
flush(x)
Test.@test read(stdin, Int8) == 31
for i in 1:7
write(x, 0xaa)
end
close(x)
"""
p = open(pipeline(`$(Base.julia_cmd()) --startup-file=no -e $writer_cmds`, stderr=stderr), "w")
# quickly read FIFO, draining it and blocking but not failing with EOFError yet
r = open(fn, "r")
# 15 proper reads
for i in 1:15
@test read(r, UInt64) === 0xaaaaaaaaaaaaaaaa
end
write(p, 0x1f)
# last read should throw EOFError when FIFO closes, since there are only 7 bytes (or less) available.
@test_throws EOFError read(r, UInt64)
close(r)
@test success(p)
rm(fn)
end
test_13559()
end

# issue #22566
# issue #24037 (disabling on FreeBSD)
if !Sys.iswindows() && !(Sys.isbsd() && !Sys.isapple())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to enable it on FreeBSD?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, is it? 😄 If you reenable locally it can you reproducing the freezing it was causing before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you reenable locally it can you reproducing the freezing it was causing before?

I reenabled it.... seems fine now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks for checking, I'll reenable it here.

function test_22566()
fn = tempname()
run(`mkfifo $fn`)

script = """
using Test
x = open($(repr(fn)), "w")
write(x, 0x42)
flush(x)
Test.@test read(stdin, Int8) == 21
close(x)
"""
cmd = `$(Base.julia_cmd()) --startup-file=no -e $script`
p = open(pipeline(cmd, stderr=stderr), "w")

r = open(fn, "r")
@test read(r, Int8) == 66
write(p, 0x15)
close(r)
@test success(p)
rm(fn)
end

# repeat opening/closing fifo file, ensure no EINTR popped out
for i = 1:50
test_22566()
end
end # !Sys.iswindows

# sig 2 is SIGINT per the POSIX.1-1990 standard
if !Sys.iswindows()
ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 0)
@test_throws InterruptException begin
ccall(:kill, Cvoid, (Cint, Cint,), getpid(), 2)
for i in 1:10
Libc.systemsleep(0.1)
ccall(:jl_gc_safepoint, Cvoid, ()) # wait for SIGINT to arrive
end
end
ccall(:jl_exit_on_sigint, Cvoid, (Cint,), 1)
end