Skip to content

Commit

Permalink
Restore cmdlineargs tests on non-Windows platforms
Browse files Browse the repository at this point in the history
These tests have been flaky for some time, but should be working better now.
  • Loading branch information
giordano committed Aug 4, 2024
1 parent f2f188d commit cc6b988
Showing 1 changed file with 29 additions and 35 deletions.
64 changes: 29 additions & 35 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,43 +339,37 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test errors_not_signals(`$exename -C invalidtarget`)
@test errors_not_signals(`$exename --cpu-target=invalidtarget`)

if Sys.iswindows()
# -t, --threads
code = "print(Threads.threadpoolsize())"
cpu_threads = ccall(:jl_effective_threads, Int32, ())
@test string(cpu_threads) ==
read(`$exename --threads auto -e $code`, String) ==
read(`$exename --threads=auto -e $code`, String) ==
read(`$exename -tauto -e $code`, String) ==
read(`$exename -t auto -e $code`, String)
for nt in (nothing, "1")
withenv("JULIA_NUM_THREADS" => nt) do
@test read(`$exename --threads=2 -e $code`, String) ==
read(`$exename -t 2 -e $code`, String) == "2"
end
end
# We want to test oversubscription, but on manycore machines, this can
# actually exhaust limited PID spaces
cpu_threads = max(2*cpu_threads, min(50, 10*cpu_threads))
if Sys.WORD_SIZE == 32
cpu_threads = min(cpu_threads, 50)
end
@test read(`$exename -t $cpu_threads -e $code`, String) == string(cpu_threads)
withenv("JULIA_NUM_THREADS" => string(cpu_threads)) do
@test read(`$exename -e $code`, String) == string(cpu_threads)
# -t, --threads
code = "print(Threads.threadpoolsize())"
cpu_threads = ccall(:jl_effective_threads, Int32, ())
@test string(cpu_threads) ==
read(`$exename --threads auto -e $code`, String) ==
read(`$exename --threads=auto -e $code`, String) ==
read(`$exename -tauto -e $code`, String) ==
read(`$exename -t auto -e $code`, String)
for nt in (nothing, "1")
withenv("JULIA_NUM_THREADS" => nt) do
@test read(`$exename --threads=2 -e $code`, String) ==
read(`$exename -t 2 -e $code`, String) == "2"
end
@test errors_not_signals(`$exename -t 0`)
@test errors_not_signals(`$exename -t -1`)
end
# We want to test oversubscription, but on manycore machines, this can
# actually exhaust limited PID spaces
cpu_threads = max(2*cpu_threads, min(50, 10*cpu_threads))
if Sys.WORD_SIZE == 32
cpu_threads = min(cpu_threads, 50)
end
@test read(`$exename -t $cpu_threads -e $code`, String) == string(cpu_threads)
withenv("JULIA_NUM_THREADS" => string(cpu_threads)) do
@test read(`$exename -e $code`, String) == string(cpu_threads)
end
@test errors_not_signals(`$exename -t 0`)
@test errors_not_signals(`$exename -t -1`)

# Combining --threads and --procs: --threads does propagate
withenv("JULIA_NUM_THREADS" => nothing) do
code = "print(sum(remotecall_fetch(Threads.threadpoolsize, x) for x in procs()))"
@test read(`$exename -p2 -t2 -e $code`, String) == "6"
end
else
@test_skip "Command line tests with -t are flakey on non-Windows OS"
# Known issue: https://github.com/JuliaLang/julia/issues/49154
# These tests should be fixed and reenabled on all operating systems.
# Combining --threads and --procs: --threads does propagate
withenv("JULIA_NUM_THREADS" => nothing) do
code = "print(sum(remotecall_fetch(Threads.threadpoolsize, x) for x in procs()))"
@test read(`$exename -p2 -t2 -e $code`, String) == "6"
end

# Combining --threads and invalid -C should yield a decent error
Expand Down

0 comments on commit cc6b988

Please sign in to comment.