diff mbox series

[v3,2/2] generic/603: use project quota create and restore common helpers

Message ID 20220512182203.2839593-2-zlang@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v3,1/2] generic: soft quota limits testing within grace time | expand

Commit Message

Zorro Lang May 12, 2022, 6:22 p.m. UTC
As common/quota has _create_project_quota and _restore_project_quota
helpers now, so replace local similar functions with them.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 tests/generic/603 | 36 ++----------------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)

Comments

Darrick J. Wong May 12, 2022, 7:07 p.m. UTC | #1
On Fri, May 13, 2022 at 02:22:03AM +0800, Zorro Lang wrote:
> As common/quota has _create_project_quota and _restore_project_quota
> helpers now, so replace local similar functions with them.
> 
> Signed-off-by: Zorro Lang <zlang@kernel.org>

LGTM
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/generic/603 | 36 ++----------------------------------
>  1 file changed, 2 insertions(+), 34 deletions(-)
> 
> diff --git a/tests/generic/603 b/tests/generic/603
> index b362a3d0..08ddcbf2 100755
> --- a/tests/generic/603
> +++ b/tests/generic/603
> @@ -13,7 +13,7 @@ _begin_fstest auto quick quota
>  # Override the default cleanup function.
>  _cleanup()
>  {
> -	restore_project
> +	_restore_project_quota
>  	cd /
>  	rm -f $tmp.*
>  }
> @@ -22,38 +22,6 @@ _cleanup()
>  . ./common/filter
>  . ./common/quota
>  
> -require_project()
> -{
> -	rm -f $tmp.projects $tmp.projid
> -	if [ -f /etc/projects ];then
> -		cat /etc/projects > $tmp.projects
> -	fi
> -	if [ -f /etc/projid ];then
> -		cat /etc/projid > $tmp.projid
> -	fi
> -
> -	cat >/etc/projects <<EOF
> -100:$SCRATCH_MNT/t
> -EOF
> -	cat >/etc/projid <<EOF
> -$qa_user:100
> -EOF
> -	PROJECT_CHANGED=1
> -}
> -
> -restore_project()
> -{
> -	if [ "$PROJECT_CHANGED" = "1" ];then
> -		rm -f /etc/projects /etc/projid
> -		if [ -f $tmp.projects ];then
> -			cat $tmp.projects > /etc/projects
> -		fi
> -		if [ -f $tmp.projid ];then
> -			cat $tmp.projid > /etc/projid
> -		fi
> -	fi
> -}
> -
>  init_files()
>  {
>  	local dir=$1
> @@ -157,7 +125,7 @@ BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
>  rm -rf $SCRATCH_MNT/t
>  mkdir $SCRATCH_MNT/t
>  $XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
> -require_project
> +_create_project_quota $SCRATCH_MNT/t 100 $qa_user
>  
>  echo "### Set up different grace timers to each type of quota"
>  UBGRACE=12
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/tests/generic/603 b/tests/generic/603
index b362a3d0..08ddcbf2 100755
--- a/tests/generic/603
+++ b/tests/generic/603
@@ -13,7 +13,7 @@  _begin_fstest auto quick quota
 # Override the default cleanup function.
 _cleanup()
 {
-	restore_project
+	_restore_project_quota
 	cd /
 	rm -f $tmp.*
 }
@@ -22,38 +22,6 @@  _cleanup()
 . ./common/filter
 . ./common/quota
 
-require_project()
-{
-	rm -f $tmp.projects $tmp.projid
-	if [ -f /etc/projects ];then
-		cat /etc/projects > $tmp.projects
-	fi
-	if [ -f /etc/projid ];then
-		cat /etc/projid > $tmp.projid
-	fi
-
-	cat >/etc/projects <<EOF
-100:$SCRATCH_MNT/t
-EOF
-	cat >/etc/projid <<EOF
-$qa_user:100
-EOF
-	PROJECT_CHANGED=1
-}
-
-restore_project()
-{
-	if [ "$PROJECT_CHANGED" = "1" ];then
-		rm -f /etc/projects /etc/projid
-		if [ -f $tmp.projects ];then
-			cat $tmp.projects > /etc/projects
-		fi
-		if [ -f $tmp.projid ];then
-			cat $tmp.projid > /etc/projid
-		fi
-	fi
-}
-
 init_files()
 {
 	local dir=$1
@@ -157,7 +125,7 @@  BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
 rm -rf $SCRATCH_MNT/t
 mkdir $SCRATCH_MNT/t
 $XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
-require_project
+_create_project_quota $SCRATCH_MNT/t 100 $qa_user
 
 echo "### Set up different grace timers to each type of quota"
 UBGRACE=12