summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYevhenii Shapovalov <yshapova@redhat.com>2017-12-15 23:45:20 +0200
committerYevhenii Shapovalov <yshapova@redhat.com>2017-12-15 23:45:20 +0200
commitc7130a987e1d3f019747be0685cfe4249bc63bad (patch)
tree1198f2c457be8e578cf4f5aec6552e33d0948c10
parent9d2d3cfd6fb7a24289fa2df8533c77a38d72ed4c (diff)
downloade2fsprogs-c7130a987e1d3f019747be0685cfe4249bc63bad.tar.gz
e2fsprogs-c7130a987e1d3f019747be0685cfe4249bc63bad.tar.xz
e2fsprogs-c7130a987e1d3f019747be0685cfe4249bc63bad.zip
Add CI tests using the standard test interfaceadd_tests
-rwxr-xr-xtests/inventory3
-rw-r--r--tests/smoke-test/Makefile59
-rw-r--r--tests/smoke-test/PURPOSE10
-rwxr-xr-xtests/smoke-test/runtest.sh238
-rw-r--r--tests/tests.yml33
5 files changed, 343 insertions, 0 deletions
diff --git a/tests/inventory b/tests/inventory
new file mode 100755
index 0000000..fe51290
--- /dev/null
+++ b/tests/inventory
@@ -0,0 +1,3 @@
+#!/bin/bash
+export TEST_DOCKER_EXTRA_ARGS="--privileged -v /dev:/dev"
+exec merge-standard-inventory "$@"
diff --git a/tests/smoke-test/Makefile b/tests/smoke-test/Makefile
new file mode 100644
index 0000000..8ed998a
--- /dev/null
+++ b/tests/smoke-test/Makefile
@@ -0,0 +1,59 @@
+# Copyright (c) 2017 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Branislav Nater <bnater@redhat.com>
+
+TOPLEVEL_NAMESPACE=
+PACKAGE_NAME=e2fsprogs
+RELATIVE_PATH=Regression/smoke-test
+
+export TEST=/e2fsprogs/Regression/smoke-test
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+ ./runtest.sh
+
+build: $(BUILT_FILES)
+ chmod a+x ./runtest.sh
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+
+$(METADATA): Makefile
+ @echo "Owner: Branislav Nater <bnater@redhat.com>" > $(METADATA)
+ @echo "Name: $(TEST)" >> $(METADATA)
+ @echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
+ @echo "Path: $(TEST_DIR)" >> $(METADATA)
+ @echo "Description: This test intends to shortly test the basic functionality of e2fsprogs" >> $(METADATA)
+ @echo "Type: Regression" >> $(METADATA)
+ @echo "TestTime: 2h" >> $(METADATA)
+ @echo "RunFor: e2fsprogs" >> $(METADATA)
+ @echo "Requires: e2fsprogs" >> $(METADATA)
+ @echo "Priority: Normal" >> $(METADATA)
+ @echo "License: GPLv3" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+
+ rhts-lint $(METADATA)
diff --git a/tests/smoke-test/PURPOSE b/tests/smoke-test/PURPOSE
new file mode 100644
index 0000000..f560e1b
--- /dev/null
+++ b/tests/smoke-test/PURPOSE
@@ -0,0 +1,10 @@
+Test Name: smoke-test
+Author: Petr Muller <pmuller@redhat.com>
+Location: /e2fsprogs/Regression/smoke-test
+
+Short Description: This test intends to shortly test the basic functionality of e2fsprogs
+
+
+Long Description:
+
+This test intends to shortly test the basic functionality of e2fsprogs
diff --git a/tests/smoke-test/runtest.sh b/tests/smoke-test/runtest.sh
new file mode 100755
index 0000000..d351328
--- /dev/null
+++ b/tests/smoke-test/runtest.sh
@@ -0,0 +1,238 @@
+#!/bin/bash
+#
+# Copyright (c) 2017 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Branislav Nater <bnater@redhat.com>
+
+PACKAGE=e2fsprogs
+
+. /usr/share/rhts-library/rhtslib.sh
+
+rlJournalStart
+
+rlPhaseStartSetup "Creating few loop devices with various filesystems"
+ LOOPDIR=`mktemp -d`
+ FAKE=$LOOPDIR/fake-disk
+ MOUNTPOINT=/tmp/testing-mountpoint
+ mkdir -p $MOUNTPOINT
+ rlRun "dd if=/dev/zero of=$FAKE count=50 bs=1024k" 0 "Creating $FAKE (50 MB)"
+ LOOP_DEV=`losetup -f`
+ rlRun "losetup $LOOP_DEV $FAKE" 0 "Assign $FAKE to $LOOP_DEV"
+ DEBUGFS=debugfs
+ RESIZEFS=resize2fs
+ DUMPFS=dumpe2fs
+ TUNEFS=tune2fs
+ FSCK=e2fsck
+ IMAGE=e2image
+ LABEL=e2label
+rlPhaseEnd
+
+debugfs_test(){
+ TARGET=$1
+ BLOCKSIZE="$2"
+ rlRun "$DEBUGFS $TARGET -R 'quit'"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -w"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -c"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -cw"
+ if [ "$BLOCKSIZE" != "" ]
+ then
+ rlRun "$DEBUGFS $TARGET -R 'quit' $BLOCKSIZE"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -w $BLOCKSIZE"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -c $BLOCKSIZE"
+ rlRun "$DEBUGFS $TARGET -R 'quit' -cw $BLOCKSIZE"
+ fi
+ rlRun "$DEBUGFS -V"
+}
+
+dumpe2fs_test(){
+ TARGET=$1
+ BLOCKSIZE="${2:3}"
+ rlRun "$DUMPFS -b $TARGET"
+ rlRun "$DUMPFS -f $TARGET"
+ rlRun "$DUMPFS -b -f $TARGET"
+ rlRun "$DUMPFS -h $TARGET"
+ rlRun "$DUMPFS -x $TARGET"
+ rlRun "$DUMPFS -V"
+}
+
+e2fsck_test(){
+ TARGET=$1
+ for op0 in "-n" "-p" "-y"
+ do
+ for op1 in "" "-c" "-c -c" "-f" "-f -c" "-f -c -c" "-c -k" "-c -c -k" "-f -c -k" "-f -c -c -k"
+ do
+ for op2 in "" "-d" "-d -D" "-D"
+ do
+ for op3 in "" "-t" "-t -t" "-v" "-v -t" "-v -t -t"
+ do
+ # -n isn't compatible with -D
+ if echo "$op0 $op1 $op2 $op3" | grep -- "-n" | grep -q -- "-D"; then continue; fi
+ # -n isn't compatilble with -c
+ if echo "$op0 $op1 $op2 $op3" | grep -- "-n" | grep -q -- "-c"; then continue; fi
+
+ echo "$FSCK $TARGET $op0 $op1 $op2 $op3"
+ rlRun "$FSCK $TARGET $op0 $op1 $op2 $op3 > /dev/null" 0
+ done
+ done
+ done
+ done
+ rlRun "$FSCK -V"
+}
+
+e2image_test(){
+ TARGET=$1
+ fil=`mktemp`
+ f="f"
+
+ # -f option only supports on RHEL7 and e2fsprogs-1.41.12-20.el6 (6.6 and later)
+ if rlIsRHEL "<6.6"; then
+ f=""
+ fi
+
+ rlRun "$IMAGE $TARGET - >/dev/null"
+ rlRun "$IMAGE -r$f $TARGET - >/dev/null"
+
+ if rlIsRHEL 5
+ then
+ rlRun "$IMAGE -s $TARGET - >/dev/null"
+ rlRun "$IMAGE -rs $TARGET - >/dev/null"
+ fi
+
+ rlRun "$IMAGE $TARGET $fil"
+ rlRun "$IMAGE -r$f $TARGET $fil"
+ if rlIsRHEL 5
+ then
+ rlRun "$IMAGE -s $TARGET $fil"
+ rlRun "$IMAGE -rs $TARGET $fil"
+ fi
+}
+
+e2label_test(){
+ TARGET=$1
+ rlRun "$LABEL $TARGET mylabel" 0
+ rlAssertEquals "Testing the label was correctly set" "`$LABEL $TARGET`" "mylabel"
+}
+
+resize2fs_test(){
+ TARGET=$1
+ rlRun "$RESIZEFS $TARGET"
+ rlRun "$RESIZEFS $TARGET rd" 1
+ rlRun "$RESIZEFS $TARGET 30M"
+ if [ "$FSTYPE" != "ext4" ]; then
+ # ext4 with 4k block size require min size > 20M
+ rlRun "$RESIZEFS $TARGET 20M"
+ rlRun "$RESIZEFS $TARGET 10M"
+ fi
+ rlRun "$RESIZEFS $TARGET 50M"
+ rlRun "$RESIZEFS $TARGET 30M"
+ rlRun "$RESIZEFS $TARGET 50M"
+ for fl0 in "" "-d 1" "-F" "-d 1 -F"
+ do
+ for fl1 in "" "-p" "-f" "-p -f"
+ do
+ rlRun "$RESIZEFS $TARGET 30M $fl0 $fl1"
+ rlRun "$RESIZEFS $TARGET 50M $fl0 $fl1"
+ done
+ done
+}
+
+tune2fs_test(){
+ TARGET=$1
+ MNT=$2
+ rlRun "$TUNEFS -c 100 $TARGET"
+ rlRun "$TUNEFS -C 100 $TARGET"
+ rlRun "$TUNEFS -c bogus $TARGET" 1
+ rlRun "$TUNEFS -C bogus $TARGET" 1
+
+ for t in d m w
+ do
+ rlRun "$TUNEFS -i 2$t $TARGET" 0
+ if rlIsRHEL 5
+ then
+ rlRun "$TUNEFS -i 9999999999$t $TARGET" 0
+ fi
+ rlRun "$TUNEFS -i 0$t $TARGET" 0
+ done
+ rlRun "$TUNEFS -i bogus $TARGET" 1
+ rlRun "$TUNEFS -l $TARGET" 0
+ rlRun "$TUNEFS -L tune2 $TARGET" 0
+ rlAssertEquals "Checking if label was set correctly" `$LABEL $TARGET` "tune2"
+ rlRun "$TUNEFS -m 10 $TARGET" 0
+ rlRun "$TUNEFS -m 5 $TARGET" 0
+ rlRun "$TUNEFS -M /root $TARGET" 0
+ rlRun "$TUNEFS -M $MNT $TARGET" 0
+ rlRun "$TUNEFS -r 1000 $TARGET" 0
+ rlRun "$TUNEFS -T now $TARGET" 0
+ rlRun "$TUNEFS -T 20081212 $TARGET" 0
+ rlRun "$TUNEFS -T 20081212121212 $TARGET" 0
+ rlRun "$TUNEFS -u root $TARGET" 0
+ umount $TARGET
+ # It refuses to run '$TUNEFS -U clear $TARGET' without do fsck first.
+ $FSCK -fy $TARGET > /dev/null
+ original="`$TUNEFS -l $TARGET | grep UUID`"
+ rlRun "$TUNEFS -U clear $TARGET" 0
+ rlAssertNotEquals "Check the UUID was cleared" "$original" "`$TUNEFS -l $TARGET | grep UUID`"
+ original="`$TUNEFS -l $TARGET | grep UUID`"
+ rlRun "$TUNEFS -U random $TARGET" 0
+ rlAssertNotEquals "Check the UUID was randomed" "$original" "`$TUNEFS -l $TARGET | grep UUID`"
+ original="`$TUNEFS -l $TARGET | grep UUID`"
+ rlRun "$TUNEFS -U time $TARGET" 0
+ rlAssertNotEquals "Check the UUID was changed to time-based" "$original" "`$TUNEFS -l $TARGET | grep UUID`"
+ if [ "$FSTYPE" == "ext4" ]; then
+ mount $TARGET $MNT
+ fi
+}
+
+for fs in ext2 ext3 ext4; do
+ export FSTYPE=$fs
+ if rlIsRHEL 5 && [ "$fs" == "ext4" ]; then
+ export DEBUGFS=debuge4fs
+ export RESIZEFS=resize4fs
+ export DUMPFS=dumpe4fs
+ export TUNEFS=tune4fs
+ export FSCK=e4fsck
+ export IMAGE=e4image
+ export LABEL=e4label
+ fi
+ for additional in "" "-b 1024" "-b 2048" "-b 4096"
+ do
+ rlPhaseStartTest "Testing on $fs with blocksize $additional"
+ rlRun "mkfs -F -t $fs $additional $LOOP_DEV" 0
+ mount $LOOP_DEV $MOUNTPOINT
+ debugfs_test $LOOP_DEV "$additional"
+ dumpe2fs_test $LOOP_DEV "$additional"
+ e2image_test $LOOP_DEV
+ e2label_test $LOOP_DEV
+ tune2fs_test $LOOP_DEV $MOUNTPOINT
+ umount $MOUNTPOINT; sleep 10
+ rlRun "$FSCK -f -y $LOOP_DEV" 0,1,2
+ resize2fs_test $LOOP_DEV
+ e2fsck_test $LOOP_DEV
+ rlPhaseEnd
+ done
+done
+
+
+rlPhaseStartCleanup
+ losetup -d $LOOP_DEV
+ rm -rf $FAKE $MOUNTPOINT
+ rlAssertNotExists $FAKE
+ rlAssertNotExists $MOUNTPOINT
+# rlCreateLogFromJournal > $OUTPUTFILE
+rlPhaseEnd
+
+rlJournalPrintText
+rlJournalEnd
diff --git a/tests/tests.yml b/tests/tests.yml
new file mode 100644
index 0000000..e2f3e54
--- /dev/null
+++ b/tests/tests.yml
@@ -0,0 +1,33 @@
+---
+# Tests suitable to run in a classic environment
+- hosts: localhost
+ tags:
+ - classic
+ roles:
+ - role: standard-test-beakerlib
+ tests:
+ - smoke-test
+ required_packages:
+ - e2fsprogs
+
+# Tests suitable to run in a docker environment
+- hosts: localhost
+ tags:
+ - container
+ roles:
+ - role: standard-test-beakerlib
+ tests:
+ - smoke-test
+ required_packages:
+ - e2fsprogs
+
+# Tests suitable to run in an Atomic Host environment
+- hosts: localhost
+ tags:
+ - atomic
+ roles:
+ - role: standard-test-beakerlib
+ tests:
+ - smoke-test
+ required_packages:
+ - e2fsprogs