1 /*
2 * Copyright (c) 2020 Friedt Professional Engineering Services, Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #define _main_defined 1
8
9 #include "_main.h"
10
11 LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);
12
13 #include <zephyr/logging/log.h>
14 #include <zephyr/net/socket.h>
15 #include <zephyr/ztest.h>
16
17 static ZTEST_DMEM struct net_socketpair_fixture fixture;
setup(void)18 static void *setup(void)
19 {
20 k_thread_system_pool_assign(k_current_get());
21
22 return &fixture;
23 }
24
before(void * arg)25 static void before(void *arg)
26 {
27 struct net_socketpair_fixture *fixture = arg;
28
29 for (int i = 0; i < 2; ++i) {
30 if (fixture->sv[i] >= 0) {
31 fixture->sv[i] = -1;
32 }
33 }
34 zassert_ok(zsock_socketpair(AF_UNIX, SOCK_STREAM, 0, fixture->sv));
35 }
36
after(void * arg)37 static void after(void *arg)
38 {
39 struct net_socketpair_fixture *fixture = arg;
40
41 for (int i = 0; i < 2; ++i) {
42 if (fixture->sv[i] >= 0) {
43 zassert_ok(zsock_close(fixture->sv[i]));
44 fixture->sv[i] = -1;
45 }
46 }
47 }
48
49 ZTEST_SUITE(net_socketpair, NULL, setup, before, after, NULL);
50