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_fcntl)9 ZTEST_USER_F(net_socketpair, test_fcntl)
10 {
11 	int res;
12 	int flags;
13 
14 	res = fcntl(fixture->sv[0], F_GETFL, 0);
15 	zassert_not_equal(res, -1,
16 		"fcntl(fixture->sv[0], F_GETFL) failed. errno: %d", errno);
17 
18 	flags = res;
19 	zassert_equal(res & O_NONBLOCK, 0,
20 		"socketpair should block by default");
21 
22 	res = fcntl(fixture->sv[0], F_SETFL, flags | O_NONBLOCK);
23 	zassert_not_equal(res, -1,
24 		"fcntl(fixture->sv[0], F_SETFL, flags | O_NONBLOCK) failed. errno: %d",
25 		errno);
26 
27 	res = fcntl(fixture->sv[0], F_GETFL, 0);
28 	zassert_equal(res ^ flags, O_NONBLOCK, "expected O_NONBLOCK set");
29 }
30