Skip to contentSkip to conversation

generic/63{4,5}: Modify criteria for passing test

PATCH In review Joanne Chang 2 participants 2 messages Jun 2 – Jun 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/63{4,5}: Modify criteria for passing test

The two tests pass when a timestamp is not preserved after the remount, because "cmp -s" does not print to the output file, and status is set to 0 regardless of the return value of cmp. So, use "diff" instead to correctly fail the test and flag the error case in the output file.

Also, as the tests are focused on timestamps, don't print file contents so the tests can still pass if only the file contents differ.

---
 tests/generic/634 | 4 ++--
 tests/generic/635 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tests/generic/634 +2 -2
index 8a4210a3..d7dd9dd8 100755
@@ -52,7 +52,7 @@ touchme() {
 report() {
 	local files=($SCRATCH_MNT/t_*)
 	for file in "${files[@]}"; do
-		echo "${file}: $(cat "${file}")"
+		echo "${file}:"
 		TZ=UTC stat -c '%y %Y %n' "${file}"
 		test $test_statx -gt 0 && \
 			$XFS_IO_PROG -c 'statx -r' "${file}" | grep 'stat.mtime'
@@ -98,7 +98,7 @@ report > $tmp.after_remount
 cat $tmp.after_remount >> $seqres.full
 
 # Did they match?
-cmp -s $tmp.before_remount $tmp.after_remount
+diff $tmp.before_remount $tmp.after_remount
 
 # success, all done
 echo Silence is golden.
tests/generic/635 +2 -2
index 018b868c..f74d0cd7 100755
@@ -55,7 +55,7 @@ touchme() {
 report() {
 	local files=($SCRATCH_MNT/t_*)
 	for file in "${files[@]}"; do
-		echo "${file}: $(cat "${file}")"
+		echo "${file}:"
 		TZ=UTC stat -c '%y %Y %n' "${file}"
 		test $test_statx -gt 0 && \
 			$XFS_IO_PROG -c 'statx -r' "${file}" | grep 'stat.mtime'
@@ -102,7 +102,7 @@ report > $tmp.after_crash
 cat $tmp.after_crash >> $seqres.full
 
 # Did they match?
-cmp -s $tmp.before_crash $tmp.after_crash
+diff $tmp.before_crash $tmp.after_crash
 
 # success, all done
 status=0
Signature · 1 line
2.54.0.929.g9b7fa37559-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Joanne Chang

The two tests pass when a timestamp is not preserved after the remount, because "cmp -s" does not print to the output file, and status is set to 0 regardless of the return value of cmp. So, use "diff" instead to correctly fail the test and flag the error case in the output file.

Also, as the tests are focused on timestamps, don't print file contents so the tests can still pass if only the file contents differ.

---
 tests/generic/634 | 4 ++--
 tests/generic/635 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
tests/generic/634 +1 -1
index 8a4210a3..d7dd9dd8 100755
@@ -52,7 +52,7 @@ touchme() {
 report() {
 	local files=($SCRATCH_MNT/t_*)
 	for file in "${files[@]}"; do
-		echo "${file}: $(cat "${file}")"
+		echo "${file}:"
 		TZ=UTC stat -c '%y %Y %n' "${file}"
 		test $test_statx -gt 0 && \
 			$XFS_IO_PROG -c 'statx -r' "${file}" | grep 'stat.mtime'

tests/generic/634 report > $tmp.after_remount · line 101

Quoted 5 lines
tests/generic/634 +1 -1
@@ -98,7 +98,7 @@ report > $tmp.after_remount
 cat $tmp.after_remount >> $seqres.full
 
 # Did they match?
-cmp -s $tmp.before_remount $tmp.after_remount
+diff $tmp.before_remount $tmp.after_remount

Haha, looks like Darrick accidentally added the -s option :) It seems like simply dropping the -s option would fix this issue, though switching to diff works as well. If Darrick has no further review points, I'll go ahead and merge this patch.

Quoted 28 lines
tests/generic/634 +0 -0
 # success, all done
 echo Silence is golden.
tests/generic/635 +2 -2
index 018b868c..f74d0cd7 100755
@@ -55,7 +55,7 @@ touchme() {
 report() {
 	local files=($SCRATCH_MNT/t_*)
 	for file in "${files[@]}"; do
-		echo "${file}: $(cat "${file}")"
+		echo "${file}:"
 		TZ=UTC stat -c '%y %Y %n' "${file}"
 		test $test_statx -gt 0 && \
 			$XFS_IO_PROG -c 'statx -r' "${file}" | grep 'stat.mtime'
@@ -102,7 +102,7 @@ report > $tmp.after_crash
 cat $tmp.after_crash >> $seqres.full
 
 # Did they match?
-cmp -s $tmp.before_crash $tmp.after_crash
+diff $tmp.before_crash $tmp.after_crash
 
 # success, all done
 status=0
Signature · 1 line
2.54.0.929.g9b7fa37559-goog