diff mbox series

[1/1] generic/682: apply 'mv' error message fitler.

Message ID 20240119084244.56373-2-mengferry@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series add 'mv' errmsg filter and apply in generic/682 | expand

Commit Message

Ferry Meng Jan. 19, 2024, 8:42 a.m. UTC
As coreutils update to 9.4+, the 'mv' command change also results in
the mismatch output of generic/682.

This case is similar to generic/245, you can refer to 'generic/245:
Filter mv error message'(commit d9323ad7a0). Now seperate this filter
as '_filter_mv_err_msg', move it into common/filter, and apply in
generic/682.

Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
---
 common/filter         | 13 +++++++++++++
 tests/generic/245     |  9 ++++-----
 tests/generic/682     |  2 +-
 tests/generic/682.out |  2 +-
 4 files changed, 19 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/common/filter b/common/filter
index 509ee950..55f3f855 100644
--- a/common/filter
+++ b/common/filter
@@ -651,5 +651,18 @@  _filter_bash()
 	sed -e "s/^bash: line 1: /bash: /"
 }
 
+# coreutils 9.4+ modify the error msg of command 'mv'. To be compitable with
+# various coreutils versions, we synchronize the output to the latest version.
+# coreutils change was added by this commit:
+# commit 3cb862ce5f10db392cc8e6907dd9d888acfa2a30
+# Author: Paul Eggert <eggert@cs.ucla.edu>
+# Date:   Sat Jul 22 13:39:17 2023 -0700
+#
+#    mv: better diagnostic for 'mv dir x' failure
+_filter_mv_err_msg()
+{
+        sed -e "s,cannot move .* to \(.*\):\(.*\),cannot overwrite \1:\2,g"
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/generic/245 b/tests/generic/245
index 81ce4d4e..4cf7c112 100755
--- a/tests/generic/245
+++ b/tests/generic/245
@@ -29,12 +29,9 @@  _cleanup()
 # According to the rename(2) manpage you can get either EEXIST or ENOTEMPTY as an
 # error for trying to rename a non-empty directory, so just catch the error for
 # ENOTMEMPTY and replace it with the EEXIST output so that either result passes
-# Also, mv v9.4+ modified error message when a nonempty destination directory fails
-# to be overwriteen
 _filter_directory_not_empty()
 {
-	sed -e "s,Directory not empty,File exists,g" \
-	    -e "s,cannot move .* to \(.*\):\(.*\),cannot overwrite \1:\2,g"
+	sed -e "s,Directory not empty,File exists,g"
 }
  
 
@@ -46,7 +43,9 @@  touch $dir/aa/1
 mkdir $dir/ab/aa
 touch $dir/ab/aa/2
 
-mv $dir/ab/aa/ $dir 2>&1 | _filter_test_dir | _filter_directory_not_empty
+# Also, mv v9.4+ modified error message when a nonempty destination directory fails
+# to be overwriteen, now use _filter_mv_err_msg to ignore the difference
+mv $dir/ab/aa/ $dir 2>&1 | _filter_test_dir | _filter_directory_not_empty | _filter_mv_err_msg
 
 status=0
 exit $status
diff --git a/tests/generic/682 b/tests/generic/682
index b4cd0cd9..8e6c2497 100755
--- a/tests/generic/682
+++ b/tests/generic/682
@@ -62,7 +62,7 @@  for ((i = 0; i < dirents; i++)); do
 	name=$(printf "y%0254d" $i)
 	ln $scratchfile $stagedir/$name
 	su - "$qa_user" -c "mv $stagedir/$name $scratchdir/$name" 2>&1 | \
-		_filter_scratch | sed -e 's/y[0-9]*/yXXX/g'
+		_filter_mv_err_msg | _filter_scratch | sed -e 's/y[0-9]*/yXXX/g'
 	test "${PIPESTATUS[0]}" -ne 0 && break
 done
 repquota -upn $SCRATCH_MNT >> $seqres.full
diff --git a/tests/generic/682.out b/tests/generic/682.out
index b7470811..db22d5f6 100644
--- a/tests/generic/682.out
+++ b/tests/generic/682.out
@@ -1,3 +1,3 @@ 
 QA output created by 682
-mv: cannot move 'SCRATCH_MNT/staging/yXXX' to 'SCRATCH_MNT/dir/yXXX': Disk quota exceeded
+mv: cannot overwrite 'SCRATCH_MNT/dir/yXXX': Disk quota exceeded
 Silence is golden