diff mbox series

tests: make generated test scripts read-only

Message ID 20180627095744.32425-1-c17828@cray.com
State Accepted, archived
Headers show
Series tests: make generated test scripts read-only | expand

Commit Message

Artem Blagodarenko June 27, 2018, 9:57 a.m. UTC
From: Andreas Dilger <andreas.dilger@intel.com>

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.

Change-Id: I60d417b816b7c559b5e05baf4167fc2cf2a871cf
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
 tests/Makefile.in | 6 ++++--
 tests/test_one.in | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o July 2, 2018, 9:26 p.m. UTC | #1
On Wed, Jun 27, 2018 at 12:57:44PM +0300, c17828 wrote:
> diff --git a/tests/test_one.in b/tests/test_one.in
> index c1f18dc8..27e0ca64 100644
> --- a/tests/test_one.in
> +++ b/tests/test_one.in
> @@ -81,6 +81,7 @@ if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
>  		tee $test_name.slow
>  	echo "$test_name:  consider adding $test_dir/is_slow_test"
>  fi
> +[ -f $test_name.failed ] && grep . $test_name.failed
>

This change has nothing to do with the rest of the patch.  I'm also
not sure it good idea, because sometimes the output of the foo.failed
file can be quite large.  Also, if running multiple tests in parallel
which fail, the output can look quite awful.  Finally, why use "grep ."
instead of "cat"?

I can see possibly adding this to test_script, but it doesn't belong
in test_one, and it should be in its own separate commit.

I'm going to drop this change to test_one.in, but I'll take the rest
of the patch.

					- Ted
Andreas Dilger July 3, 2018, 5:17 p.m. UTC | #2
On Jul 2, 2018, at 3:26 PM, Theodore Y. Ts'o <tytso@mit.edu> wrote:
> 
> On Wed, Jun 27, 2018 at 12:57:44PM +0300, c17828 wrote:
>> diff --git a/tests/test_one.in b/tests/test_one.in
>> index c1f18dc8..27e0ca64 100644
>> --- a/tests/test_one.in
>> +++ b/tests/test_one.in
>> @@ -81,6 +81,7 @@ if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
>> 		tee $test_name.slow
>> 	echo "$test_name:  consider adding $test_dir/is_slow_test"
>> fi
>> +[ -f $test_name.failed ] && grep . $test_name.failed
>> 
> 
> This change has nothing to do with the rest of the patch.  I'm also
> not sure it good idea, because sometimes the output of the foo.failed
> file can be quite large.  Also, if running multiple tests in parallel
> which fail, the output can look quite awful.  Finally, why use "grep ."
> instead of "cat"?

The reason for "grep ." instead of "cat" is so that the filename is
prepended to the output.  This is a useful trick when looking at the
content of several files at once.

> I can see possibly adding this to test_script, but it doesn't belong
> in test_one, and it should be in its own separate commit.
> 
> I'm going to drop this change to test_one.in, but I'll take the rest
> of the patch.


Cheers, Andreas
diff mbox series

Patch

diff --git a/tests/Makefile.in b/tests/Makefile.in
index 7b9df62a..f97ebc66 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -15,6 +15,7 @@  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
 	@echo "HTREE=y" >> test_one
 	@echo "QUOTA=y" >> test_one
@@ -23,14 +24,15 @@  test_one: $(srcdir)/test_one.in Makefile mke2fs.conf
 	@echo "SIZEOF_TIME_T=@SIZEOF_TIME_T@" >> test_one
 	@echo "DD=@DD@" >>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
diff --git a/tests/test_one.in b/tests/test_one.in
index c1f18dc8..27e0ca64 100644
--- a/tests/test_one.in
+++ b/tests/test_one.in
@@ -81,6 +81,7 @@  if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then
 		tee $test_name.slow
 	echo "$test_name:  consider adding $test_dir/is_slow_test"
 fi
+[ -f $test_name.failed ] && grep . $test_name.failed
 
 if [ "$SKIP_UNLINK" != "true" ] ; then
 	rm -f $TMPFILE