From 2658eb151b0e33f406fd5272c0a96fad95a205fb Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 28 Feb 2023 17:36:29 +0100 Subject: [PATCH] tests: test the -EBUSY case for vfs_umount() --- .../unittests/tests-vfs/tests-vfs-file-system-ops.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unittests/tests-vfs/tests-vfs-file-system-ops.c b/tests/unittests/tests-vfs/tests-vfs-file-system-ops.c index 3dfd152067..8981d76bed 100644 --- a/tests/unittests/tests-vfs/tests-vfs-file-system-ops.c +++ b/tests/unittests/tests-vfs/tests-vfs-file-system-ops.c @@ -72,6 +72,7 @@ static void setup(void) static void teardown(void) { vfs_umount(&_test_vfs_mount_null, false); + atomic_store(&_test_vfs_mount_null.open_files, 0); } static void test_vfs_null_fs_ops_mount(void) @@ -92,6 +93,17 @@ static void test_vfs_null_fs_ops_umount(void) TEST_ASSERT_EQUAL_INT(-EINVAL, res); } +static void test_vfs_null_fs_ops_umount__EBUSY(void) +{ + TEST_ASSERT_EQUAL_INT(0, _test_vfs_fs_op_mount_res); + atomic_fetch_add(&_test_vfs_mount_null.open_files, 1); + int res = vfs_umount(&_test_vfs_mount_null, false); + TEST_ASSERT_EQUAL_INT(-EBUSY, res); + /* force unmount */ + res = vfs_umount(&_test_vfs_mount_null, true); + TEST_ASSERT_EQUAL_INT(0, res); +} + static void test_vfs_null_fs_ops_rename(void) { TEST_ASSERT_EQUAL_INT(0, _test_vfs_fs_op_mount_res); @@ -151,6 +163,7 @@ Test *tests_vfs_null_file_system_ops_tests(void) EMB_UNIT_TESTFIXTURES(fixtures) { new_TestFixture(test_vfs_null_fs_ops_mount), new_TestFixture(test_vfs_null_fs_ops_umount), + new_TestFixture(test_vfs_null_fs_ops_umount__EBUSY), new_TestFixture(test_vfs_null_fs_ops_rename), new_TestFixture(test_vfs_null_fs_ops_unlink), new_TestFixture(test_vfs_null_fs_ops_mkdir),