From 60bf092d3e6e68d0af55c78b679310b1687016e8 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 16 Apr 2022 14:36:27 -0700 Subject: fixes #1577 nng_stat_find_socket always returns the same stats node Also this fixes problems with uninitialized socket names, and the socket name stat not being adjusted correctly when set via API. --- tests/CMakeLists.txt | 1 - tests/stats.c | 74 ---------------------------------------------------- 2 files changed, 75 deletions(-) delete mode 100644 tests/stats.c (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc212c0f..063692cb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -137,7 +137,6 @@ add_nng_test(options 5) add_nng_test(pipe 5) add_nng_test(pollfd 5) add_nng_test(scalability 20 ON) -add_nng_test1(stats 5 NNG_ENABLE_STATS) add_nng_test(synch 5) add_nng_test(tls 60) add_nng_test(tcpsupp 10) diff --git a/tests/stats.c b/tests/stats.c deleted file mode 100644 index c42c129c..00000000 --- a/tests/stats.c +++ /dev/null @@ -1,74 +0,0 @@ -// -// Copyright 2021 Staysail Systems, Inc. -// Copyright 2018 Capitar IT Group BV -// -// 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 -#include - -#include "convey.h" -#include "stubs.h" -#include "trantest.h" - -#define SECONDS(x) ((x) *1000) - -TestMain("Stats Test", { - - Convey("We are able to open a PAIR socket", { - nng_socket s1; - - So(nng_pair_open(&s1) == 0); - - Reset({ nng_close(s1); }); - - Convey("We can send and receive messages", { - nng_socket s2; - int len; - size_t sz; - nng_duration to = SECONDS(3); - char * buf; - char * a = "inproc://stats"; - nng_stat * stats; - - So(nng_pair_open(&s2) == 0); - Reset({ nng_close(s2); }); - - So(nng_socket_set_int(s1, NNG_OPT_RECVBUF, 1) == 0); - So(nng_socket_get_int(s1, NNG_OPT_RECVBUF, &len) == 0); - So(len == 1); - - So(nng_socket_set_int(s1, NNG_OPT_SENDBUF, 1) == 0); - So(nng_socket_set_int(s2, NNG_OPT_SENDBUF, 1) == 0); - - So(nng_socket_set_ms(s1, NNG_OPT_SENDTIMEO, to) == 0); - So(nng_socket_set_ms(s1, NNG_OPT_RECVTIMEO, to) == 0); - So(nng_socket_set_ms(s2, NNG_OPT_SENDTIMEO, to) == 0); - So(nng_socket_set_ms(s2, NNG_OPT_RECVTIMEO, to) == 0); - - So(nng_listen(s1, a, NULL, 0) == 0); - So(nng_dial(s2, a, NULL, 0) == 0); - - So(nng_send(s1, "abc", 4, 0) == 0); - So(nng_recv(s2, &buf, &sz, NNG_FLAG_ALLOC) == 0); - So(buf != NULL); - So(sz == 4); - So(memcmp(buf, "abc", 4) == 0); - nng_free(buf, sz); - - Convey("We can collect stats", { - So(nng_stats_get(&stats) == 0); - nng_stats_dump(stats); - nng_stats_free(stats); - }); - }); - }); -}) -- cgit v1.2.3-70-g09d2