/
githubmirror
/
strace
Обзор
Документация
Войти
/
githubmirror
/
strace
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tests/strace-DD.test
87 строк
2 KB
Dmitry V. Levin
Update copyright headers
15 июн 2026, 11:00
15 июн 2026, 11:00
726d2e4
Код
Авторство
О чём код?
#!/bin/sh -efu # # Check -DD option. # # Copyright (c) 2019-2026 Dmitry V. Levin <ldv@strace.io> # All rights reserved. # # SPDX-License-Identifier: GPL-2.0-or-later . "${srcdir=.}/init.sh" [ "$STRACE" = "$STRACE_EXE" ] || skip_ 'Not applicable: $STRACE != $STRACE_EXE' run_prog_skip_if_failed \ kill -0 $$ status_file=/proc/self/status get_tracer_pid() { get_prefix_value 'TracerPid:[[:space:]]*' } [ "$(get_tracer_pid < "$status_file")" -ge 0 ] || framework_skip_ "$status_file is not available" run_prog ../sleep 0 sleep_duration="$((TIMEOUT_DURATION/2))" test_D() { local tracee_pid tracer_pid rc sig=15 set -- $STRACE --output="$LOG" --columns=39 \ --interruptible=anywhere --trace=nanosleep "$@" -- \ ../sleep "$sleep_duration" > "$LOG" ../setpgrp-exec "$@" & tracee_pid=$! # Wait for the tracer to start tracing. while tracer_pid="$(get_tracer_pid < "/proc/$tracee_pid/status")"; do [ "$tracer_pid" = 0 ] || break $SLEEP_A_BIT done # Wait for the tracer to log something before terminating the tracee. if [ "$tracer_pid" != 0 ]; then while [ ! -s "$LOG" ]; do kill -0 "$tracer_pid" 2> /dev/null || break $SLEEP_A_BIT done fi # Terminate the tracee. $SLEEP_A_BIT kill -$sig -$tracee_pid # Wait for the tracee to complete. wait $tracee_pid && rc=0 || rc=$? [ "$rc" -eq $((128 + sig)) ] || dump_log_and_fail_with \ "$* failed with unexpected exit status $rc" # Wait for the tracer to complete. while kill -0 "$tracer_pid" 2> /dev/null; do $SLEEP_A_BIT done match_diff "$LOG" "$EXP" } printf 'nanosleep({tv_sec=%s, tv_nsec=0}' "$sleep_duration" > "$EXP" test_D -D uid="${UID:-`id -u`}" cat > "$EXP" <<__EOF__ nanosleep({tv_sec=$sleep_duration, tv_nsec=0}, NULL) = ? ERESTART_RESTARTBLOCK (Interrupted by signal) --- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=$$, si_uid=$uid} --- +++ killed by SIGTERM +++ __EOF__ test_D -DD test_D -DDD