Skip to contentSkip to conversation

xfstests: exit non-0 if fs check fails

PATCH In review Eric Sandeen 4 participants 4 messages Mar 31, 2010 – Apr 15, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: exit non-0 if fs check fails

Right now if any of the _check_scratch_fs tests etc fail, the check script exits but with 0 status.

This change will cause the status to be non-0 so we can detect the error.

---

(aside - we could make it 2 instead of 1, so that a calling script could fsck and continue ... thoughts?)

common.rc +2 -0
index 2103a77..301ae6a 100644
@@ -959,6 +959,7 @@ _check_generic_filesystem()
         echo "*** mount output ***"                             >>$here/$seq.full
         _mount                                                  >>$here/$seq.full
         echo "*** end mount output"                             >>$here/$seq.full
+        status=1
     elif [ "$type" = "$FSTYP" ]
     then
 	# was mounted ...
@@ -1054,6 +1055,7 @@ _check_xfs_filesystem()
         echo "*** mount output ***"                             >>$here/$seq.full
         _mount                                                  >>$here/$seq.full
         echo "*** end mount output"                             >>$here/$seq.full
+        status=1
     elif [ "$type" = "xfs" ]
     then
 	_mount_or_remount_rw "$extra_mount_options" $device $mountpoint

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 7 lines · Eric Sandeen

Right now if any of the _check_scratch_fs tests etc fail, the check script exits but with 0 status.

This change will cause the status to be non-0 so we can detect the error.

Wouldn't it be better to do:

- [ $ok -eq 0 ] && exit 1
+ if [ $ok -eq 0 ]; then
+ status=1
+ exit 1
+ fi

To catch all failures rather than just the fsck failure?

Quoted 4 lines

---

(aside - we could make it 2 instead of 1, so that a calling script could fsck and continue ... thoughts?)

I think if a test corrupts a filesystem, the test run should stop so the failure can be analysed without needing to reproduce it again...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 17 lines · Dave Chinner
Quoted 7 lines · Eric Sandeen

Right now if any of the _check_scratch_fs tests etc fail, the check script exits but with 0 status.

This change will cause the status to be non-0 so we can detect the error.

Wouldn't it be better to do:

(quoted diff) +4 -1
-   [ $ok -eq 0 ] && exit 1
+    if [ $ok -eq 0 ]; then
+	status=1
+	exit 1
+    fi
Quoted 1 line

To catch all failures rather than just the fsck failure?

sure, that sounds better. I'll check that version in w/ your SOB unless I hear otherwise :)

Thanks,
-Eric

Quoted 5 lines
Quoted 4 lines

---

(aside - we could make it 2 instead of 1, so that a calling script could fsck and continue ... thoughts?)

Quoted 7 lines

I think if a test corrupts a filesystem, the test run should stop so the failure can be analysed without needing to reproduce it again...

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 12 lines · Eric Sandeen
Quoted 11 lines · Dave Chinner
Quoted 7 lines · Eric Sandeen

Right now if any of the _check_scratch_fs tests etc fail, the check script exits but with 0 status.

This change will cause the status to be non-0 so we can detect the error.

Wouldn't it be better to do:

Quoted 7 lines
Quoted 7 lines
(quoted diff) +4 -1
-   [ $ok -eq 0 ] && exit 1
+    if [ $ok -eq 0 ]; then
+	status=1
+	exit 1
+    fi

To catch all failures rather than just the fsck failure?

I see this patch is already committed to xfstests-dev.

I don't see the point of setting status=1 before exiting. If what you meant was to set the status and then *return* a non-zero value it would make sense.

How do you feel about updating your patch and committing the result to the -dev tree?

If you change "exit" to "return" in both spots you can consider it reviewed by me.

-Alex

PS Here is a script that shows what's going on.

#!/bin/bash

echo =============
status=1
echo top-level shell PID is $$
echo initial status is $status

bash <<!
echo -------------
echo sub-shell PID is \$$
echo sub-shell initial status is \$status

foo() { echo foo PID is \$$; status=2; return 3; } bar() { echo bar PID is \$$; status=4; exit 5; }

echo -------------
status=0
foo # This is run in the current (sub) shell
echo foo result is \$?
echo post-foo status is \$status
echo current shell PID is \$$

echo -------------
status=0
bar # This will exit to the top-level shell
# And the next three will not get executed echo bar result is \$?
echo post-bar status is \$status echo current shell PID is \$$
!
R=$?
echo -------------
echo final result is $R
echo final shell PID is $$
echo final status is $status

echo =============

exit 0

Quoted 15 lines

sure, that sounds better. I'll check that version in w/ your SOB unless I hear otherwise :)

Thanks,
-Eric

Quoted 9 lines
Quoted 4 lines

---

(aside - we could make it 2 instead of 1, so that a calling script could fsck and continue ... thoughts?)

I think if a test corrupts a filesystem, the test run should stop so the failure can be analysed without needing to reproduce it again...

Quoted 8 lines
Quoted 3 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs