aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.circleci/build-and-test.sh4
-rwxr-xr-x.circleci/build-demos.sh13
-rw-r--r--.circleci/config.yml60
-rwxr-xr-x.circleci/run-cmake.sh11
-rw-r--r--CMakeLists.txt22
-rw-r--r--demo/async/CMakeLists.txt24
-rw-r--r--demo/async/README.adoc9
-rw-r--r--demo/http_client/CMakeLists.txt18
-rw-r--r--demo/http_client/README.adoc12
-rw-r--r--demo/http_client/http_client.c1
-rw-r--r--demo/raw/CMakeLists.txt20
-rw-r--r--demo/raw/README.adoc35
-rw-r--r--demo/raw/raw.c (renamed from demo/raw/async.c)0
-rw-r--r--demo/reqrep/CMakeLists.txt17
-rw-r--r--demo/reqrep/README.adoc15
-rw-r--r--demo/rest/CMakeLists.txt17
-rw-r--r--demo/rest/README.adoc24
-rw-r--r--demo/rest/server.c2
-rw-r--r--docs/man/CMakeLists.txt8
-rw-r--r--perf/CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt45
-rw-r--r--src/compat/nanomsg/nn.h15
-rw-r--r--src/nng.h9
-rw-r--r--tests/CMakeLists.txt193
-rw-r--r--tests/errors.c4
-rw-r--r--tests/httpclient.c7
-rw-r--r--tests/httpserver.c24
-rw-r--r--tests/sock.c5
-rw-r--r--tests/trantest.h6
29 files changed, 447 insertions, 177 deletions
diff --git a/.circleci/build-and-test.sh b/.circleci/build-and-test.sh
index 068f0f91..c4fb8eaa 100755
--- a/.circleci/build-and-test.sh
+++ b/.circleci/build-and-test.sh
@@ -4,12 +4,12 @@
# common build & test steps for CircleCI jobs
#
-uname -a
cmake --version
ninja --version
mkdir build
cd build
-cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} ..
+cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} -DBUILD_SHARED_LIBS=${SHARED_LIBS:=ON} ..
ninja
+ninja install
env CTEST_OUTPUT_ON_FAILURE=1 ninja test
diff --git a/.circleci/build-demos.sh b/.circleci/build-demos.sh
new file mode 100755
index 00000000..488c142d
--- /dev/null
+++ b/.circleci/build-demos.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+#
+# build the demos to make sure they all build cleanly
+#
+
+for dir in demo/*; do
+ demo=$(basename $dir)
+ mkdir build-demo-${demo}
+ ( cd build-demo-${demo} &&
+ cmake -G Ninja ../demo/${demo} &&
+ ninja ) || exit 1
+done
diff --git a/.circleci/config.yml b/.circleci/config.yml
index efe64900..2a3711f7 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -22,7 +22,6 @@ jobs:
- run: >
apt-get install -y --allow-unauthenticated
build-essential
- curl
asciidoctor
cmake
libmbedtls-dev
@@ -32,6 +31,52 @@ jobs:
- run: ./etc/format-check.sh
- run: ./.circleci/build-and-test.sh
+ "gcc - static":
+ docker:
+ - image: ubuntu:16.04
+ environment:
+ CC: gcc
+ CXX: g++
+ SHARED_LIBS: OFF
+ CTEST_OUTPUT_ON_FAILURE: 1
+ steps:
+ - checkout
+ - run: apt-get update -qq
+ - run: apt-get install -y software-properties-common
+ - run: add-apt-repository ppa:ubuntu-toolchain-r/test
+ - run: apt-get update -qq
+ - run: >
+ apt-get install -y --allow-unauthenticated
+ build-essential
+ cmake
+ libmbedtls-dev
+ ninja-build
+ - run: ./.circleci/build-and-test.sh
+
+ "gcc - demos":
+ docker:
+ - image: ubuntu:16.04
+ environment:
+ CC: gcc
+ CXX: g++
+ CTEST_OUTPUT_ON_FAILURE: 1
+ steps:
+ - checkout
+ - run: apt-get update -qq
+ - run: apt-get install -y software-properties-common
+ - run: add-apt-repository ppa:ubuntu-toolchain-r/test
+ - run: apt-get update -qq
+ - run: >
+ apt-get install -y --allow-unauthenticated
+ build-essential
+ cmake
+ libmbedtls-dev
+ ninja-build
+ - run: ./.circleci/run-cmake.sh
+ - run: ninja -C build
+ - run: ninja -C build install
+ - run: ./.circleci/build-demos.sh
+
"gcc - build, test, coverage":
docker:
- image: ubuntu:16.04
@@ -40,6 +85,7 @@ jobs:
CXX: g++-8
COVERAGE: "ON"
GCOV: gcov-8
+ CTEST_OUTPUT_ON_FAILURE: 1
steps:
- checkout
- run: apt-get update -qq
@@ -64,11 +110,13 @@ workflows:
build_and_test:
jobs:
- "clang - build, test"
+ - "gcc - static"
- "gcc - build, test, coverage"
+ - "gcc - demos"
-notify:
- webhooks:
- # A list of hook hashes, containing the url field
- # gitter hook
- - url: ${GITTER_WEBHOOK}
+#notify:
+# webhooks:
+# # A list of hook hashes, containing the url field
+# # gitter hook
+# - url: ${GITTER_WEBHOOK}
diff --git a/.circleci/run-cmake.sh b/.circleci/run-cmake.sh
new file mode 100755
index 00000000..ca0caaa4
--- /dev/null
+++ b/.circleci/run-cmake.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+#
+# common build & test steps for CircleCI jobs
+#
+cmake --version
+ninja --version
+
+mkdir build
+cd build
+cmake -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} -DNNG_ENABLE_COVERAGE=${COVERAGE:-OFF} -DBUILD_SHARED_LIBS=${SHARED_LIBS:=ON} ..
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ee50ce0d..60b1726c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ include (CheckSymbolExists)
include (CheckStructHasMember)
include (CheckLibraryExists)
include (CheckCSourceCompiles)
+include (CheckCCompilerFlag)
include (CMakeDependentOption)
include (GNUInstallDirs)
include (TestBigEndian)
@@ -55,6 +56,7 @@ set (NNG_DESCRIPTION "High-Performance Scalability Protocols NextGen")
set (ISSUE_REPORT_MSG "Please consider opening an issue at https://github.com/nanomsg/nng")
# Determine library versions.
+set (NNG_ABI_SOVERSION 1)
set (NNG_ABI_VERSION "1.0.0")
# Determine package version.
@@ -86,6 +88,8 @@ endif()
# User-defined options.
+option(BUILD_SHARED_LIBS "Build shared library" ${BUILD_SHARED_LIBS})
+
option (NNG_TESTS "Build and run tests" ON)
option (NNG_TOOLS "Build extra tools" ON)
option (NNG_ENABLE_NNGCAT "Enable building nngcat utility." ${NNG_TOOLS})
@@ -267,6 +271,14 @@ else()
add_definitions (-DNNG_LITTLE_ENDIAN)
endif()
+# If the compiler is not on Windows, does it support hiding the
+# symbols by default? For shared libraries we would like to do this.
+if (NOT WIN32 AND NOT CYGWIN)
+ check_c_compiler_flag(-fvisibility=hidden NNG_HIDDEN_VISIBILITY)
+ if (NNG_HIDDEN_VISIBILITY)
+ add_definitions (-DNNG_HIDDEN_VISIBILITY)
+ endif()
+endif()
find_package (Threads REQUIRED)
@@ -408,6 +420,16 @@ nng_check_sym (strnlen string.h NNG_HAVE_STRNLEN)
nng_check_sym (strcasecmp string.h NNG_HAVE_STRCASECMP)
nng_check_sym (strncasecmp string.h NNG_HAVE_STRNCASECMP)
+# Set a static symbol. We do this for testing, so that tests can
+# be skipped if they would rely on symbols that might not be exported.
+# For example, idhash depends on private symbols, so don't test it
+# when using a shared library on Windows because the symbols won't
+# resolve.
+if (NOT(BUILD_SHARED_LIBS))
+ set (NNG_STATIC_LIB ON)
+ message(STATUS "Building static libs")
+endif()
+
add_subdirectory (src)
if (NNG_TESTS)
diff --git a/demo/async/CMakeLists.txt b/demo/async/CMakeLists.txt
new file mode 100644
index 00000000..614bcfc3
--- /dev/null
+++ b/demo/async/CMakeLists.txt
@@ -0,0 +1,24 @@
+#
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+#
+# 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.
+
+cmake_minimum_required (VERSION 2.8.7)
+
+project(nng-asyncdemo)
+
+set(PARALLEL 128 CACHE STRING "Parallelism (min 4, max 1000)")
+
+# Call this from your own project's makefile.
+find_package(nng CONFIG REQUIRED)
+
+add_executable(server server.c)
+target_link_libraries(server nng::nng)
+target_compile_definitions(server PRIVATE -DPARALLEL=${PARALLEL})
+
+add_executable(client client.c)
+target_link_libraries(client nng::nng)
diff --git a/demo/async/README.adoc b/demo/async/README.adoc
index ec91c722..87c44cec 100644
--- a/demo/async/README.adoc
+++ b/demo/async/README.adoc
@@ -6,8 +6,11 @@ processing with minimal fuss.
== Compiling
-You can override the level of concurrency with the `PARALLEL`
-define. This determines how many requests the server will accept
+This is set up for configuration with CMake for ease of use.
+
+You can override the level of concurrency with the `PARALLEL` option.
+
+This determines how many requests the server will accept
at a time, and keep outstanding. Note that for our toy implementation,
we create this many "logical" flows of execution (contexts) (these are
_NOT_ threads), where a request is followed by a reply.
@@ -20,6 +23,8 @@ you can't have more than one client per descriptor. Contexts can be used
on the client side to support many thousands of concurrent requests over
even just a single TCP connection, however.)
+You can also build this all by hand with Make or whatever.
+
On UNIX-style systems:
[source, bash]
diff --git a/demo/http_client/CMakeLists.txt b/demo/http_client/CMakeLists.txt
new file mode 100644
index 00000000..3fe126f9
--- /dev/null
+++ b/demo/http_client/CMakeLists.txt
@@ -0,0 +1,18 @@
+#
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+#
+# 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.
+
+cmake_minimum_required (VERSION 2.8.7)
+
+project(http_client)
+
+# Call this from your own project's makefile.
+find_package(nng CONFIG REQUIRED)
+
+add_executable(http_client http_client.c)
+target_link_libraries(http_client nng::nng)
diff --git a/demo/http_client/README.adoc b/demo/http_client/README.adoc
index a0fb54e4..f8777557 100644
--- a/demo/http_client/README.adoc
+++ b/demo/http_client/README.adoc
@@ -30,6 +30,17 @@ Linux and macOS:
% ${CC} ${CPPFLAGS} http_client.c -o http_client ${LDFLAGS}
----
+Alternatively, CMake can be used. Here's an example if you have
+Ninja build handy (highly recommended):
+
+[source, bash]
+----
+% mkdir build
+% cd build
+% cmake -G Ninja ..
+% ninja
+----
+
== Running
Make sure you specify the full URL (if the root page include
@@ -39,4 +50,3 @@ the simple "/". The URL parser does not add it for you automatically.)
----
% ./http_client http://httpbin.org/ip
----
-
diff --git a/demo/http_client/http_client.c b/demo/http_client/http_client.c
index 522c1cd1..a00c842f 100644
--- a/demo/http_client/http_client.c
+++ b/demo/http_client/http_client.c
@@ -34,6 +34,7 @@
//
#include <nng/nng.h>
+#include <nng/supplemental/http/http.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/demo/raw/CMakeLists.txt b/demo/raw/CMakeLists.txt
new file mode 100644
index 00000000..15e481d5
--- /dev/null
+++ b/demo/raw/CMakeLists.txt
@@ -0,0 +1,20 @@
+#
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+#
+# 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.
+
+cmake_minimum_required (VERSION 2.8.7)
+
+project(raw)
+
+set(PARALLEL 128 CACHE STRING "Parallelism (min 4, max 1000)")
+
+find_package(nng CONFIG REQUIRED)
+
+add_executable(raw raw.c)
+target_link_libraries(raw nng::nng)
+target_compile_definitions(raw PRIVATE -DPARALLEL=${PARALLEL})
diff --git a/demo/raw/README.adoc b/demo/raw/README.adoc
index 35290616..2190dc49 100644
--- a/demo/raw/README.adoc
+++ b/demo/raw/README.adoc
@@ -1,14 +1,15 @@
-= async
+= raw
This is a simple asynchronous demo, that demonstrates use of the RAW
-option with a server, along with async message handling, to obtain a
+sockets with a server, along with async message handling, to obtain a
very high level of asynchronous operation, suitable for use in a highly
concurrent server application.
== Compiling
-You can override the level of concurrency with the `PARALLEL`
-define. This determines how many requests the server will accept
+You can override the level of concurrency with the `PARALLEL` option.
+
+This determines how many requests the server will accept
at a time, and keep outstanding. Note that for our toy
implementation, we create this many "logical" flows of execution
(these are _NOT_ threads), where a request is followed by a reply.
@@ -16,14 +17,24 @@ implementation, we create this many "logical" flows of execution
The value of `PARALLEL` must be at least one, and may be as large
as your memory will permit. (The default value is 32.)
-On UNIX-style systems:
+The best way to build is using cmake and Ninja build:
+
+[source, bash]
+----
+% mkdir build
+% cd build
+% cmake -G Ninja ..
+% ninja
+----
+
+You can also build the hard way. For example, on UNIX-style systems:
[source, bash]
----
% export CPPFLAGS="-D PARALLEL=32 -I /usr/local/include"
% export LDFLAGS="-L /usr/local/lib -lnng"
% export CC="cc"
-% ${CC} ${CPPFLAGS} async.c -o async ${LDFLAGS}
+% ${CC} ${CPPFLAGS} raw.c -o raw ${LDFLAGS}
----
== Running
@@ -42,12 +53,12 @@ In the following example, all of the clients should complete within
----
% export URL="tcp://127.0.0.1:55995"
# start the server
-% ./async $URL -s &
+% ./raw $URL -s &
# start a bunch of clients
# Note that these all run concurrently!
-% ./async $URL 2 &
-% ./async $URL 2 &
-% ./async $URL 2 &
-% ./async $URL 2 &
-% ./async $URL 2 &
+% ./raw $URL 2 &
+% ./raw $URL 2 &
+% ./raw $URL 2 &
+% ./raw $URL 2 &
+% ./raw $URL 2 &
----
diff --git a/demo/raw/async.c b/demo/raw/raw.c
index 0285d8d2..0285d8d2 100644
--- a/demo/raw/async.c
+++ b/demo/raw/raw.c
diff --git a/demo/reqrep/CMakeLists.txt b/demo/reqrep/CMakeLists.txt
new file mode 100644
index 00000000..d6982446
--- /dev/null
+++ b/demo/reqrep/CMakeLists.txt
@@ -0,0 +1,17 @@
+#
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+#
+# 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.
+
+cmake_minimum_required (VERSION 2.8.7)
+
+project(reqrep)
+
+find_package(nng CONFIG REQUIRED)
+
+add_executable(reqrep reqrep.c)
+target_link_libraries(reqrep nng::nng)
diff --git a/demo/reqrep/README.adoc b/demo/reqrep/README.adoc
index b66d694c..5bc3d043 100644
--- a/demo/reqrep/README.adoc
+++ b/demo/reqrep/README.adoc
@@ -19,8 +19,19 @@ compiled on 64-bit systems.)
== Compiling
-The following is an example typical of UNIX and similar systems like
-Linux and macOS:
+CMake with ninja-build is simplest:
+
+[source, bash]
+----
+% mkdir build
+% cd build
+% cmake -G Ninja ..
+% ninja
+----
+
+Or if you prefer a traditional approach,
+the following is an example typical of UNIX and similar systems like
+Linux and macOS may appeal:
[source, bash]
----
diff --git a/demo/rest/CMakeLists.txt b/demo/rest/CMakeLists.txt
new file mode 100644
index 00000000..5466e3c7
--- /dev/null
+++ b/demo/rest/CMakeLists.txt
@@ -0,0 +1,17 @@
+#
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+#
+# 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.
+
+cmake_minimum_required (VERSION 2.8.7)
+
+project(rest)
+
+find_package(nng CONFIG REQUIRED)
+
+add_executable(rest-server server.c)
+target_link_libraries(rest-server nng::nng)
diff --git a/demo/rest/README.adoc b/demo/rest/README.adoc
index 6a363329..df3e30b0 100644
--- a/demo/rest/README.adoc
+++ b/demo/rest/README.adoc
@@ -3,7 +3,7 @@
This is a somewhat contrived demonstration, but may be useful
in a pattern for solving real world problems.
-There is a single "server" program, that does these:
+There is a single "server" (rest-server) program, that does these:
. REST API at /api/rest/rot13 - this API takes data from HTTP POST commands,
and forwards them to an NNG REQ socket. When the REQ response comes,
@@ -17,9 +17,29 @@ There is a single "server" program, that does these:
[source, bash]
----
% env PORT=8888 # default
-% ./server &
+% ./rest-server &
% curl -d ABC http://127.0.0.1:8888/api/rest/rot13; echo
NOP
% curl -d ABC http://127.0.0.1:8888/api/rest/rot13; echo
ABC
----
+
+== Compiling
+
+To build the program, we recommend CMake and Ninja-Build.
+
+[source, bash]
+----
+% mkdir build
+% cd build
+% cmake -G Ninja ..
+% ninja
+----
+
+Alternatively, you can go old-school.
+Here's the simplest option for Linux:
+
+[source, bash]
+----
+% cc server.c -o rest-server -I /usr/local/include -lnng
+----
diff --git a/demo/rest/server.c b/demo/rest/server.c
index 788fc8f1..72c24cb1 100644
--- a/demo/rest/server.c
+++ b/demo/rest/server.c
@@ -98,7 +98,7 @@ rest_free_job(rest_job *job)
if (job->msg != NULL) {
nng_msg_free(job->msg);
}
- if (job->ctx != 0) {
+ if (nng_ctx_id(job->ctx) != 0) {
nng_ctx_close(job->ctx);
}
free(job);
diff --git a/docs/man/CMakeLists.txt b/docs/man/CMakeLists.txt
index 66421553..726d95c4 100644
--- a/docs/man/CMakeLists.txt
+++ b/docs/man/CMakeLists.txt
@@ -36,7 +36,7 @@ if (NNG_ENABLE_DOC)
add_custom_command (
OUTPUT ${NAME}.${SECT}.html
- COMMAND ${NNG_A2H} -o ${NAME}.html ${NNG_DOCDIR}/${NAME}.${SECT}.adoc
+ COMMAND ${NNG_A2H} -o ${NAME}.${SECT}.html ${NNG_DOCDIR}/${NAME}.${SECT}.adoc
MAIN_DEPENDENCY ${NNG_DOCDIR}/${NAME}.${SECT}.adoc
)
@@ -44,7 +44,7 @@ if (NNG_ENABLE_DOC)
set(NNG_HTMLS ${NNG_HTMLS} ${NAME}.${SECT}.html)
install (
- FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.{SECT}.html
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${SECT}.html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
install (
@@ -187,7 +187,7 @@ if (NNG_ENABLE_DOC)
nn_socket
nn_strerror
nn_term
- nng_compat
+ nng_compat
)
set(NNG_MAN3HTTP
@@ -328,7 +328,7 @@ if (NNG_ENABLE_DOC)
foreach(F ${NNG_MAN3})
nng_man(${F} 3)
endforeach()
-
+
foreach(F ${NNG_MAN3COMPAT})
nng_man(${F} 3compat)
endforeach()
diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt
index 5bbc2c81..83e08e88 100644
--- a/perf/CMakeLists.txt
+++ b/perf/CMakeLists.txt
@@ -31,9 +31,9 @@ include_directories(AFTER SYSTEM ${PROJECT_SOURCE_DIR}/src)
if (NNG_TESTS)
macro (add_nng_perf NAME)
add_executable (${NAME} perf.c)
- target_link_libraries (${NAME} ${PROJECT_NAME}_static)
+ target_link_libraries (${NAME} ${PROJECT_NAME})
target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES})
- target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB)
+ target_compile_definitions(${NAME} PUBLIC)
if (CMAKE_THREAD_LIBS_INIT)
target_link_libraries (${NAME} "${CMAKE_THREAD_LIBS_INIT}")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2db46c60..cfb6ff16 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -191,38 +191,53 @@ foreach (f ${NNG_SOURCES})
source_group ("${SRC_GROUP}" FILES ${f})
endforeach ()
-# Static libary
-add_library (${PROJECT_NAME}_static STATIC ${NNG_SOURCES})
-target_compile_definitions(${PROJECT_NAME}_static PUBLIC -DNNG_STATIC_LIB)
-
-# Shared library
-add_library (${PROJECT_NAME} SHARED ${NNG_SOURCES})
-target_compile_definitions(${PROJECT_NAME} PRIVATE -DNNG_SHARED_LIB)
+# Library
+add_library (${PROJECT_NAME} ${NNG_SOURCES})
+
+# When building shared libraries we prefer to suppress default symbol
+# visibility, so that only the symbols that should be exposed in the
+# resulting library are. This is the default with Windows.
+if (BUILD_SHARED_LIBS)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE -DNNG_SHARED_LIB)
+ if (NNG_HIDDEN_VISIBILITY)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE -DNNG_HIDDEN_VISIBILITY)
+ set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET hidden)
+ endif()
+else()
+ target_compile_definitions(${PROJECT_NAME} PUBLIC -DNNG_STATIC_LIB)
+endif()
set_target_properties (${PROJECT_NAME}
- PROPERTIES SOVERSION "${NNG_ABI_VERSION}")
+ PROPERTIES SOVERSION ${NNG_ABI_SOVERSION} VERSION "${NNG_ABI_VERSION}")
# Set library outputs same as top-level project binary outputs
-set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}_static
+set_target_properties (${PROJECT_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}_static
+set_target_properties (${PROJECT_NAME}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}_static
+set_target_properties (${PROJECT_NAME}
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
-set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}_static
+set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}
PROPERTIES FRAMEWORK OFF)
-target_link_libraries (${PROJECT_NAME} ${NNG_REQUIRED_LIBRARIES})
-target_link_libraries (${PROJECT_NAME} Threads::Threads)
+target_link_libraries (${PROJECT_NAME} PRIVATE ${NNG_REQUIRED_LIBRARIES})
+target_link_libraries (${PROJECT_NAME} PRIVATE Threads::Threads)
-install (TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static
+install (TARGETS ${PROJECT_NAME}
+ EXPORT ${PROJECT_NAME}-target
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools
)
+install (EXPORT ${PROJECT_NAME}-target
+ FILE ${PROJECT_NAME}-config.cmake
+ NAMESPACE nng::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+)
+
# Install the header files. It would be much better if we could use
# the PUBLIC_HEADER facility, but it stupidly flattens the directories.
foreach (f ${NNG_HEADERS})
diff --git a/src/compat/nanomsg/nn.h b/src/compat/nanomsg/nn.h
index 789aed3e..63431728 100644
--- a/src/compat/nanomsg/nn.h
+++ b/src/compat/nanomsg/nn.h
@@ -44,10 +44,9 @@ extern "C" {
// clang-format off
// NNG_DECL is used on declarations to deal with scope.
-// For building Windows DLLs, it should be the appropriate
-// __declspec(). (We recommend *not* building this library
-// as a DLL, but instead linking it statically for your projects
-// to minimize questions about link dependencies later.)
+// For building Windows DLLs, it should be the appropriate __declspec().
+// For shared libraries with platforms that support hidden visibility,
+// it should evaluate to __attribute__((visibility("default"))).
#ifndef NN_DECL
#if defined(_WIN32) && !defined(NNG_STATIC_LIB)
#if defined(NNG_SHARED_LIB)
@@ -56,8 +55,12 @@ extern "C" {
#define NN_DECL __declspec(dllimport)
#endif // NNG_SHARED_LIB
#else
-#define NN_DECL extern
-#endif // _WIN32 && !NNG_STATIC_LIB
+#if defined(NNG_SHARED_LIB) && defined(NNG_HIDDEN_VISIBILITY)
+#define NN_DECL __attribute__((visibility("default")))
+#else
+#define NN_DECL extern
+#endif
+#endif // _WIN32 && !NNG_STATIC_LIB
#endif // NN_DECL
#define AF_SP 1
diff --git a/src/nng.h b/src/nng.h
index af119bdb..42ca0727 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -27,9 +27,8 @@ extern "C" {
// NNG_DECL is used on declarations to deal with scope.
// For building Windows DLLs, it should be the appropriate __declspec().
-// (We recommend *not* building this library as a DLL, but instead linking
-// it statically for your project to minimize concerns about link
-// dependencies later.)
+// For shared libraries with platforms that support hidden visibility,
+// it should evaluate to __attribute__((visibility("default"))).
#ifndef NNG_DECL
#if defined(_WIN32) && !defined(NNG_STATIC_LIB)
#if defined(NNG_SHARED_LIB)
@@ -38,7 +37,11 @@ extern "C" {
#define NNG_DECL __declspec(dllimport)
#endif // NNG_SHARED_LIB
#else
+#if defined(NNG_SHARED_LIB) && defined(NNG_HIDDEN_VISIBILITY)
+#define NNG_DECL __attribute__((visibility("default")))
+#else
#define NNG_DECL extern
+#endif
#endif // _WIN32 && !NNG_STATIC_LIB
#endif // NNG_DECL
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e7d751ac..31b5fe29 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,10 +1,10 @@
#
+# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+# Copyright 2018 Capitar IT Group BV <info@capitar.com>
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
# Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
-# Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
-# Copyright 2018 Capitar IT Group BV <info@capitar.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
@@ -27,37 +27,31 @@
# Build unit tests.
+# Note that tests which depend on internal (not public) APIs are not
+# enabled unless a static library is built. This is because on some
+# systems (e.g. Windows) we do not expose symbols that are not in the
+# public API. (When CMake learns more about using mapfiles to suppress
+# symbol visibility we will do this even more, to protect the namespace
+# of the user.)
+
include_directories(AFTER SYSTEM ${PROJECT_SOURCE_DIR}/src)
if (NNG_TESTS)
- if (THREADS_HAVE_PTHREAD_ARG)
- add_definitions (-pthread)
- endif()
-
# convey tests -- verify the test framework works!
add_executable(convey_test convey_test.c convey.c)
- if (CMAKE_THREAD_LIBS_INIT)
- target_link_libraries (convey_test "${CMAKE_THREAD_LIBS_INIT}")
- endif()
+ target_link_libraries (convey_test Threads::Threads)
add_test (NAME convey_test COMMAND convey_test
-v -d -p ENV_TEST=ON -p ANOTHERNAME -p AGAIN=yes extra)
- set_tests_properties( convey_test PROPERTIES TIMEOUT 2)
- list (APPEND all_tests convey_test)
-
- set (TEST_PORT 12100)
- macro (add_nng_test NAME TIMEOUT COND)
- if (${COND})
- list (APPEND all_tests ${NAME})
- add_executable (${NAME} ${NAME}.c convey.c)
- target_link_libraries (${NAME} ${PROJECT_NAME}_static)
- target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES})
- target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB)
-
- add_test (NAME ${NAME} COMMAND ${NAME} -v -p TEST_PORT=${TEST_PORT})
- set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
- math (EXPR TEST_PORT "${TEST_PORT}+20")
- endif()
+ set_tests_properties (convey_test PROPERTIES TIMEOUT 2)
+
+ set (NNG_TEST_PORT 13000)
+ macro (add_nng_test NAME TIMEOUT)
+ add_executable (${NAME} ${NAME}.c convey.c)
+ target_link_libraries (${NAME} ${PROJECT_NAME} Threads::Threads)
+ add_test (NAME ${NAME} COMMAND ${NAME} -v -p TEST_PORT=${NNG_TEST_PORT})
+ set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
+ math (EXPR NNG_TEST_PORT "${NNG_TEST_PORT}+20")
endmacro (add_nng_test)
# Compatibility tests are only added if all of the legacy protocols
@@ -73,17 +67,14 @@ if (NNG_TESTS)
NNG_PROTO_PULL0)
macro (add_nng_compat_test NAME TIMEOUT)
- list (APPEND all_tests ${NAME})
add_executable (${NAME} ${NAME}.c compat_testutil.c)
- target_link_libraries (${NAME} ${PROJECT_NAME}_static)
- target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES})
- target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB)
+ target_link_libraries (${NAME} ${PROJECT_NAME})
target_include_directories(${NAME} PUBLIC
${PROJECT_SOURCE_DIR}/src/compat)
- add_test (NAME ${NAME} COMMAND ${NAME} ${TEST_PORT})
+ add_test (NAME ${NAME} COMMAND ${NAME} ${NNG_TEST_PORT})
set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
- math (EXPR TEST_PORT "${TEST_PORT}+10")
+ math (EXPR NNG_TEST_PORT "${NNG_TEST_PORT}+20")
endmacro (add_nng_compat_test)
else ()
macro (add_nng_compat_test NAME TIMEOUT)
@@ -94,87 +85,103 @@ if (NNG_TESTS)
macro (add_nng_cpp_test NAME TIMEOUT)
if (NOT NNG_ENABLE_COVERAGE)
enable_language (CXX)
- list (APPEND all_tests ${NAME})
add_executable (${NAME} ${NAME}.cc)
- target_link_libraries (${NAME} ${PROJECT_NAME}_static)
- target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES})
- target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB)
-
+ target_link_libraries (${NAME} ${PROJECT_NAME})
add_test (NAME ${NAME} COMMAND ${NAME} ${TEST_PORT})
set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
- math (EXPR TEST_PORT "${TEST_PORT}+10")
+ math (EXPR TEST_PORT "${NNG_TEST_PORT}+20")
endif()
endmacro (add_nng_cpp_test)
- macro (add_nng_proto_test NAME TIMEOUT P1 P2)
- if (${P1} AND ${P2})
+ macro (add_nng_test1 NAME TIMEOUT COND1)
+ if (${COND1})
+ add_nng_test(${NAME} ${TIMEOUT})
+ else()
+ message (STATUS "Test ${NAME} disabled (unconfigured)")
+ endif()
+ endmacro()
+
+ macro (add_nng_test2 NAME TIMEOUT COND1 COND2)
+ if (${COND1} AND ${COND2})
+ add_nng_test(${NAME} ${TIMEOUT})
+ else()
+ message (STATUS "Test ${NAME} disabled (unconfigured)")
+ endif()
+ endmacro()
+
+ macro (add_nng_test3 NAME TIMEOUT COND1 COND2 COND3)
+ if (${COND1} AND ${COND2} AND ${COND3})
add_nng_test(${NAME} ${TIMEOUT} ON)
else()
- message (STATUS "Protocol test ${NAME} disabled (unconfigured)")
+ message (STATUS "Test ${NAME} disabled (unconfigured)")
endif()
endmacro()
else ()
- macro (add_nng_test NAME TIMEOUT COND)
+ macro (add_nng_test NAME TIMEOUT)
endmacro (add_nng_test)
macro (add_nng_compat_test NAME TIMEOUT)
endmacro (add_nng_compat_test)
macro (add_nng_cpp_test NAME TIMEOUT)
endmacro (add_nng_cpp_test)
- macro (add_nng_proto_test NAME TIMEOUT P1 P2)
- endmacro()
+ macro (add_nng_test1 NAME TIMEOUT COND1)
+ endmacro(add_nng_test1)
+ macro (add_nng_test2 NAME TIMEOUT COND1 COND2)
+ endmacro(add_nng_test2)
+ macro (add_nng_test3 NAME TIMEOUT COND1 COND2 COND3)
+ endmacro(add_nng_test3)
endif ()
-add_nng_test(aio 5 ON)
-add_nng_test(bufsz 5 NNG_PROTO_PAIR0)
-add_nng_test(base64 5 NNG_SUPP_BASE64)
-add_nng_test(device 5 ON)
-add_nng_test(errors 2 ON)
-add_nng_test(files 5 ON)
-add_nng_test(httpclient 60 NNG_SUPP_HTTP)
-add_nng_test(httpserver 30 NNG_SUPP_HTTP)
-add_nng_test(idhash 5 ON)
-add_nng_test(inproc 5 NNG_TRANSPORT_INPROC)
-add_nng_test(ipc 5 NNG_TRANSPORT_IPC)
-add_nng_test(ipcperms 5 NNG_TRANSPORT_IPC)
-add_nng_test(ipcwinsec 5 NNG_TRANSPORT_IPC)
-add_nng_test(list 5 ON)
-add_nng_test(message 5 ON)
-add_nng_test(multistress 60 ON)
-add_nng_test(nonblock 60 ON)
-add_nng_test(options 5 ON)
-add_nng_test(pipe 5 ON)
-add_nng_test(platform 5 ON)
-add_nng_test(pollfd 5 ON)
-add_nng_test(reconnect 5 ON)
-add_nng_test(resolv 10 ON)
+add_nng_test(aio 5)
+add_nng_test2(base64 5 NNG_STATIC_LIB NNG_SUPP_BASE64)
+add_nng_test1(bufsz 5 NNG_PROTO_PAIR0)
+add_nng_test(device 5)
+add_nng_test(errors 2)
+add_nng_test1(files 5 NNG_STATIC_LIB)
+add_nng_test1(httpclient 60 NNG_SUPP_HTTP)
+add_nng_test2(httpserver 30 NNG_STATIC_LIB NNG_SUPP_HTTP)
+add_nng_test1(idhash 5 NNG_STATIC_LIB)
+add_nng_test1(inproc 5 NNG_TRANSPORT_INPROC)
+add_nng_test1(ipc 5 NNG_TRANSPORT_IPC)
+add_nng_test1(ipcperms 5 NNG_TRANSPORT_IPC)
+add_nng_test1(ipcwinsec 5 NNG_TRANSPORT_IPC)
+add_nng_test1(list 5 NNG_STATIC_LIB)
+add_nng_test(message 5)
+add_nng_test(multistress 60)
+add_nng_test(nonblock 60)
+add_nng_test(options 5)
+add_nng_test(pipe 5)
+add_nng_test(platform 5)
+add_nng_test(pollfd 5)
+add_nng_test(reconnect 5)
+add_nng_test1(resolv 10 NNG_STATIC_LIB)
add_nng_test(scalability 20 ON)
-add_nng_test(sha1 5 NNG_SUPP_SHA1)
-add_nng_test(sock 5 ON)
-add_nng_test(synch 5 ON)
-add_nng_test(tls 60 NNG_TRANSPORT_TLS)
-add_nng_test(tcp 180 NNG_TRANSPORT_TCP)
-add_nng_test(tcp6 60 NNG_TRANSPORT_TCP)
-add_nng_test(transport 5 ON)
-add_nng_test(udp 5 ON)
-add_nng_test(url 5 ON)
-add_nng_test(ws 30 NNG_TRANSPORT_WS)
-add_nng_test(wss 30 NNG_TRANSPORT_WSS)
-add_nng_test(wssfile 30 NNG_TRANSPORT_WSS)
-add_nng_test(zt 60 NNG_TRANSPORT_ZEROTIER)
-
-add_nng_proto_test(bus 5 NNG_PROTO_BUS0 NNG_PROTO_BUS0)
-add_nng_test(pipeline 5 NNG_PROTO_PULL0 NNG_PROTO_PIPELINE0)
-add_nng_proto_test(pair1 5 NNG_PROTO_PAIR1 NNG_PROTO_PAIR1)
-add_nng_proto_test(pubsub 5 NNG_PROTO_PUB0 NNG_PROTO_SUB0)
-add_nng_proto_test(reqctx 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
-add_nng_proto_test(reqpoll 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
-add_nng_proto_test(reqrep 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
-add_nng_proto_test(reqstress 60 NNG_PROTO_REQ0 NNG_PROTO_REP0)
-add_nng_proto_test(respondpoll 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
-add_nng_test(survey 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
-add_nng_proto_test(surveyctx 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
-add_nng_proto_test(surveypoll 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
+add_nng_test2(sha1 5 NNG_STATIC_LIB NNG_SUPP_SHA1)
+add_nng_test(sock 5)
+add_nng_test1(synch 5 NNG_STATIC_LIB)
+add_nng_test2(tls 60 NNG_STATIC_LIB NNG_TRANSPORT_TLS)
+add_nng_test1(tcp 180 NNG_TRANSPORT_TCP)
+add_nng_test2(tcp6 60 NNG_STATIC_LIB NNG_TRANSPORT_TCP)
+add_nng_test1(transport 5 NNG_STATIC_LIB)
+add_nng_test1(udp 5 NNG_STATIC_LIB)
+add_nng_test(url 5)
+add_nng_test1(ws 30 NNG_TRANSPORT_WS)
+add_nng_test1(wss 30 NNG_TRANSPORT_WSS)
+add_nng_test2(wssfile 30 NNG_STATIC_LIB NNG_TRANSPORT_WSS)
+add_nng_test1(zt 60 NNG_TRANSPORT_ZEROTIER)
+
+add_nng_test1(bus 5 NNG_PROTO_BUS0)
+add_nng_test2(pipeline 5 NNG_PROTO_PULL0 NNG_PROTO_PUSH0)
+add_nng_test1(pair1 5 NNG_PROTO_PAIR1)
+add_nng_test2(pubsub 5 NNG_PROTO_PUB0 NNG_PROTO_SUB0)
+add_nng_test2(reqctx 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
+add_nng_test2(reqpoll 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
+add_nng_test2(reqrep 5 NNG_PROTO_REQ0 NNG_PROTO_REP0)
+add_nng_test2(reqstress 60 NNG_PROTO_REQ0 NNG_PROTO_REP0)
+add_nng_test2(respondpoll 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
+add_nng_test2(survey 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
+add_nng_test2(surveyctx 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
+add_nng_test2(surveypoll 5 NNG_PROTO_SURVEYOR0 NNG_PROTO_RESPONDENT0)
# compatbility tests
# We only support these if ALL the legacy protocols are supported. This
@@ -201,7 +208,7 @@ add_nng_compat_test(compat_ws 60)
# These are special tests for compat mode, not inherited from the
# legacy libnanomsg suite.
-add_nng_test(compat_options 5 NNG_PROTO_REP0)
+add_nng_test1(compat_options 5 NNG_PROTO_REP0)
# c++ tests
add_nng_cpp_test(cplusplus_pair 5)
diff --git a/tests/errors.c b/tests/errors.c
index f5e857e2..06747c24 100644
--- a/tests/errors.c
+++ b/tests/errors.c
@@ -8,12 +8,11 @@
//
#include "convey.h"
-#include "nng.c"
+#include "nng.h"
#include <errno.h>
#include <string.h>
TestMain("Error messages work", {
-
Convey("Known errors work", {
So(strcmp(nng_strerror(NNG_ECLOSED), "Object closed") == 0);
So(strcmp(nng_strerror(NNG_ETIMEDOUT), "Timed out") == 0);
@@ -28,6 +27,5 @@ TestMain("Error messages work", {
strerror(ENOENT)) == 0);
So(strcmp(nng_strerror(NNG_ESYSERR + EINVAL),
strerror(EINVAL)) == 0);
-
});
})
diff --git a/tests/httpclient.c b/tests/httpclient.c
index e167587e..96597d0c 100644
--- a/tests/httpclient.c
+++ b/tests/httpclient.c
@@ -18,6 +18,7 @@
// Basic HTTP client tests.
#include "core/nng_impl.h"
#include "supplemental/http/http.h"
+#include "supplemental/sha1/sha1.c"
#include "supplemental/sha1/sha1.h"
#include "supplemental/tls/tls.h"
@@ -26,8 +27,6 @@ const uint8_t example_sum[20] = { 0x0e, 0x97, 0x3b, 0x59, 0xf4, 0x76, 0x00,
0xc0 };
TestMain("HTTP Client", {
-
- nni_init();
atexit(nng_fini);
Convey("Given a TCP connection to httpbin.org", {
@@ -86,9 +85,9 @@ TestMain("HTTP Client", {
sz = atoi(cstr);
So(sz > 0);
- data = nni_alloc(sz);
+ data = nng_alloc(sz);
So(data != NULL);
- Reset({ nni_free(data, sz); });
+ Reset({ nng_free(data, sz); });
iov.iov_buf = data;
iov.iov_len = sz;
diff --git a/tests/httpserver.c b/tests/httpserver.c
index fb8e300e..9898a0ff 100644
--- a/tests/httpserver.c
+++ b/tests/httpserver.c
@@ -73,7 +73,7 @@ httpdo(nng_url *url, nng_http_req *req, nng_http_res *res, void **datap,
if (clen > 0) {
nng_iov iov;
- data = nni_alloc(clen);
+ data = nng_alloc(clen);
iov.iov_buf = data;
iov.iov_len = clen;
nng_aio_set_iov(aio, 1, &iov);
@@ -128,7 +128,7 @@ httpget(const char *addr, void **datap, size_t *sizep, uint16_t *statp,
if (clen > 0) {
if ((ptr = nng_http_res_get_header(res, "Content-Type")) !=
NULL) {
- ctype = nni_strdup(ptr);
+ ctype = strdup(ptr);
}
}
@@ -139,9 +139,9 @@ httpget(const char *addr, void **datap, size_t *sizep, uint16_t *statp,
fail:
if (rv != 0) {
if (data != NULL) {
- nni_free(data, clen);
+ nng_free(data, clen);
}
- nni_strfree(ctype);
+ free(ctype);
}
if (url != NULL) {
nni_url_free(url);
@@ -289,19 +289,19 @@ TestMain("HTTP Server", {
Reset({
nng_http_server_release(s);
- nni_strfree(tmpdir);
+ free(tmpdir);
nni_file_delete(file1);
nni_file_delete(file2);
nni_file_delete(file3);
nni_file_delete(subdir1);
nni_file_delete(subdir2);
nni_file_delete(workdir);
- nni_strfree(workdir);
- nni_strfree(file1);
- nni_strfree(file2);
- nni_strfree(file3);
- nni_strfree(subdir1);
- nni_strfree(subdir2);
+ free(workdir);
+ free(file1);
+ free(file2);
+ free(file3);
+ free(subdir1);
+ free(subdir2);
nng_url_free(url);
});
@@ -325,7 +325,7 @@ TestMain("HTTP Server", {
So(size == strlen(doc1));
So(memcmp(data, doc1, size) == 0);
So(strcmp(ctype, "text/html") == 0);
- nni_strfree(ctype);
+ free(ctype);
nng_free(data, size);
});
diff --git a/tests/sock.c b/tests/sock.c
index 37b713dd..29043cb3 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -25,7 +25,6 @@
#define SECONDS(x) ((x) *1000)
TestMain("Socket Operations", {
-
atexit(nng_fini);
// Reset({ nng_fini(); });
Reset({ nng_closeall(); });
@@ -98,7 +97,7 @@ TestMain("Socket Operations", {
So(nng_getopt(
s1, NNG_OPT_SOCKNAME, name, &sz) == 0);
So(sz > 0 && sz < 64);
- So(sz == nni_strnlen(name, 64) + 1);
+ So(sz == strlen(name) + 1);
So(atoi(name) == (int) s1.id);
So(nng_setopt(
@@ -409,7 +408,6 @@ TestMain("Socket Operations", {
l.id = ep.id;
So(nng_listener_start(l, 0) == NNG_ENOTSUP);
});
-
});
Convey("Listener creation ok", {
@@ -496,7 +494,6 @@ TestMain("Socket Operations", {
NNG_ENOENT);
So(nng_listener_getopt_ms(l, NNG_OPT_SENDTIMEO, &t) ==
NNG_ENOENT);
-
});
Convey("We can send and receive messages", {
diff --git a/tests/trantest.h b/tests/trantest.h
index de82099c..92d1db09 100644
--- a/tests/trantest.h
+++ b/tests/trantest.h
@@ -124,7 +124,7 @@ trantest_next_address(char *out, const char *template)
// start at a different port each time -- 5000 - 10000 --
// unless a specific port is given.
- trantest_port = nni_clock() % 5000 + 5000;
+ trantest_port = nng_clock() % 5000 + 5000;
if (((pstr = ConveyGetEnv("TEST_PORT")) != NULL) &&
(atoi(pstr) != 0)) {
trantest_port = atoi(pstr);
@@ -146,7 +146,7 @@ trantest_init(trantest *tt, const char *addr)
{
trantest_next_address(tt->addr, addr);
-#if defined(NNG_HAVE_REQ0) && defined(NNG_HAVE_REP0)
+#if defined(NNG_HAVE_REQ0) && defined(NNG_HAVE_REP0) && defined(NNG_STATIC_LIB)
So(nng_req_open(&tt->reqsock) == 0);
So(nng_rep_open(&tt->repsock) == 0);
@@ -426,7 +426,7 @@ trantest_send_recv_large(trantest *tt)
So((data = nng_alloc(size)) != NULL);
for (int i = 0; (size_t) i < size; i++) {
- data[i] = nni_random() & 0xff;
+ data[i] = nng_random() & 0xff;
}
So(trantest_listen(tt, &l) == 0);