summaryrefslogtreecommitdiffstats
path: root/tests/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scripts')
-rwxr-xr-xtests/scripts/gen-test-data23
-rwxr-xr-xtests/scripts/mkdup49
-rwxr-xr-xtests/scripts/repair-test9
-rwxr-xr-xtests/scripts/resize_test183
4 files changed, 264 insertions, 0 deletions
diff --git a/tests/scripts/gen-test-data b/tests/scripts/gen-test-data
new file mode 100755
index 0000000..0cbd928
--- /dev/null
+++ b/tests/scripts/gen-test-data
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+t1="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. "
+t2="Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment. Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring. Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line. "
+t3="Licensed Product under the copyright owner that is not possible to put the Notice in a manner which does not specify a version number of this document is to say, a work based on the Program (including Contributions) may always be distributed subject to the Licensed Product. Intellectual Property Matters. Third Party Claims. If you develop a new version of the Derivative Works, in at least six (6) months after a subsequent version of this section has the right to acquire, license, develop, have others develop for it, market and/or distribute the Program (or a work based on infringement of intellectual property laws of the Package, in its Contribution, if any, specified by the terms of this Agreement more than your cost of all necessary servicing, repair, or correction. In no event and under no obligation to respond to any patent claims licensable by a copyright notice appear in all copies of it that are distributed by the terms applicable to software that is included in any Digital Font Program, which may be used to render or display fonts. Program shall mean a computer system. "
+
+export LANG=C
+export LC_ALL=C
+
+t="$t1$t2$t3"
+len=${#t}
+
+c=131072
+
+while test $c -gt 0 ; do
+ if test $c -gt $len ; then
+ echo -n "$t"
+ c=$(($c - $len))
+ else
+ echo -n "$t" | cut -c -$(($c - 1))
+ c=0
+ fi
+done
diff --git a/tests/scripts/mkdup b/tests/scripts/mkdup
new file mode 100755
index 0000000..c48a9f0
--- /dev/null
+++ b/tests/scripts/mkdup
@@ -0,0 +1,49 @@
+#!/bin/sh
+OPTS="-O bigalloc -C 8192"
+SIZE=4096
+IMG=/tmp/foo.img
+TMP=$(mktemp)
+SIZE_A=15000
+SIZE_B=5000
+SIZE_C=20000
+
+DEBUGFS=./debugfs/debugfs
+MKE2FS=./misc/mke2fs
+FSCK=./e2fsck/e2fsck
+
+dd if=/dev/zero of=$IMG bs=1k count=$SIZE
+echo $MKE2FS -F -t ext4 -L test $OPTS test.img $SIZE
+$MKE2FS -F -t ext4 -L test $OPTS $IMG $SIZE
+dd if=/dev/zero of=$TMP bs=$SIZE_A count=1 >& /dev/null
+echo Writing $SIZE_A bytes to a
+$DEBUGFS -w -R "write $TMP a" $IMG
+BLKS=$(./debugfs/debugfs -R "blocks a" $IMG)
+cp /dev/null $TMP
+echo "Releasing blocks $BLKS"
+for i in $BLKS ; do echo "freeb $i" >> $TMP; done
+$DEBUGFS -w $IMG < $TMP >& /dev/null
+
+echo Writing $SIZE_B bytes to b
+dd if=/dev/zero of=$TMP bs=$SIZE_B count=1 >& /dev/null
+$DEBUGFS -w -R "write $TMP b" $IMG
+if [ -n "$SIZE_C" ]; then
+ BLKS=$(./debugfs/debugfs -R "blocks b" $IMG)
+ cp /dev/null $TMP
+ echo "Releasing blocks $BLKS"
+ for i in $BLKS ; do echo "freeb $i" >> $TMP; done
+ $DEBUGFS -w $IMG < $TMP >& /dev/null
+
+ echo Writing $SIZE_C bytes to c
+ dd if=/dev/zero of=$TMP bs=$SIZE_C count=1 >& /dev/null
+ $DEBUGFS -w -R "write $TMP c" $IMG
+fi
+echo "set_inode_field a mtime 201107040000" > $TMP
+echo "set_inode_field b mtime 201107050000" >> $TMP
+if [ -n "$SIZE_C" ]; then
+ echo "set_inode_field c mtime 201107060000" >> $TMP
+fi
+$DEBUGFS -w $IMG < $TMP >& /dev/null
+
+$FSCK -fy $IMG
+rm $TMP
+
diff --git a/tests/scripts/repair-test b/tests/scripts/repair-test
new file mode 100755
index 0000000..c164e6e
--- /dev/null
+++ b/tests/scripts/repair-test
@@ -0,0 +1,9 @@
+#!/bin/sh
+for T in "$*"; do
+ [ -f "$T.failed" -a -d "$T" ] ||
+ { echo "usage: $0 <test_to_repair>"; exit 1; }
+
+ cp $T.1.log $T/expect.1
+ cp $T.2.log $T/expect.2
+ ./test_one $T
+done
diff --git a/tests/scripts/resize_test b/tests/scripts/resize_test
new file mode 100755
index 0000000..a000c85
--- /dev/null
+++ b/tests/scripts/resize_test
@@ -0,0 +1,183 @@
+#!/bin/sh
+
+# old distros are missing "truncate", emulate it with "dd" if necessary
+do_truncate()
+{
+ [ "$1" = "-s" ] && size=$2 && shift 2
+
+ if ! truncate -s $size $1 >> $LOG 2>&1 ; then
+ dd if=/dev/zero of=$1 bs=1 count=0 seek=$size >> $LOG 2>&1
+ fi
+}
+
+resize_test () {
+DBG_FLAGS=63
+
+echo $test_description starting > $LOG
+rm -f $TMPFILE
+touch $TMPFILE
+
+# Verify that the $TMP filesystem handles $SIZE_2 sparse files.
+# If that fails, try the local filesystem instead.
+if do_truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then
+ echo "using $TMPFILE" >> $LOG
+else
+ rm $TMPFILE
+ export TMPFILE=$(mktemp ./$test_name.tmp.XXXXXX)
+ touch $TMPFILE
+ echo "using $TMPFILE" >> $LOG
+ if ! do_truncate -s $SIZE_2 $TMPFILE >> $LOG 2>&1; then
+ rm $TMPFILE
+ return 111
+ fi
+fi
+> $TMPFILE
+
+echo $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
+$MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
+
+OUT_TMP=$(mktemp ${TMPDIR:-/tmp}/csum-tmp.XXXXXX)
+
+date > $OUT_TMP
+cat $E2FSCK >> $OUT_TMP
+echo $CRCSUM $OUT_TMP >> $LOG 2>&1
+CSUM_1=$($CRCSUM $OUT_TMP)
+echo Checksum is $CSUM_1 >> $LOG
+
+echo Setting up file system >> $LOG
+$DEBUGFS -w $TMPFILE >> $LOG 2>&1 << EOF
+mkdir test
+cd test
+write $OUT_TMP e2fsck
+ls /test
+stat /test/e2fsck
+quit
+EOF
+echo " " >> $LOG
+
+rm -f $OUT_TMP
+
+echo $FSCK -fy $TMPFILE >> $LOG 2>&1
+$FSCK -fy $TMPFILE >> $LOG 2>&1
+
+chmod u-w $TMPFILE
+echo $RESIZE2FS -P $TMPFILE >> $LOG 2>&1
+if ! $RESIZE2FS -P $TMPFILE >> $LOG 2>&1
+then
+ return 1
+fi
+chmod u+w $TMPFILE
+
+echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
+if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS $TMPFILE $SIZE_2 >> $LOG 2>&1
+then
+ return 1
+fi
+
+echo $FSCK -fy $TMPFILE >> $LOG 2>&1
+if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
+then
+ $DUMPE2FS $TMPFILE >> $LOG
+ return 1
+fi
+
+echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+
+echo $CRCSUM $OUT_TMP >> $LOG 2>&1
+CSUM_2=$($CRCSUM $OUT_TMP)
+echo Checksum is $CSUM_2 >> $LOG
+
+if test "$CSUM_1" != "$CSUM_2"
+then
+ return 1
+fi
+
+# Uncomment to grab extra debugging image
+#
+#mv $TMPFILE /tmp/foo.img
+#return 0
+
+echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+then
+ return 1
+fi
+
+echo $FSCK -fy $TMPFILE >> $LOG 2>&1
+if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
+then
+ $DUMPE2FS $TMPFILE >> $LOG
+ return 1
+fi
+
+echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+
+echo $CRCSUM $OUT_TMP >> $LOG 2>&1
+CSUM_2=$($CRCSUM $OUT_TMP)
+echo Checksum is $CSUM_2 >> $LOG
+
+if test "$CSUM_1" != "$CSUM_2"
+then
+ return 1
+fi
+
+echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+then
+ return 1
+fi
+
+echo $FSCK -fy $TMPFILE >> $LOG 2>&1
+if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
+then
+ $DUMPE2FS $TMPFILE >> $LOG
+ return 1
+fi
+
+echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+
+echo $CRCSUM $OUT_TMP >> $LOG 2>&1
+CSUM_2=$($CRCSUM $OUT_TMP)
+echo Checksum is $CSUM_2 >> $LOG
+
+if test "$CSUM_1" != "$CSUM_2"
+then
+ return 1
+fi
+
+echo $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+if ! $RESIZE2FS $RESIZE2FS_OPTS -d $DBG_FLAGS -M $TMPFILE $SIZE_2 >> $LOG 2>&1
+then
+ return 1
+fi
+
+echo $FSCK -fy $TMPFILE >> $LOG 2>&1
+if ! $FSCK -fy $TMPFILE >> $LOG 2>&1
+then
+ $DUMPE2FS $TMPFILE >> $LOG
+ return 1
+fi
+
+echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
+
+echo $CRCSUM $OUT_TMP >> $LOG 2>&1
+CSUM_2=$($CRCSUM $OUT_TMP)
+echo Checksum is $CSUM_2 >> $LOG
+
+rm $OUT_TMP
+unset OUT_TMP
+
+rm -f $TMPFILE
+
+if test "$CSUM_1" != "$CSUM_2"
+then
+ return 1
+fi
+
+return 0
+
+}