#!/bin/sh

# Check -bexecve behavior.

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

run_strace_redir()
{
	args="$*"
	$STRACE "$@" 2> "$LOG"
}

run_strace_redir -enone sh -c 'exec false'
[ $? -eq 1 ] ||
	dump_log_and_fail_with "$STRACE $args: unexpected exit status"

run_strace_redir -bexecve -enone sh -c 'exec false' ||
	dump_log_and_fail_with "$STRACE $args: unexpected exit status"

pattern='Process [1-9][0-9]* detached'

LC_ALL=C grep -x "$pattern" "$LOG" > /dev/null ||
	dump_log_and_fail_with "$STRACE $args: output mismatch"

if LC_ALL=C grep -v -x "$pattern" "$LOG" > /dev/null; then
	dump_log_and_fail_with "$STRACE $args: unexpected output"
fi

exit 0