Skip to content

Commit ae703be

Browse files
authored
add pid to test logs under rr (#39577)
Should make starting replay much easier
1 parent 1ef49c8 commit ae703be

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

test/runtests.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ include("testenv.jl")
1313
tests, net_on, exit_on_error, use_revise, seed = choosetests(ARGS)
1414
tests = unique(tests)
1515

16+
if Sys.islinux()
17+
const SYS_rrcall_check_presence = 1008
18+
global running_under_rr() = 0 == ccall(:syscall, Int,
19+
(Int, Int, Int, Int, Int, Int, Int),
20+
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)
21+
else
22+
global running_under_rr() = false
23+
end
24+
1625
if use_revise
1726
using Revise
1827
union!(Revise.stdlib_names, Symbol.(STDLIBS))
@@ -137,17 +146,22 @@ cd(@__DIR__) do
137146
finally
138147
unlock(print_lock)
139148
end
149+
nothing
140150
end
141151

142152
global print_testworker_started = (name, wrkr)->begin
153+
pid = running_under_rr() ? remotecall_fetch(getpid, wrkr) : 0
154+
at = lpad("($wrkr)", name_align - textwidth(name) + 1, " ")
143155
lock(print_lock)
144156
try
145-
printstyled(name, color=:white)
146-
printstyled(lpad("($wrkr)", name_align - textwidth(name) + 1, " "), " |",
147-
" "^elapsed_align, "started at $(now())\n", color=:white)
157+
printstyled(name, at, " |", " "^elapsed_align,
158+
"started at $(now())",
159+
(pid > 0 ? " on pid $pid" : ""),
160+
"\n", color=:white)
148161
finally
149162
unlock(print_lock)
150163
end
164+
nothing
151165
end
152166

153167
function print_testworker_errored(name, wrkr, @nospecialize(e))

test/threads.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ let cmd = `$(Base.julia_cmd()) --depwarn=error --rr-detach --startup-file=no thr
1111
end
1212

1313
# issue #34415 - make sure external affinity settings work
14-
const SYS_rrcall_check_presence = 1008
15-
running_under_rr() = 0 == ccall(:syscall, Int,
16-
(Int, Int, Int, Int, Int, Int, Int),
17-
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)
18-
1914
if Sys.islinux()
15+
const SYS_rrcall_check_presence = 1008
16+
global running_under_rr() = 0 == ccall(:syscall, Int,
17+
(Int, Int, Int, Int, Int, Int, Int),
18+
SYS_rrcall_check_presence, 0, 0, 0, 0, 0, 0)
2019
if Sys.CPU_THREADS > 1 && Sys.which("taskset") !== nothing && !running_under_rr()
2120
run_with_affinity(spec) = readchomp(`taskset -c $spec $(Base.julia_cmd()) -e "run(\`taskset -p \$(getpid())\`)"`)
2221
@test endswith(run_with_affinity("1"), "2")

0 commit comments

Comments
 (0)