Whamcloud - gitweb
LU-2694 test: fix is_empty_fs in t-f
authorNiu Yawei <niu@whamcloud.com>
Mon, 4 Mar 2013 14:25:25 +0000 (09:25 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 12 Mar 2013 05:04:00 +0000 (01:04 -0400)
The original is_empty_fs is incorrect, which can cause unexpected
error when running lfsck.sh, because lfsck sets the max error
level based on whether filesystem is empty.

Test-Parameters: testlist=lfsck
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I2269cc41744e3c9fe228898323a1508a03616efe
Reviewed-on: http://review.whamcloud.com/5576
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Tested-by: Hudson
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/lfsck.sh
lustre/tests/test-framework.sh

index 53ec4ff..8d2ad27 100644 (file)
@@ -265,8 +265,10 @@ fi
 generate_db
 
 # remount filesystem
+ORIG_REFORMAT=$REFORMAT
 REFORMAT=""
 check_and_setup_lustre
+REFORMAT=$ORIG_REFORMAT
 
 # run lfsck
 rc=0
index c7e03d0..e21f50d 100644 (file)
@@ -3353,17 +3353,17 @@ is_mounted () {
 }
 
 is_empty_dir() {
-    [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
-    return 1
+       [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
+       return 1
 }
 
 # empty lustre filesystem may have empty directories lost+found and .lustre
 is_empty_fs() {
-    [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
-       -print | wc -l) = 1 ] || return 1
-    [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
-    [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
-    return 1
+       [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
+               -print | wc -l) = 1 ] || return 1
+       [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found || return 1
+       [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre || return 1
+       return 0
 }
 
 check_and_setup_lustre() {