From a1c0a8ae11fca718ed0752bf2e5f43561e9d3971 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 9 Feb 2021 19:43:59 -0500 Subject: [PATCH] add pid to test logs under rr (#39577) Should make starting replay much easier --- test/runtests.jl | 20 +++++++++++++++++--- test/threads.jl | 9 ++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 2f9cd058bbf18d..ad029557a33779 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)) @@ -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)) diff --git a/test/threads.jl b/test/threads.jl index 8ba90a26bee83a..736cecada3cd8c 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -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")