MOS Source Code
Loading...
Searching...
No Matches
test_vfs.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
5#include "test_engine_impl.h"
6
7static void stat_receiver(int depth, const dentry_t *dentry, bool mountroot, void *data)
8{
9 MOS_UNUSED(data);
10 pr_info2("%*s%s: %zu%s", depth * 4, "", dentry_name(dentry), dentry->refcount, mountroot ? " (mountroot)" : "");
11}
12
13MOS_TEST_DECL_PTEST(vfs_mount_test, "Mount %s in %s, with rootfs: %d", const char *fs, const char *mountpoint, bool rootfs)
14{
15 long ok = false;
16
17 if (rootfs)
18 {
19 ok = vfs_mount("none", "/", "tmpfs", "");
20 MOS_TEST_ASSERT(ok == 0, "failed to mount tmpfs on /");
21 }
22
23 ok = vfs_mkdir(mountpoint);
24 MOS_TEST_ASSERT((ok == 0) == rootfs, "creating %s should %sbe successful", mountpoint, rootfs ? "" : "not");
26
27 ok = vfs_mount("none", mountpoint, fs, "");
28 MOS_TEST_ASSERT((ok == 0) == rootfs, "mounting %s on %s should %sbe successful", fs, mountpoint, rootfs ? "" : "not");
30
31 ok = vfs_unmount(mountpoint);
32 MOS_TEST_ASSERT((ok == 0) == rootfs, "unmounting /tmp should %sbe successful", rootfs ? "" : "not");
34
35 ok = vfs_rmdir(mountpoint);
36 MOS_TEST_ASSERT((ok == 0) == rootfs, "removing %s should %sbe successful", mountpoint, rootfs ? "" : "not");
38
39 if (rootfs)
40 {
41 ok = vfs_unmount("/");
42 MOS_TEST_ASSERT(ok == 0, "failed to unmount rootfs");
43 }
44}
45
46MOS_TEST_PTEST_INSTANCE(vfs_mount_test, "tmpfs", "/tmp", false);
47MOS_TEST_PTEST_INSTANCE(vfs_mount_test, "tmpfs", "/tmp", true);
void dentry_dump_refstat(const dentry_t *dentry, dump_refstat_receiver_t *receiver, void *receiver_data)
dentry_t * root_dentry
Definition vfs.c:36
long vfs_unmount(const char *path)
Unmount a filesystem at a given path.
Definition vfs.c:536
long vfs_rmdir(const char *path)
Definition vfs.c:689
long vfs_mount(const char *device, const char *path, const char *fs, const char *options)
Mount a filesystem at a given existing path.
Definition vfs.c:466
long vfs_mkdir(const char *path)
Create a directory.
Definition vfs.c:664
#define MOS_UNUSED(x)
Definition mos_global.h:64
#define NULL
Definition pb_syshdr.h:46
#define pr_info2(fmt,...)
Definition printk.h:36
atomic_t refcount
Definition vfs_types.h:116
#define MOS_TEST_DECL_PTEST(_PTestName, ptest_args_printf_format,...)
#define MOS_TEST_ASSERT(condition, format,...)
#define MOS_TEST_PTEST_INSTANCE(_PTestName,...)
static void stat_receiver(int depth, const dentry_t *dentry, bool mountroot, void *data)
Definition test_vfs.c:7
#define dentry_name(dentry)
Definition vfs_types.h:125