tests: posix: env: colocate with single_process option group
Move the previously singular env testsuite to be with the other features that are part of the POSIX_SINGLE_PROCESS Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
5f30744b28
commit
6aa760a4d9
11 changed files with 47 additions and 72 deletions
13
tests/posix/env/CMakeLists.txt
vendored
13
tests/posix/env/CMakeLists.txt
vendored
|
@ -1,13 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(posix_common)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
# For setenv() and unsetenv()
|
||||
target_compile_options(app PRIVATE -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L)
|
||||
# For getenv_r() visibility and testing
|
||||
target_compile_definitions(app PRIVATE _BSD_SOURCE)
|
6
tests/posix/env/prj.conf
vendored
6
tests/posix/env/prj.conf
vendored
|
@ -1,6 +0,0 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_POSIX_SINGLE_PROCESS=y
|
||||
# Let's explicitly choose PICOLIBC, so it is used if supported even if it would not have been the
|
||||
# default (otherwise native targets default to the host C library)
|
||||
CONFIG_PICOLIBC=y
|
||||
CONFIG_COMMON_LIBC_MALLOC=y
|
32
tests/posix/env/testcase.yaml
vendored
32
tests/posix/env/testcase.yaml
vendored
|
@ -1,32 +0,0 @@
|
|||
common:
|
||||
filter: not CONFIG_NATIVE_LIBC
|
||||
integration_platforms:
|
||||
- qemu_riscv64
|
||||
tags: posix
|
||||
tests:
|
||||
portability.posix.env:
|
||||
extra_configs:
|
||||
- CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=256
|
||||
portability.posix.env.armclang_std_libc:
|
||||
toolchain_allow: armclang
|
||||
extra_configs:
|
||||
- CONFIG_ARMCLANG_STD_LIBC=y
|
||||
portability.posix.env.arcmwdtlib:
|
||||
toolchain_allow: arcmwdt
|
||||
extra_configs:
|
||||
- CONFIG_ARCMWDT_LIBC=y
|
||||
portability.posix.env.minimal:
|
||||
extra_configs:
|
||||
- CONFIG_MINIMAL_LIBC=y
|
||||
- CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=256
|
||||
portability.posix.env.newlib:
|
||||
platform_exclude:
|
||||
- hifive1
|
||||
filter: TOOLCHAIN_HAS_NEWLIB == 1
|
||||
extra_configs:
|
||||
- CONFIG_NEWLIB_LIBC=y
|
||||
portability.posix.env.picolibc:
|
||||
tags: picolibc
|
||||
filter: CONFIG_PICOLIBC_SUPPORTED
|
||||
extra_configs:
|
||||
- CONFIG_PICOLIBC=y
|
|
@ -8,4 +8,7 @@ FILE(GLOB app_sources src/*.c)
|
|||
|
||||
target_sources(app PRIVATE ${app_sources})
|
||||
|
||||
# For setenv() and unsetenv()
|
||||
target_compile_options(app PRIVATE -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L)
|
||||
# For getenv_r() visibility and testing
|
||||
target_compile_definitions(app PRIVATE _BSD_SOURCE)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
CONFIG_POSIX_API=y
|
||||
CONFIG_ZTEST=y
|
||||
|
||||
CONFIG_POSIX_AEP_CHOICE_BASE=y
|
||||
CONFIG_POSIX_SINGLE_PROCESS=y
|
||||
|
||||
# Let's explicitly choose PICOLIBC, so it is used if supported even if it would not have been the
|
||||
# default (otherwise native targets default to the host C library)
|
||||
CONFIG_PICOLIBC=y
|
||||
CONFIG_COMMON_LIBC_MALLOC=y
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/posix/unistd.h>
|
||||
#include <zephyr/sys/util.h>
|
||||
|
||||
ZTEST(posix_single_process, test_confstr)
|
||||
|
|
|
@ -33,7 +33,7 @@ static DEFINE_ENVIRON(pwd, "PWD", M_PWD);
|
|||
|
||||
static char *environ_for_test[] = {home, uid, pwd, NULL};
|
||||
|
||||
ZTEST(env, test_getenv)
|
||||
ZTEST(posix_single_process, test_getenv)
|
||||
{
|
||||
zassert_equal(getenv(NULL), NULL);
|
||||
zassert_equal(getenv(""), NULL);
|
||||
|
@ -46,7 +46,7 @@ ZTEST(env, test_getenv)
|
|||
zassert_mem_equal(getenv("PWD"), M_PWD, strlen(M_PWD) + 1);
|
||||
}
|
||||
|
||||
ZTEST(env, test_getenv_r)
|
||||
ZTEST(posix_single_process, test_getenv_r)
|
||||
{
|
||||
static char buf[16];
|
||||
static const int exp_errno[] = {
|
||||
|
@ -74,8 +74,7 @@ ZTEST(env, test_getenv_r)
|
|||
|
||||
BUILD_ASSERT(ARRAY_SIZE(exp_errno) == ARRAY_SIZE(args));
|
||||
|
||||
ARRAY_FOR_EACH(args, i)
|
||||
{
|
||||
ARRAY_FOR_EACH(args, i) {
|
||||
errno = 0;
|
||||
zassert_equal(getenv_r(args[i].name, args[i].buf, args[i].size), -1,
|
||||
"getenv_r(\"%s\", %p, %zu): expected to fail", args[i].name,
|
||||
|
@ -90,7 +89,7 @@ ZTEST(env, test_getenv_r)
|
|||
zassert_mem_equal(getenv("PWD"), M_PWD, strlen(M_PWD) + 1);
|
||||
}
|
||||
|
||||
ZTEST(env, test_setenv)
|
||||
ZTEST(posix_single_process, test_setenv)
|
||||
{
|
||||
zassert_equal(setenv(NULL, NULL, 0), -1);
|
||||
zassert_equal(errno, EINVAL);
|
||||
|
@ -114,7 +113,7 @@ ZTEST(env, test_setenv)
|
|||
zassert_mem_equal(getenv("HOME"), "/root", strlen("/root") + 1);
|
||||
}
|
||||
|
||||
ZTEST(env, test_unsetenv)
|
||||
ZTEST(posix_single_process, test_unsetenv)
|
||||
{
|
||||
/* not hardened / application should fault */
|
||||
zassert_equal(unsetenv(NULL), -1);
|
||||
|
@ -137,7 +136,7 @@ ZTEST(env, test_unsetenv)
|
|||
zassert_is_null(getenv("HOME"));
|
||||
}
|
||||
|
||||
ZTEST(env, test_watertight)
|
||||
ZTEST(posix_single_process, test_watertight)
|
||||
{
|
||||
extern size_t posix_env_get_allocated_space(void);
|
||||
|
||||
|
@ -158,7 +157,7 @@ ZTEST(env, test_watertight)
|
|||
zassert_equal(posix_env_get_allocated_space(), 0);
|
||||
}
|
||||
|
||||
static void before(void *arg)
|
||||
void test_env_before(void)
|
||||
{
|
||||
old_environ = environ;
|
||||
|
||||
|
@ -172,9 +171,7 @@ static void before(void *arg)
|
|||
zassert_equal((environ = environ_for_test), environ_for_test);
|
||||
}
|
||||
|
||||
static void after(void *arg)
|
||||
void test_env_after(void)
|
||||
{
|
||||
environ = old_environ;
|
||||
}
|
||||
|
||||
ZTEST_SUITE(env, NULL, NULL, before, after, NULL);
|
|
@ -7,4 +7,17 @@
|
|||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST_SUITE(posix_single_process, NULL, NULL, NULL, NULL, NULL);
|
||||
void test_env_before(void);
|
||||
void test_env_after(void);
|
||||
|
||||
static void before(void *arg)
|
||||
{
|
||||
test_env_before();
|
||||
}
|
||||
|
||||
static void after(void *arg)
|
||||
{
|
||||
test_env_after();
|
||||
}
|
||||
|
||||
ZTEST_SUITE(posix_single_process, NULL, NULL, before, after, NULL);
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
*/
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <zephyr/posix/unistd.h>
|
||||
|
||||
ZTEST(posix_single_process, test_posix_sysconf)
|
||||
{
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <zephyr/posix/sys/utsname.h>
|
||||
#include <zephyr/posix/unistd.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST(posix_single_process, test_uname)
|
||||
|
|
|
@ -10,10 +10,21 @@ common:
|
|||
min_flash: 64
|
||||
min_ram: 32
|
||||
tests:
|
||||
portability.single_process: {}
|
||||
portability.posix.single_process:
|
||||
extra_configs:
|
||||
- CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=256
|
||||
portability.posix.single_process.armclang_std_libc:
|
||||
toolchain_allow: armclang
|
||||
extra_configs:
|
||||
- CONFIG_ARMCLANG_STD_LIBC=y
|
||||
portability.posix.single_process.arcmwdtlib:
|
||||
toolchain_allow: arcmwdt
|
||||
extra_configs:
|
||||
- CONFIG_ARCMWDT_LIBC=y
|
||||
portability.posix.single_process.minimal:
|
||||
extra_configs:
|
||||
- CONFIG_MINIMAL_LIBC=y
|
||||
- CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=256
|
||||
portability.posix.single_process.newlib:
|
||||
filter: TOOLCHAIN_HAS_NEWLIB == 1
|
||||
extra_configs:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue