From ad51d200438a0c600a75fe8acfa27d29bb45bdac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Fri, 16 Nov 2018 16:06:18 +0100 Subject: tests/cert-tests/pem-decoding: Increase portability (fix for busybox) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tim Rühsen --- tests/cert-tests/pem-decoding | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/cert-tests/pem-decoding b/tests/cert-tests/pem-decoding index 1daf926317..267a1fc7f3 100755 --- a/tests/cert-tests/pem-decoding +++ b/tests/cert-tests/pem-decoding @@ -24,7 +24,6 @@ srcdir="${srcdir:-.}" CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}" -DIFF="${DIFF:-diff -b -B}" if ! test -x "${CERTTOOL}"; then exit 77 @@ -34,6 +33,8 @@ if ! test -z "${VALGRIND}"; then VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND}" fi +. "${srcdir}/../scripts/common.sh" + TMPFILE=tmp-$$.pem.tmp TMPFILE1=tmp1-$$.pem.tmp TMPFILE2=tmp2-$$.pem.tmp @@ -57,8 +58,7 @@ if test "${rc}" != "0"; then exit ${rc} fi -#FIXME: the output string differs in windows and linux on the last char. -${DIFF} -I 'Algorithm Security Level' "${srcdir}/data/bmpstring.pem" ${TMPFILE} || ${DIFF} -I 'Algorithm Security Level' --strip-trailing-cr "${srcdir}/data/bmpstring.pem" ${TMPFILE} +check_if_equal "${srcdir}/data/bmpstring.pem" ${TMPFILE} "Algorithm Security Level" rc=$? if test "${rc}" != "0"; then @@ -75,9 +75,7 @@ if test "${rc}" != "0"; then exit ${rc} fi -cat "${srcdir}/data/complex-cert.pem" |grep -v "Not After:" >${TMPFILE1} -cat ${TMPFILE} |grep -v "Not After:" >${TMPFILE2} -${DIFF} -I 'Algorithm Security Level' ${TMPFILE1} ${TMPFILE2} || ${DIFF} -I 'Algorithm Security Level' --strip-trailing-cr ${TMPFILE1} ${TMPFILE2} +check_if_equal "${srcdir}/data/complex-cert.pem" ${TMPFILE} "Not After:|Algorithm Security Level" rc=$? if test "${rc}" != "0"; then @@ -94,9 +92,7 @@ if test "${rc}" != "0"; then exit ${rc} fi -cat "${srcdir}/data/xmpp-othername.pem" |grep -v "Not After:" >${TMPFILE1} -cat ${TMPFILE} |grep -v "Not After:" >${TMPFILE2} -${DIFF} -I ^warning -I 'Algorithm Security Level' ${TMPFILE1} ${TMPFILE2} || ${DIFF} -I 'Algorithm Security Level' --strip-trailing-cr ${TMPFILE1} ${TMPFILE2} +check_if_equal "${srcdir}/data/xmpp-othername.pem" ${TMPFILE} "^warning|Not After:|Algorithm Security Level" rc=$? if test "${rc}" != "0"; then @@ -112,9 +108,9 @@ if test "${rc}" != "0"; then exit ${rc} fi -cat ${TMPFILE} |grep "KRB5Principal:" >${TMPFILE1} -cat "${srcdir}/data/template-krb5name-full.pem" |grep "KRB5Principal:" >${TMPFILE2} -${DIFF} -I 'Algorithm Security Level' -u ${TMPFILE1} ${TMPFILE2} || ${DIFF} -I 'Algorithm Security Level' -u --strip-trailing-cr ${TMPFILE1} ${TMPFILE2} +grep "KRB5Principal:" ${TMPFILE} >${TMPFILE1} +grep "KRB5Principal:" "${srcdir}/data/template-krb5name-full.pem" >${TMPFILE2} +check_if_equal ${TMPFILE1} ${TMPFILE2} rc=$? if test "${rc}" != "0"; then @@ -138,7 +134,7 @@ if test "${rc}" != "0"; then exit ${rc} fi -${DIFF} -u ${TMPFILE} "${GOSTCERT}" || ${DIFF} -u --strip-trailing-cr "${TMPFILE}" "${GOSTCERT}" +check_if_equal ${TMPFILE} "${GOSTCERT}" rc=$? if test "${rc}" != "0"; then @@ -155,7 +151,7 @@ if test "${rc}" != "0"; then exit ${rc} fi -${DIFF} -I 'Algorithm Security Level' ${TMPFILE} "${srcdir}/data/gost94-cert.pem" || ${DIFF} -I 'Algorithm Security Level' --strip-trailing-cr "${TMPFILE}" "${srcdir}/data/gost94-cert.pem" +check_if_equal ${TMPFILE} "${srcdir}/data/gost94-cert.pem" "Algorithm Security Level" rc=$? if test "${rc}" != "0"; then @@ -171,7 +167,8 @@ if test "${rc}" != "0"; then exit ${rc} fi -${DIFF} -I 'Algorithm Security Level' ${TMPFILE} "${srcdir}/data/multi-value-dn.pem" || ${DIFF} -I 'Algorithm Security Level' --strip-trailing-cr "${TMPFILE}" "${srcdir}/data/multi-value-dn.pem" +# Needed for FIPS140 mode +check_if_equal "${srcdir}/data/multi-value-dn.pem" ${TMPFILE} "Algorithm Security Level:" rc=$? if test "${rc}" != "0"; then -- cgit v1.2.1