[gnutls-devel] [PATCH] tests: dsa: cleanup shell usage
Alon Bar-Lev
alon.barlev at gmail.com
Wed Jun 17 23:57:04 CEST 2015
Add quotes for most usages of variables.
Added ${} for variables.
Cleanup trailing spaces.
Removal of unneeded ';'.
Minor fix in tests/scripts/common.sh at trap to pass message and avoid
killing.
Signed-off-by: Alon Bar-Lev <alon.barlev at gmail.com>
---
tests/dsa/testdsa | 88 ++++++++++++++++++++++++-------------------------
tests/scripts/common.sh | 36 ++++++++++----------
2 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/tests/dsa/testdsa b/tests/dsa/testdsa
index dea4297..0334e63 100755
--- a/tests/dsa/testdsa
+++ b/tests/dsa/testdsa
@@ -30,126 +30,126 @@ if test "${WINDIR}" != "";then
exit 77
fi
-. $srcdir/../scripts/common.sh
+. "${srcdir}/../scripts/common.sh"
PORT="${PORT:-$RPORT}"
-echo "Checking various DSA key sizes (port $PORT)"
+echo "Checking various DSA key sizes (port ${PORT})"
# DSA 1024 + TLS 1.0
echo "Checking DSA-1024 with TLS 1.0"
-launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem >/dev/null 2>&1 & PID=$!
-wait_server $PID
+launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile "${srcdir}/cert.dsa.1024.pem" --x509keyfile "${srcdir}/dsa.1024.pem" >/dev/null 2>&1 & PID=$!
+wait_server "${PID}"
PRIO="--priority NORMAL:+DHE-DSS:+SIGN-DSA-SHA512:+SIGN-DSA-SHA384:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1"
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 1024 key and TLS 1.0!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 1024 key and TLS 1.0!"
echo "Checking server DSA-1024 with client DSA-1024 and TLS 1.0"
#try with client key of 1024 bits (should succeed)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 1024 key and TLS 1.0!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.1024.pem" --x509keyfile "${srcdir}/dsa.1024.pem" </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 1024 key and TLS 1.0!"
echo "Checking server DSA-1024 with client DSA-2048 and TLS 1.0"
#try with client key of 2048 bits (should fail)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem </dev/null >/dev/null 2>&1 && \
- fail $PID "Succeeded connection to a server with a client DSA 2048 key and TLS 1.0!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.2048.pem" --x509keyfile "${srcdir}/dsa.2048.pem" </dev/null >/dev/null 2>&1 && \
+ fail "${PID}" "Succeeded connection to a server with a client DSA 2048 key and TLS 1.0!"
echo "Checking server DSA-1024 with client DSA-3072 and TLS 1.0"
#try with client key of 3072 bits (should fail)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem </dev/null >/dev/null 2>&1 && \
- fail $PID "Succeeded connection to a server with a client DSA 3072 key and TLS 1.0!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.3072.pem" --x509keyfile "${srcdir}/dsa.3072.pem" </dev/null >/dev/null 2>&1 && \
+ fail "${PID}" "Succeeded connection to a server with a client DSA 3072 key and TLS 1.0!"
-kill $PID
+kill "${PID}"
wait
# DSA 1024 + TLS 1.2
echo "Checking DSA-1024 with TLS 1.2"
-launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem >/dev/null 2>&1 & PID=$!
-wait_server $PID
+launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile "${srcdir}/cert.dsa.1024.pem" --x509keyfile "${srcdir}/dsa.1024.pem" >/dev/null 2>&1 & PID=$!
+wait_server "${PID}"
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 1024 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 1024 key and TLS 1.2!"
echo "Checking server DSA-1024 with client DSA-1024 and TLS 1.2"
#try with client key of 1024 bits (should succeed)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 1024 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.1024.pem" --x509keyfile "${srcdir}/dsa.1024.pem" </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 1024 key and TLS 1.2!"
echo "Checking server DSA-1024 with client DSA-2048 and TLS 1.2"
#try with client key of 2048 bits (should succeed)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with a client DSA 2048 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.2048.pem" --x509keyfile "${srcdir}/dsa.2048.pem" </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with a client DSA 2048 key and TLS 1.2!"
echo "Checking server DSA-1024 with client DSA-3072 and TLS 1.2"
#try with client key of 3072 bits (should succeed)
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with a client DSA 3072 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure --x509certfile "${srcdir}/cert.dsa.3072.pem" --x509keyfile "${srcdir}/dsa.3072.pem" </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with a client DSA 3072 key and TLS 1.2!"
-kill $PID
+kill "${PID}"
wait
# DSA 2048 + TLS 1.0
#echo "Checking DSA-2048 with TLS 1.0"
-#launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem >/dev/null 2>&1 & PID=$!
-#wait_server $PID
+#launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile "${srcdir}/cert.dsa.2048.pem" --x509keyfile "${srcdir}/dsa.2048.pem" >/dev/null 2>&1 & PID=$!
+#wait_server "${PID}"
-#$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
-# fail $PID "Succeeded connection to a server with DSA 2048 key and TLS 1.0. Should have failed!"
+#"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
+# fail "${PID}" "Succeeded connection to a server with DSA 2048 key and TLS 1.0. Should have failed!"
-#kill $PID
+#kill "${PID}"
#wait
# DSA 2048 + TLS 1.2
echo "Checking DSA-2048 with TLS 1.2"
-launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem >/dev/null 2>&1 & PID=$!
-wait_server $PID
+launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile "${srcdir}/cert.dsa.2048.pem" --x509keyfile "${srcdir}/dsa.2048.pem" >/dev/null 2>&1 & PID=$!
+wait_server "${PID}"
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 2048 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 2048 key and TLS 1.2!"
-kill $PID
+kill "${PID}"
wait
# DSA 3072 + TLS 1.0
#echo "Checking DSA-3072 with TLS 1.0"
-#launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem >/dev/null 2>&1 & PID=$!
-#wait_server $PID
+#launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile "${srcdir}/cert.dsa.3072.pem" --x509keyfile "${srcdir}/dsa.3072.pem" >/dev/null 2>&1 & PID=$!
+#wait_server "${PID}"
#
-#$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
-# fail $PID "Succeeded connection to a server with DSA 3072 key and TLS 1.0. Should have failed!"
+#"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
+# fail "${PID}" "Succeeded connection to a server with DSA 3072 key and TLS 1.0. Should have failed!"
#
-#kill $PID
+#kill "${PID}"
#wait
# DSA 3072 + TLS 1.2
echo "Checking DSA-3072 with TLS 1.2"
-launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem >/dev/null 2>&1 & PID=$!
-wait_server $PID
+launch_server $$ --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2:+DHE-DSS:+SIGN-DSA-SHA256:+SIGN-DSA-SHA1" --x509certfile "${srcdir}/cert.dsa.3072.pem" --x509keyfile "${srcdir}/dsa.3072.pem" >/dev/null 2>&1 & PID=$!
+wait_server "${PID}"
-$CLI $DEBUG $PRIO -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
- fail $PID "Failed connection to a server with DSA 3072 key and TLS 1.2!"
+"${CLI}" ${DEBUG} ${PRIO} -p "${PORT}" 127.0.0.1 --insecure </dev/null >/dev/null || \
+ fail "${PID}" "Failed connection to a server with DSA 3072 key and TLS 1.2!"
-kill $PID
+kill "${PID}"
wait
exit 0
diff --git a/tests/scripts/common.sh b/tests/scripts/common.sh
index 50880f5..3ccfc03 100644
--- a/tests/scripts/common.sh
+++ b/tests/scripts/common.sh
@@ -21,18 +21,18 @@
RPORT="$(((($$<<15)|RANDOM) % 63001 + 2000))"
fail() {
- PID=$1
- shift;
+ PID="$1"
+ shift
echo "Failure: $1" >&2
- kill $PID
+ [ -n "${PID}" ] && kill ${PID}
exit 1
}
launch_server() {
- PARENT=$1;
- shift;
- $SERV $DEBUG -p $PORT $* >/dev/null 2>&1 &
- LOCALPID="$!";
+ PARENT="$1"
+ shift
+ ${SERV} ${DEBUG} -p "${PORT}" $* >/dev/null 2>&1 &
+ LOCALPID="$!"
trap "[ ! -z \"${LOCALPID}\" ] && kill ${LOCALPID};" 15
wait "${LOCALPID}"
LOCALRET="$?"
@@ -44,12 +44,12 @@ launch_server() {
}
launch_pkcs11_server() {
- PARENT=$1;
- shift;
- PROVIDER=$1;
- shift;
- $VALGRIND $SERV $PROVIDER $DEBUG -p $PORT $* &
- LOCALPID="$!";
+ PARENT="$1"
+ shift
+ PROVIDER="$1"
+ shift
+ ${VALGRIND} ${SERV} "${PROVIDER}" ${DEBUG} -p "${PORT}" $* &
+ LOCALPID="$!"
trap "[ ! -z \"${LOCALPID}\" ] && kill ${LOCALPID};" 15
wait "${LOCALPID}"
LOCALRET="$?"
@@ -61,10 +61,10 @@ launch_pkcs11_server() {
}
launch_bare_server() {
- PARENT=$1;
- shift;
- $SERV $* >/dev/null 2>&1 &
- LOCALPID="$!";
+ PARENT="$1"
+ shift
+ ${SERV} $* >/dev/null 2>&1 &
+ LOCALPID="$!"
trap "[ ! -z \"${LOCALPID}\" ] && kill ${LOCALPID};" 15
wait "${LOCALPID}"
LOCALRET="$?"
@@ -80,4 +80,4 @@ wait_server() {
sleep 4
}
-trap "fail \"Failed to launch a gnutls-serv server, aborting test... \"" 10
+trap "fail '' 'Failed to launch a gnutls-serv server, aborting test... '" 10
--
2.3.6
More information about the Gnutls-devel
mailing list