diff options
Diffstat (limited to 'tests/fs-tests')
-rw-r--r-- | tests/fs-tests/Makemodule.am | 42 | ||||
-rwxr-xr-x | tests/fs-tests/fs_help_all.sh.in | 6 | ||||
-rwxr-xr-x | tests/fs-tests/fs_run_all.sh.in | 6 | ||||
-rw-r--r-- | tests/fs-tests/integrity/integck.c | 285 | ||||
-rw-r--r-- | tests/fs-tests/lib/tests.c | 1 | ||||
-rwxr-xr-x | tests/fs-tests/stress/fs_stress00.sh.in | 6 | ||||
-rwxr-xr-x | tests/fs-tests/stress/fs_stress01.sh.in | 6 |
7 files changed, 148 insertions, 204 deletions
diff --git a/tests/fs-tests/Makemodule.am b/tests/fs-tests/Makemodule.am index 2eae860..0c58c9c 100644 --- a/tests/fs-tests/Makemodule.am +++ b/tests/fs-tests/Makemodule.am @@ -3,84 +3,76 @@ integck_LDADD = libubi.a libmissing.a integck_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/ubi-utils/include test_1_SOURCES = tests/fs-tests/simple/test_1.c tests/fs-tests/lib/tests.c +test_1_SOURCES += tests/fs-tests/lib/tests.h test_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib test_2_SOURCES = tests/fs-tests/simple/test_2.c tests/fs-tests/lib/tests.c +test_2_SOURCES += tests/fs-tests/lib/tests.h test_2_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib ftrunc_SOURCES = tests/fs-tests/simple/ftrunc.c tests/fs-tests/lib/tests.c +ftrunc_SOURCES += tests/fs-tests/lib/tests.h ftrunc_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib perf_SOURCES = tests/fs-tests/simple/perf.c tests/fs-tests/lib/tests.c +perf_SOURCES += tests/fs-tests/lib/tests.h perf_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib orph_SOURCES = tests/fs-tests/simple/orph.c tests/fs-tests/lib/tests.c +orph_SOURCES += tests/fs-tests/lib/tests.h orph_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_1_SOURCES = tests/fs-tests/stress/atoms/stress_1.c -stress_1_SOURCES += tests/fs-tests/lib/tests.c +stress_1_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_1_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_2_SOURCES = tests/fs-tests/stress/atoms/stress_2.c -stress_2_SOURCES += tests/fs-tests/lib/tests.c +stress_2_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_2_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib stress_3_SOURCES = tests/fs-tests/stress/atoms/stress_3.c -stress_3_SOURCES += tests/fs-tests/lib/tests.c +stress_3_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h stress_3_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib pdfrun_SOURCES = tests/fs-tests/stress/atoms/pdfrun.c -pdfrun_SOURCES += tests/fs-tests/lib/tests.c +pdfrun_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h pdfrun_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndwrite00_SOURCES = tests/fs-tests/stress/atoms/rndwrite00.c -rndwrite00_SOURCES += tests/fs-tests/lib/tests.c +rndwrite00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndwrite00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib fwrite00_SOURCES = tests/fs-tests/stress/atoms/fwrite00.c -fwrite00_SOURCES += tests/fs-tests/lib/tests.c +fwrite00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h fwrite00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rmdir00_SOURCES = tests/fs-tests/stress/atoms/rmdir00.c -rmdir00_SOURCES += tests/fs-tests/lib/tests.c +rmdir00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rmdir00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndrm00_SOURCES = tests/fs-tests/stress/atoms/rndrm00.c -rndrm00_SOURCES += tests/fs-tests/lib/tests.c +rndrm00_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndrm00_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib rndrm99_SOURCES = tests/fs-tests/stress/atoms/rndrm99.c -rndrm99_SOURCES += tests/fs-tests/lib/tests.c +rndrm99_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h rndrm99_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib gcd_hupper_SOURCES = tests/fs-tests/stress/atoms/gcd_hupper.c -gcd_hupper_SOURCES += tests/fs-tests/lib/tests.c +gcd_hupper_SOURCES += tests/fs-tests/lib/tests.c tests/fs-tests/lib/tests.h gcd_hupper_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/tests/fs-tests/lib fstest_monitor_SOURCES = tests/fs-tests/utils/fstest_monitor.c free_space_SOURCES = tests/fs-tests/utils/free_space.c -FSTEST_BINS = \ +test_PROGRAMS += \ integck test_1 test_2 ftrunc perf orph \ stress_1 stress_2 stress_3 pdfrun gcd_hupper \ rndwrite00 fwrite00 rmdir00 rndrm00 rndrm99 \ fstest_monitor free_space -FSTEST_SH = \ +test_SCRIPTS += \ tests/fs-tests/fs_help_all.sh tests/fs-tests/fs_run_all.sh \ tests/fs-tests/stress/fs_stress00.sh \ tests/fs-tests/stress/fs_stress01.sh - -FSTEST_HEADER = \ - tests/fs-tests/lib/tests.h - -EXTRA_DIST += $(FSTEST_HEADER) - -if INSTALL_TESTS -pkglibexec_SCRIPTS += $(FSTEST_SH) -pkglibexec_PROGRAMS += $(FSTEST_BINS) -else -noinst_SCRIPTS += $(FSTEST_SH) -noinst_PROGRAMS += $(FSTEST_BINS) -endif diff --git a/tests/fs-tests/fs_help_all.sh.in b/tests/fs-tests/fs_help_all.sh.in index 39219b2..3898fbd 100755 --- a/tests/fs-tests/fs_help_all.sh.in +++ b/tests/fs-tests/fs_help_all.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ echo ------------------------------------------------------------------------------- $TESTBINDIR/test_1 -h diff --git a/tests/fs-tests/fs_run_all.sh.in b/tests/fs-tests/fs_run_all.sh.in index a3676f9..f15a63b 100755 --- a/tests/fs-tests/fs_run_all.sh.in +++ b/tests/fs-tests/fs_run_all.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 0a7f142..4a6ef16 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -2577,6 +2577,122 @@ static int rm_minus_rf_dir(const char *dir_name) return 0; } +/* + * Detach the MTD device from UBI and attach it back. This function is used + * whed performing emulated power cut testing andthe power cuts are amulated by + * UBI, not by UBIFS. In this case, to recover from the emulated power cut we + * have to unmount UBIFS and re-attach the MTD device. + */ +static int reattach(void) +{ + int err = 0; + libubi_t libubi; + struct ubi_attach_request req; + + libubi = libubi_open(); + if (!libubi) { + if (errno == 0) + return errmsg("UBI is not present in the system"); + return sys_errmsg("cannot open libubi"); + } + + err = ubi_detach_mtd(libubi, "/dev/ubi_ctrl", args.mtdn); + if (err) { + sys_errmsg("cannot detach mtd%d", args.mtdn); + goto out; + } + + req.dev_num = UBI_DEV_NUM_AUTO; + req.mtd_num = args.mtdn; + req.vid_hdr_offset = 0; + req.mtd_dev_node = NULL; + req.max_beb_per1024 = 0; + + err = ubi_attach(libubi, "/dev/ubi_ctrl", &req); + if (err) + sys_errmsg("cannot attach mtd%d", args.mtdn); + +out: + libubi_close(libubi); + return err; +} + +/** + * Unmount and mount back the test file-system. + */ +static int umount_and_remount(int mounted, int reatt, int um_rorw) +{ + int ret = 0; + unsigned long flags; + + if (mounted) + CHECK(umount(fsinfo.mount_point) != -1); + + if (reatt) + CHECK(reattach() == 0); + + if (!um_rorw) { + ret = mount(fsinfo.fsdev, fsinfo.mount_point, + fsinfo.fstype, fsinfo.mount_flags, + fsinfo.mount_opts); + if (ret) { + pcv("unmounted %s, but cannot mount it back R/W", + fsinfo.mount_point); + return -1; + } + } else { + ret = mount(fsinfo.fsdev, fsinfo.mount_point, + fsinfo.fstype, fsinfo.mount_flags | MS_RDONLY, + fsinfo.mount_opts); + if (ret) { + pcv("unmounted %s, but cannot mount it back R/O", + fsinfo.mount_point); + return -1; + } + + flags = fsinfo.mount_flags | MS_REMOUNT; + flags &= ~((unsigned long)MS_RDONLY); + ret = mount(fsinfo.fsdev, fsinfo.mount_point, + fsinfo.fstype, flags, fsinfo.mount_opts); + if (ret) { + pcv("unmounted %s, mounted R/O, but cannot re-mount it R/W", + fsinfo.mount_point); + return -1; + } + } + + return 0; +} + +/** + * Remount the test file-system RO first, then RW. + */ +static int remount_ro_rw(const char *tries) +{ + int ret; + unsigned long flags; + + flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT; + ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, + flags, fsinfo.mount_opts); + if (ret) { + pcv("cannot remount %s R/O%s", tries, fsinfo.mount_point); + return -1; + } + + flags = fsinfo.mount_flags | MS_REMOUNT; + flags &= ~((unsigned long)MS_RDONLY); + ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, + flags, fsinfo.mount_opts); + if (ret) { + pcv("remounted %s R/O%s, but cannot re-mount it R/W", + tries, fsinfo.mount_point); + return -1; + } + + return 0; +} + /** * Re-mount the test file-system. This function randomly select how to * re-mount. @@ -2601,24 +2717,9 @@ static int remount_tested_fs(void) um = 1; if (rorw1) { - flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT; - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("cannot remount %s R/O (1)", - fsinfo.mount_point); - return -1; - } - - flags = fsinfo.mount_flags | MS_REMOUNT; - flags &= ~((unsigned long)MS_RDONLY); - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("remounted %s R/O (1), but cannot re-mount it R/W", - fsinfo.mount_point); + ret = remount_ro_rw(" (1)"); + if (ret) return -1; - } } if (um) { @@ -2633,61 +2734,15 @@ static int remount_tested_fs(void) } } - ret = umount(fsinfo.mount_point); - if (ret) { - pcv("cannot unmount %s", fsinfo.mount_point); + ret = umount_and_remount(1, 0, um_rorw); + if (ret) return -1; - } - - if (!um_rorw) { - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, fsinfo.mount_flags, - fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, but cannot mount it back R/W", - fsinfo.mount_point); - return -1; - } - } else { - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, fsinfo.mount_flags | MS_RDONLY, - fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, but cannot mount it back R/O", - fsinfo.mount_point); - return -1; - } - - flags = fsinfo.mount_flags | MS_REMOUNT; - flags &= ~((unsigned long)MS_RDONLY); - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, flags, fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, mounted R/O, but cannot re-mount it R/W", - fsinfo.mount_point); - return -1; - } - } } if (rorw2) { - flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT; - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("cannot re-mount %s R/O (3)", fsinfo.mount_point); - return -1; - } - - flags = fsinfo.mount_flags | MS_REMOUNT; - flags &= ~((unsigned long)MS_RDONLY); - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("remounted %s R/O (3), but cannot re-mount it back R/W", - fsinfo.mount_point); + ret = remount_ro_rw(" (3)"); + if (ret) return -1; - } } CHECK(chdir(fsinfo.mount_point) == 0); @@ -3144,53 +3199,12 @@ static void free_fs_info(struct dir_info *dir) } /* - * Detach the MTD device from UBI and attach it back. This function is used - * whed performing emulated power cut testing andthe power cuts are amulated by - * UBI, not by UBIFS. In this case, to recover from the emulated power cut we - * have to unmount UBIFS and re-attach the MTD device. - */ -static int reattach(void) -{ - int err = 0; - libubi_t libubi; - struct ubi_attach_request req; - - libubi = libubi_open(); - if (!libubi) { - if (errno == 0) - return errmsg("UBI is not present in the system"); - return sys_errmsg("cannot open libubi"); - } - - err = ubi_detach_mtd(libubi, "/dev/ubi_ctrl", args.mtdn); - if (err) { - sys_errmsg("cannot detach mtd%d", args.mtdn); - goto out; - } - - req.dev_num = UBI_DEV_NUM_AUTO; - req.mtd_num = args.mtdn; - req.vid_hdr_offset = 0; - req.mtd_dev_node = NULL; - req.max_beb_per1024 = 0; - - err = ubi_attach(libubi, "/dev/ubi_ctrl", &req); - if (err) - sys_errmsg("cannot attach mtd%d", args.mtdn); - -out: - libubi_close(libubi); - return err; -} - -/* * Recover the tested file-system from an emulated power cut failure by * unmounting it and mounting it again. */ static int recover_tested_fs(void) { int ret; - unsigned long flags; unsigned int um_rorw, rorw2; struct mntent *mntent; @@ -3206,60 +3220,15 @@ static int recover_tested_fs(void) * while mounting in 'remount_tested_fs()'. */ mntent = get_tested_fs_mntent(); - if (mntent) - CHECK(umount(fsinfo.mount_point) != -1); - if (args.reattach) - CHECK(reattach() == 0); - - if (!um_rorw) { - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, fsinfo.mount_flags, - fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, but cannot mount it back R/W", - fsinfo.mount_point); - return -1; - } - } else { - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, fsinfo.mount_flags | MS_RDONLY, - fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, but cannot mount it back R/O", - fsinfo.mount_point); - return -1; - } - - flags = fsinfo.mount_flags | MS_REMOUNT; - flags &= ~((unsigned long)MS_RDONLY); - ret = mount(fsinfo.fsdev, fsinfo.mount_point, - fsinfo.fstype, flags, fsinfo.mount_opts); - if (ret) { - pcv("unmounted %s, mounted R/O, but cannot re-mount it R/W", - fsinfo.mount_point); - return -1; - } - } + ret = umount_and_remount(!!mntent, args.reattach, um_rorw); + if (ret) + return -1; if (rorw2) { - flags = fsinfo.mount_flags | MS_RDONLY | MS_REMOUNT; - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("cannot re-mount %s R/O", fsinfo.mount_point); - return -1; - } - - flags = fsinfo.mount_flags | MS_REMOUNT; - flags &= ~((unsigned long)MS_RDONLY); - ret = mount(fsinfo.fsdev, fsinfo.mount_point, fsinfo.fstype, - flags, fsinfo.mount_opts); - if (ret) { - pcv("remounted %s R/O, but cannot re-mount it back R/W", - fsinfo.mount_point); + ret = remount_ro_rw(""); + if (ret) return -1; - } } return 0; diff --git a/tests/fs-tests/lib/tests.c b/tests/fs-tests/lib/tests.c index d1a2e0c..3db0426 100644 --- a/tests/fs-tests/lib/tests.c +++ b/tests/fs-tests/lib/tests.c @@ -35,7 +35,6 @@ #include <sys/vfs.h> #include <sys/mount.h> #include <sys/statvfs.h> -#include <linux/fs.h> #include <linux/jffs2.h> #include "tests.h" diff --git a/tests/fs-tests/stress/fs_stress00.sh.in b/tests/fs-tests/stress/fs_stress00.sh.in index 85ec7a2..f7d317c 100755 --- a/tests/fs-tests/stress/fs_stress00.sh.in +++ b/tests/fs-tests/stress/fs_stress00.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; diff --git a/tests/fs-tests/stress/fs_stress01.sh.in b/tests/fs-tests/stress/fs_stress01.sh.in index d0ea8f9..da6babf 100755 --- a/tests/fs-tests/stress/fs_stress01.sh.in +++ b/tests/fs-tests/stress/fs_stress01.sh.in @@ -1,10 +1,6 @@ #!/bin/sh -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libexecpath=@libexecdir@/mtd-utils -TESTBINDIR=@testbindir@ +TESTBINDIR=@TESTBINDIR@ TEST_DIR=$TEST_FILE_SYSTEM_MOUNT_DIR if test -z "$TEST_DIR"; |