Skip to content

Commit

Permalink
add pid to test logs under rr (JuliaLang#39577)
Browse files Browse the repository at this point in the history
Should make starting replay much easier
  • Loading branch information
vtjnash authored and antoine-levitt committed May 9, 2021
1 parent 63d679c commit a1c0a8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
20 changes: 17 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ include("testenv.jl")
tests, net_on, exit_on_error, use_revise, seed = choosetests(ARGS)
tests = unique(tests)

if Sys.islinux()
const SYS_rrcall_check_presence = 1008
global running_under_rr() = 0 == ccall(:syscall, Int,
(Int, Int, Int, Int, Int, Int, Int),
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)
else
global running_under_rr() = false
end

if use_revise
using Revise
union!(Revise.stdlib_names, Symbol.(STDLIBS))
Expand Down Expand Up @@ -137,17 +146,22 @@ cd(@__DIR__) do
finally
unlock(print_lock)
end
nothing
end

global print_testworker_started = (name, wrkr)->begin
pid = running_under_rr() ? remotecall_fetch(getpid, wrkr) : 0
at = lpad("($wrkr)", name_align - textwidth(name) + 1, " ")
lock(print_lock)
try
printstyled(name, color=:white)
printstyled(lpad("($wrkr)", name_align - textwidth(name) + 1, " "), " |",
" "^elapsed_align, "started at $(now())\n", color=:white)
printstyled(name, at, " |", " "^elapsed_align,
"started at $(now())",
(pid > 0 ? " on pid $pid" : ""),
"\n", color=:white)
finally
unlock(print_lock)
end
nothing
end

function print_testworker_errored(name, wrkr, @nospecialize(e))
Expand Down
9 changes: 4 additions & 5 deletions test/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ let cmd = `$(Base.julia_cmd()) --depwarn=error --rr-detach --startup-file=no thr
end

# issue #34415 - make sure external affinity settings work
const SYS_rrcall_check_presence = 1008
running_under_rr() = 0 == ccall(:syscall, Int,
(Int, Int, Int, Int, Int, Int, Int),
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)

if Sys.islinux()
const SYS_rrcall_check_presence = 1008
global running_under_rr() = 0 == ccall(:syscall, Int,
(Int, Int, Int, Int, Int, Int, Int),
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)
if Sys.CPU_THREADS > 1 && Sys.which("taskset") !== nothing && !running_under_rr()
run_with_affinity(spec) = readchomp(`taskset -c $spec $(Base.julia_cmd()) -e "run(\`taskset -p \$(getpid())\`)"`)
@test endswith(run_with_affinity("1"), "2")
Expand Down

0 comments on commit a1c0a8a

Please sign in to comment.