mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-14 17:58:01 +08:00
Problem: no test for (invalid) too long ipc endpoint name
Solution: add test
This commit is contained in:
parent
90d5cf29d8
commit
2741e93361
@ -30,6 +30,8 @@
|
|||||||
#include "testutil.hpp"
|
#include "testutil.hpp"
|
||||||
#include "testutil_unity.hpp"
|
#include "testutil_unity.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
SETUP_TEARDOWN_TESTCONTEXT
|
SETUP_TEARDOWN_TESTCONTEXT
|
||||||
|
|
||||||
void test_roundtrip ()
|
void test_roundtrip ()
|
||||||
@ -48,11 +50,32 @@ void test_roundtrip ()
|
|||||||
test_context_socket_close (sb);
|
test_context_socket_close (sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char prefix[] = "ipc://";
|
||||||
|
|
||||||
|
void test_endpoint_too_long ()
|
||||||
|
{
|
||||||
|
std::string endpoint_too_long;
|
||||||
|
endpoint_too_long.append (prefix);
|
||||||
|
for (size_t i = 0; i < 108; ++i) {
|
||||||
|
endpoint_too_long.append ("a");
|
||||||
|
}
|
||||||
|
|
||||||
|
void *sb = test_context_socket (ZMQ_PAIR);
|
||||||
|
// TODO ENAMETOOLONG is not listed in the errors returned by zmq_bind,
|
||||||
|
// should this be EINVAL?
|
||||||
|
TEST_ASSERT_FAILURE_ERRNO (ENAMETOOLONG,
|
||||||
|
zmq_bind (sb, endpoint_too_long.data ()));
|
||||||
|
|
||||||
|
test_context_socket_close (sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
setup_test_environment ();
|
setup_test_environment ();
|
||||||
|
|
||||||
UNITY_BEGIN ();
|
UNITY_BEGIN ();
|
||||||
RUN_TEST (test_roundtrip);
|
RUN_TEST (test_roundtrip);
|
||||||
|
RUN_TEST (test_endpoint_too_long);
|
||||||
return UNITY_END ();
|
return UNITY_END ();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user