strace/tests/qual_inject-retval.test
Dmitry V. Levin be73ca4bae Implement -e inject= option
Introduce -e inject= as a general injection option,
limit -e fault= option to syscall fault injection.

Change default return code of syscall fault injection to ENOSYS.

* qualify.c (parse_inject_token): Add fault_tokens_only argument,
do not accept retval= and signal= tokens when fault_tokens_only
is set to true.
(parse_inject_expression): Add fault_tokens_only argument,
forward it to parse_inject_token.
(qualify_inject_common): New function.
(qualify_fault): Use it.
(qualify_inject): New function.
(qual_options): New entry.
* strace.1: Describe -e inject= option.
* NEWS: Mention -e inject= option.
* tests/qual_fault-syntax.test: Test that -e fault= option does not
support retval=, signal=, and multiple error= tokens.
* tests/qual_fault.c (DEFAULT_ERRNO): Set to ENOSYS unconditionally.
* tests/qual_inject-retval.test: Replace -e fault= option
with -e inject= option.
* tests/qual_inject-syntax.test: New test.
* tests/Makefile.am (MISC_TESTS): Add it.
2017-02-08 09:28:38 +00:00

22 lines
337 B
Bash
Executable File

#!/bin/sh
# Check success injection.
. "${srcdir=.}/scno_tampering.sh"
check_injection()
{
local syscall rval
syscall=chdir
rval="$1"; shift
run_strace -a12 -e$syscall -einject="$syscall:retval=$rval" "$@" \
./qual_inject-retval "$rval" > "$EXP"
match_diff "$LOG" "$EXP"
rm -f "$EXP"
}
check_injection 0
check_injection 42