From 8b9ad4405fa2722254520129ad2ed53917971311 Mon Sep 17 00:00:00 2001 From: Boyang Xue <bxue@redhat.com> Date: Thu, 12 Dec 2024 13:55:14 +0800 Subject: [PATCH] gating: introduce e2fsprogs gating test in c9s Resolves: RHELMISC-7593 Signed-off-by: Boyang Xue <bxue@redhat.com> --- .fmf/version | 1 + gating.yaml | 5 +- plan.fmf | 8 + tests/e2fsprogs-smoke-test/Makefile | 59 +++++++ tests/e2fsprogs-smoke-test/PURPOSE | 10 ++ tests/e2fsprogs-smoke-test/main.fmf | 21 +++ tests/e2fsprogs-smoke-test/runtest.sh | 244 ++++++++++++++++++++++++++ 7 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 .fmf/version create mode 100644 plan.fmf create mode 100644 tests/e2fsprogs-smoke-test/Makefile create mode 100644 tests/e2fsprogs-smoke-test/PURPOSE create mode 100644 tests/e2fsprogs-smoke-test/main.fmf create mode 100755 tests/e2fsprogs-smoke-test/runtest.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml index c190bde..dd6ed2b 100644 --- a/gating.yaml +++ b/gating.yaml @@ -1,6 +1,5 @@ --- !Policy -product_versions: - - rhel-9 + decision_context: osci_compose_gate rules: - - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/plan.fmf b/plan.fmf new file mode 100644 index 0000000..09778f1 --- /dev/null +++ b/plan.fmf @@ -0,0 +1,8 @@ +summary: e2fsprogs gating test +execute: + how: tmt +discover: + how: fmf + test: [ + "e2fsprogs-smoke-test", + ] diff --git a/tests/e2fsprogs-smoke-test/Makefile b/tests/e2fsprogs-smoke-test/Makefile new file mode 100644 index 0000000..8ed998a --- /dev/null +++ b/tests/e2fsprogs-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/e2fsprogs-smoke-test/PURPOSE b/tests/e2fsprogs-smoke-test/PURPOSE new file mode 100644 index 0000000..f560e1b --- /dev/null +++ b/tests/e2fsprogs-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/e2fsprogs-smoke-test/main.fmf b/tests/e2fsprogs-smoke-test/main.fmf new file mode 100644 index 0000000..6ca84a4 --- /dev/null +++ b/tests/e2fsprogs-smoke-test/main.fmf @@ -0,0 +1,21 @@ +summary: This test intends to shortly test the basic functionality of e2fsprogs +description: | + 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 +contact: Boyang Xue <bxue@redhat.com> +component: + - e2fsprogs +test: ./runtest.sh +framework: beakerlib +recommend: + - e2fsprogs + - beakerlib +duration: 2h diff --git a/tests/e2fsprogs-smoke-test/runtest.sh b/tests/e2fsprogs-smoke-test/runtest.sh new file mode 100755 index 0000000..a43cfa8 --- /dev/null +++ b/tests/e2fsprogs-smoke-test/runtest.sh @@ -0,0 +1,244 @@ +#!/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/beakerlib/beakerlib.sh || exit 1 + +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 +} + +mke2fs_test(){ + # https://bugzilla.redhat.com/show_bug.cgi?id=1889464#c15 + rlRun "! MKE2FS_CONFIG= mkfs.$fs 2>&1 | grep 'Syntax error'" 0 +} + +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 + mke2fs_test + rlPhaseEnd + done +done + + +rlPhaseStartCleanup + losetup -d $LOOP_DEV + rm -rf $FAKE $MOUNTPOINT + rlAssertNotExists $FAKE + rlAssertNotExists $MOUNTPOINT +# rlCreateLogFromJournal > $OUTPUTFILE +rlPhaseEnd + +rlJournalPrintText +rlJournalEnd