aboutsummaryrefslogtreecommitdiff
blob: adf3badf204918d733b5588791901f87e92a9818 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# only exported things work in test scripts

export abs_top_srcdir abs_top_builddir abs_srcdir abs_builddir
export AWK="@AWK@"
export HOST="@host@"

if ! ${at_clean} ; then
	export SB_UID=$(./get-user)
	export SB_GID=$(./get-group)
fi

export at_xfail

# portage likes to do `addpredict /` ... we dont need/want
# that garbage messing up our env
export SANDBOX_PREDICT=${SANDBOX_PREDICT%:/}

if [ "${AUTOTEST_PATH}" = "tests" ] ; then
	AUTOTEST_PATH="src:tests"
fi

export SANDBOX_VERBOSE=0

# If the terminal has this flag set, the tests get all messed up.
stty -tostop 2>/dev/null || :

# Some tests want this internal path.
for devfd in /proc/self/fd /dev/fd ; do
	[ -e "${devfd}" ] && break
done

# GNU make likes to leak fds when using jobservers (i.e. using -j).
case "${MAKEFLAGS}" in
*--jobserver-auth=*)
	flags=${MAKEFLAGS#*--jobserver-auth=}
	flags=${flags%% *}
	for fd in $(echo "${flags}" | tr ',' ' ') ; do
		if [ -e "${devfd}/${fd}" ] ; then
			eval "exec ${fd}>&-"
		fi
	done
	;;
esac

# Figure out currently YAMA ptrace_scope restriction level.
at_yama_ptrace_scope=$(cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null || echo 0)
if [ ${at_yama_ptrace_scope} -gt 0 ] ; then
	if [ "$(id -u)" -eq 0 ] ; then
		at_yama_ptrace_scope=0
	fi
fi
export at_yama_ptrace_scope

# This script must finish with ($? == 0) else the autotest runner gets upset.
: