Skip to content

Commit

Permalink
tests: fdtable: check for negative fd
Browse files Browse the repository at this point in the history
Check for negative file descriptor.

Fixes #18448
Fixes #18450
Fixes #18449
Fixes #18451

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif committed Dec 2, 2019
1 parent 42c5b0a commit afe5b25
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/lib/fdtable/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void test_z_reserve_fd(void)
{
int fd = z_reserve_fd(); /* function being tested */

zassert_equal(fd >= 0, true, "fd < 0");
zassert_true(fd >= 0, "fd < 0");

z_free_fd(fd);
}
Expand All @@ -23,6 +23,7 @@ void test_z_get_fd_obj_and_vtable(void)
const struct fd_op_vtable *vtable;

int fd = z_reserve_fd();
zassert_true(fd >= 0, "fd < 0");

int *obj;
obj = z_get_fd_obj_and_vtable(fd, &vtable); /* function being tested */
Expand All @@ -35,6 +36,8 @@ void test_z_get_fd_obj_and_vtable(void)
void test_z_get_fd_obj(void)
{
int fd = z_reserve_fd();
zassert_true(fd >= 0, "fd < 0");

int err = -1;
const struct fd_op_vtable *vtable = 0;
const struct fd_op_vtable *vtable2 = vtable+1;
Expand Down Expand Up @@ -64,6 +67,8 @@ void test_z_finalize_fd(void)
const struct fd_op_vtable *vtable;

int fd = z_reserve_fd();
zassert_true(fd >= 0, NULL);

int *obj = z_get_fd_obj_and_vtable(fd, &vtable);

const struct fd_op_vtable *original_vtable = vtable;
Expand All @@ -85,6 +90,7 @@ void test_z_alloc_fd(void)
int *obj = NULL;

int fd = z_alloc_fd(obj, vtable); /* function being tested */
zassert_true(fd >= 0, NULL);

obj = z_get_fd_obj_and_vtable(fd, &vtable);

Expand All @@ -99,6 +105,7 @@ void test_z_free_fd(void)
const struct fd_op_vtable *vtable = NULL;

int fd = z_reserve_fd();
zassert_true(fd >= 0, NULL);

z_free_fd(fd); /* function being tested */

Expand Down

0 comments on commit afe5b25

Please sign in to comment.