From 69e8152fc1d262625728e54e5b46c478a534711f Mon Sep 17 00:00:00 2001 From: Marvin Ouma Date: Tue, 5 Nov 2024 21:35:14 +0300 Subject: [PATCH] tests: posix: common: separate posix spinlock tests into standalone test posix.common contains testsuites that can be separated into smaller groups of tests. This change moves spinlock into a singular testsuite at tests/posix/spinlocks app directory. Signed-off-by: Marvin Ouma --- tests/posix/spinlocks/CMakeLists.txt | 9 ++++++ tests/posix/spinlocks/prj.conf | 5 ++++ .../src/spinlock.c => spinlocks/src/main.c} | 8 +++--- tests/posix/spinlocks/testcase.yaml | 28 +++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 tests/posix/spinlocks/CMakeLists.txt create mode 100644 tests/posix/spinlocks/prj.conf rename tests/posix/{common/src/spinlock.c => spinlocks/src/main.c} (92%) create mode 100644 tests/posix/spinlocks/testcase.yaml diff --git a/tests/posix/spinlocks/CMakeLists.txt b/tests/posix/spinlocks/CMakeLists.txt new file mode 100644 index 00000000000..66006e8c52f --- /dev/null +++ b/tests/posix/spinlocks/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(posix_spinlocks) + +target_sources(app PRIVATE src/main.c) + +target_compile_options(app PRIVATE -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L) diff --git a/tests/posix/spinlocks/prj.conf b/tests/posix/spinlocks/prj.conf new file mode 100644 index 00000000000..08f71929c7f --- /dev/null +++ b/tests/posix/spinlocks/prj.conf @@ -0,0 +1,5 @@ +CONFIG_POSIX_API=y +CONFIG_ZTEST=y + +CONFIG_POSIX_AEP_CHOICE_BASE=y +CONFIG_POSIX_SPIN_LOCKS=y diff --git a/tests/posix/common/src/spinlock.c b/tests/posix/spinlocks/src/main.c similarity index 92% rename from tests/posix/common/src/spinlock.c rename to tests/posix/spinlocks/src/main.c index 14072e729b4..40ac2de3900 100644 --- a/tests/posix/common/src/spinlock.c +++ b/tests/posix/spinlocks/src/main.c @@ -9,7 +9,7 @@ #include #include -ZTEST(spinlock, test_spin_init_destroy) +ZTEST(posix_spinlocks, test_spin_init_destroy) { pthread_spinlock_t lock; @@ -24,7 +24,7 @@ ZTEST(spinlock, test_spin_init_destroy) zassert_ok(pthread_spin_destroy(&lock), "pthread_spin_destroy() failed"); } -ZTEST(spinlock, test_spin_descriptor_leak) +ZTEST(posix_spinlocks, test_spin_descriptor_leak) { pthread_spinlock_t lock[CONFIG_MAX_PTHREAD_SPINLOCK_COUNT]; @@ -47,7 +47,7 @@ ZTEST(spinlock, test_spin_descriptor_leak) } } -ZTEST(spinlock, test_spin_lock_unlock) +ZTEST(posix_spinlocks, test_spin_lock_unlock) { pthread_spinlock_t lock; @@ -70,4 +70,4 @@ ZTEST(spinlock, test_spin_lock_unlock) zassert_equal(pthread_spin_destroy(&lock), EINVAL, "pthread_spin_unlock() did not fail"); } -ZTEST_SUITE(spinlock, NULL, NULL, NULL, NULL, NULL); +ZTEST_SUITE(posix_spinlocks, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/posix/spinlocks/testcase.yaml b/tests/posix/spinlocks/testcase.yaml new file mode 100644 index 00000000000..c11e0092efc --- /dev/null +++ b/tests/posix/spinlocks/testcase.yaml @@ -0,0 +1,28 @@ +common: + filter: not CONFIG_NATIVE_LIBC + tags: + - posix + - spinlocks + # 1 tier0 platform per supported architecture + platform_key: + - arch + - simulation + min_flash: 64 + min_ram: 32 +tests: + portability.posix.spinlocks: {} + portability.posix.spinlocks.minimal: + extra_configs: + - CONFIG_MINIMAL_LIBC=y + portability.posix.spinlocks.newlib: + filter: TOOLCHAIN_HAS_NEWLIB == 1 + extra_configs: + - CONFIG_NEWLIB_LIBC=y + portability.posix.spinlocks.picolibc: + tags: picolibc + filter: CONFIG_PICOLIBC_SUPPORTED + extra_configs: + - CONFIG_PICOLIBC=y + portability.posix.spinlocks.no_spin_validate: + extra_configs: + - CONFIG_SPIN_VALIDATE=n