aboutsummaryrefslogtreecommitdiff
path: root/tests/compat_testutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compat_testutil.h')
-rw-r--r--tests/compat_testutil.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/compat_testutil.h b/tests/compat_testutil.h
index cac8d5a2..da9baaa9 100644
--- a/tests/compat_testutil.h
+++ b/tests/compat_testutil.h
@@ -3,7 +3,7 @@
Copyright 2017 Garrett D'Amore <garrett@damore.org>
Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
Copyright 2018 Capitar IT Group BV <info@capitar.com>
- Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+ Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -31,17 +31,16 @@
#ifndef COMPAT_TESTUTIL_H_INCLUDED
#define COMPAT_TESTUTIL_H_INCLUDED
-#include <assert.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define nn_err_strerror nn_strerror
#define nn_err_abort abort
-#define nn_assert assert
-#define errno_assert assert
-#define wsa_assert assert
-#define alloc_assert(x) assert((x) != NULL)
+#define errno_assert nn_assert
+#define wsa_assert nn_assert
+#define alloc_assert(x) nn_assert((x) != NULL)
#if defined __GNUC__ || defined __llvm__ || defined __clang__
#define NN_UNUSED __attribute__((unused))
@@ -49,6 +48,8 @@
#define NN_UNUSED
#endif
+#define nn_assert(x) nn_assert_impl(x, #x, __FILE__, __LINE__)
+
extern int test_socket_impl(char *file, int line, int family, int protocol);
extern int test_connect_impl(char *file, int line, int sock, char *address);
extern int test_bind_impl(char *file, int line, int sock, char *address);
@@ -57,11 +58,13 @@ extern void test_send_impl(char *file, int line, int sock, char *data);
extern void test_recv_impl(char *file, int line, int sock, char *data);
extern void test_drop_impl(char *file, int line, int sock, int err);
extern int test_setsockopt_impl(char *file, int line, int sock, int level,
- int option, const void *optval, size_t optlen);
-extern int get_test_port(int argc, const char *argv[]);
-extern void test_addr_from(char *out, const char *proto, const char *ip,
- int port);
+ int option, const void *optval, size_t optlen);
+extern int get_test_port(int argc, const char *argv[]);
+extern void test_addr_from(
+ char *out, const char *proto, const char *ip, int port);
extern void nn_sleep(int);
+extern void nn_assert_impl(
+ bool b, const char *expression, const char *file, int line);
#define test_socket(f, p) test_socket_impl(__FILE__, __LINE__, (f), (p))
#define test_connect(s, a) test_connect_impl(__FILE__, __LINE__, (s), (a))
@@ -77,7 +80,7 @@ struct nn_thread {
void *thr;
};
-extern int nn_thread_init(struct nn_thread *, void (*)(void *), void *);
+extern int nn_thread_init(struct nn_thread *, void (*)(void *), void *);
extern void nn_thread_term(struct nn_thread *);
#endif // COMPAT_TESTUTIL_H_INCLUDED