Whamcloud - gitweb
tests: make generated test scripts read-only
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 23 May 2012 21:05:21 +0000 (15:05 -0600)
committerAndreas Dilger <adilger@dilger.ca>
Fri, 28 Aug 2015 17:08:53 +0000 (11:08 -0600)
Make generated test scripts read-only, to avoid errors by developers
editing the generated test scripts and then having them accidentally
clobbered when "make" is run again.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
tests/Makefile.in
tests/test_one.in

index 37a043e..2e184f8 100644 (file)
@@ -15,20 +15,22 @@ all:: @DO_TEST_SUITE@ test_one test_script
 
 test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
        @echo "Creating test_one script..."
+       @[ -f test_one ] && chmod u+w test_one || true
        @echo "#!/bin/sh" > test_one
 @HTREE_CMT@    @echo "HTREE=y" >> test_one
 @QUOTA_CMT@    @echo "QUOTA=y" >> test_one
        @echo "SRCDIR=@srcdir@" >> test_one
        @echo "DIFF_OPTS=@UNI_DIFF_OPTS@" >> test_one
        @cat $(srcdir)/test_one.in >> test_one
-       @chmod +x test_one
+       @chmod +x-w test_one
 
 test_script: test_one test_script.in Makefile mke2fs.conf
        @echo "Creating test_script..."
+       @[ -f test_script ] && chmod u+w test_script || true
        @echo "#!/bin/sh" > test_script
        @echo "SRCDIR=@srcdir@" >> test_script
        @cat $(srcdir)/test_script.in >> test_script
-       @chmod +x test_script
+       @chmod +x-w test_script
 
 mke2fs.conf: $(srcdir)/mke2fs.conf.in
        $(CP) $(srcdir)/mke2fs.conf.in mke2fs.conf
index c2bd1a1..f0778f6 100644 (file)
@@ -49,7 +49,7 @@ else
        test_description=
 fi
 
-rm -f $test_name.ok $test_name.failed
+rm -f $test_name.ok $test_name.failed $test_name.log
 #echo -e -n "$test_name: $test_description:\r"
 
 if [ -f $test_dir/script ]; then
@@ -62,8 +62,8 @@ else
        else
                echo "$test_name: Missing test script $default_script!"
        fi
-       [ -f $test_name.failed ] && cat $test_name.failed
 fi
+[ -f $test_name.failed ] && grep . $test_name.failed
 
 if [ "$SKIP_UNLINK" != "true" ] ; then
        rm -f $TMPFILE