From 838b38dadd00252c04fa5d548223b3a38062fe96 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Tue, 6 Nov 2007 13:08:12 +0200 Subject: fs-tests: add simple performance test Signed-off-by: Adrian Hunter --- tests/fs-tests/lib/tests.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/fs-tests/lib/tests.h | 6 ++++++ 2 files changed, 48 insertions(+) (limited to 'tests/fs-tests/lib') diff --git a/tests/fs-tests/lib/tests.c b/tests/fs-tests/lib/tests.c index 9b8f443..aaf3907 100644 --- a/tests/fs-tests/lib/tests.c +++ b/tests/fs-tests/lib/tests.c @@ -1002,6 +1002,48 @@ void tests_remount(void) CHECK(chdir(cwd) != -1); } +/* Un-mount or re-mount test file system */ +static void tests_mnt(int mnt) +{ + static struct mntent mount_info; + char *source; + char *target; + char *filesystemtype; + unsigned long mountflags; + void *data; + static char cwd[4096]; + + if (mnt == 0) { + CHECK(tests_get_mount_info(&mount_info)); + if (strcmp(mount_info.mnt_dir,"/") == 0) + return; + CHECK(getcwd(cwd, 4096) != NULL); + CHECK(chdir("/") != -1); + CHECK(umount(tests_file_system_mount_dir) != -1); + } else { + source = mount_info.mnt_fsname; + target = tests_file_system_mount_dir; + filesystemtype = tests_file_system_type; + mountflags = 0; + data = NULL; + CHECK(mount(source, target, filesystemtype, mountflags, data) + != -1); + CHECK(chdir(cwd) != -1); + } +} + +/* Unmount test file system */ +void tests_unmount(void) +{ + tests_mnt(0); +} + +/* Mount test file system */ +void tests_mount(void) +{ + tests_mnt(1); +} + /* Check whether the test file system is also the root file system */ int tests_fs_is_rootfs(void) { diff --git a/tests/fs-tests/lib/tests.h b/tests/fs-tests/lib/tests.h index db08628..04c834d 100644 --- a/tests/fs-tests/lib/tests.h +++ b/tests/fs-tests/lib/tests.h @@ -146,6 +146,12 @@ int64_t tests_remove_entry(void); /* Un-mount and re-mount test file system */ void tests_remount(void); +/* Un-mount test file system */ +void tests_unmount(void); + +/* Mount test file system */ +void tests_mount(void); + /* Check whether the test file system is also the root file system */ int tests_fs_is_rootfs(void); -- cgit v1.2.3