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
3
#include "
mos/filesystem/dentry.h
"
4
#include "
mos/filesystem/vfs.h
"
5
#include "
test_engine_impl.h
"
6
7
static
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
13
MOS_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"
);
25
dentry_dump_refstat
(
root_dentry
,
stat_receiver
,
NULL
);
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"
);
29
dentry_dump_refstat
(
root_dentry
,
stat_receiver
,
NULL
);
30
31
ok =
vfs_unmount
(mountpoint);
32
MOS_TEST_ASSERT
((ok == 0) == rootfs,
"unmounting /tmp should %sbe successful"
, rootfs ?
""
:
"not"
);
33
dentry_dump_refstat
(
root_dentry
,
stat_receiver
,
NULL
);
34
35
ok =
vfs_rmdir
(mountpoint);
36
MOS_TEST_ASSERT
((ok == 0) == rootfs,
"removing %s should %sbe successful"
, mountpoint, rootfs ?
""
:
"not"
);
37
dentry_dump_refstat
(
root_dentry
,
stat_receiver
,
NULL
);
38
39
if
(rootfs)
40
{
41
ok =
vfs_unmount
(
"/"
);
42
MOS_TEST_ASSERT
(ok == 0,
"failed to unmount rootfs"
);
43
}
44
}
45
46
MOS_TEST_PTEST_INSTANCE
(vfs_mount_test,
"tmpfs"
,
"/tmp"
,
false
);
47
MOS_TEST_PTEST_INSTANCE
(vfs_mount_test,
"tmpfs"
,
"/tmp"
,
true
);
dentry.h
dentry_dump_refstat
void dentry_dump_refstat(const dentry_t *dentry, dump_refstat_receiver_t *receiver, void *receiver_data)
Definition
dentry_utils.c:85
root_dentry
dentry_t * root_dentry
Definition
vfs.c:36
vfs_unmount
long vfs_unmount(const char *path)
Unmount a filesystem at a given path.
Definition
vfs.c:536
vfs_rmdir
long vfs_rmdir(const char *path)
Definition
vfs.c:689
vfs_mount
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
vfs_mkdir
long vfs_mkdir(const char *path)
Create a directory.
Definition
vfs.c:664
MOS_UNUSED
#define MOS_UNUSED(x)
Definition
mos_global.h:64
NULL
#define NULL
Definition
pb_syshdr.h:46
pr_info2
#define pr_info2(fmt,...)
Definition
printk.h:36
dentry_t
Definition
vfs_types.h:113
dentry_t::refcount
atomic_t refcount
Definition
vfs_types.h:116
test_engine_impl.h
MOS_TEST_DECL_PTEST
#define MOS_TEST_DECL_PTEST(_PTestName, ptest_args_printf_format,...)
Definition
test_engine_impl.h:62
MOS_TEST_ASSERT
#define MOS_TEST_ASSERT(condition, format,...)
Definition
test_engine_impl.h:118
MOS_TEST_PTEST_INSTANCE
#define MOS_TEST_PTEST_INSTANCE(_PTestName,...)
Definition
test_engine_impl.h:66
stat_receiver
static void stat_receiver(int depth, const dentry_t *dentry, bool mountroot, void *data)
Definition
test_vfs.c:7
vfs.h
dentry_name
#define dentry_name(dentry)
Definition
vfs_types.h:125
kernel
tests
vfs
test_vfs.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0