Re: [PATCH] fstests: cleanup tmp files in tests

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



Hi Eryu,

On Fri, Jan 06, 2017 at 11:45:07AM +0800, Eryu Guan wrote:
> $tmp.* files should be removed in _cleanup() even if the test is not
> using any $tmp.* file explicitly, because common helper functions
> may take use of them too.
> 
> So cleanup tmp files properly in tests, and add a _cleanup()
> function and trap it on exit if the test doesn't do so, to make all
> tests consistent on the way they do cleanup.
> 
> Also remove other tmp files used by the tests and the harness so
> that we leave no new tmp files in /tmp dir after a full test run.
> 

Why exactly can't the boilerplate go in a preamble file which is sourced by all
the tests?  For example common/preamble containing something like:

	seq=`basename $0`
	seqres=$RESULT_DIR/$seq
	echo "QA output created by $seq"

	_cleanup()
	{
		cd /
		rm -f $tmp.*
	}

	here=`pwd`
	tmp=/tmp/$$
	status=1        # failure is the default!
	trap "_cleanup; exit \$status" 0 1 2 3 15

	. ./common/rc

Tests that need to do more cleanup could override the default trap.

Eric
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux