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 <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2024-04-15 10:14:13 -04:00 committed by Carles Cufí
parent cdb1193f3e
commit 6e7be16118
2 changed files with 36 additions and 0 deletions

View file

@ -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)

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 Tenstorrent AI ULC
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "_common.h"
#ifdef CONFIG_POSIX_API
#include <aio.h>
#else
#include <zephyr/posix/aio.h>
#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);
}
}