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

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



On Fri, Jan 6, 2017 at 5:45 AM, Eryu Guan <eguan@xxxxxxxxxx> 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.
>
> Signed-off-by: Eryu Guan <eguan@xxxxxxxxxx>
> ---

So much duplicated code!!

Did you consider consolidating all those lines that MUST start every test
with:

# Always start a test with this line
. ./common/prologue
# This is the standatd cleanup trigger - remove to implement a private
cleanup trigger
. ./common/cleanup

And while at it, why not put exit \$status inside the generic _cleanup()?

non generic cleanup implementations could looks like this:

trap "my_cleanup" 0 1 2 3 15

my_cleanup()
{
        # my cleanup stuff...
        # generic cleanup and exit $status
        _cleanup
}
--
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