# Regenerate the sparse file used for testing and skip the test if it fails
# Usage: GFS_TGT_REGEN
m4_define([GFS_TGT_REGEN],
[AT_CHECK([rm -f $GFS_TGT && truncate -s ${GFS_TGT_SZ}G ${GFS_TGT}], [ignore], [ignore], [ignore])
AT_SKIP_IF([test ! -f ${GFS_TGT}])])
# Regenerate the sparse file used for testing, with a given size, and skip the test if it fails
# Usage: GFS_TGT_REGEN(<size>)
m4_define([GFS_TGT_SIZE],
[AT_CHECK([rm -f $GFS_TGT && truncate -s $1 ${GFS_TGT}], [ignore], [ignore], [ignore])
AT_SKIP_IF([test ! -f ${GFS_TGT}])])
# Regenerate, check, fsck is used a lot so combine it into one macro
# Usage: GFS_FSCK_CHECK ([mkfs.gfs2 ... $GFS_TGT])
m4_define([GFS_FSCK_CHECK],
[GFS_TGT_REGEN
AT_CHECK($1, 0, [ignore], [ignore])
AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])])
# Regenerate, mkfs, modify fs with gfs2l, fsck
# Usage: GFS_LANG_CHECK ([<mkfs.gfs2 command>], [<gfs2l script>])
m4_define([GFS_LANG_CHECK],
[GFS_TGT_REGEN
AT_CHECK($1, 0, [ignore], [ignore])
AT_CHECK([echo "$2" | gfs2l ${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])])
# Regenerate, mkfs, modify fs with nukerg, fsck
# Usage: GFS_NUKERG_CHECK ([<mkfs.gfs2 command>], [<gfs2l script>])
m4_define([GFS_NUKERG_CHECK],
[GFS_TGT_REGEN
AT_CHECK($1, 0, [ignore], [ignore])
AT_CHECK([nukerg $2 $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])])
# Set up a unit test, skipping if unit tests are disabled
# Usage: GFS_UNIT_TEST ([name], [keywords])
m4_define([GFS_UNIT_TEST],
[AT_SETUP($1)
AT_KEYWORDS($2)
AT_CHECK([test x"$ENABLE_UNIT_TESTS" = "xyes" || exit 77])])
# Test suite begins here
AT_INIT([])
AT_COLOR_TESTS
m4_include([mkfs.at])
m4_include([fsck.at])
m4_include([edit.at])
m4_include([libgfs2.at])