X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftest%2Ffailtest_helper.c;h=ab79de1978c5d80291426dfa565b7a544b8cf48b;hb=a6b5111fe6948e51114c33aa34785c9fd0d403e6;hp=f3ef09a6c3e84b33d0ca1807967505771835f17c;hpb=9571a41e8494f3135557e3ec50c2de856392173e;p=ccan diff --git a/ccan/tdb2/test/failtest_helper.c b/ccan/tdb2/test/failtest_helper.c index f3ef09a6..ab79de19 100644 --- a/ccan/tdb2/test/failtest_helper.c +++ b/ccan/tdb2/test/failtest_helper.c @@ -25,21 +25,6 @@ bool failmatch(const struct failtest_call *call, == '/'))); } -static const struct failtest_call * -find_repeat(const struct tlist_calls *history, - const struct failtest_call *call) -{ - const struct failtest_call *i; - - tlist_for_each(history, i, list) { - if (i != call) - continue; - if (failmatch(i, call->file, call->line, call->type)) - return i; - } - return NULL; -} - static bool is_nonblocking_lock(const struct failtest_call *call) { return call->type == FAILTEST_FCNTL && call->u.fcntl.cmd == F_SETLK; @@ -85,9 +70,9 @@ bool exit_check_log(struct tlist_calls *history) enum failtest_result block_repeat_failures(struct tlist_calls *history) { - const struct failtest_call *i, *last; + const struct failtest_call *last; - last = tlist_tail(history, struct failtest_call, list); + last = tlist_tail(history, list); if (failtest_suppress) return FAIL_DONT_FAIL; @@ -95,25 +80,17 @@ block_repeat_failures(struct tlist_calls *history) if (failmatch(last, INITIAL_TDB_MALLOC) || failmatch(last, URANDOM_OPEN) || failmatch(last, URANDOM_READ)) { - if (find_repeat(history, last)) - return FAIL_DONT_FAIL; return FAIL_PROBE; } - /* Unlock or non-blocking lock is fail-once. */ - if (is_unlock(last)) { - /* Find a previous unlock at this point? */ - i = find_repeat(history, last); - if (i && is_unlock(i)) - return FAIL_DONT_FAIL; + /* We handle mmap failing, by falling back to read/write, so + * don't try all possible paths. */ + if (last->type == FAILTEST_MMAP) return FAIL_PROBE; - } else if (is_nonblocking_lock(last)) { - /* Find a previous non-blocking lock at this point? */ - i = find_repeat(history, last); - if (i && is_nonblocking_lock(i)) - return FAIL_DONT_FAIL; + + /* Unlock or non-blocking lock is fail-once. */ + if (is_unlock(last) || is_nonblocking_lock(last)) return FAIL_PROBE; - } return FAIL_OK; }