From b826bfc171d90f8bde7bd672c0ac14201b8b2742 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 16 Nov 2020 20:44:29 -0800 Subject: Work for test refactoring. There are a few major areas in this change. * CMake options are now located in a common cmake/NNGOptions.cmake file. This should make it easier for folks to figure out what the options are, and how they are used. * Tests are now scoped with their directory name, which should avoid possible name collisions with test names. * A number of tests have been either moved or incorporated into the newer testutil/acutest framework. We are moving away from my old c-convey framework to something easier to debug. * We use CMake directories a bit more extensively leading to a much cleaner CMake structure. It's not complete, but a big step in the right direction, and a preview of future work. * Tests are now run with verbose flags, so we get more test results in the CI/CD logs. --- src/protocol/CMakeLists.txt | 20 ++++++++++++++++++ src/protocol/bus0/CMakeLists.txt | 9 ++++---- src/protocol/bus0/bug1247_test.c | 39 +++++++++++++++++++++++++++++++++++ src/protocol/pair0/CMakeLists.txt | 5 ++--- src/protocol/pair1/CMakeLists.txt | 4 ++-- src/protocol/pipeline0/CMakeLists.txt | 6 +----- src/protocol/pubsub0/CMakeLists.txt | 6 +----- src/protocol/reqrep0/CMakeLists.txt | 6 +----- src/protocol/survey0/CMakeLists.txt | 6 +----- 9 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 src/protocol/CMakeLists.txt create mode 100644 src/protocol/bus0/bug1247_test.c (limited to 'src/protocol') diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt new file mode 100644 index 00000000..fd480523 --- /dev/null +++ b/src/protocol/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright 2020 Staysail Systems, Inc. +# +# This software is supplied under the terms of the MIT License, a +# copy of which should be located in the distribution where this +# file was obtained (LICENSE.txt). A copy of the license may also be +# found online at https://opensource.org/licenses/MIT. +# + +# Protocols. +nng_directory(protocol) + +add_subdirectory(bus0) +add_subdirectory(pair0) +add_subdirectory(pair1) +add_subdirectory(pipeline0) +add_subdirectory(pubsub0) +add_subdirectory(reqrep0) +add_subdirectory(survey0) + diff --git a/src/protocol/bus0/CMakeLists.txt b/src/protocol/bus0/CMakeLists.txt index 1115e2ec..01c0b05b 100644 --- a/src/protocol/bus0/CMakeLists.txt +++ b/src/protocol/bus0/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2019 Staysail Systems, Inc. +# Copyright 2020 Staysail Systems, Inc. # Copyright 2018 Capitar IT Group BV # # This software is supplied under the terms of the MIT License, a @@ -9,9 +9,10 @@ # # Bus protocol -option (NNG_PROTO_BUS0 "Enable BUSv0 protocol." ON) -mark_as_advanced(NNG_PROTO_BUS0) +nng_directory(bus0) nng_sources_if(NNG_PROTO_BUS0 bus.c) nng_headers_if(NNG_PROTO_BUS0 nng/protocol/bus0/bus.h) -nng_defines_if(NNG_PROTO_BUS0 NNG_HAVE_BUS0) \ No newline at end of file +nng_defines_if(NNG_PROTO_BUS0 NNG_HAVE_BUS0) + +nng_test(bug1247_test) \ No newline at end of file diff --git a/src/protocol/bus0/bug1247_test.c b/src/protocol/bus0/bug1247_test.c new file mode 100644 index 00000000..6f418f53 --- /dev/null +++ b/src/protocol/bus0/bug1247_test.c @@ -0,0 +1,39 @@ +// +// Copyright 2020 Staysail Systems, Inc. +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#include + +#include +#include + +#include "acutest.h" +#include "testutil.h" + +void +test_bug1247(void) +{ + nng_socket bus1, bus2; + char addr[64]; + + testutil_scratch_addr("tcp", sizeof(addr), addr); + + TEST_NNG_PASS(nng_bus0_open(&bus1)); + TEST_NNG_PASS(nng_bus0_open(&bus2)); + + TEST_NNG_PASS(nng_listen(bus1, addr, NULL, 0)); + TEST_NNG_FAIL(nng_listen(bus2, addr, NULL, 0), NNG_EADDRINUSE); + + TEST_NNG_PASS(nng_close(bus2)); + TEST_NNG_PASS(nng_close(bus1)); +} + +TEST_LIST = { + { "bug1247", test_bug1247 }, + { NULL, NULL }, +}; diff --git a/src/protocol/pair0/CMakeLists.txt b/src/protocol/pair0/CMakeLists.txt index c3da1b07..b12583ab 100644 --- a/src/protocol/pair0/CMakeLists.txt +++ b/src/protocol/pair0/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2019 Staysail Systems, Inc. +# Copyright 2020 Staysail Systems, Inc. # Copyright 2018 Capitar IT Group BV # # This software is supplied under the terms of the MIT License, a @@ -9,8 +9,7 @@ # # PAIRv0 protocol -option (NNG_PROTO_PAIR0 "Enable PAIRv0 protocol." ON) -mark_as_advanced(NNG_PROTO_PAIR0) +nng_directory(pair0) nng_sources_if(NNG_PROTO_PAIR0 pair.c) nng_headers_if(NNG_PROTO_PAIR0 nng/protocol/pair0/pair.h) diff --git a/src/protocol/pair1/CMakeLists.txt b/src/protocol/pair1/CMakeLists.txt index f586fabe..12e12607 100644 --- a/src/protocol/pair1/CMakeLists.txt +++ b/src/protocol/pair1/CMakeLists.txt @@ -9,12 +9,12 @@ # # PAIRv1 protocol -option (NNG_PROTO_PAIR1 "Enable PAIRv1 protocol." ON) -mark_as_advanced(NNG_PROTO_PAIR1) +nng_directory(pair1) # XXX: break pair1_poly into an ifdef. nng_sources_if(NNG_PROTO_PAIR1 pair.c pair1_poly.c) nng_headers_if(NNG_PROTO_PAIR1 nng/protocol/pair1/pair.h) nng_defines_if(NNG_PROTO_PAIR1 NNG_HAVE_PAIR1) + nng_test(pair1_test) nng_test(pair1_poly_test) \ No newline at end of file diff --git a/src/protocol/pipeline0/CMakeLists.txt b/src/protocol/pipeline0/CMakeLists.txt index 0e211cf5..4f591450 100644 --- a/src/protocol/pipeline0/CMakeLists.txt +++ b/src/protocol/pipeline0/CMakeLists.txt @@ -9,11 +9,7 @@ # # Pipeline protocol -option (NNG_PROTO_PUSH0 "Enable PUSHv0 protocol." ON) -mark_as_advanced(NNG_PROTO_PUSH0) - -option (NNG_PROTO_PULL0 "Enable PULLv0 protocol." ON) -mark_as_advanced(NNG_PROTO_PULL0) +nng_directory(pipeline0) nng_sources_if(NNG_PROTO_PUSH0 push.c) nng_headers_if(NNG_PROTO_PUSH0 nng/protocol/pipeline0/push.h) diff --git a/src/protocol/pubsub0/CMakeLists.txt b/src/protocol/pubsub0/CMakeLists.txt index 8687de4e..160b7462 100644 --- a/src/protocol/pubsub0/CMakeLists.txt +++ b/src/protocol/pubsub0/CMakeLists.txt @@ -9,11 +9,7 @@ # # Pub/Sub protocol -option (NNG_PROTO_PUB0 "Enable PUBv0 protocol." ON) -mark_as_advanced(NNG_PROTO_PUB0) - -option (NNG_PROTO_SUB0 "Enable SUBv0 protocol." ON) -mark_as_advanced(NNG_PROTO_SUB0) +nng_directory(pubsub0) nng_sources_if(NNG_PROTO_PUB0 pub.c) nng_headers_if(NNG_PROTO_PUB0 nng/protocol/pubsub0/pub.h) diff --git a/src/protocol/reqrep0/CMakeLists.txt b/src/protocol/reqrep0/CMakeLists.txt index 46eb7abf..a3cecfd0 100644 --- a/src/protocol/reqrep0/CMakeLists.txt +++ b/src/protocol/reqrep0/CMakeLists.txt @@ -9,11 +9,7 @@ # # Req/Rep protocol -option(NNG_PROTO_REQ0 "Enable REQv0 protocol." ON) -mark_as_advanced(NNG_PROTO_REQ0) - -option(NNG_PROTO_REP0 "Enable REPv0 protocol." ON) -mark_as_advanced(NNG_PROTO_REP0) +nng_directory(reqrep0) nng_sources_if(NNG_PROTO_REQ0 req.c xreq.c) nng_headers_if(NNG_PROTO_REQ0 nng/protocol/reqrep0/req.h) diff --git a/src/protocol/survey0/CMakeLists.txt b/src/protocol/survey0/CMakeLists.txt index 6b3c8277..b5daca41 100644 --- a/src/protocol/survey0/CMakeLists.txt +++ b/src/protocol/survey0/CMakeLists.txt @@ -9,11 +9,7 @@ # # Surveyor/Respondent protocol -option (NNG_PROTO_RESPONDENT0 "Enable RESPONDENTv0 protocol." ON) -mark_as_advanced(NNG_PROTO_RESPONDENT0) - -option (NNG_PROTO_SURVEYOR0 "Enable SURVEYORv0 protocol." ON) -mark_as_advanced(NNG_PROTO_SURVEYOR0) +nng_directory(survey0) nng_sources_if(NNG_PROTO_SURVEYOR0 survey.c xsurvey.c) nng_headers_if(NNG_PROTO_SURVEYOR0 nng/protocol/survey0/survey.h) -- cgit v1.2.3-70-g09d2