From 02597f8edb4e5ec0f7e680b6f28e4959f8499c4b Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Wed, 5 Jul 2023 00:51:22 +0800 Subject: [PATCH] tests: posix: uname: add test add ztest for uname api Signed-off-by: Yong Cong Sin --- tests/posix/common/src/uname.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/posix/common/src/uname.c diff --git a/tests/posix/common/src/uname.c b/tests/posix/common/src/uname.c new file mode 100644 index 000000000000000..b414c78850aabbc --- /dev/null +++ b/tests/posix/common/src/uname.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 meta + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +ZTEST(posix_apis, test_posix_uname) +{ + int rc; + + rc = uname(NULL); + zassert_equal(rc, -1, "rc expected to be -1, but got %d", rc); + + struct utsname info; + + zassert_ok(uname(&info)); + zassert_ok(strncmp(info.sysname, "Zephyr", sizeof(info.sysname))); + zassert_ok(strncmp(info.machine, CONFIG_ARCH, sizeof(info.machine))); +}