From: Dmitry V. Levin Date: Thu, 17 Nov 2016 15:44:21 +0000 (+0000) Subject: Make -e fault= expressions cumulative X-Git-Tag: v4.15~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1658e9d4c66dcb50e25089de99fff2e81daca9d0;p=strace Make -e fault= expressions cumulative Change the way how subsequent -e fault= expressions are interpreted to implement a cumulative behavior. For example, -e fault=file:when=3+ -e fault=chdir now specifies that all chdir syscalls and 3+ file related syscalls except chdir are subject for fault injection. * syscall.c (qualify): Do not reset qual_vec for QUAL_FAULT. * tests/fault_injection.test: Check it. --- diff --git a/syscall.c b/syscall.c index 3f917bdf..02a82e6a 100644 --- a/syscall.c +++ b/syscall.c @@ -739,14 +739,16 @@ qualify(const char *s) not = 1 - not; s = "all"; } - if (opt->bitflag != QUAL_FAULT && strcmp(s, "all") == 0) { - for (i = 0; i < num_quals; i++) { - qualify_one(i, opt->bitflag, not, -1, NULL); + if (opt->bitflag != QUAL_FAULT) { + if (strcmp(s, "all") == 0) { + for (i = 0; i < num_quals; ++i) { + qualify_one(i, opt->bitflag, not, -1, NULL); + } + return; + } + for (i = 0; i < num_quals; ++i) { + qualify_one(i, opt->bitflag, !not, -1, NULL); } - return; - } - for (i = 0; i < num_quals; i++) { - qualify_one(i, opt->bitflag, !not, -1, NULL); } copy = xstrdup(s); for (p = strtok(copy, ","); p; p = strtok(NULL, ",")) { diff --git a/tests/fault_injection.test b/tests/fault_injection.test index bf6006f0..004bcb0d 100755 --- a/tests/fault_injection.test +++ b/tests/fault_injection.test @@ -38,12 +38,13 @@ N=16 check_fault_injection() { - local trace fault err first step + local trace fault err first step extra trace=$1; shift fault=$1; shift err=$1; shift first=$1; shift step=$1; shift + extra="$*" local when= if [ -z "$first$step" ]; then @@ -74,7 +75,7 @@ check_fault_injection() outgot="$NAME.out.got" run_strace -a11 -e trace=$trace \ - -e fault=$fault$when$error "$@" \ + "$@" -e fault=$fault$when$error $extra \ ./$NAME $raw "$err" "$first" "$step" $N \ > "$EXP" 4> "$outexp" 5> "$outgot" @@ -86,7 +87,7 @@ check_fault_injection() for err in '' ENOSYS 22 EINVAL; do for fault in writev 51,desc; do check_fault_injection \ - writev $fault "$err" '' '' + writev $fault "$err" '' '' -efault=chdir for F in 1 2 3 5 7 11; do check_fault_injection \ writev $fault "$err" $F ''