fstests: add missing remove of the $seqres.full file for some tests
[xfstests-dev.git] / tests / btrfs / 036
index 7e5f281e164e490408438eef86afdb4a950e828a..36b652fd7fd7f9898f1efe90f61261858acdc3c3 100755 (executable)
@@ -1,27 +1,11 @@
 #!/bin/bash
-# FS QA Test No. btrfs/036
-#
-# Regression test for running snapshots and send concurrently.
-#
-#-----------------------------------------------------------------------
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2014 Fujitsu.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+# FS QA Test No. btrfs/036
 #
-#-----------------------------------------------------------------------
+# Regression test for running snapshots and send concurrently.
 #
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -36,12 +20,19 @@ _cleanup()
        # kill backgroud snapshots
        if [ $snapshots_pid -ne 0 ] && ps -p $snapshots_pid | grep -q $snapshots_pid; then
                kill -TERM $snapshots_pid 2> /dev/null
+               wait $snapshots_pid
        fi
        rm -f $tmp.*
 }
 
 do_snapshots()
 {
+       # Wait for any running 'btrfs subvolume snapshot' subcommand before
+       # exitting so that after the test kills the subshell running this
+       # function, it does not fail with EBUSY when unmounting the scratch
+       # device.
+       trap "wait; exit" SIGTERM
+
        i=2
        while [ 1 ]
        do
@@ -58,9 +49,11 @@ trap "_cleanup ; exit \$status" 0 1 2 3 15
 . ./common/rc
 . ./common/filter
 
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
 # real QA test starts here
 _supported_fs btrfs
-_supported_os Linux
 _require_scratch
 
 _scratch_mkfs > /dev/null 2>&1