Skip to content

Commit

Permalink
tests: posix: use standard headers and canonical order
Browse files Browse the repository at this point in the history
The POSIX testsuite should be run with standard POSIX
header locations.

Additionally, reorder headers to follow the recommendation
in #41543.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
  • Loading branch information
cfriedt committed Jul 6, 2023
1 parent 7f3c970 commit 85110ad
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 27 deletions.
3 changes: 2 additions & 1 deletion tests/posix/common/src/_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <pthread.h>

#include <zephyr/ztest.h>

ZTEST_SUITE(posix_apis, NULL, NULL, NULL, NULL, NULL);
7 changes: 4 additions & 3 deletions tests/posix/common/src/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

#include <zephyr/ztest.h>
#include <zephyr/posix/time.h>
#include <zephyr/posix/sys/time.h>
#include <zephyr/posix/unistd.h>

#define SLEEP_SECONDS 1
#define CLOCK_INVALID -1
Expand Down
4 changes: 2 additions & 2 deletions tests/posix/common/src/cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>

#include <pthread.h>

#include <zephyr/ztest.h>

/**
* @brief Test to demonstrate limited condition variable resources
*
Expand Down
3 changes: 2 additions & 1 deletion tests/posix/common/src/fnmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/posix/fnmatch.h>
#include <fnmatch.h>

#include <zephyr/ztest.h>

/*
Expand Down
4 changes: 2 additions & 2 deletions tests/posix/common/src/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <pthread.h>

#include <zephyr/sys/util.h>
#include <zephyr/ztest.h>

#define N_THR 2
#define N_KEY 2
Expand Down
7 changes: 3 additions & 4 deletions tests/posix/common/src/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <fcntl.h>
#include <zephyr/sys/util.h>
#include <mqueue.h>
#include <pthread.h>

#include <zephyr/sys/util.h>
#include <zephyr/ztest.h>

#define N_THR 2
#define STACKSZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
#define SENDER_THREAD 0
Expand Down
7 changes: 3 additions & 4 deletions tests/posix/common/src/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
*/

#include <errno.h>
#include <pthread.h>

#include <zephyr/ztest.h>

#include <pthread.h>

#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

static K_THREAD_STACK_DEFINE(stack, STACK_SIZE);
Expand Down Expand Up @@ -56,7 +55,7 @@ void *recursive_mutex_entry(void *p1)
* and pthread_mutex_lock are tested with mutex type being
* normal.
*/
ZTEST(posix_apis, test_normal_mutex)
ZTEST(posix_apis, test_mutex_normal)
{
pthread_t thread_1;
pthread_attr_t attr;
Expand Down Expand Up @@ -112,7 +111,7 @@ ZTEST(posix_apis, test_normal_mutex)
* twice and unlocked for the same number of time.
*
*/
ZTEST(posix_apis, test_recursive_mutex)
ZTEST(posix_apis, test_mutex_recursive)
{
pthread_t thread_2;
pthread_attr_t attr2;
Expand Down
5 changes: 3 additions & 2 deletions tests/posix/common/src/nanosleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <errno.h>
#include <zephyr/posix/time.h>
#include <stdint.h>
#include <time.h>

#include <zephyr/sys_clock.h>
#include <zephyr/ztest.h>

/** req and rem are both NULL */
ZTEST(posix_apis, test_nanosleep_NULL_NULL)
Expand Down
6 changes: 3 additions & 3 deletions tests/posix/common/src/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <zephyr/kernel.h>
#include <pthread.h>
#include <semaphore.h>

#include <zephyr/sys/util.h>
#include <zephyr/ztest.h>

#ifndef min
#define min(a, b) ((a) < (b)) ? (a) : (b)
Expand Down Expand Up @@ -411,7 +411,7 @@ ZTEST(posix_apis, test_pthread_execution)
printk("Barrier test OK\n");
}

ZTEST(posix_apis, test_pthread_error_condition)
ZTEST(posix_apis, test_pthread_errors_errno)
{
pthread_attr_t attr;
struct sched_param param;
Expand Down
5 changes: 3 additions & 2 deletions tests/posix/common/src/rwlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <pthread.h>

#include <zephyr/sys/util.h>
#include <zephyr/ztest.h>

#define N_THR 3
#define STACKSZ (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
Expand Down Expand Up @@ -53,7 +54,7 @@ static void *thread_top(void *p1)
return NULL;
}

ZTEST(posix_apis, test_posix_rw_lock)
ZTEST(posix_apis, test_rw_lock)
{
int32_t i, ret;
pthread_attr_t attr[N_THR];
Expand Down
3 changes: 2 additions & 1 deletion tests/posix/common/src/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>

#include <zephyr/ztest.h>

#define STACK_SIZE 1024

sem_t sema;
Expand Down
3 changes: 2 additions & 1 deletion tests/posix/common/src/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/posix/unistd.h>
#include <unistd.h>

#include <zephyr/ztest.h>

struct waker_work {
Expand Down
3 changes: 2 additions & 1 deletion tests/posix/common/src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/ztest.h>
#include <time.h>
#include <unistd.h>

#include <zephyr/ztest.h>

#define SECS_TO_SLEEP 2
#define DURATION_SECS 1
#define DURATION_NSECS 0
Expand Down

0 comments on commit 85110ad

Please sign in to comment.