1 /*
2 * Copyright (c) 2020 Friedt Professional Engineering Services, Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "_main.h"
8
ZTEST_USER_F(net_socketpair,test_unsupported_calls)9 ZTEST_USER_F(net_socketpair, test_unsupported_calls)
10 {
11 int res;
12 struct sockaddr_un addr = {
13 .sun_family = AF_UNIX,
14 };
15 socklen_t len = sizeof(addr);
16
17 for (size_t i = 0; i < 2; ++i) {
18
19 res = zsock_bind(fixture->sv[i], (struct sockaddr *)&addr, len);
20 zassert_equal(res, -1,
21 "bind should fail on a socketpair endpoint");
22 zassert_equal(errno, EISCONN,
23 "bind should set errno to EISCONN");
24
25 res = zsock_connect(fixture->sv[i], (struct sockaddr *)&addr, len);
26 zassert_equal(res, -1,
27 "connect should fail on a socketpair endpoint");
28 zassert_equal(errno, EISCONN,
29 "connect should set errno to EISCONN");
30
31 res = zsock_listen(fixture->sv[i], 1);
32 zassert_equal(res, -1,
33 "listen should fail on a socketpair endpoint");
34 zassert_equal(errno, EINVAL,
35 "listen should set errno to EINVAL");
36
37 res = zsock_accept(fixture->sv[i], (struct sockaddr *)&addr, &len);
38 zassert_equal(res, -1,
39 "accept should fail on a socketpair endpoint");
40 zassert_equal(errno, EOPNOTSUPP,
41 "accept should set errno to EOPNOTSUPP");
42 }
43 }
44