Blame tests/cert-tests/certtool-long-oids

Packit 549fdc
#!/bin/sh
Packit 549fdc
Packit 549fdc
# Copyright (C) 2016 Red Hat, Inc.
Packit 549fdc
#
Packit 549fdc
# This file is part of GnuTLS.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is free software; you can redistribute it and/or modify it
Packit 549fdc
# under the terms of the GNU General Public License as published by the
Packit 549fdc
# Free Software Foundation; either version 3 of the License, or (at
Packit 549fdc
# your option) any later version.
Packit 549fdc
#
Packit 549fdc
# GnuTLS is distributed in the hope that it will be useful, but
Packit 549fdc
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 549fdc
# General Public License for more details.
Packit 549fdc
#
Packit 549fdc
# You should have received a copy of the GNU General Public License
Packit 549fdc
# along with GnuTLS; if not, write to the Free Software Foundation,
Packit 549fdc
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit 549fdc
Packit 549fdc
#set -e
Packit 549fdc
Packit 549fdc
# This checks whether OIDs > 2^32 are correctly decoded.
Packit 549fdc
Packit 549fdc
srcdir="${srcdir:-.}"
Packit 549fdc
CERTTOOL="${CERTTOOL:-../../src/certtool${EXEEXT}}"
Packit 549fdc
DIFF="${DIFF:-diff -b -B}"
Packit 549fdc
OUTFILE="long-oids.$$.pem.tmp"
Packit 549fdc
TMPFILE1="long-oids1.$$.pem.tmp"
Packit 549fdc
Packit 549fdc
if ! test -x "${CERTTOOL}"; then
Packit 549fdc
	exit 77
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
if ! test -z "${VALGRIND}"; then
Packit 549fdc
	VALGRIND="${LIBTOOL:-libtool} --mode=execute ${VALGRIND} --error-exitcode=3"
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
${VALGRIND} "${CERTTOOL}" -i --infile "${srcdir}/data/long-oids.pem"|grep -v "Not After:"|grep -v ^warning >$OUTFILE
Packit 549fdc
rc=$?
Packit 549fdc
Packit 549fdc
if test "${rc}" != 0;then
Packit 549fdc
	echo "Could not read cert with long OIDs"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
cat "${srcdir}/data/long-oids.pem" |grep -v "Not After:"|grep -v ^warning >${TMPFILE1}
Packit 549fdc
$DIFF ${TMPFILE1} ${OUTFILE}
Packit 549fdc
if test $? != 0;then
Packit 549fdc
	echo "Error in parsing cert with long OIDs"
Packit 549fdc
	exit 1
Packit 549fdc
fi
Packit 549fdc
Packit 549fdc
rm -f "$OUTFILE" "${TMPFILE1}" "${TMPFILE2}"
Packit 549fdc
Packit 549fdc
exit 0