Skip to content

Commit 5248587

Browse files
AbhinavMircarlescufi
authored andcommitted
posix: Add tests for stropts
Add tests, Fix config issues, Re-add Timer Signed-off-by: Abhinav Srivastava <[email protected]>
1 parent 93e9491 commit 5248587

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

include/zephyr/posix/stropts.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#ifndef ZEPHYR_INCLUDE_POSIX_STROPTS_H_
77
#define ZEPHYR_INCLUDE_POSIX_STROPTS_H_
8+
#define RS_HIPRI BIT(0)
89

910
#ifdef __cplusplus
1011
extern "C" {

lib/posix/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ zephyr_library_sources_ifdef(CONFIG_PTHREAD_RWLOCK rwlock.c)
5757
zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c)
5858
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c)
5959
zephyr_library_sources_ifdef(CONFIG_PTHREAD_SPINLOCK spinlock.c)
60+
zephyr_library_sources_ifdef(CONFIG_TIMER timer.c)
6061
zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c)
6162

6263
zephyr_library_include_directories(

tests/posix/common/src/stropts.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024 Abhinav Srivastava
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <zephyr/ztest.h>
7+
#include <stropts.h>
8+
#include <errno.h>
9+
10+
ZTEST(stropts, test_putmsg)
11+
{
12+
const struct strbuf *ctrl = NULL;
13+
const struct strbuf *data = NULL;
14+
int fd = -1;
15+
int ret = putmsg(fd, ctrl, data, 0);
16+
17+
zassert_equal(ret, -1, "Expected return value -1, got %d", ret);
18+
zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
19+
}
20+
21+
ZTEST_SUITE(stropts, NULL, NULL, NULL, NULL, NULL);

tests/posix/headers/src/stropts_h.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2024 Abhinav Srivastava
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include "_common.h"
7+
#ifdef CONFIG_POSIX_API
8+
#include <stropts.h>
9+
#else
10+
#include <zephyr/posix/stropts.h>
11+
#endif
12+
13+
/**
14+
* @brief Test existence and basic functionality of stropts.h
15+
*
16+
* @see stropts.h
17+
*/
18+
ZTEST(posix_headers, test_stropts_h)
19+
{
20+
#ifdef CONFIG_POSIX_API
21+
zassert_not_null((void *)putmsg, "putmsg is null");
22+
23+
zassert_true(sizeof(((struct strbuf *)0)->maxlen) > 0, "maxlen size is 0");
24+
zassert_true(sizeof(((struct strbuf *)0)->len) > 0, "len size is 0");
25+
zassert_true(sizeof(((struct strbuf *)0)->buf) > 0, "buf size is 0");
26+
zassert_not_equal(RS_HIPRI, ~RS_HIPRI);
27+
#endif
28+
}

0 commit comments

Comments
 (0)