From 254c6711eda323adcb924b4433e7e8535663b389 Mon Sep 17 00:00:00 2001 From: Christopher Friedt Date: Thu, 12 Oct 2023 21:01:11 -0400 Subject: [PATCH] tests: posix: common: init check for stdin, stdout, and stderr Add a test to help ensure stdin, stdout, and stderr are initialized statically. Signed-off-by: Christopher Friedt --- tests/posix/common/src/_main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/posix/common/src/_main.c b/tests/posix/common/src/_main.c index 264b2e403f..cfec4adbd4 100644 --- a/tests/posix/common/src/_main.c +++ b/tests/posix/common/src/_main.c @@ -4,8 +4,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include - #include -ZTEST_SUITE(posix_apis, NULL, NULL, NULL, NULL, NULL); +extern bool fdtable_fd_is_initialized(int fd); + +static void *setup(void) +{ + /* ensure that the the stdin, stdout, and stderr fdtable entries are initialized */ + zassert_true(fdtable_fd_is_initialized(0)); + zassert_true(fdtable_fd_is_initialized(1)); + zassert_true(fdtable_fd_is_initialized(2)); + + return NULL; +} + +ZTEST_SUITE(posix_apis, NULL, setup, NULL, NULL, NULL);