1 /*
2 * Copyright (c) 2023, Meta
3 * Copyright (c) 2024, Adam Wojasinski <awojasinski@baylibre.com>
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include <zephyr/ztest.h>
9
10 #include <zephyr/posix/unistd.h>
11
ZTEST(posix_single_process,test_posix_sysconf)12 ZTEST(posix_single_process, test_posix_sysconf)
13 {
14 long ret;
15
16 /* SC that's implemented */
17 ret = sysconf(_SC_VERSION);
18 zassert_equal(ret, _POSIX_VERSION, "sysconf returned unexpected value %d", ret);
19
20 /* SC that's not implemented */
21 ret = sysconf(_SC_MEMLOCK_RANGE);
22 zassert_equal(ret, -1, "sysconf returned unexpected value %d", ret);
23
24 /* SC that value depends on target's configuration */
25 ret = sysconf(_SC_SEMAPHORES);
26 if (IS_ENABLED(CONFIG_POSIX_THREADS)) {
27 zassert_equal(ret, _POSIX_VERSION, "sysconf returned unexpected value %d", ret);
28 } else {
29 zassert_equal(ret, -1L, "sysconf returned unexpected value %d", ret);
30 }
31 }
32