From 6e7be161189a80b37bbd67236bfeefab8883de59 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 15 Apr 2024 10:14:13 -0400 Subject: [PATCH] tests: posix: add tests for functions and structs in aio.h Add tests to ensure that the aio.h header exists, the structures are declared, and that the functions are present. Signed-off-by: Chris Friedt --- tests/posix/headers/CMakeLists.txt | 1 + tests/posix/headers/src/aio_h.c | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/posix/headers/src/aio_h.c diff --git a/tests/posix/headers/CMakeLists.txt b/tests/posix/headers/CMakeLists.txt index 16616d5885..f34002d6ce 100644 --- a/tests/posix/headers/CMakeLists.txt +++ b/tests/posix/headers/CMakeLists.txt @@ -6,3 +6,4 @@ project(posix_headers) FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) +target_compile_options(app PRIVATE -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L) diff --git a/tests/posix/headers/src/aio_h.c b/tests/posix/headers/src/aio_h.c new file mode 100644 index 0000000000..5888b83925 --- /dev/null +++ b/tests/posix/headers/src/aio_h.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Tenstorrent AI ULC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "_common.h" + +#ifdef CONFIG_POSIX_API +#include +#else +#include +#endif + +ZTEST(posix_headers, test_aio_h) +{ + zassert_not_equal(offsetof(struct aiocb, aio_fildes), -1); + zassert_not_equal(offsetof(struct aiocb, aio_offset), -1); + zassert_not_equal(offsetof(struct aiocb, aio_buf), -1); + zassert_not_equal(offsetof(struct aiocb, aio_nbytes), -1); + zassert_not_equal(offsetof(struct aiocb, aio_reqprio), -1); + zassert_not_equal(offsetof(struct aiocb, aio_sigevent), -1); + zassert_not_equal(offsetof(struct aiocb, aio_lio_opcode), -1); + + if (IS_ENABLED(CONFIG_POSIX_API)) { + zassert_not_null(aio_cancel); + zassert_not_null(aio_error); + zassert_not_null(aio_fsync); + zassert_not_null(aio_read); + zassert_not_null(aio_return); + zassert_not_null(aio_suspend); + zassert_not_null(aio_write); + zassert_not_null(lio_listio); + } +}