The setting is deprecated so change the code to either use the native zsock_* API or enable POSIX_API to use the BSD socket API. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
/*
|
|
* Copyright (c) 2020 Friedt Professional Engineering Services, Inc
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "_main.h"
|
|
|
|
ZTEST_USER_F(net_socketpair, test_unsupported_calls)
|
|
{
|
|
int res;
|
|
struct sockaddr_un addr = {
|
|
.sun_family = AF_UNIX,
|
|
};
|
|
socklen_t len = sizeof(addr);
|
|
|
|
for (size_t i = 0; i < 2; ++i) {
|
|
|
|
res = zsock_bind(fixture->sv[i], (struct sockaddr *)&addr, len);
|
|
zassert_equal(res, -1,
|
|
"bind should fail on a socketpair endpoint");
|
|
zassert_equal(errno, EISCONN,
|
|
"bind should set errno to EISCONN");
|
|
|
|
res = zsock_connect(fixture->sv[i], (struct sockaddr *)&addr, len);
|
|
zassert_equal(res, -1,
|
|
"connect should fail on a socketpair endpoint");
|
|
zassert_equal(errno, EISCONN,
|
|
"connect should set errno to EISCONN");
|
|
|
|
res = zsock_listen(fixture->sv[i], 1);
|
|
zassert_equal(res, -1,
|
|
"listen should fail on a socketpair endpoint");
|
|
zassert_equal(errno, EINVAL,
|
|
"listen should set errno to EINVAL");
|
|
|
|
res = zsock_accept(fixture->sv[i], (struct sockaddr *)&addr, &len);
|
|
zassert_equal(res, -1,
|
|
"accept should fail on a socketpair endpoint");
|
|
zassert_equal(errno, EOPNOTSUPP,
|
|
"accept should set errno to EOPNOTSUPP");
|
|
}
|
|
}
|