]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/build/run-tests.sh: fix issues reported by shellcheck
authorArturo Borrero Gonzalez <arturo@netfilter.org>
Mon, 17 Jul 2023 10:13:24 +0000 (12:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jul 2023 11:18:16 +0000 (13:18 +0200)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
.gitignore
tests/build/run-tests.sh

index 6b37b1237037f780a11856b92bcea2f3057bd0d7..d6f17e4fc22914e13e923b41b112da54331c7670 100644 (file)
@@ -16,6 +16,7 @@ libtool
 
 # Generated by tests
 *.payload.got
+tests/build/tests.log
 
 # Debian package build temporary files
 build-stamp
index f78cc9019a30ebd6e5b2cf613fdfd81de2b82311..4616387f8e6088f71d82e1bec5f8aeaa946aafc5 100755 (executable)
@@ -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 ]