Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
bfec30b1
Commit
bfec30b1
authored
Mar 24, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: test_address_tipc is unnecessarily verbose
Solution: make use of custom Unity macros
parent
386de330
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
59 deletions
+16
-59
test_address_tipc.cpp
tests/test_address_tipc.cpp
+16
-59
No files found.
tests/test_address_tipc.cpp
View file @
bfec30b1
...
...
@@ -30,41 +30,21 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unity.h>
void
setUp
()
{
}
void
tearDown
()
{
}
SETUP_TEARDOWN_TESTCONTEXT
void
test_tipc_port_name_and_domain
()
{
void
*
ctx
=
zmq_ctx_new
();
TEST_ASSERT_NOT_NULL
(
ctx
);
// test Port Name addressing
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_REP
);
TEST_ASSERT_NOT_NULL
(
sb
);
int
rc
=
zmq_bind
(
sb
,
"tipc://{5560,0,0}"
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
void
*
sb
=
test_context_socket
(
ZMQ_REP
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_bind
(
sb
,
"tipc://{5560,0,0}"
));
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
TEST_ASSERT_NOT_NULL
(
sc
);
rc
=
zmq_connect
(
sc
,
"tipc://{5560,0}@0.0.0"
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
void
*
sc
=
test_context_socket
(
ZMQ_REQ
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
sc
,
"tipc://{5560,0}@0.0.0"
));
bounce
(
sb
,
sc
);
rc
=
zmq_close
(
sc
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
rc
=
zmq_close
(
sb
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
zmq_ctx_term
(
ctx
);
test_context_socket_close
(
sc
);
test_context_socket_close
(
sb
);
}
void
test_tipc_port_identity
()
...
...
@@ -72,14 +52,8 @@ void test_tipc_port_identity ()
char
endpoint
[
256
];
unsigned
int
z
,
c
,
n
,
ref
;
void
*
ctx
=
zmq_ctx_new
();
TEST_ASSERT_NOT_NULL
(
ctx
);
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_REP
);
TEST_ASSERT_NOT_NULL
(
sb
);
void
*
sc
=
zmq_socket
(
ctx
,
ZMQ_REQ
);
TEST_ASSERT_NOT_NULL
(
sc
);
void
*
sb
=
test_context_socket
(
ZMQ_REP
);
void
*
sc
=
test_context_socket
(
ZMQ_REQ
);
// Test binding to random Port Identity and
// test resolving assigned address, should return a properly formatted string
...
...
@@ -91,44 +65,27 @@ void test_tipc_port_identity ()
TEST_ASSERT_NOT_EQUAL_MESSAGE
(
0
,
ref
,
"tipc port number must not be 0 after random assignment"
);
rc
=
zmq_connect
(
sc
,
endpoint
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
sc
,
endpoint
));
bounce
(
sb
,
sc
);
rc
=
zmq_close
(
sc
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
rc
=
zmq_close
(
sb
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
zmq_ctx_term
(
ctx
);
test_context_socket_close
(
sc
);
test_context_socket_close
(
sb
);
}
void
test_tipc_bad_addresses
()
{
void
*
ctx
=
zmq_ctx_new
();
TEST_ASSERT_NOT_NULL
(
ctx
);
// Test Port Name addressing
void
*
sb
=
zmq_socket
(
ctx
,
ZMQ_REP
);
TEST_ASSERT_NOT_NULL
(
sb
);
void
*
sb
=
test_context_socket
(
ZMQ_REP
);
// Test binding to a fixed address, should fail
int
rc
=
zmq_bind
(
sb
,
"tipc://<1.2.3:123123>"
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
rc
);
TEST_ASSERT_EQUAL_INT
(
EINVAL
,
errno
);
TEST_ASSERT_FAILURE_ERRNO
(
EINVAL
,
zmq_bind
(
sb
,
"tipc://<1.2.3:123123>"
));
// Test connecting to random identity, should fail
rc
=
zmq_connect
(
sb
,
"tipc://<*>"
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
rc
);
TEST_ASSERT_EQUAL_INT
(
EINVAL
,
errno
);
TEST_ASSERT_FAILURE_ERRNO
(
EINVAL
,
zmq_connect
(
sb
,
"tipc://<*>"
));
// Clean up
rc
=
zmq_close
(
sb
);
TEST_ASSERT_EQUAL_INT
(
0
,
rc
);
zmq_ctx_term
(
ctx
);
test_context_socket_close
(
sb
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment