unittests/vfs: Add test for vfs_bind invalid FD argument
This commit is contained in:
parent
490e7c87e0
commit
85125d04ef
@ -107,11 +107,25 @@ static void test_vfs_bind__leak_fds(void)
|
||||
test_vfs_bind();
|
||||
}
|
||||
|
||||
static void test_vfs_bind__allocate_invalid_fd(void)
|
||||
{
|
||||
/* Check that fds >= VFS_MAX_OPEN_FILES fails with -ENFILE, to avoid out of
|
||||
* bounds array access */
|
||||
/* This test assumes FD numbering begins at 0, update this test if
|
||||
* VFS_MAX_OPEN_FILES is a valid fd number */
|
||||
int fd;
|
||||
fd = vfs_bind(VFS_MAX_OPEN_FILES, O_RDONLY, &_test_bind_ops, NULL);
|
||||
TEST_ASSERT_EQUAL_INT(-ENFILE, fd);
|
||||
fd = vfs_bind((VFS_MAX_OPEN_FILES + 1), O_RDONLY, &_test_bind_ops, NULL);
|
||||
TEST_ASSERT_EQUAL_INT(-ENFILE, fd);
|
||||
}
|
||||
|
||||
Test *tests_vfs_bind_tests(void)
|
||||
{
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_vfs_bind),
|
||||
new_TestFixture(test_vfs_bind__leak_fds),
|
||||
new_TestFixture(test_vfs_bind__allocate_invalid_fd),
|
||||
};
|
||||
|
||||
EMB_UNIT_TESTCALLER(vfs_bind_tests, NULL, NULL, fixtures);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user