public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] quota_remount_test01: update to new API
Date: Fri, 5 Feb 2021 12:00:24 +0100	[thread overview]
Message-ID: <YB0lSFi5LVAo6TPb@pevik> (raw)
In-Reply-To: <YBQdn3S9sPJT/wea@pevik>

Hi all,

FYI patch merged with additional cleanup.
Kory, thanks for your work!

Kind regards,
Petr

diff --git testcases/kernel/fs/quota_remount/quota_remount_test01.sh testcases/kernel/fs/quota_remount/quota_remount_test01.sh
index adcbbe846..a67e13903 100755
--- testcases/kernel/fs/quota_remount/quota_remount_test01.sh
+++ testcases/kernel/fs/quota_remount/quota_remount_test01.sh
@@ -2,79 +2,79 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) Jan Kara <jack@suse.cz>, 2008
 # Copyright (c) International Business Machines  Corp., 2009
-# Copyright (c) K?ry Maincent <kory.maincent@bootlin.com> 2020
+# Copyright (c) K?ry Maincent <kory.maincent@bootlin.com> 2021
+# Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
 
-TST_NEEDS_CMDS="quotacheck quotaon mkfs.ext3"
+TST_NEEDS_CMDS="dd mkfs.ext3 mount quota quotacheck quotaon sed tail"
 TST_NEEDS_DRIVERS="quota_v2"
+TST_NEEDS_ROOT=1
 TST_NEEDS_TMPDIR=1
 TST_SETUP=do_setup
 TST_CLEANUP=do_clean
 TST_TESTFUNC=do_test
+TST_MIN_KVER="2.6.26"
 
 . tst_test.sh
 
 do_setup()
 {
-	if tst_kvcmp -lt "2.6.25"; then
-	        tst_res TCONF "Remounting with quotas enabled is not supported!"
-	        tst_brk TCONF "You should have kernel 2.6.26 and above running....."
-	fi
-
 	if [ ! -d /proc/sys/fs/quota ]; then
-	        tst_brk TCONF "Quota not supported in kernel!"
-	        exit 0
+		tst_brk TCONF "quota not supported in kernel"
 	fi
-	MNTDIR=$TMPDIR/mnt
-	IMAGE=ltp-$$-fs-image
-	dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
-	mkfs.ext3 -q -F -b 4096 $IMAGE
+
+	MNTDIR="mnt.$$"
+	IMAGE="ltp-$$-fs-image"
+	ROD dd if=/dev/zero of=$IMAGE bs=4096 count=8000 2>/dev/null
+	ROD mkfs.ext3 -q -F -b 4096 $IMAGE
 	mkdir $MNTDIR
 }
 
 do_clean()
 {
-	umount 2>/dev/null $MNTDIR
-	rm 2>/dev/null $IMAGE
+	[ "$mounted" ] || return
+	tst_umount $MNTDIR
+	mounted=
+}
+
+get_blocks()
+{
+	quota -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'
 }
 
 do_test()
 {
-	EXPECT_PASS mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
-	tst_res TINFO "Successfully mounted the File System"
+	tst_res TINFO "testing quota on remount"
+
+	local blocks newblocks
+
+	ROD mount -t ext3 -o loop,usrquota,grpquota $IMAGE $MNTDIR
+	mounted=1
 
 	# some distros (CentOS 6.x, for example) doesn't permit creating
 	# of quota files in a directory with SELinux file_t type
-	if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
-		chcon -t tmp_t $MNTDIR || tst_brk TFAIL "Could not change SELinux file type"
-		tst_res TINFO "Successfully changed SELinux file type"
+	if tst_selinux_enabled &&
+		tst_cmd_available chcon && ! chcon -t tmp_t $MNTDIR; then
+			tst_brk TCONF "could not change SELinux file type"
 	fi
 
-	EXPECT_PASS quotacheck -cug $MNTDIR
-	tst_res TINFO "Successfully Created Quota Files"
+	ROD quotacheck -cug $MNTDIR
+	ROD quotaon -ug $MNTDIR
+	ROD echo "blah" />$MNTDIR/file
 
-	EXPECT_PASS quotaon -ug $MNTDIR
-	tst_res TINFO "Successfully Turned on Quota"
+	blocks=$(get_blocks)
+	ROD mount -o remount,ro $MNTDIR
+	ROD mount -o remount,rw $MNTDIR
 
-	EXPECT_PASS echo "blah" />$MNTDIR/file
-	tst_res TINFO "Successfully wrote to the filesystem"
+	ROD rm $MNTDIR/file
+	newblocks=$(get_blocks)
 
-	# Get current quota usage
-	BLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-	EXPECT_PASS mount -o remount,ro $MNTDIR
-	tst_res TINFO "Successfully Remounted Read-Only FS"
+	if [ $blocks -eq $newblocks ]; then
+	   tst_brk TFAIL "usage did not change after remount"
+	fi
 
-	EXPECT_PASS mount -o remount,rw $MNTDIR
-	tst_res TINFO "Successfully Remounted Read-Write FS"
+	tst_res TPASS "quota on remount passed"
 
-	rm $MNTDIR/file
-	# Get quota usage after removing the file
-	NEWBLOCKS=`quota  -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
-	# Has quota usage changed properly?
-	if [ $BLOCKS -eq $NEWBLOCKS ]; then
-	   tst_brk TWARN "Usage did not change after remount"
-	fi
-	tst_res TINFO "Usage successfully Changed after Remount"
-	tst_res TPASS "Quota on Remount Successfull"
+	do_clean
 }
 
 tst_run

  reply	other threads:[~2021-02-05 11:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28 17:10 [LTP] [PATCH] quota_remount_test01: update to new API Kory Maincent
2021-01-29 14:37 ` Petr Vorel
2021-02-05 11:00   ` Petr Vorel [this message]
2021-01-29 15:22 ` Petr Vorel
2021-01-29 15:51   ` =?unknown-8bit?q?K=C3=B6ry?= Maincent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YB0lSFi5LVAo6TPb@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox