[Git][NTPsec/ntpsec][master] 2 commits: tests/python3-tester.sh: remove bash-isms
Gary E. Miller
gitlab at mg.gitlab.com
Tue Oct 9 23:38:53 UTC 2018
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
faa798fa by Gary E. Miller at 2018-10-09T23:37:36Z
tests/python3-tester.sh: remove bash-isms
Many OS do not use bash. Sometimes do to license issues.
- - - - -
a75366dc by Gary E. Miller at 2018-10-09T23:38:22Z
tests/option-tester.sh: remove bash-isms
Many OS do not use bash. Sometimes do to license issues.
- - - - -
2 changed files:
- tests/option-tester.sh
- tests/python3-tester.sh
Changes:
=====================================
tests/option-tester.sh
=====================================
@@ -1,6 +1,6 @@
-#!/usr/bin/env bash
-# sh on NetBSD and FreeBSD says:
-# sh: ${PIPESTATUS[...}: Bad substitution
+#!/bin/sh
+# keep this POSIX sh compatible. No bash-isms!
+# replace |& with 2>&1 |
# This is a hack to build with various configuration options.
# The intent is to check building combinations that normal testing doesn't use.
@@ -8,6 +8,11 @@
# Stuff goes into various test-* directories.
# Running again starts by deleting everything in the directory.
+# set pipefail to catch pipeline failures
+set -o pipefail
+# crash on unset shell variables
+set -u
+
LINUX=""
if [ `uname -s` = "Linux" -a -f /usr/include/seccomp.h ]
then
@@ -20,47 +25,47 @@ doit ()
DIR=test-$1
[ ! -d $DIR ] && mkdir $DIR
rm -rf $DIR/*
- ./waf configure --out=$DIR $2 |& tee $DIR/test.log
- WAF1=${PIPESTATUS[0]}
+ ./waf configure --out=$DIR $2 2>&1 | tee $DIR/test.log
+ WAF1=$?
WAF2=0
WAF3=0
if [ "$WAF1" = 0 ]
then
- echo |& tee -a $DIR/test.log
- ./waf build |& tee -a $DIR/test.log
- WAF2=${PIPESTATUS[0]}
+ echo 2>&1 | tee -a $DIR/test.log
+ ./waf build 2>&1 | tee -a $DIR/test.log
+ WAF2=$?
if [ "$WAF2" = 0 ]
then
- echo |& tee -a $DIR/test.log
- ./waf check |& tee -a $DIR/test.log
- WAF3=${PIPESTATUS[0]}
+ echo 2>&1 | tee -a $DIR/test.log
+ ./waf check 2>&1 | tee -a $DIR/test.log
+ WAF3=$?
fi
fi
if [ "$WAF1" != 0 -o "$WAF2" != 0 -o "$WAF3" != 0 ]
then
- echo |& tee -a $DIR/test.log
- echo "Trouble with $DIR" |& tee -a $DIR/test.log
+ echo 2>&1 | tee -a $DIR/test.log
+ echo "Trouble with $DIR" 2>&1 | tee -a $DIR/test.log
else
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpd/ntpd --version |& tee -a $DIR/test.log
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpclients/ntpq --version |& tee -a $DIR/test.log
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpclients/ntpdig --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpd/ntpd --version 2>&1 | tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpclients/ntpq --version 2>&1 | tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpclients/ntpdig --version 2>&1 | tee -a $DIR/test.log
if [ `uname -s` != "NetBSD" ]
then
# no Python/curses on NetBSD
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpclients/ntpmon --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpclients/ntpmon --version 2>&1 | tee -a $DIR/test.log
fi
if [ "`which gpsmon 2>/dev/null`" != "" ]
then
# needs GPSD library
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpclients/ntploggps --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpclients/ntploggps --version 2>&1 | tee -a $DIR/test.log
fi
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpclients/ntplogtemp --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpclients/ntplogtemp --version 2>&1 | tee -a $DIR/test.log
fi
echo
echo
=====================================
tests/python3-tester.sh
=====================================
@@ -1,10 +1,15 @@
-#!/usr/bin/env bash
-# sh on NetBSD and FreeBSD says:
-# sh: ${PIPESTATUS[...}: Bad substitution
+#!/bin/sh
+# keep this POSIX sh compatible. No bash-isms!
+# replace |& with 2>&1 |
# This is a clone of option-tester.sh
# to build with python3 and do minimal (version) testing.
+# set pipefail to catch pipeline failures
+set -o pipefail
+# crash on unset shell variables
+set -u
+
if [ "`which python3 2>/dev/null`" = "" ]
then
echo "# Error: No python3 on this system."
@@ -16,47 +21,47 @@ doit ()
DIR=test-$1
[ ! -d $DIR ] && mkdir $DIR
rm -rf $DIR/*
- python3 ./waf configure --out=$DIR $2 |& tee $DIR/test.log
- WAF1=${PIPESTATUS[0]}
+ python3 ./waf configure --out=$DIR $2 2>&1 | tee $DIR/test.log
+ WAF1=$?
WAF2=0
WAF3=0
if [ "$WAF1" = 0 ]
then
- echo |& tee -a $DIR/test.log
- python3 ./waf build |& tee -a $DIR/test.log
- WAF2=${PIPESTATUS[0]}
+ echo 2>&1 | tee -a $DIR/test.log
+ python3 ./waf build 2>&1 | tee -a $DIR/test.log
+ WAF2=$?
if [ "$WAF2" = 0 ]
then
- echo |& tee -a $DIR/test.log
- python3 ./waf check |& tee -a $DIR/test.log
- WAF3=${PIPESTATUS[0]}
+ echo 2>&1 | tee -a $DIR/test.log
+ python3 ./waf check 2>&1 | tee -a $DIR/test.log
+ WAF3=$?
fi
fi
if [ "$WAF1" != 0 -o "$WAF2" != 0 -o "$WAF3" != 0 ]
then
- echo |& tee -a $DIR/test.log
- echo "Trouble with $DIR" |& tee -a $DIR/test.log
+ echo 2>&1 | tee -a $DIR/test.log
+ echo "Trouble with $DIR" 2>&1 | tee -a $DIR/test.log
else
- echo -n "VERSION: " |& tee -a $DIR/test.log
- ./$DIR/main/ntpd/ntpd --version |& tee -a $DIR/test.log
- echo -n "VERSION: " |& tee -a $DIR/test.log
- python3 ./$DIR/main/ntpclients/ntpq --version |& tee -a $DIR/test.log
- echo -n "VERSION: " |& tee -a $DIR/test.log
- python3 ./$DIR/main/ntpclients/ntpdig --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ ./$DIR/main/ntpd/ntpd --version 2>&1 | tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ python3 ./$DIR/main/ntpclients/ntpq --version 2>&1 | tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ python3 ./$DIR/main/ntpclients/ntpdig --version 2>&1 | tee -a $DIR/test.log
if [ `uname -s` != "NetBSD" ]
then
# no Python/curses on NetBSD
- echo -n "VERSION: " |& tee -a $DIR/test.log
- python3 ./$DIR/main/ntpclients/ntpmon --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ python3 ./$DIR/main/ntpclients/ntpmon --version 2>&1 | tee -a $DIR/test.log
fi
# if [ "`which gpsmon 2>/dev/null`" != "" ]
# then
# needs GPSD library - don't know how to test for python3 version
- # echo -n "VERSION: " |& tee -a $DIR/test.log
- # python3 ./$DIR/main/ntpclients/ntploggps --version |& tee -a $DIR/test.log
+ # echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ # python3 ./$DIR/main/ntpclients/ntploggps --version 2>&1 | tee -a $DIR/test.log
# fi
- echo -n "VERSION: " |& tee -a $DIR/test.log
- python3 ./$DIR/main/ntpclients/ntplogtemp --version |& tee -a $DIR/test.log
+ echo -n "VERSION: " 2>&1 | tee -a $DIR/test.log
+ python3 ./$DIR/main/ntpclients/ntplogtemp --version 2>&1 | tee -a $DIR/test.log
fi
echo
echo
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/53520eeef68b1fcaf2c2984f26fe45ac07fd5420...a75366dc536f030dba5935ecbf20f76ffc7b021e
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/53520eeef68b1fcaf2c2984f26fe45ac07fd5420...a75366dc536f030dba5935ecbf20f76ffc7b021e
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20181009/4189d930/attachment-0001.html>
More information about the vc
mailing list