lib: posix: add stubs for thread-safe grp & pwd functions
Create stubs for getpwnam_r, getpwuid_r, getgrgid_r & getgrnam_r. These functions are in the _POSIX_THREAD_SAFE_FUNCTIONS option group. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is contained in:
parent
b7ad4c53b0
commit
2ccfe8202d
8 changed files with 187 additions and 4 deletions
18
tests/posix/common/src/grp.c
Normal file
18
tests/posix/common/src/grp.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Meta Platforms
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST(grp, test_grp_stubs)
|
||||
{
|
||||
zassert_equal(getgrnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS);
|
||||
zassert_equal(getgrgid_r(42, NULL, NULL, 42, NULL), ENOSYS);
|
||||
}
|
||||
|
||||
ZTEST_SUITE(grp, NULL, NULL, NULL, NULL, NULL);
|
18
tests/posix/common/src/pwd.c
Normal file
18
tests/posix/common/src/pwd.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Meta Platforms
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
ZTEST(pwd, test_pwd_stubs)
|
||||
{
|
||||
zassert_equal(getpwnam_r(NULL, NULL, NULL, 42, NULL), ENOSYS);
|
||||
zassert_equal(getpwuid_r(42, NULL, NULL, 42, NULL), ENOSYS);
|
||||
}
|
||||
|
||||
ZTEST_SUITE(pwd, NULL, NULL, NULL, NULL, NULL);
|
Loading…
Add table
Add a link
Reference in a new issue