File: looping_threads.test

package info (click to toggle)
strace 6.13%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 71,488 kB
  • sloc: ansic: 176,497; sh: 9,675; makefile: 4,133; cpp: 885; awk: 353; perl: 267; exp: 62; sed: 9
file content (39 lines) | stat: -rwxr-xr-x 834 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
#
# Check tracing of looping threads.
#
# Copyright (c) 2009-2024 The strace developers.
# All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later

. "${srcdir=.}/init.sh"
. "${srcdir=.}/PTRACE_SEIZE.sh"

run_prog ../orphaned_process_group > /dev/null

run_prog_skip_if_failed date +%s > /dev/null
s0="$(date +%s)"

check_prog nproc
inc="$(nproc)"
[ "$inc" -ge 1 ] || inc=1

[ 4 -le "$TIMEOUT_DURATION" ] || TIMEOUT_DURATION=4
timeout_2="$((TIMEOUT_DURATION/2))"
timeout_4_sqr=$(sq_root "$((TIMEOUT_DURATION/4))")
nproc=1

run_prog "../$NAME" "$timeout_4_sqr" "$nproc"

while :; do
	run_strace --follow-forks -qq -enone -esignal=none "../$NAME" "$timeout_2" "$nproc"

	s1="$(date +%s)"
	[ "$((s1-s0))" -lt "$timeout_4_sqr" ] ||
		break

	nproc="$((nproc+inc))"
done

warn_ "$ME_: nproc=$nproc elapsed=$((s1-s0))"