forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for implentation and header file. Signed-off-by: Abhinav Srivastava <[email protected]>
- Loading branch information
1 parent
8ce5f72
commit 42a2fb1
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2024 Abhinav Srivastava | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <zephyr/ztest.h> | ||
#include <stropts.h> | ||
#include <errno.h> | ||
|
||
ZTEST(stropts, test_putmsg) | ||
{ | ||
const struct strbuf *ctrl = NULL; | ||
const struct strbuf *data = NULL; | ||
int fd = -1; | ||
int ret = putmsg(fd, ctrl, data, 0); | ||
|
||
zassert_equal(ret, -1, "Expected return value -1, got %d", ret); | ||
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno); | ||
} | ||
|
||
ZTEST_SUITE(stropts, NULL, NULL, NULL, NULL, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <ztest.h> | ||
#include <zephyr/posix/stropts.h> | ||
#include <stropts.h> | ||
/** | ||
* @brief Test existence and basic functionality of stropts.h | ||
* | ||
* @see stropts.h | ||
*/ | ||
ZTEST(posix_headers, test_stropts_h) | ||
{ | ||
zassert_not_null((void *)putmsg, "putmsg is null"); | ||
|
||
zassert_true(sizeof(((struct strbuf *)0)->maxlen) > 0, "maxlen size is 0"); | ||
zassert_true(sizeof(((struct strbuf *)0)->len) > 0, "len size is 0"); | ||
zassert_true(sizeof(((struct strbuf *)0)->buf) > 0, "buf size is 0"); | ||
} | ||
|
||
void test_main(void) | ||
{ | ||
ztest_test_suite(posix_stropts_test, | ||
ztest_unit_test(test_stropts_h) | ||
); | ||
|
||
ztest_run_test_suite(posix_stropts_test); | ||
} |