Skip to contentSkip to conversation

generic/245: Filter mv error message

PATCH In review Su Yue 2 participants 2 messages Oct 19, 2023

lore
Share & tools
lore

Su Yue

author
#0 lore raw

PATCH v2 1/1 generic/245: Filter mv error message

Coreutils commit 3cb862ce5f10 ( mv: better diagnostic for 'mv dir x' failure) was released in v9.4, changed the error message from
'mv: cannot move 'b/t' to 'a/t': Directory not empty' to
'mv: cannot overwrite 'a/t': Directory not empty' in case of EDQUOT/EEXIST/EISDIR/EMLINK/ENOSPC/ENOTEMPTY/ETXTBSY.

The change breaks generic/245 due to the mismatched output:

generic/245 1s ... - output mismatch (see /root/xfstests-dev/results//generic/245.out.bad)
--- tests/generic/245.out 2023-10-05 11:15:21.124295738 +0800
+++ /root/xfstests-dev/results//generic/245.out.bad 2023-10-05 11:15:23.456315468 +0800
@@ -1,2 +1,2 @@
QA output created by 245
-mv: cannot move 'TEST_DIR/test-mv/ab/aa/' to 'TEST_DIR/test-mv/aa': File exists
+mv: cannot overwrite 'TEST_DIR/test-mv/aa': File exists
...
(Run 'diff -u /root/xfstests-dev/tests/generic/245.out /root/xfstests-dev/results//generic/245.out.bad' to see the entire diff)

Filter out and replace mv error messages to fix the test.

---
v2:
change sed regrex expression as Zorro suggested.

---
 tests/generic/245     | 5 ++++-
 tests/generic/245.out | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
tests/generic/245 +4 -1
index e2d5c926e906..8e0f22366db3 100755
@@ -29,9 +29,12 @@ _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"
+	sed -e "s,Directory not empty,File exists,g" \
+		-e "s,cannot move .* to \(.*\):\(.*\),cannot overwrite \1:\2,g"
 }
  
 
tests/generic/245.out +1 -1
index f5b5f182619d..19b598e4a175 100644
@@ -1,2 +1,2 @@
 QA output created by 245
-mv: cannot move 'TEST_DIR/test-mv/ab/aa/' to 'TEST_DIR/test-mv/aa': File exists
+mv: cannot overwrite 'TEST_DIR/test-mv/aa': File exists
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 34 lines · Su Yue

Coreutils commit 3cb862ce5f10 ( mv: better diagnostic for 'mv dir x' failure) was released in v9.4, changed the error message from
'mv: cannot move 'b/t' to 'a/t': Directory not empty' to
'mv: cannot overwrite 'a/t': Directory not empty' in case of EDQUOT/EEXIST/EISDIR/EMLINK/ENOSPC/ENOTEMPTY/ETXTBSY.

The change breaks generic/245 due to the mismatched output:

generic/245 1s ... - output mismatch (see /root/xfstests-dev/results//generic/245.out.bad)
--- tests/generic/245.out 2023-10-05 11:15:21.124295738 +0800
+++ /root/xfstests-dev/results//generic/245.out.bad 2023-10-05 11:15:23.456315468 +0800
@@ -1,2 +1,2 @@
QA output created by 245
-mv: cannot move 'TEST_DIR/test-mv/ab/aa/' to 'TEST_DIR/test-mv/aa': File exists
+mv: cannot overwrite 'TEST_DIR/test-mv/aa': File exists
...
(Run 'diff -u /root/xfstests-dev/tests/generic/245.out /root/xfstests-dev/results//generic/245.out.bad' to see the entire diff)

Filter out and replace mv error messages to fix the test.

---
v2:
change sed regrex expression as Zorro suggested.

---
 tests/generic/245     | 5 ++++-
 tests/generic/245.out | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
tests/generic/245 +0 -0
index e2d5c926e906..8e0f22366db3 100755

tests/generic/245 _cleanup() · line 37

Quoted 10 lines
tests/generic/245 +4 -1
@@ -29,9 +29,12 @@ _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"
+	sed -e "s,Directory not empty,File exists,g" \
+		-e "s,cannot move .* to \(.*\):\(.*\),cannot overwrite \1:\2,g"

This version looks good to me, just the alignment problem, I'll change it a bit when I merge it.

Thanks,
Zorro

Quoted 14 lines
tests/generic/245 +0 -0
 }
 
 
tests/generic/245.out +1 -1
index f5b5f182619d..19b598e4a175 100644
@@ -1,2 +1,2 @@
 QA output created by 245
-mv: cannot move 'TEST_DIR/test-mv/ab/aa/' to 'TEST_DIR/test-mv/aa': File exists
+mv: cannot overwrite 'TEST_DIR/test-mv/aa': File exists
Signature · 1 line
2.41.0