netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] tests/build/run-tests.sh: fix issues reported by shellcheck
@ 2023-07-17 10:13 Arturo Borrero Gonzalez
  2023-07-17 11:19 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Arturo Borrero Gonzalez @ 2023-07-17 10:13 UTC (permalink / raw)
  To: netfilter-devel

Improve a bit the script as reported by shellcheck, also including
information about the log file.

The log file, by the way, is added to the gitignore to reduce noise
in the git tree.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
---
 .gitignore               |    1 +
 tests/build/run-tests.sh |   34 +++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6b37b123..d6f17e4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ libtool
 
 # Generated by tests
 *.payload.got
+tests/build/tests.log
 
 # Debian package build temporary files
 build-stamp
diff --git a/tests/build/run-tests.sh b/tests/build/run-tests.sh
index f78cc901..4616387f 100755
--- a/tests/build/run-tests.sh
+++ b/tests/build/run-tests.sh
@@ -1,32 +1,36 @@
 #!/bin/bash
 
-log_file="`pwd`/tests.log"
+log_file="$(pwd)/tests.log"
 dir=../..
 argument=( --without-cli --with-cli=linenoise --with-cli=editline --enable-debug --with-mini-gmp
 	   --enable-man-doc --with-xtables --with-json)
 ok=0
 failed=0
 
-[ -f $log_file ] && rm -rf $log_file
+[ -f "$log_file" ] && rm -rf "$log_file"
 
 tmpdir=$(mktemp -d)
-if [ ! -w $tmpdir ] ; then
+if [ ! -w "$tmpdir" ] ; then
         echo "Failed to create tmp file" >&2
         exit 0
 fi
 
-git clone $dir $tmpdir >/dev/null 2>>$log_file
-cd $tmpdir
+git clone "$dir" "$tmpdir" >/dev/null 2>>"$log_file"
+cd "$tmpdir" || exit
 
-autoreconf -fi >/dev/null 2>>$log_file
-./configure >/dev/null 2>>$log_file
+if ! autoreconf -fi >"$log_file" 2>>"$log_file" ; then
+	echo "Something went wrong. Check the log '${log_file}' for details."
+	exit 1
+fi
 
-echo  "Testing build with distcheck"
-make distcheck >/dev/null 2>>$log_file
-rt=$?
+if ! ./configure >"$log_file" 2>>"$log_file" ; then
+	echo "Something went wrong. Check the log '${log_file}' for details."
+	exit 1
+fi
 
-if [ $rt != 0 ] ; then
-	echo "Something went wrong. Check the log for details."
+echo  "Testing build with distcheck"
+if ! make distcheck >/dev/null 2>>"$log_file" ; then
+	echo "Something went wrong. Check the log '${log_file}' for details."
 	exit 1
 fi
 
@@ -35,8 +39,8 @@ echo "Build works. Now, testing compile options"
 
 for var in "${argument[@]}" ; do
 	echo "[EXECUTING] Testing compile option $var"
-	./configure $var >/dev/null 2>>$log_file
-	make -j 8 >/dev/null 2>>$log_file
+	./configure "$var" >/dev/null 2>>"$log_file"
+	make -j 8 >/dev/null 2>>"$log_file"
 	rt=$?
 	echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
 
@@ -49,7 +53,7 @@ for var in "${argument[@]}" ; do
 	fi
 done
 
-rm -rf $tmpdir
+rm -rf "$tmpdir"
 
 echo "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"
 [ "$failed" -eq 0 ]


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nft PATCH] tests/build/run-tests.sh: fix issues reported by shellcheck
  2023-07-17 10:13 [nft PATCH] tests/build/run-tests.sh: fix issues reported by shellcheck Arturo Borrero Gonzalez
@ 2023-07-17 11:19 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2023-07-17 11:19 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel

On Mon, Jul 17, 2023 at 12:13:24PM +0200, Arturo Borrero Gonzalez wrote:
> Improve a bit the script as reported by shellcheck, also including
> information about the log file.
> 
> The log file, by the way, is added to the gitignore to reduce noise
> in the git tree.

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-17 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 10:13 [nft PATCH] tests/build/run-tests.sh: fix issues reported by shellcheck Arturo Borrero Gonzalez
2023-07-17 11:19 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).