tdb2: consolidate testing failtest suppression routines.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 5 Dec 2011 06:33:19 +0000 (17:03 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 5 Dec 2011 06:33:19 +0000 (17:03 +1030)
Less cut & paste means less patching as failtest changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit 1819a36a3e69565bd7b853503fceb846558a45bd)

lib/tdb2/test/failtest_helper.c
lib/tdb2/test/failtest_helper.h
lib/tdb2/test/run-01-new_database.c
lib/tdb2/test/run-02-expand.c
lib/tdb2/test/run-05-readonly-open.c
lib/tdb2/test/run-10-simple-store.c
lib/tdb2/test/run-11-simple-fetch.c
lib/tdb2/test/run-12-check.c

index 1358a6c6b261d3b296a296d123c36693afe07ff1..d24ac4c42b11077693f5126293e095eb2963e4ea 100644 (file)
@@ -3,6 +3,8 @@
 #include <string.h>
 #include <ccan/tap/tap.h>
 
+bool failtest_suppress = false;
+
 /* FIXME: From ccan/str */
 static inline bool strends(const char *str, const char *postfix)
 {
@@ -84,6 +86,9 @@ block_repeat_failures(struct failtest_call *history, unsigned num)
 {
        const struct failtest_call *i, *last = &history[num-1];
 
+       if (failtest_suppress)
+               return FAIL_DONT_FAIL;
+
        if (failmatch(last, INITIAL_TDB_MALLOC)
            || failmatch(last, URANDOM_OPEN)
            || failmatch(last, URANDOM_READ)) {
index 02acac8c3cf493a0bd64316651cefb25d810f78b..7f912bb5e9146ba312f90ec904e1c9ff6641a278 100644 (file)
@@ -14,4 +14,7 @@ bool failmatch(const struct failtest_call *call,
 enum failtest_result
 block_repeat_failures(struct failtest_call *history, unsigned num);
 
+/* Set this to suppress failure. */
+extern bool failtest_suppress;
+
 #endif /* TDB2_TEST_LOGGING_H */
index 07a9703533286e0d0be88f22890e671dc578b5ec..e08e3201e657de5cae636967c4029b1e33ee6164 100644 (file)
@@ -5,17 +5,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want expand testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -30,7 +19,7 @@ int main(int argc, char *argv[])
                        TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 };
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 3);
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
index 192a3547d84604f726e24add5310cf37bdd88c49..dacf5f2194557d74291603467b46519512b08727 100644 (file)
@@ -5,17 +5,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want expand testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -28,7 +17,7 @@ int main(int argc, char *argv[])
        plan_tests(sizeof(flags) / sizeof(flags[0]) * 11 + 1);
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
 
        for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
index c4776f53b23651771175f596d1930605b11f7012..80eb56759b703b95b866424b43e3c69b830af97c 100644 (file)
@@ -5,17 +5,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want expand testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -31,7 +20,7 @@ int main(int argc, char *argv[])
        unsigned int msgs = 0;
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
 
        seed_attr.base.attr = TDB_ATTRIBUTE_SEED;
index bedb64baf09a67cac2eb117f58f248db801fdddd..b195d80ab1ddd86fc5918c36e4a798f5d024ad46 100644 (file)
@@ -5,17 +5,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want expand testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -32,7 +21,7 @@ int main(int argc, char *argv[])
        struct tdb_data data = tdb_mkdata("data", 4);
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
 
        failtest_suppress = true;
index bb06000ef7cdd4801287f82706ac30c7478041e3..8681eef22c5f412b1ee6084148c25432f5def765 100644 (file)
@@ -5,17 +5,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want fetch testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -32,7 +21,7 @@ int main(int argc, char *argv[])
        struct tdb_data data = tdb_mkdata("data", 4);
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
 
        failtest_suppress = true;
index 06abe422ab436e1198e9625ef48f8b1eb7af39f1..b55bfe7d46384e5f041d6c83f9f9c9360e7a757a 100644 (file)
@@ -6,17 +6,6 @@
 #include "logging.h"
 #include "failtest_helper.h"
 
-static bool failtest_suppress = false;
-
-/* Don't need to test everything here, just want expand testing. */
-static enum failtest_result
-suppress_failure(struct failtest_call *history, unsigned num)
-{
-       if (failtest_suppress)
-               return FAIL_DONT_FAIL;
-       return block_repeat_failures(history, num);
-}
-
 int main(int argc, char *argv[])
 {
        unsigned int i;
@@ -32,7 +21,7 @@ int main(int argc, char *argv[])
        struct tdb_data data = tdb_mkdata("data", 4);
 
        failtest_init(argc, argv);
-       failtest_hook = suppress_failure;
+       failtest_hook = block_repeat_failures;
        failtest_exit_check = exit_check_log;
 
        failtest_suppress = true;