Commit a4ea4e29 authored by Gaetan Perrot's avatar Gaetan Perrot Committed by Fabio Baltieri
Browse files

posix: Implement test for fdetach and fattach



Add tests for `fdetach()` and `fattach()`

signed-off-by: default avatarGaetan Perrot <gaetanperrotpro@gmail.com>
parent 6a5af7b5
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -18,4 +18,23 @@ ZTEST(stropts, test_putmsg)
	zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST(stropts, test_fdetach)
{
	char *path = NULL;
	int ret = fdetach(path);

	zassert_equal(ret, -1, "Expected return value -1, got %d", ret);
	zassert_equal(errno, ENOSYS, "Expected errno ENOSYS, got %d", errno);
}

ZTEST(stropts, test_fattach)
{
	char *path = NULL;
	int fd = -1;
	int ret = fattach(fd, path);

	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);
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ ZTEST(posix_headers, test_stropts_h)
{
	#ifdef CONFIG_POSIX_API
	zassert_not_null((void *)putmsg, "putmsg is null");
	zassert_not_null((void *)fdetach, "fdetach is null");
	zassert_not_null((void *)fattach, "fattach 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");