AT_TESTED([fsck.gfs2])
AT_BANNER([fsck.gfs2 tests])
AT_SETUP([Conflicting options])
AT_KEYWORDS(fsck.gfs2 fsck)
# Error code 16 is FSCK_USAGE
AT_CHECK([fsck.gfs2 -y -n $GFS_TGT], 16, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -n -y $GFS_TGT], 16, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -n -p $GFS_TGT], 16, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -p -n $GFS_TGT], 16, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -y -p $GFS_TGT], 16, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -p -y $GFS_TGT], 16, [ignore], [ignore])
AT_CLEANUP
AT_SETUP([Fix invalid block sizes])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 0 }])
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 1 }])
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 513 }])
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 4095 }])
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set sb { sb_bsize: 4097 }])
AT_CLEANUP
AT_SETUP([Fix invalid goal blocks])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set '/' { di_goal_meta: 0 }])
AT_CLEANUP
AT_SETUP([Fix bad resource group #0])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-r 0])
AT_CLEANUP
AT_SETUP([Fix bad resource group #1])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-r 1])
AT_CLEANUP
#AT_SETUP([Fix bad rindex entry #0])
#AT_KEYWORDS(fsck.gfs2 fsck)
#GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 0])
#AT_CLEANUP
AT_SETUP([Fix bad rindex entry #1])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 1])
AT_CLEANUP
AT_SETUP([Rebuild bad journal])
AT_KEYWORDS(fsck.gfs2 fsck)
GFS_TGT_REGEN
AT_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], 0, [ignore], [ignore])
AT_CHECK([gfs2_edit -p journal0 field di_header.mh_magic 0 $GFS_TGT], 0, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])
AT_CLEANUP