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
7ad0ff5e
Commit
7ad0ff5e
authored
Aug 20, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: test_stream_empty not yet using unity
Solution: migrate to unity
parent
7b39d2cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
34 deletions
+39
-34
Makefile.am
Makefile.am
+2
-1
test_stream_empty.cpp
tests/test_stream_empty.cpp
+37
-33
No files found.
Makefile.am
View file @
7ad0ff5e
...
...
@@ -547,7 +547,8 @@ tests_test_stream_SOURCES = tests/test_stream.cpp
tests_test_stream_LDADD
=
src/libzmq.la
tests_test_stream_empty_SOURCES
=
tests/test_stream_empty.cpp
tests_test_stream_empty_LDADD
=
src/libzmq.la
tests_test_stream_empty_LDADD
=
src/libzmq.la
${
UNITY_LIBS
}
tests_test_stream_empty_CPPFLAGS
=
${
UNITY_CPPFLAGS
}
tests_test_stream_timeout_SOURCES
=
tests/test_stream_timeout.cpp
tests_test_stream_timeout_LDADD
=
src/libzmq.la
...
...
tests/test_stream_empty.cpp
View file @
7ad0ff5e
...
...
@@ -28,48 +28,52 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
int
main
(
void
)
void
setUp
()
{
setup_test_context
();
}
void
tearDown
()
{
teardown_test_context
();
}
void
test_stream_empty
()
{
setup_test_environment
();
size_t
len
=
MAX_SOCKET_STRING
;
char
my_endpoint
[
MAX_SOCKET_STRING
];
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
stream
=
zmq_socket
(
ctx
,
ZMQ_STREAM
);
assert
(
stream
);
void
*
dealer
=
zmq_socket
(
ctx
,
ZMQ_DEALER
);
assert
(
dealer
);
int
rc
=
zmq_bind
(
stream
,
"tcp://127.0.0.1:*"
);
assert
(
rc
>=
0
);
rc
=
zmq_getsockopt
(
stream
,
ZMQ_LAST_ENDPOINT
,
my_endpoint
,
&
len
);
assert
(
rc
==
0
);
rc
=
zmq_connect
(
dealer
,
my_endpoint
);
assert
(
rc
>=
0
);
zmq_send
(
dealer
,
""
,
0
,
0
);
void
*
stream
=
test_context_socket
(
ZMQ_STREAM
);
void
*
dealer
=
test_context_socket
(
ZMQ_DEALER
);
bind_loopback_ipv4
(
stream
,
my_endpoint
,
sizeof
my_endpoint
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_connect
(
dealer
,
my_endpoint
));
send_string_expect_success
(
dealer
,
""
,
0
);
zmq_msg_t
ident
,
empty
;
zmq_msg_init
(
&
ident
);
rc
=
zmq_msg_recv
(
&
ident
,
stream
,
0
);
assert
(
rc
>=
0
);
rc
=
zmq_msg_init_data
(
&
empty
,
(
void
*
)
""
,
0
,
NULL
,
NULL
);
assert
(
rc
>=
0
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_recv
(
&
ident
,
stream
,
0
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_init_data
(
&
empty
,
(
void
*
)
""
,
0
,
NULL
,
NULL
));
rc
=
zmq_msg_send
(
&
ident
,
stream
,
ZMQ_SNDMORE
);
assert
(
rc
>=
0
);
rc
=
zmq_msg_close
(
&
ident
);
assert
(
rc
>=
0
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_send
(
&
ident
,
stream
,
ZMQ_SNDMORE
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_close
(
&
ident
));
rc
=
zmq_msg_send
(
&
empty
,
stream
,
0
);
assert
(
rc
>=
0
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_send
(
&
empty
,
stream
,
0
));
// This close used to fail with Bad Address
rc
=
zmq_msg_close
(
&
empty
);
assert
(
rc
>=
0
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_msg_close
(
&
empty
));
test_context_socket_close_zero_linger
(
dealer
);
test_context_socket_close_zero_linger
(
stream
);
}
int
main
()
{
setup_test_environment
();
close_zero_linger
(
dealer
);
close_zero_linger
(
stream
);
zmq_ctx_term
(
ctx
);
UNITY_BEGIN
(
);
RUN_TEST
(
test_stream_empty
);
return
UNITY_END
(
);
}
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