On Wed, Jun 27, 2018 at 11:20 AM, Dave Chinner <david@xxxxxxxxxxxxx> wrote: > From: Dave Chinner <dchinner@xxxxxxxxxx> > > So many tests chop random bits out of the mandaotry test setup > preamble which leads to subtle problems and stray files being dumped > all over the place. Create a common test preamble with hooks for > local cleanup functions so we can prevent this in future. > > Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx> > --- > common/setup_test | 31 +++++++++++++++++++++++++++++++ > new | 35 ++++++++--------------------------- > soak | 19 +++++++------------ > 3 files changed, 46 insertions(+), 39 deletions(-) > create mode 100644 common/setup_test > > diff --git a/common/setup_test b/common/setup_test > new file mode 100644 > index 000000000000..f25ed11c2306 > --- /dev/null > +++ b/common/setup_test > @@ -0,0 +1,31 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# > +# common test setup preamble > +# test specific cleanup is done via the cleanup() function now. > + > +seq=`basename $0` > +seqres=$RESULT_DIR/$seq > +echo "QA output created by $seq" > + > +here=`pwd` > +tmp=/tmp/$$ > +status=1 # failure is the default! > +trap "_cleanup_test; exit \$status" 0 1 2 3 15 > + > +_cleanup_test() > +{ > + # call local test cleanup function first, then cleanup tmp files > + cleanup > + cd / > + rm -f $tmp.* > +} > + > +_success() > +{ > + status=0 > + exit > +} > + > +# get standard environment, filters and checks > +. ./common/rc > +. ./common/filter > diff --git a/new b/new > index 2bb8ce5055c1..1f11fdad1b8c 100755 > --- a/new > +++ b/new > @@ -9,12 +9,11 @@ > iam=new > . ./common/test_names > > -trap "rm -f /tmp/$$.; exit" 0 1 2 3 15 > > -_cleanup() > -{ > - : > +_cleanup() { > + rm -f /tmp/$$. > } > +trap "_cleanup; exit" 0 1 2 3 15 > 1. that looks like a bug in 'new' cleanup. should be rm -f /tmp/$$.* (or /tmp/$$.group) 2. if we are going with convention that local cleanup is without _, may as well stick with this convention here as well even though we are not sourcing setup_test Thanks, Amir. -- 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