Skip to content

Commit

Permalink
posix: Tests for putmsg
Browse files Browse the repository at this point in the history
Add tests for implentation and header file.

Signed-off-by: Abhinav Srivastava <[email protected]>
  • Loading branch information
AbhinavMir committed Jan 26, 2024
1 parent 8ce5f72 commit 42a2fb1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/posix/common/src/stropts.c
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);
25 changes: 25 additions & 0 deletions tests/posix/headers/src/stropts_h.c
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);
}

0 comments on commit 42a2fb1

Please sign in to comment.