1 /* 2 * Copyright (c) 2023 Antmicro 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/ztest.h> 8 #include <zephyr/fs/fs.h> 9 10 #include "utils.h" 11 12 void test_fs_dirops(void); 13 14 /* Mount structure needed by test_fs_basic tests. */ 15 struct fs_mount_t *fs_dirops_test_mp = &testfs_mnt; 16 ZTEST(ext2tests,test_dirops)17ZTEST(ext2tests, test_dirops) 18 { 19 struct fs_mount_t *mp = &testfs_mnt; 20 struct fs_dirent de; 21 22 zassert_equal(fs_mount(mp), 0, "Mount failed"); 23 24 /* 'lost+found' directory is created automatically. test_fs_dirops expects empty root 25 * directory hence we have to remove it before starting test. 26 */ 27 if (fs_stat("/sml/lost+found", &de) == 0) { 28 zassert_equal(fs_unlink("/sml/lost+found"), 0, "unlink failed"); 29 } 30 zassert_equal(fs_unmount(mp), 0, "Unount failed"); 31 32 /* Common dirops tests. 33 * (File system is mounted and unmounted during that test.) 34 */ 35 test_fs_dirops(); 36 } 37