Repository: qpid-proton Updated Branches: refs/heads/master a56b23466 -> f790480d5
NO-JIRA: [c] add inverted tests to the C test framework Setting c->inverted=true at the top of a test will make it silent if it fails, and print "UNEXPECTED PASS" if it passes. Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/069bb5ff Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/069bb5ff Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/069bb5ff Branch: refs/heads/master Commit: 069bb5ff7728aba3e7e4bb89d924b08a2ea1ad4f Parents: a56b234 Author: Alan Conway <acon...@redhat.com> Authored: Fri Aug 10 10:38:40 2018 -0400 Committer: Alan Conway <acon...@redhat.com> Committed: Fri Aug 10 10:38:40 2018 -0400 ---------------------------------------------------------------------- c/tests/connection_driver.c | 8 ++++---- c/tests/test_handler.h | 26 ++++++++++++++------------ c/tests/test_tools.h | 7 ++++++- 3 files changed, 24 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/069bb5ff/c/tests/connection_driver.c ---------------------------------------------------------------------- diff --git a/c/tests/connection_driver.c b/c/tests/connection_driver.c index 796c262..16d75a3 100644 --- a/c/tests/connection_driver.c +++ b/c/tests/connection_driver.c @@ -491,11 +491,13 @@ static void test_duplicate_link_server(test_t *t) { test_connection_drivers_destroy(&client, &server); } -/* Regression test for https://issues.apache.org/jira/browse/PROTON-1832. +/* Reproducer test for https://issues.apache.org/jira/browse/PROTON-1832. Make sure the client does not generate an illegal "attach; attach; detach" sequence from a legal "pn_link_open(); pn_link_close(); pn_link_open()" sequence */ static void test_duplicate_link_client(test_t *t) { + /* This test will fail till PROTON-1832 is fully fixed */ + t->inverted = true; /* Set up the initial link */ test_connection_driver_t client, server; test_connection_drivers_init(t, &client, open_close_handler, &server, open_close_handler); @@ -536,8 +538,6 @@ int main(int argc, char **argv) { RUN_ARGV_TEST(failed, t, test_message_abort_mixed(&t)); RUN_ARGV_TEST(failed, t, test_session_flow_control(&t)); RUN_ARGV_TEST(failed, t, test_duplicate_link_server(&t)); - fprintf(stderr, "\n==== Following tests are expected to fail ====\n"); - int ignore = 0; /* run but don't fail the build */ - RUN_ARGV_TEST(ignore, t, test_duplicate_link_client(&t)); + RUN_ARGV_TEST(failed, t, test_duplicate_link_client(&t)); return failed; } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/069bb5ff/c/tests/test_handler.h ---------------------------------------------------------------------- diff --git a/c/tests/test_handler.h b/c/tests/test_handler.h index 7ffd4d3..8799fb3 100644 --- a/c/tests/test_handler.h +++ b/c/tests/test_handler.h @@ -83,19 +83,21 @@ void test_etypes_expect_(test_t *t, pn_event_type_t *etypes, size_t size, const } if (i < size || want) { test_errorf_(t, NULL, file, line, "event mismatch"); - fprintf(stderr, "after:"); - for (size_t j = 0; j < i; ++j) { /* These events matched */ - fprintf(stderr, " %s", pn_event_type_name(etypes[j])); + if (!t->inverted) { + fprintf(stderr, "after:"); + for (size_t j = 0; j < i; ++j) { /* These events matched */ + fprintf(stderr, " %s", pn_event_type_name(etypes[j])); + } + fprintf(stderr, "\n want:"); + for (; want; want = (pn_event_type_t)va_arg(ap, int)) { + fprintf(stderr, " %s", pn_event_type_name(want)); + } + fprintf(stderr, "\n got:"); + for (; i < size; ++i) { + fprintf(stderr, " %s", pn_event_type_name(etypes[i])); + } + fprintf(stderr, "\n"); } - fprintf(stderr, "\n want:"); - for (; want; want = (pn_event_type_t)va_arg(ap, int)) { - fprintf(stderr, " %s", pn_event_type_name(want)); - } - fprintf(stderr, "\n got:"); - for (; i < size; ++i) { - fprintf(stderr, " %s", pn_event_type_name(etypes[i])); - } - fprintf(stderr, "\n"); } va_end(ap); } http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/069bb5ff/c/tests/test_tools.h ---------------------------------------------------------------------- diff --git a/c/tests/test_tools.h b/c/tests/test_tools.h index 55dba75..6910450 100644 --- a/c/tests/test_tools.h +++ b/c/tests/test_tools.h @@ -44,6 +44,7 @@ typedef struct test_t { const char* name; int errors; uintptr_t data; /* Test can store some non-error data here */ + bool inverted; /* An inverted test prints no output and reports failure if it passes */ } test_t; /* Internal, use macros. Print error message and increase the t->errors count. @@ -52,6 +53,7 @@ typedef struct test_t { void test_vlogf_(test_t *t, const char *prefix, const char* expr, const char* file, int line, const char *fmt, va_list ap) { + if (t->inverted) return; fprintf(stderr, "%s:%d", file, line); if (prefix && *prefix) fprintf(stderr, ": %s", prefix); if (expr && *expr) fprintf(stderr, ": %s", expr); @@ -186,9 +188,12 @@ bool test_str_equal_(test_t *t, const char* want, const char* got, const char *f fflush(stdout); \ test_t T = { #EXPR, 0 }; \ (EXPR); \ - if (T.errors) { \ + if (T.errors && !t.inverted) { \ fprintf(stderr, "FAIL: %s (%d errors)\n", #EXPR, T.errors); \ ++(FAILED); \ + } else if (!T.errors && t.inverted) { \ + fprintf(stderr, "UNEXPECTED PASS: %s", #EXPR); \ + ++(FAILED); \ } \ } while(0) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org