diff options
Diffstat (limited to 'libotr/libgpg-error-1.42/tests')
-rw-r--r-- | libotr/libgpg-error-1.42/tests/Makefile.am | 44 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/Makefile.in | 920 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/etc/t-argparse.conf | 80 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-argparse.c | 168 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-argparse.conf | 16 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-b64.c | 374 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-common.h | 136 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-lock.c | 333 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-logging.c | 250 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-malloc.c | 141 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-poll.c | 440 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-printf.c | 544 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-strerror.c | 63 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-stringutils.c | 395 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-syserror.c | 87 | ||||
-rw-r--r-- | libotr/libgpg-error-1.42/tests/t-version.c | 178 |
16 files changed, 4169 insertions, 0 deletions
diff --git a/libotr/libgpg-error-1.42/tests/Makefile.am b/libotr/libgpg-error-1.42/tests/Makefile.am new file mode 100644 index 0000000..be04df3 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/Makefile.am @@ -0,0 +1,44 @@ +# Makefile.am for libgpg-error/tests. +# Copyright (C) 2003 g10 Code GmbH +# +# This file is part of libgpg-error. +# +# libgpg-error is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# libgpg-error is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +if HAVE_W32CE_SYSTEM +extra_includes = -idirafter $(top_builddir)/src/gpg-extra +else +extra_includes = +endif + +EXTRA_DIST = t-argparse.conf etc/t-argparse.conf + +gpg_error_lib = ../src/libgpg-error.la + +TESTS = t-version t-strerror t-syserror t-lock t-printf t-poll t-b64 \ + t-argparse t-logging t-stringutils t-malloc + +AM_CPPFLAGS = -I$(top_builddir)/src $(extra_includes) + +AM_LDFLAGS = -no-install +LDADD = $(gpg_error_lib) @LDADD_FOR_TESTS_KLUDGE@ + +noinst_PROGRAMS = $(TESTS) +noinst_HEADERS = t-common.h + +t_lock_LDADD = $(LDADD) $(LIBMULTITHREAD) +t_poll_LDADD = $(LDADD) $(LIBMULTITHREAD) diff --git a/libotr/libgpg-error-1.42/tests/Makefile.in b/libotr/libgpg-error-1.42/tests/Makefile.in new file mode 100644 index 0000000..2640a2b --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/Makefile.in @@ -0,0 +1,920 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Makefile.am for libgpg-error/tests. +# Copyright (C) 2003 g10 Code GmbH +# +# This file is part of libgpg-error. +# +# libgpg-error is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of the +# License, or (at your option) any later version. +# +# libgpg-error is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +TESTS = t-version$(EXEEXT) t-strerror$(EXEEXT) t-syserror$(EXEEXT) \ + t-lock$(EXEEXT) t-printf$(EXEEXT) t-poll$(EXEEXT) \ + t-b64$(EXEEXT) t-argparse$(EXEEXT) t-logging$(EXEEXT) \ + t-stringutils$(EXEEXT) t-malloc$(EXEEXT) +noinst_PROGRAMS = $(am__EXEEXT_1) +subdir = tests +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/autobuild.m4 \ + $(top_srcdir)/m4/ax_cc_for_build.m4 \ + $(top_srcdir)/m4/estream.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gnupg-misc.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/threadlib.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = t-version$(EXEEXT) t-strerror$(EXEEXT) \ + t-syserror$(EXEEXT) t-lock$(EXEEXT) t-printf$(EXEEXT) \ + t-poll$(EXEEXT) t-b64$(EXEEXT) t-argparse$(EXEEXT) \ + t-logging$(EXEEXT) t-stringutils$(EXEEXT) t-malloc$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +t_argparse_SOURCES = t-argparse.c +t_argparse_OBJECTS = t-argparse.$(OBJEXT) +t_argparse_LDADD = $(LDADD) +t_argparse_DEPENDENCIES = $(gpg_error_lib) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +t_b64_SOURCES = t-b64.c +t_b64_OBJECTS = t-b64.$(OBJEXT) +t_b64_LDADD = $(LDADD) +t_b64_DEPENDENCIES = $(gpg_error_lib) +t_lock_SOURCES = t-lock.c +t_lock_OBJECTS = t-lock.$(OBJEXT) +am__DEPENDENCIES_1 = $(gpg_error_lib) +am__DEPENDENCIES_2 = +t_lock_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +t_logging_SOURCES = t-logging.c +t_logging_OBJECTS = t-logging.$(OBJEXT) +t_logging_LDADD = $(LDADD) +t_logging_DEPENDENCIES = $(gpg_error_lib) +t_malloc_SOURCES = t-malloc.c +t_malloc_OBJECTS = t-malloc.$(OBJEXT) +t_malloc_LDADD = $(LDADD) +t_malloc_DEPENDENCIES = $(gpg_error_lib) +t_poll_SOURCES = t-poll.c +t_poll_OBJECTS = t-poll.$(OBJEXT) +t_poll_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +t_printf_SOURCES = t-printf.c +t_printf_OBJECTS = t-printf.$(OBJEXT) +t_printf_LDADD = $(LDADD) +t_printf_DEPENDENCIES = $(gpg_error_lib) +t_strerror_SOURCES = t-strerror.c +t_strerror_OBJECTS = t-strerror.$(OBJEXT) +t_strerror_LDADD = $(LDADD) +t_strerror_DEPENDENCIES = $(gpg_error_lib) +t_stringutils_SOURCES = t-stringutils.c +t_stringutils_OBJECTS = t-stringutils.$(OBJEXT) +t_stringutils_LDADD = $(LDADD) +t_stringutils_DEPENDENCIES = $(gpg_error_lib) +t_syserror_SOURCES = t-syserror.c +t_syserror_OBJECTS = t-syserror.$(OBJEXT) +t_syserror_LDADD = $(LDADD) +t_syserror_DEPENDENCIES = $(gpg_error_lib) +t_version_SOURCES = t-version.c +t_version_OBJECTS = t-version.$(OBJEXT) +t_version_LDADD = $(LDADD) +t_version_DEPENDENCIES = $(gpg_error_lib) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/t-argparse.Po ./$(DEPDIR)/t-b64.Po \ + ./$(DEPDIR)/t-lock.Po ./$(DEPDIR)/t-logging.Po \ + ./$(DEPDIR)/t-malloc.Po ./$(DEPDIR)/t-poll.Po \ + ./$(DEPDIR)/t-printf.Po ./$(DEPDIR)/t-strerror.Po \ + ./$(DEPDIR)/t-stringutils.Po ./$(DEPDIR)/t-syserror.Po \ + ./$(DEPDIR)/t-version.Po +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = t-argparse.c t-b64.c t-lock.c t-logging.c t-malloc.c \ + t-poll.c t-printf.c t-strerror.c t-stringutils.c t-syserror.c \ + t-version.c +DIST_SOURCES = t-argparse.c t-b64.c t-lock.c t-logging.c t-malloc.c \ + t-poll.c t-printf.c t-strerror.c t-stringutils.c t-syserror.c \ + t-version.c +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build-aux/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_FILEVERSION = @BUILD_FILEVERSION@ +BUILD_REVISION = @BUILD_REVISION@ +BUILD_TIMESTAMP = @BUILD_TIMESTAMP@ +BUILD_VERSION = @BUILD_VERSION@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@ +FGREP = @FGREP@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GPG_ERROR_CONFIG_CFLAGS = @GPG_ERROR_CONFIG_CFLAGS@ +GPG_ERROR_CONFIG_HOST = @GPG_ERROR_CONFIG_HOST@ +GPG_ERROR_CONFIG_LIBS = @GPG_ERROR_CONFIG_LIBS@ +GPG_ERROR_CONFIG_LIBS_PRIVATE = @GPG_ERROR_CONFIG_LIBS_PRIVATE@ +GPG_ERROR_CONFIG_MT_CFLAGS = @GPG_ERROR_CONFIG_MT_CFLAGS@ +GPG_ERROR_CONFIG_MT_LIBS = @GPG_ERROR_CONFIG_MT_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALLSHELLPATH = @INSTALLSHELLPATH@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LD = @LD@ +LDADD_FOR_TESTS_KLUDGE = @LDADD_FOR_TESTS_KLUDGE@ +LDFLAGS = @LDFLAGS@ +LIBGPG_ERROR_LT_AGE = @LIBGPG_ERROR_LT_AGE@ +LIBGPG_ERROR_LT_CURRENT = @LIBGPG_ERROR_LT_CURRENT@ +LIBGPG_ERROR_LT_REVISION = @LIBGPG_ERROR_LT_REVISION@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBMULTITHREAD = @LIBMULTITHREAD@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBTHREAD = @LIBTHREAD@ +LIBTOOL = @LIBTOOL@ +LIB_NETWORK = @LIB_NETWORK@ +LIB_SCHED_YIELD = @LIB_SCHED_YIELD@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBMULTITHREAD = @LTLIBMULTITHREAD@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBTHREAD = @LTLIBTHREAD@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +RC = @RC@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +VERSION_NUMBER = @VERSION_NUMBER@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +@HAVE_W32CE_SYSTEM_FALSE@extra_includes = +@HAVE_W32CE_SYSTEM_TRUE@extra_includes = -idirafter $(top_builddir)/src/gpg-extra +EXTRA_DIST = t-argparse.conf etc/t-argparse.conf +gpg_error_lib = ../src/libgpg-error.la +AM_CPPFLAGS = -I$(top_builddir)/src $(extra_includes) +AM_LDFLAGS = -no-install +LDADD = $(gpg_error_lib) @LDADD_FOR_TESTS_KLUDGE@ +noinst_HEADERS = t-common.h +t_lock_LDADD = $(LDADD) $(LIBMULTITHREAD) +t_poll_LDADD = $(LDADD) $(LIBMULTITHREAD) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +t-argparse$(EXEEXT): $(t_argparse_OBJECTS) $(t_argparse_DEPENDENCIES) $(EXTRA_t_argparse_DEPENDENCIES) + @rm -f t-argparse$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_argparse_OBJECTS) $(t_argparse_LDADD) $(LIBS) + +t-b64$(EXEEXT): $(t_b64_OBJECTS) $(t_b64_DEPENDENCIES) $(EXTRA_t_b64_DEPENDENCIES) + @rm -f t-b64$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_b64_OBJECTS) $(t_b64_LDADD) $(LIBS) + +t-lock$(EXEEXT): $(t_lock_OBJECTS) $(t_lock_DEPENDENCIES) $(EXTRA_t_lock_DEPENDENCIES) + @rm -f t-lock$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_lock_OBJECTS) $(t_lock_LDADD) $(LIBS) + +t-logging$(EXEEXT): $(t_logging_OBJECTS) $(t_logging_DEPENDENCIES) $(EXTRA_t_logging_DEPENDENCIES) + @rm -f t-logging$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_logging_OBJECTS) $(t_logging_LDADD) $(LIBS) + +t-malloc$(EXEEXT): $(t_malloc_OBJECTS) $(t_malloc_DEPENDENCIES) $(EXTRA_t_malloc_DEPENDENCIES) + @rm -f t-malloc$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_malloc_OBJECTS) $(t_malloc_LDADD) $(LIBS) + +t-poll$(EXEEXT): $(t_poll_OBJECTS) $(t_poll_DEPENDENCIES) $(EXTRA_t_poll_DEPENDENCIES) + @rm -f t-poll$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_poll_OBJECTS) $(t_poll_LDADD) $(LIBS) + +t-printf$(EXEEXT): $(t_printf_OBJECTS) $(t_printf_DEPENDENCIES) $(EXTRA_t_printf_DEPENDENCIES) + @rm -f t-printf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_printf_OBJECTS) $(t_printf_LDADD) $(LIBS) + +t-strerror$(EXEEXT): $(t_strerror_OBJECTS) $(t_strerror_DEPENDENCIES) $(EXTRA_t_strerror_DEPENDENCIES) + @rm -f t-strerror$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_strerror_OBJECTS) $(t_strerror_LDADD) $(LIBS) + +t-stringutils$(EXEEXT): $(t_stringutils_OBJECTS) $(t_stringutils_DEPENDENCIES) $(EXTRA_t_stringutils_DEPENDENCIES) + @rm -f t-stringutils$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_stringutils_OBJECTS) $(t_stringutils_LDADD) $(LIBS) + +t-syserror$(EXEEXT): $(t_syserror_OBJECTS) $(t_syserror_DEPENDENCIES) $(EXTRA_t_syserror_DEPENDENCIES) + @rm -f t-syserror$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_syserror_OBJECTS) $(t_syserror_LDADD) $(LIBS) + +t-version$(EXEEXT): $(t_version_OBJECTS) $(t_version_DEPENDENCIES) $(EXTRA_t_version_DEPENDENCIES) + @rm -f t-version$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(t_version_OBJECTS) $(t_version_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-argparse.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-b64.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-lock.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-logging.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-malloc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-poll.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-printf.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-strerror.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-stringutils.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-syserror.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-version.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(PROGRAMS) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -f ./$(DEPDIR)/t-argparse.Po + -rm -f ./$(DEPDIR)/t-b64.Po + -rm -f ./$(DEPDIR)/t-lock.Po + -rm -f ./$(DEPDIR)/t-logging.Po + -rm -f ./$(DEPDIR)/t-malloc.Po + -rm -f ./$(DEPDIR)/t-poll.Po + -rm -f ./$(DEPDIR)/t-printf.Po + -rm -f ./$(DEPDIR)/t-strerror.Po + -rm -f ./$(DEPDIR)/t-stringutils.Po + -rm -f ./$(DEPDIR)/t-syserror.Po + -rm -f ./$(DEPDIR)/t-version.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f ./$(DEPDIR)/t-argparse.Po + -rm -f ./$(DEPDIR)/t-b64.Po + -rm -f ./$(DEPDIR)/t-lock.Po + -rm -f ./$(DEPDIR)/t-logging.Po + -rm -f ./$(DEPDIR)/t-malloc.Po + -rm -f ./$(DEPDIR)/t-poll.Po + -rm -f ./$(DEPDIR)/t-printf.Po + -rm -f ./$(DEPDIR)/t-strerror.Po + -rm -f ./$(DEPDIR)/t-stringutils.Po + -rm -f ./$(DEPDIR)/t-syserror.Po + -rm -f ./$(DEPDIR)/t-version.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ + check-am clean clean-generic clean-libtool \ + clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libotr/libgpg-error-1.42/tests/etc/t-argparse.conf b/libotr/libgpg-error-1.42/tests/etc/t-argparse.conf new file mode 100644 index 0000000..6559266 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/etc/t-argparse.conf @@ -0,0 +1,80 @@ +# Global test config file for t-argparse + +# Options applied to all user's config files +#verbose + + +# The meta command echo simply prints the argument. With a dash +# prefix it does not prepend the file name and line number. +[-echo Begin global config] + +[-echo use $${user} to echo the current user (${user})] +[-echo use $${file} to echo the current file (${file})] +[-echo use $${line} to echo the current line (${line})] +[-echo use $${epoch} to echo a timestamp (${epoch})] + +[verbose] + +[user joy] +# All the following options are applied only if the current user's +# account name is "joy" (case-insensitive). This ends with the next +# user statement. This does not affect "echo" and "verbose". + +# info is an alias for echo but only executed if a user secion is active. +# For future compatibility do not use percent or dollar signs. +[-info In user Joy but real user id ${user}] + +[-verbose] +[+force] +# All following option are forced and thus ignored when set in user +# config files. Valid until the next [user] statement. Take care +# that there are often "no-", "disable-", or "enable-" versions of +# options; these should be explictly marked as ignored so that they +# can't be used to override the force attribute. + +[ignore] + +# The compliance is set immutable for these users +verbose + +[-force] +not-my-option + +# If uncommented The next shall raise an error due to the garbage at the end. +#<off>[+ignore] fooo + + +[+ignore-all] +# All options are ignored. + + +[-ignore] # Comment at line end +# Options wich shall not be ignored. */ +#no-verbose + + +# Options applied only for user joy end here. +[user wk ] +[-info Options applied only for user wk follow] + +[ignore] +output +[-ignore] + + +# Change the immutable attribute back to mutable. +[-force] +#compliance gnupg + +# Default key for user john +my-option 42 + +# Options applied only for user joy end here. +[user *] +[-info All the following options are applied only if the] +[-info current user has no specific section above.] + +# The default algorithm for new keys is set to this. +a-long-option + +[-echo End global config] diff --git a/libotr/libgpg-error-1.42/tests/t-argparse.c b/libotr/libgpg-error-1.42/tests/t-argparse.c new file mode 100644 index 0000000..8ba5841 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-argparse.c @@ -0,0 +1,168 @@ +/* t-argparse.c - Check the argparse API + * Copyright (C) 2018, 2020 g10 Code GmbH + * + * This file is part of Libgpg-error. + * + * Libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#define PGM "t-argparse" +#include "t-common.h" + + +static struct { + int verbose; + int debug; + char *outfile; + char *crf; + int myopt; + int echo; + int a_long_one; +} opt; + + + +static const char * +my_strusage (int level) +{ + const char *p; + + switch (level) + { + case 9: p = "LGPL-2.1-or-later"; break; + + case 11: p = "t-argparse"; break; + + default: p = NULL; + } + return p; +} + + + +int +main (int argc, char **argv) +{ + gpgrt_opt_t opts[] = { + ARGPARSE_verbatim("Now for the options:\n"), + ARGPARSE_x ('v', "verbose", NONE, 0, "Laut sein"), + ARGPARSE_s_n('e', "echo" , ("Zeile ausgeben, damit wir sehen, " + "was wir eingegeben haben")), + ARGPARSE_s_n('d', "debug", "Debug\nfalls mal etwas\nschief geht"), + ARGPARSE_s_s('o', "output", 0 ), + ARGPARSE_o_s('c', "cross-ref", "cross-reference erzeugen\n" ), + /* Note that on a non-utf8 terminal the ß might garble the output. */ + ARGPARSE_header("extra-options", "List of extra options"), + ARGPARSE_s_n('s', "street","|Straße|set the name of the street to Straße"), + ARGPARSE_o_i('m', "my-option", 0), + ARGPARSE_o_i('M', "not-my-option", 0), + ARGPARSE_s_n(500, "a-long-option", 0 ), + ARGPARSE_conffile(501, "options", "|FILE|read options from FILE"), + ARGPARSE_noconffile(502, "no-options", "Ignore conf files"), + ARGPARSE_verbatim("This epilog consists\nof only 2 lines\n"), + ARGPARSE_end() + }; + gpgrt_argparse_t pargs = { &argc, &argv, (ARGPARSE_FLAG_ALL + | ARGPARSE_FLAG_MIXED + | ARGPARSE_FLAG_ONEDASH + | ARGPARSE_FLAG_SYS + | ARGPARSE_FLAG_USER + /* | ARGPARSE_FLAG_VERBOSE */ + /* | ARGPARSE_FLAG_WITHATTR */ + ) }; + int i; + const char *srcdir; + int any_warn = 0; + + gpgrt_set_strusage (my_strusage); + srcdir = getenv ("srcdir"); + if (!srcdir) + srcdir = "."; + gpgrt_set_confdir (GPGRT_CONFDIR_USER, srcdir); + { + char *p = gpgrt_fnameconcat (srcdir, "etc", NULL); + gpgrt_set_confdir (GPGRT_CONFDIR_SYS, p); + xfree (p); + } + + while (gpgrt_argparser (&pargs, opts, PGM".conf")) + { + /* printf ("got option %3d type %0x04x\n", pargs.r_opt, pargs.r_type); */ + /* if (pargs.r_type & (ARGPARSE_ATTR_IGNORE|ARGPARSE_ATTR_FORCE)) */ + /* printf ("attributes:%s%s\n", */ + /* (pargs.r_type & ARGPARSE_ATTR_IGNORE)? " ignore":"", */ + /* (pargs.r_type & ARGPARSE_ATTR_FORCE)? " force":""); */ + /* if (pargs.r_type & ARGPARSE_OPT_IGNORE) */ + /* { */ + /* printf ("ignored\n"); */ + /* continue; */ + /* } */ + switch (pargs.r_opt) + { + case ARGPARSE_CONFFILE: + printf ("current conffile='%s'\n", + pargs.r_type? pargs.r.ret_str: "[cmdline]"); + break; + case ARGPARSE_IS_ARG : + printf ("arg='%s'\n", pargs.r.ret_str); + break; + + case 'v': opt.verbose++; break; + case 'e': opt.echo++; break; + case 'd': opt.debug++; debug=1;break; + case 'o': opt.outfile = pargs.r.ret_str; break; + case 'c': opt.crf = pargs.r_type? pargs.r.ret_str:"a.crf"; break; + case 'm': opt.myopt = pargs.r_type? pargs.r.ret_int : 1; break; + case 'M': opt.myopt = 0; break; + case 500: opt.a_long_one++; break; + default : pargs.err = ARGPARSE_PRINT_WARNING; any_warn = 1; break; + } + } + for (i=0; i < argc; i++ ) + printf ("%3d -> (%s)\n", i, argv[i] ); + if (opt.verbose) + puts ("Options:"); + if (opt.verbose) + printf (" verbose=%d\n", opt.verbose ); + if (opt.debug) + printf (" debug=%d\n", opt.debug ); + if (opt.outfile) + printf (" outfile='%s'\n", opt.outfile ); + if (opt.crf) + printf (" crffile='%s'\n", opt.crf ); + if (opt.myopt) + printf (" myopt=%d\n", opt.myopt ); + if (opt.a_long_one) + printf (" a-long-one=%d\n", opt.a_long_one ); + if (opt.echo) + printf (" echo=%d\n", opt.echo ); + + gpgrt_argparse (NULL, &pargs, NULL); + + (void)show; + (void)fail; + (void)die; + + return !!any_warn; +} diff --git a/libotr/libgpg-error-1.42/tests/t-argparse.conf b/libotr/libgpg-error-1.42/tests/t-argparse.conf new file mode 100644 index 0000000..431ee7d --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-argparse.conf @@ -0,0 +1,16 @@ +# User test config file for t-argparse + +[-echo begin of user config (user=${user})] +[+verbose] +# Options applied to all user's config files +echo + +# The next should be flagged as unexpected meta command. +#<off>[ignore] + +my-option 4711 + +not-my-option + +verbose +[-echo end of user config] diff --git a/libotr/libgpg-error-1.42/tests/t-b64.c b/libotr/libgpg-error-1.42/tests/t-b64.c new file mode 100644 index 0000000..0171909 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-b64.c @@ -0,0 +1,374 @@ +/* t-b64.c - b64dec tests. + * Copyright (C) 2017, 2018 g10 Code GmbH + * + * This file is part of Libgpg-error. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <string.h> +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#define PGM "t-b64" +#include "t-common.h" + +static const char *test_string = "libgpg-error is free software; " + "you can redistribute it and/or modify it under the terms of " + "the GNU Lesser General Public License as published by the Free " + "Software Foundation; either version 2.1 of the License, or " + "(at your option) any later version."; + +static const char *test_string_b64_0 = "bGliZ3BnLWVycm9yIGlzIGZyZWUgc29" + "mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkgaXQgd" + "W5kZXIgdGhlIHRlcm1zIG9mIHRoZSBHTlUgTGVzc2VyIEdlbmVyYWwgUHVibGljIEx" + "pY2Vuc2UgYXMgcHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb" + "247IGVpdGhlciB2ZXJzaW9uIDIuMSBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXI" + "gb3B0aW9uKSBhbnkgbGF0ZXIgdmVyc2lvbi4="; + +static const char *test_string_b64_1 = + "bGliZ3BnLWVycm9yIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmli\n" + "dXRlIGl0IGFuZC9vciBtb2RpZnkgaXQgdW5kZXIgdGhlIHRlcm1zIG9mIHRoZSBH\n" + "TlUgTGVzc2VyIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgYXMgcHVibGlzaGVkIGJ5\n" + "IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uIDIu\n" + "MSBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXIgb3B0aW9uKSBhbnkgbGF0ZXIg\n" + "dmVyc2lvbi4=\n"; + +static const char *test_string_b64_2 = + "-----BEGIN DATA-----\n" + "bGliZ3BnLWVycm9yIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmli\n" + "dXRlIGl0IGFuZC9vciBtb2RpZnkgaXQgdW5kZXIgdGhlIHRlcm1zIG9mIHRoZSBH\n" + "TlUgTGVzc2VyIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgYXMgcHVibGlzaGVkIGJ5\n" + "IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uIDIu\n" + "MSBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXIgb3B0aW9uKSBhbnkgbGF0ZXIg\n" + "dmVyc2lvbi4=\n" + "-----END DATA-----\n"; + +static const char *test_string_b64_3 = + "-----BEGIN PGP ARMORED FILE-----\n" + "\n" + "bGliZ3BnLWVycm9yIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmli\n" + "dXRlIGl0IGFuZC9vciBtb2RpZnkgaXQgdW5kZXIgdGhlIHRlcm1zIG9mIHRoZSBH\n" + "TlUgTGVzc2VyIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgYXMgcHVibGlzaGVkIGJ5\n" + "IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb247IGVpdGhlciB2ZXJzaW9uIDIu\n" + "MSBvZiB0aGUgTGljZW5zZSwgb3IgKGF0IHlvdXIgb3B0aW9uKSBhbnkgbGF0ZXIg\n" + "dmVyc2lvbi4=\n" + "=4BMJ\n" + "-----END PGP ARMORED FILE-----\n"; + +static const char *test_blob_1 = "\x01\x03\x04\xff"; +static const char *test_blob_1_b64_0 = "AQME/w=="; +static const char *test_blob_2 = "\x01\x03\x04\xff""A"; +static const char *test_blob_2_b64_0 = "AQME/0E="; +static const char *test_blob_3 = "\x01\x03\x04\xff""AB"; +static const char *test_blob_3_b64_0 = "AQME/0FC"; + + +#define FAIL(a) do { fail ("line %d: test %d failed\n", __LINE__, (a)); \ + } while(0) + +static gpg_error_t +test_b64enc_string (const char *string, const char *expected, const char *title) +{ + gpg_err_code_t err; + estream_t fp; + gpgrt_b64state_t state; + char *result; + + fp = es_fopenmem (0, "rwb"); + if (!fp) + die ("es_fopenmem failed: %s\n", gpg_strerror (gpg_error_from_syserror ())); + + state = gpgrt_b64enc_start (fp, title); + if (!state) + { + err = gpg_err_code_from_syserror (); + fail ("gpgrt_b64enc_start failed: %s\n", gpg_strerror (err)); + return err; + } + + err = gpgrt_b64enc_write (state, string, strlen (string)); + if (err) + { + fail ("gpgrt_b64enc_write failed: %s\n", gpg_strerror (err)); + return err; + } + + err = gpgrt_b64enc_finish (state); + if (err) + { + fail ("gpgrt_b64enc_finish failed: %s\n", gpg_strerror (err)); + return err; + } + + es_fputc (0, fp); + if (es_fclose_snatch (fp, (void**)&result, NULL)) + die ("es_fclose_snatch failed: %s\n", + gpg_strerror (gpg_error_from_syserror ())); + + if (strcmp (result, expected)) + { + if (verbose) + { + gpgrt_log_debug_string (result, "result: "); + gpgrt_log_debug_string (expected, "expect: "); + } + return GPG_ERR_FALSE; + } + + es_free (result); + return 0; +} + + +static gpg_error_t +test_b64dec_string (const char *string, const char *expected, const char *title) +{ + gpg_error_t err; + gpgrt_b64state_t state; + char *buffer; + size_t len; + + len = strlen (string); + buffer = malloc (strlen (string) + 1); + if (!buffer) + { + err = gpg_error_from_syserror (); + return err; + } + strcpy (buffer, string); + + state = gpgrt_b64dec_start (title); + if (!state) + { + err = gpg_err_code_from_syserror (); + fail ("gpgrt_b64dec_start failed: %s\n", gpg_strerror (err)); + free (buffer); + return err; + } + + err = gpgrt_b64dec_proc (state, buffer, len, &len); + if (err) + { + if (gpg_err_code (err) != GPG_ERR_EOF) + { + free (buffer); + free (state); + return err; + } + } + + err = gpgrt_b64dec_finish (state); + if (err) + { + free (buffer); + return err; + } + + if (len != strlen (expected) || strncmp (buffer, expected, len)) + { + if (verbose) + { + gpgrt_log_debug_string (buffer, "result(len=%zu): ", len); + gpgrt_log_debug_string (expected, "expect(len=%zu): ", + strlen (expected)); + } + return GPG_ERR_FALSE; + } + + free (buffer); + return 0; +} + + +static void +encoder_tests (void) +{ + gpg_err_code_t err; + + if (verbose) + show ("running encoder tests\n"); + + err = test_b64enc_string (test_string, test_string_b64_0, ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string (test_string, test_string_b64_1, NULL); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string (test_string, test_string_b64_2, "DATA"); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string (test_string, test_string_b64_3, "PGP ARMORED FILE"); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + /* Note that the _test_ function dows not allow to provide a string + * with an empdded Nul. */ + err = test_b64enc_string (test_blob_1, test_blob_1_b64_0, ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string (test_blob_2, test_blob_2_b64_0, ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string (test_blob_3, test_blob_3_b64_0, ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + err = test_b64enc_string ("@", "QA==", ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string ("@", "QA==\n", NULL); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string ("@", + "-----BEGIN PGP SOMETHING-----\n" + "\n" + "QA==\n" + "=eMoB\n" + "-----END PGP SOMETHING-----\n", + "PGP SOMETHING"); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + err = test_b64enc_string ("", "", ""); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string ("", "", NULL); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + err = test_b64enc_string ("", "", "PGP SOMETHING"); + if (err) + fail ("encoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); +} + + +static void +decoder_tests (void) +{ + gpg_err_code_t err; + + if (verbose) + show ("running decoder tests\n"); + + err = test_b64dec_string (test_string_b64_0, test_string, NULL); + if (err) + fail ("decoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + err = test_b64dec_string (test_string_b64_1, test_string, NULL); + if (err) + fail ("decoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + err = test_b64dec_string (test_string_b64_2, test_string, ""); + if (err) + fail ("decoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + + err = test_b64dec_string (test_string_b64_2, test_string, NULL); + if (err != GPG_ERR_BAD_DATA) + fail ("decoder test at line %d failed: %s\n", __LINE__, gpg_strerror (err)); + +} + + +static gpg_error_t +extra_tests (void) +{ + gpg_err_code_t err; + gpgrt_b64state_t state; + + if (verbose) + show ("running extra tests\n"); + + /* Check that we detect mismacthed use of enc and dec functions. */ + state = gpgrt_b64enc_start (es_stdout, NULL); + if (!state) + { + err = gpg_err_code_from_syserror (); + fail ("gpgrt_b64enc_start failed: %s\n", gpg_strerror (err)); + return err; + } + + err = gpgrt_b64dec_finish (state); + if (err != GPG_ERR_CONFLICT) + { + fail ("gpgrt_b64dec_finish failed: %s\n", gpg_strerror (err)); + return err; + } + + state = gpgrt_b64dec_start (NULL); + if (!state) + { + err = gpg_err_code_from_syserror (); + fail ("gpgrt_b64dec_start failed: %s\n", gpg_strerror (err)); + return err; + } + + err = gpgrt_b64enc_finish (state); + if (err != GPG_ERR_CONFLICT) + { + fail ("gpgrt_b64enc_finish failed: %s\n", gpg_strerror (err)); + return err; + } + + return 0; +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./" PGM " [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + encoder_tests (); + decoder_tests (); + extra_tests (); + + return !!errorcount; +} diff --git a/libotr/libgpg-error-1.42/tests/t-common.h b/libotr/libgpg-error-1.42/tests/t-common.h new file mode 100644 index 0000000..db496e2 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-common.h @@ -0,0 +1,136 @@ +/* t-common.h - Common code for the tests. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +#include <stdarg.h> + +#include "../src/gpgrt.h" + +#ifndef PGM +# error Macro PGM not defined. +#endif +#ifndef DIM +# define DIM(array) (sizeof (array) / sizeof (*array)) +#endif + + +static int verbose; +static int debug; +static int errorcount; + + +static void die (const char *format, ...) GPGRT_ATTR_NR_PRINTF(1,2); +static void fail (const char *format, ...) GPGRT_ATTR_PRINTF(1,2); +static void show (const char *format, ...) GPGRT_ATTR_PRINTF(1,2); + + +static void * +xmalloc (size_t n) +{ + char *p = gpgrt_malloc (n); + if (!p) + die ("out of core\n"); + return p; +} + +static char * +xstrdup (const char *s) +{ + char *p = gpgrt_strdup (s); + if (!p) + die ("out of core\n"); + return p; +} + +static void +xfree (void *p) +{ + if (p) + gpgrt_free (p); +} + + + +static void +die (const char *format, ...) +{ + va_list arg_ptr ; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format) ; + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + xfree (xstrdup ("")); /* To avoid compiler warnings. */ + xfree (xmalloc (16)); /* To avoid compiler warnings. */ + exit (1); +} + + +static void +fail (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif + errorcount++; + if (errorcount >= 50) + die ("stopped after 50 errors."); +} + + +static void +show (const char *format, ...) +{ + va_list arg_ptr; + + if (!verbose) + return; +#ifdef HAVE_FLOCKFILE + flockfile (stderr); +#endif + fprintf (stderr, "%s: ", PGM); + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + if (*format && format[strlen(format)-1] != '\n') + putc ('\n', stderr); + va_end (arg_ptr); +#ifdef HAVE_FLOCKFILE + funlockfile (stderr); +#endif +} diff --git a/libotr/libgpg-error-1.42/tests/t-lock.c b/libotr/libgpg-error-1.42/tests/t-lock.c new file mode 100644 index 0000000..6add18b --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-lock.c @@ -0,0 +1,333 @@ +/* t-lock.c - Check the lock functions + * Copyright (C) 2013, 2015 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <sys/types.h> +#include <unistd.h> +#ifdef _WIN32 +# include <windows.h> +# include <time.h> +#else +# ifdef USE_POSIX_THREADS +# include <pthread.h> +# endif +#endif + +#define PGM "t-lock" + +#include "t-common.h" + +#ifdef _WIN32 +# define THREAD_RET_TYPE DWORD WINAPI +# define THREAD_RET_VALUE 0 +#else +# define THREAD_RET_TYPE void * +# define THREAD_RET_VALUE NULL +#endif + + +/* Our tests works by having a a couple of accountant threads which do + random transactions between accounts and a revision threads which + checks that the balance of all accounts is invariant. The idea for + this check is due to Bruno Haible. */ +#define N_ACCOUNT 8 +#define ACCOUNT_VALUE 42 +static int account[N_ACCOUNT]; +GPGRT_LOCK_DEFINE (accounts_lock); + +/* Number of transactions done by each accountant. */ +#define N_TRANSACTIONS 1000 + +/* Number of accountants to run. */ +#define N_ACCOUNTANTS 5 + +/* Maximum transaction value. A quite low value is used so that we + would get an integer overflow. */ +#define MAX_TRANSACTION_VALUE 50 + +/* Flag to tell the revision thread to finish. */ +static volatile int stop_revision_thread; + + +/* Initialze all accounts. */ +static void +init_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + account[i] = ACCOUNT_VALUE; +} + + +/* Check that the sum of all accounts matches the initial sum. */ +static void +check_accounts (void) +{ + int i, sum; + + sum = 0; + for (i = 0; i < N_ACCOUNT; i++) + sum += account[i]; + if (sum != N_ACCOUNT * ACCOUNT_VALUE) + die ("accounts out of balance"); +} + + +static void +print_accounts (void) +{ + int i; + + for (i=0; i < N_ACCOUNT; i++) + printf ("account %d: %6d\n", i, account[i]); +} + + +#if defined(_WIN32) || defined(USE_POSIX_THREADS) +/* Get a a random integer value in the range 0 to HIGH. */ +static unsigned int +get_rand (int high) +{ + return (unsigned int)(1+(int)((double)(high+1)*rand ()/(RAND_MAX+1.0))) - 1; +} + + +/* Pick a random account. Note that this function is not + thread-safe. */ +static int +pick_account (void) +{ + return get_rand (N_ACCOUNT - 1); +} + + +/* Pick a random value for a transaction. This is not thread-safe. */ +static int +pick_value (void) +{ + return get_rand (MAX_TRANSACTION_VALUE); +} + + +/* This is the revision department. */ +static THREAD_RET_TYPE +revision_thread (void *arg) +{ + gpg_err_code_t rc; + int i = 0; + + (void)arg; + + while (!stop_revision_thread) + { + rc = gpgrt_lock_lock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc)); + + check_accounts (); + rc = gpgrt_lock_unlock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc)); + if (!(++i%7)) + gpgrt_yield (); + } + return THREAD_RET_VALUE; +} + + +/* This is one of our accountants. */ +static THREAD_RET_TYPE +accountant_thread (void *arg) +{ + gpg_err_code_t rc; + int i; + int acc1, acc2; + int value; + + (void)arg; + +#ifdef _WIN32 + srand (time(NULL)*getpid()); /* Windows needs it per thread. */ +#endif + for (i = 0; i < N_TRANSACTIONS; i++) + { + rc = gpgrt_lock_lock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc)); + + acc1 = pick_account (); + acc2 = pick_account (); + value = pick_value (); + account[acc1] += value; + account[acc2] -= value; + + rc = gpgrt_lock_unlock (&accounts_lock); + if (rc) + fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc)); + if (i && !(i%8)) + gpgrt_yield (); + } + return THREAD_RET_VALUE; +} +#endif /*_WIN32||USE_POSIX_THREADS*/ + + +static void +run_test (void) +{ +#ifdef _WIN32 + HANDLE rthread; + HANDLE athreads[N_ACCOUNTANTS]; + int i; + int rc; + + stop_revision_thread = 0; + rthread = CreateThread (NULL, 0, revision_thread, NULL, 0, NULL); + if (!rthread) + die ("error creating revision thread: rc=%d", (int)GetLastError ()); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + athreads[i] = CreateThread (NULL, 0, accountant_thread, NULL, 0, NULL); + if (!athreads[i]) + die ("error creating accountant thread %d: rc=%d", + i, (int)GetLastError ()); + } + + for (i=0; i < N_ACCOUNTANTS; i++) + { + rc = WaitForSingleObject (athreads[i], INFINITE); + if (rc == WAIT_OBJECT_0) + show ("accountant thread %d has terminated", i); + else + fail ("waiting for accountant thread %d failed: %d", + i, (int)GetLastError ()); + CloseHandle (athreads[i]); + } + stop_revision_thread = 1; + + rc = WaitForSingleObject (rthread, INFINITE); + if (rc == WAIT_OBJECT_0) + show ("revision thread has terminated"); + else + fail ("waiting for revision thread failed: %d", (int)GetLastError ()); + CloseHandle (rthread); + +#else /*!_WIN32*/ +# ifdef USE_POSIX_THREADS + pthread_t rthread; + pthread_t athreads[N_ACCOUNTANTS]; + int i; + + stop_revision_thread = 0; + pthread_create (&rthread, NULL, revision_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + pthread_create (&athreads[i], NULL, accountant_thread, NULL); + + for (i=0; i < N_ACCOUNTANTS; i++) + { + pthread_join (athreads[i], NULL); + show ("accountant thread %d has terminated", i); + } + + stop_revision_thread = 1; + pthread_join (rthread, NULL); + show ("revision thread has terminated"); +# else /*!USE_POSIX_THREADS*/ + verbose++; + show ("no thread support - skipping test\n", PGM); + verbose--; +# endif /*!USE_POSIX_THREADS*/ +#endif /*!_WIN32*/ + + gpgrt_lock_destroy (&accounts_lock); +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + int rc; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./t-lock [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + srand (time(NULL)*getpid()); + + if (!gpg_error_check_version (GPG_ERROR_VERSION)) + { + die ("gpg_error_check_version returned an error"); + errorcount++; + } + + init_accounts (); + check_accounts (); + run_test (); + check_accounts (); + /* Run a second time to check deinit code. */ + run_test (); + check_accounts (); + /* And a third time to test an explicit init. */ + rc = gpgrt_lock_init (&accounts_lock); + if (rc) + fail ("gpgrt_lock_init failed at %d: %s", __LINE__, gpg_strerror (rc)); + run_test (); + check_accounts (); + if (verbose) + print_accounts (); + + return errorcount ? 1 : 0; +} diff --git a/libotr/libgpg-error-1.42/tests/t-logging.c b/libotr/libgpg-error-1.42/tests/t-logging.c new file mode 100644 index 0000000..4fcb64b --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-logging.c @@ -0,0 +1,250 @@ +/* t-logging.c - Check the logging interface + * Copyright (C) 2018 g10 Code GmbH + * + * This file is part of Libgpg-error. + * + * Libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <unistd.h> + +#define PGM "t-logging" +#include "t-common.h" + +/* The memory based estream we use for logging. */ +static estream_t logmemfp; + + +static const char * +my_strusage (int level) +{ + const char *p; + + switch (level) + { + case 9: p = "LGPL-2.1-or-later"; break; + case 11: p = PGM; break; + default: p = NULL; + } + return p; +} + + +/* Read all data from the log stream into a new malloced buffer and return + * that buffer. The buffer is always 0 terminated. Either returns a + * string or dies. The stream will be truncated to zero. */ +static char * +log_to_string (void) +{ +#define NCHUNK 1024 + estream_t stream = gpgrt_log_get_stream (); + char *buffer; + size_t bufsize, buflen; + size_t nread; + + gpgrt_log_flush (); + gpgrt_rewind (stream); + + buffer = NULL; + buflen = bufsize = 0; + do + { + bufsize += NCHUNK; + buffer = realloc (buffer, bufsize+1); + if (!buffer) + die ("malloc failed at line %d\n", __LINE__); + + nread = gpgrt_fread (buffer + buflen, 1, NCHUNK, stream); + if (nread < NCHUNK && gpgrt_ferror (stream)) + die ("fread failed at line %d: %s\n", __LINE__, + gpg_strerror (gpg_err_code_from_syserror ())); + buflen += nread; + } + while (nread == NCHUNK); + buffer[nread] = 0; + + if (strlen (buffer) != buflen) + fail ("stream_to_string detected an embedded nul"); + + gpgrt_ftruncate (stream, 0); + return buffer; +#undef NCHUNK +} + + +static void +check_log_info (void) +{ + char *logbuf; + + log_info ("first log\n"); + logbuf = log_to_string (); + if (strcmp (logbuf, "t-logging: first log\n")) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* The second line should not have a LF. */ + log_info ("second log line"); + log_info ("third log line"); + logbuf = log_to_string (); + if (strcmp (logbuf, ("t-logging: second log line\n" + "t-logging: third log line"))) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* Now a multi line log. */ + log_info ("This is log line 1\nand 2\nand 3\n"); + logbuf = log_to_string (); + if (strcmp (logbuf, ("t-logging: This is log line 1\n" + "and 2\n" + "and 3\n"))) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* With arguments. */ + log_info ("file '%s' line %d: %s\n", "/foo/bar.txt", 20, "not found"); + logbuf = log_to_string (); + if (strcmp (logbuf, "t-logging: file '/foo/bar.txt' line 20: not found\n")) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* With arguments and a control char in the string arg. */ + log_info ("file '%s' line %d: %s\n", "/foo/bar.txt\b", 20, "not found"); + logbuf = log_to_string (); + if (strcmp (logbuf, + "t-logging: file '/foo/bar.txt\\b' line 20: not found\n")) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* With arguments and the prefix in a string arg. */ + log_info ("file '%s': %s\n", "/foo/bar.txt\nt-logging", "not \x01 found"); + logbuf = log_to_string (); + if (strcmp (logbuf, + "t-logging: file '/foo/bar.txt\\nt-logging': not \\x01 found\n")) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + + /* With arguments and byte with bit 7 set in a string arg. */ + log_info ("file '%s': %s\n", "/foo/bar.txt\n", "not \x81 found"); + logbuf = log_to_string (); + if (strcmp (logbuf, + "t-logging: file '/foo/bar.txt\\n': not \x81 found\n")) + fail ("log_info test failed at line %d\n", __LINE__); + /* show ("===>%s<===\n", logbuf); */ + + free (logbuf); +} + + +static void +check_with_pid (void) +{ + char testbuf[100]; + char *logbuf; + + snprintf (testbuf, sizeof testbuf, "t-logging[%u]: ", + (unsigned int)getpid ()); + + log_info ("first log\n"); + logbuf = log_to_string (); + if (strncmp (logbuf, testbuf, strlen (testbuf)) + || strcmp (logbuf+strlen (testbuf), "first log\n")) + fail ("log_with_pid test failed at line %d\n", __LINE__); + free (logbuf); + + log_info ("This is log line 1\nand 2\nand 3\n"); + logbuf = log_to_string (); + if (strncmp (logbuf, testbuf, strlen (testbuf)) + || strcmp (logbuf+strlen (testbuf), ("This is log line 1\n" + "and 2\n" + "and 3\n"))) + fail ("log_with_pid test failed at line %d\n", __LINE__); + free (logbuf); +} + + +static void +check_log_error (void) +{ + char *logbuf; + + if (log_get_errorcount (0)) + fail ("log_get_errorcount() != 0 at line %d\n", __LINE__); + + log_error ("Hola, something went wrong\n"); + if (log_get_errorcount (0) != 1) + fail ("log_get_errorcount() != 1 at line %d\n", __LINE__); + logbuf = log_to_string (); + if (strcmp (logbuf, "t-logging: Hola, something went wrong\n")) + fail ("log_info test failed at line %d\n", __LINE__); + free (logbuf); + if (log_get_errorcount (0) != 1) + fail ("log_get_errorcount() != 1 at line %d\n", __LINE__); + if (log_get_errorcount (1) != 1) /* note: clear returns old value. */ + fail ("log_get_errorcount() != 1 at line %d\n", __LINE__); + if (log_get_errorcount (0)) + fail ("log_get_errorcount() != 0 after clear at line %d\n", __LINE__); +} + + +int +main (int argc, char **argv) +{ + gpgrt_opt_t opts[] = { + ARGPARSE_x ('v', "verbose", NONE, 0, "Print more diagnostics"), + ARGPARSE_s_n('d', "debug", "Flyswatter"), + ARGPARSE_end() + }; + gpgrt_argparse_t pargs = { &argc, &argv, 0 }; + + gpgrt_set_strusage (my_strusage); + gpgrt_log_set_prefix (gpgrt_strusage (11), GPGRT_LOG_WITH_PREFIX); + + while (gpgrt_argparse (NULL, &pargs, opts)) + { + switch (pargs.r_opt) + { + case 'v': verbose++; break; + case 'd': debug++; break; + default : pargs.err = ARGPARSE_PRINT_ERROR; break; + } + } + gpgrt_argparse (NULL, &pargs, NULL); + + show ("testing logging using a memory log stream\n"); + logmemfp = gpgrt_fopenmem (0, "w+b"); + if (!logmemfp) + die ("fopenmem failed at line %d\n", __LINE__); + gpgrt_log_set_sink (NULL, logmemfp, -1); + + check_log_info (); + gpgrt_log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX|GPGRT_LOG_WITH_PID); + check_with_pid (); + gpgrt_log_set_prefix (NULL, GPGRT_LOG_WITH_PREFIX); + check_log_error (); + + /* FIXME: Add more tests. */ + + show ("testing logging finished\n"); + return !!errorcount; +} diff --git a/libotr/libgpg-error-1.42/tests/t-malloc.c b/libotr/libgpg-error-1.42/tests/t-malloc.c new file mode 100644 index 0000000..be2ec81 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-malloc.c @@ -0,0 +1,141 @@ +/* t-malloc.c - Check some malloc functions + * Copyright (C) 2020 g10 Code GmbH + * + * This file is part of Libgpg-error. + * + * Libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <unistd.h> +#include <errno.h> + +#define PGM "t-malloc" +#include "t-common.h" + + +static const char * +my_strusage (int level) +{ + const char *p; + + switch (level) + { + case 9: p = "LGPL-2.1-or-later"; break; + case 11: p = PGM; break; + default: p = NULL; + } + return p; +} + + +static void +check_reallocarray (void) +{ + struct foo_s { const char *a; int b; } *array; + size_t n; + + array = gpgrt_calloc (10, sizeof *array); + if (!array) + die ("%s: malloc failed\n", __func__); + + for (n=0; n < 10; n++) + if (array[n].a || array[n].b) + fail ("%s: array not cleared at index %zu\n", __func__, n); + + for (n=0; n < 10; n++) + { + array[n].a = "dummy string"; + array[n].b = 100+n; + } + + array = gpgrt_reallocarray (array, 10, 20, sizeof *array); + if (!array) + die ("%s: realloc failed\n", __func__); + + for (n=0; n < 10; n++) + { + if (!array[n].a || strcmp (array[n].a, "dummy string")) + fail ("%s: string in realloced array changed at index %zu\n", + __func__, n); + + if (array[n].b != 100 + n) + fail ("%s: number in realloced array changed at index %zu\n", + __func__, n); + } + for (n=10; n < 20; n++) + if (array[n].a || array[n].b) + fail ("%s: realloced array not cleared at index %zu\n", __func__, n); + + /* We can't easily check whether the reallocated array does not + * iniitialze in the case OLDN is equal or larger to N, so we skip + * this. Let's do a simple shrink test instead. */ + + array = gpgrt_reallocarray (array, 20, 7, sizeof *array); + if (!array) + die ("%s: realloc (shrinking) failed\n", __func__); + + for (n=0; n < 7; n++) + { + if (!array[n].a || strcmp (array[n].a, "dummy string")) + fail ("%s: string in shrunk array changed at index %zu\n", + __func__, n); + + if (array[n].b != 100 + n) + fail ("%s: number in shrunk array changed at index %zu\n", + __func__, n); + } + + xfree (array); +} + + +int +main (int argc, char **argv) +{ + gpgrt_opt_t opts[] = { + ARGPARSE_x ('v', "verbose", NONE, 0, "Print more diagnostics"), + ARGPARSE_s_n('d', "debug", "Flyswatter"), + ARGPARSE_end() + }; + gpgrt_argparse_t pargs = { &argc, &argv, 0 }; + + gpgrt_set_strusage (my_strusage); + gpgrt_log_set_prefix (gpgrt_strusage (11), GPGRT_LOG_WITH_PREFIX); + + while (gpgrt_argparse (NULL, &pargs, opts)) + { + switch (pargs.r_opt) + { + case 'v': verbose++; break; + case 'd': debug++; break; + default : pargs.err = ARGPARSE_PRINT_ERROR; break; + } + } + gpgrt_argparse (NULL, &pargs, NULL); + + show ("testing malloc functions\n"); + + check_reallocarray (); + + return !!errorcount; +} diff --git a/libotr/libgpg-error-1.42/tests/t-poll.c b/libotr/libgpg-error-1.42/tests/t-poll.c new file mode 100644 index 0000000..ec79416 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-poll.c @@ -0,0 +1,440 @@ +/* t-poll.c - Check the poll function + * Copyright (C) 2015 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +/* FIXME: We need much better tests that this very basic one. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <sys/types.h> +#include <unistd.h> +#include <errno.h> +#ifdef _WIN32 +# include <windows.h> +# include <time.h> +#else +# ifdef USE_POSIX_THREADS +# include <pthread.h> +# endif +#endif + +#define PGM "t-poll" + +#include "t-common.h" + +#ifdef _WIN32 +# define THREAD_RET_TYPE DWORD WINAPI +# define THREAD_RET_VALUE 0 +#else +# define THREAD_RET_TYPE void * +# define THREAD_RET_VALUE NULL +#endif + + +/* Object to convey data to a thread. */ +struct thread_arg +{ + const char *name; + estream_t stream; + volatile int stop_me; +#ifdef USE_POSIX_THREADS + pthread_t thread; +#elif _WIN32 + HANDLE thread; +#endif +}; + + +static struct thread_arg peer_stdin; /* Thread to feed the stdin. */ +static struct thread_arg peer_stdout; /* Thread to feed the stdout. */ +static struct thread_arg peer_stderr; /* Thread to feed the stderr. */ + +static estream_t test_stdin; +static estream_t test_stdout; +static estream_t test_stderr; + +#if defined(_WIN32) || defined(USE_POSIX_THREADS) + +/* This thread feeds data to the given stream. */ +static THREAD_RET_TYPE +producer_thread (void *argaddr) +{ + struct thread_arg *arg = argaddr; + int i = 0; + + (void)arg; + + while (!arg->stop_me && i++ < 3) + { + show ("thread '%s' about to write\n", arg->name); + es_fprintf (arg->stream, "This is '%s' count=%d\n", arg->name, i); + es_fflush (arg->stream); + } + es_fclose (arg->stream); + return THREAD_RET_VALUE; +} + +/* This thread eats data from the given stream. */ +static THREAD_RET_TYPE +consumer_thread (void *argaddr) +{ + struct thread_arg *arg = argaddr; + char buf[15]; + + (void)arg; + + while (!arg->stop_me) + { + show ("thread '%s' ready to read\n", arg->name); + if (!es_fgets (buf, sizeof buf, arg->stream)) + { + show ("Thread '%s' received EOF or error\n", arg->name); + break; + } + show ("Thread '%s' got: '%s'\n", arg->name, buf); + } + es_fclose (arg->stream); + return THREAD_RET_VALUE; +} + +#endif /*_WIN32 || USE_POSIX_THREADS */ + + +static void +launch_thread (THREAD_RET_TYPE (*fnc)(void *), struct thread_arg *th) +{ + int fd; + + th->stop_me = 0; + fd = es_fileno (th->stream); +#ifdef _WIN32 + + th->thread = CreateThread (NULL, 0, fnc, th, 0, NULL); + if (!th->thread) + die ("creating thread '%s' failed: rc=%d", th->name, (int)GetLastError ()); + show ("thread '%s' launched (fd=%d)\n", th->name, fd); + +#elif USE_POSIX_THREADS + + if (pthread_create (&th->thread, NULL, fnc, th)) + die ("creating thread '%s' failed: %s\n", th->name, strerror (errno)); + show ("thread '%s' launched (fd=%d)\n", th->name, fd); + +# else /* no thread support */ + + verbose++; + show ("no thread support - skipping test\n", PGM); + verbose--; + +#endif /* no thread support */ +} + + +static void +join_thread (struct thread_arg *th) +{ +#ifdef _WIN32 + int rc; + + rc = WaitForSingleObject (th->thread, INFINITE); + if (rc == WAIT_OBJECT_0) + show ("thread '%s' has terminated\n", th->name); + else + fail ("waiting for thread '%s' failed: %d", th->name, (int)GetLastError ()); + CloseHandle (th->thread); + +#elif USE_POSIX_THREADS + + pthread_join (th->thread, NULL); + show ("thread '%s' has terminated\n", th->name); + +#endif +} + + +static void +create_pipe (estream_t *r_in, estream_t *r_out) +{ + gpg_error_t err; + int filedes[2]; + +#ifdef _WIN32 + if (_pipe (filedes, 512, 0) == -1) +#else + if (pipe (filedes) == -1) +#endif + { + err = gpg_error_from_syserror (); + die ("error creating a pipe: %s\n", gpg_strerror (err)); + } + + show ("created pipe [%d, %d]\n", filedes[0], filedes[1]); + + *r_in = es_fdopen (filedes[0], "r,pollable"); + if (!*r_in) + { + err = gpg_error_from_syserror (); + die ("error creating a stream for a pipe: %s\n", gpg_strerror (err)); + } + + *r_out = es_fdopen (filedes[1], "w,pollable"); + if (!*r_out) + { + err = gpg_error_from_syserror (); + die ("error creating a stream for a pipe: %s\n", gpg_strerror (err)); + } +} + + +static void +test_poll (void) +{ + int ret; + gpgrt_poll_t fds[3]; + char buffer[16]; + size_t used, nwritten; + int c; + + memset (fds, 0, sizeof fds); + fds[0].stream = test_stdin; + fds[0].want_read = 1; + fds[1].stream = test_stdout; + fds[1].want_write = 1; + /* FIXME: We don't use the next stream at all. */ + fds[2].stream = test_stderr; + fds[2].want_write = 1; + fds[2].ignore = 1; + + + used = 0; + while (used || !fds[0].ignore) + { + ret = gpgrt_poll (fds, DIM(fds), -1); + if (ret == -1) + { + fail ("gpgrt_poll failed: %s\n", strerror (errno)); + continue; + } + if (!ret) + { + fail ("gpgrt_poll unexpectedly timed out\n"); + continue; + } + + show ("gpgrt_poll detected %d events\n", ret); + if (debug) + show ("gpgrt_poll: r=%d" + " 0:%c%c%c%c%c%c%c%c%c%c%c%c" + " 1:%c%c%c%c%c%c%c%c%c%c%c%c" + " 2:%c%c%c%c%c%c%c%c%c%c%c%c" + "\n", + ret, + fds[0].want_read? 'r':'-', + fds[0].want_write? 'w':'-', + fds[0].want_oob? 'o':'-', + fds[0].want_rdhup? 'h':'-', + fds[0].ignore? '!':'=', + fds[0].got_read? 'r':'-', + fds[0].got_write? 'w':'-', + fds[0].got_oob? 'o':'-', + fds[0].got_rdhup? 'h':'-', + fds[0].got_hup? 'H':' ', + fds[0].got_err? 'e':' ', + fds[0].got_nval? 'n':' ', + + fds[1].want_read? 'r':'-', + fds[1].want_write? 'w':'-', + fds[1].want_oob? 'o':'-', + fds[1].want_rdhup? 'h':'-', + fds[1].ignore? '!':'=', + fds[1].got_read? 'r':'-', + fds[1].got_write? 'w':'-', + fds[1].got_oob? 'o':'-', + fds[1].got_rdhup? 'h':'-', + fds[1].got_hup? 'H':' ', + fds[1].got_err? 'e':' ', + fds[1].got_nval? 'n':' ', + + fds[2].want_read? 'r':'-', + fds[2].want_write? 'w':'-', + fds[2].want_oob? 'o':'-', + fds[2].want_rdhup? 'h':'-', + fds[2].ignore? '!':'=', + fds[2].got_read? 'r':'-', + fds[2].got_write? 'w':'-', + fds[2].got_oob? 'o':'-', + fds[2].got_rdhup? 'h':'-', + fds[2].got_hup? 'H':' ', + fds[2].got_err? 'e':' ', + fds[2].got_nval? 'n':' ' + ); + else + show ("gpgrt_poll detected %d events\n", ret); + + if (fds[0].got_read) + { + /* Read from the producer. */ + for (;;) + { + c = es_fgetc (fds[0].stream); + if (c == EOF) + { + if (es_feof (fds[0].stream)) + { + show ("reading '%s': EOF\n", peer_stdin.name); + fds[0].ignore = 1; /* Not anymore needed. */ + peer_stdin.stop_me = 1; /* Tell the thread to stop. */ + } + else if (es_ferror (fds[0].stream)) + { + fail ("error reading '%s': %s\n", + peer_stdin.name, strerror (errno)); + fds[0].ignore = 1; /* Disable. */ + peer_stdin.stop_me = 1; /* Tell the thread to stop. */ + } + else + show ("reading '%s': EAGAIN\n", peer_stdin.name); + break; + } + else + { + if (used <= sizeof buffer -1) + buffer[used++] = c; + if (used == sizeof buffer) + { + show ("throttling reading from '%s'\n", peer_stdin.name); + fds[0].ignore = 1; + break; + } + } + } + show ("read from '%s': %zu bytes\n", peer_stdin.name, used); + if (used) + fds[1].ignore = 0; /* Data to send. */ + } + if (fds[1].got_write) + { + if (used) + { + ret = es_write (fds[1].stream, buffer, used, &nwritten); + show ("result for writing to '%s': ret=%d, n=%zu, nwritten=%zu\n", + peer_stdout.name, ret, used, nwritten); + if (!ret) + { + assert (nwritten <= used); + /* Move the remaining data to the front of buffer. */ + memmove (buffer, buffer + nwritten, + sizeof buffer - nwritten); + used -= nwritten; + } + ret = es_fflush (fds[1].stream); + if (ret) + fail ("Flushing for '%s' failed: %s\n", + peer_stdout.name, strerror (errno)); + } + if (!used) + fds[1].ignore = 1; /* No need to send data. */ + } + + if (used < sizeof buffer / 2 && !peer_stdin.stop_me && fds[0].ignore) + { + show ("accelerate reading from '%s'\n", peer_stdin.name); + fds[0].ignore = 0; + } + } +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./t-poll [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + if (!gpg_error_check_version (GPG_ERROR_VERSION)) + { + die ("gpg_error_check_version returned an error"); + errorcount++; + } + + peer_stdin.name = "stdin producer"; + create_pipe (&test_stdin, &peer_stdin.stream); + peer_stdout.name = "stdout consumer"; + create_pipe (&peer_stdout.stream, &test_stdout); + peer_stderr.name = "stderr consumer"; + create_pipe (&peer_stderr.stream, &test_stderr); + + if (es_set_nonblock (test_stdin, 1)) + fail ("error setting test_stdin to nonblock: %s\n", strerror (errno)); + if (es_set_nonblock (test_stdout, 1)) + fail ("error setting test_stdout to nonblock: %s\n", strerror (errno)); + if (es_set_nonblock (test_stderr, 1)) + fail ("error setting test_stderr to nonblock: %s\n", strerror (errno)); + + launch_thread (producer_thread, &peer_stdin ); + launch_thread (consumer_thread, &peer_stdout); + launch_thread (consumer_thread, &peer_stderr); + test_poll (); + show ("Waiting for threads to terminate...\n"); + es_fclose (test_stdin); + es_fclose (test_stdout); + es_fclose (test_stderr); + peer_stdin.stop_me = 1; + peer_stdout.stop_me = 1; + peer_stderr.stop_me = 1; + join_thread (&peer_stdin); + join_thread (&peer_stdout); + join_thread (&peer_stderr); + + return errorcount ? 1 : 0; +} diff --git a/libotr/libgpg-error-1.42/tests/t-printf.c b/libotr/libgpg-error-1.42/tests/t-printf.c new file mode 100644 index 0000000..c261838 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-printf.c @@ -0,0 +1,544 @@ +/* t-printf.c - Check the estream printf fucntions. + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +/* Note that these tests check against glibc behaviour. On non glibc + systems expect non matching return codes in some border cases. */ + + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <errno.h> +#include <locale.h> + +#define PGM "t-printf" + +#include "t-common.h" + + +static char *one_test_buf1; +static int one_test_rc1; + + + + +/* Read all data from STREAM into a new malloced buffer and return + * that buffer. The buffer is always 0 terminated. Either returns a + * string or dies. The stream will be trunctaed to zero. */ +static char * +stream_to_string (gpgrt_stream_t stream) +{ +#define NCHUNK 1024 + char *buffer; + size_t bufsize, buflen; + size_t nread; + + gpgrt_rewind (stream); + + buffer = NULL; + buflen = bufsize = 0; + do + { + bufsize += NCHUNK; + buffer = realloc (buffer, bufsize+1); + if (!buffer) + die ("malloc failed at line %d\n", __LINE__); + + nread = gpgrt_fread (buffer + buflen, 1, NCHUNK, stream); + if (nread < NCHUNK && gpgrt_ferror (stream)) + die ("fread failed at line %d: %s\n", __LINE__, strerror (errno)); + buflen += nread; + } + while (nread == NCHUNK); + buffer[nread] = 0; + + if (strlen (buffer) != buflen) + fail ("stream_to_string detected an embedded nul"); + + gpgrt_ftruncate (stream, 0); + return buffer; +#undef NCHUNK +} + + + +static void +one_test_x0 (const char *format, ...) +{ + va_list arg_ptr; + + show ("format: ->%s<-\n", format); + + errno = ENOENT; /* For the "%m" test. */ + va_start (arg_ptr, format); +#ifdef HAVE_VASPRINTF + one_test_rc1 = vasprintf (&one_test_buf1, format, arg_ptr); +#else + one_test_rc1 = -1; +#endif + va_end (arg_ptr); + if (one_test_rc1 == -1) + { + fail (" sys: errno=%d (%s)\n", errno, strerror (errno)); + one_test_buf1 = NULL; + } + else + show (" sys: ->%s<-\n", one_test_buf1); +} + +static void +one_test_x1 (const char *format, ...) +{ + int rc2; + va_list arg_ptr; + char *buf2; + + errno = ENOENT; + va_start (arg_ptr, format); + rc2 = gpgrt_vasprintf (&buf2, format, arg_ptr); + va_end (arg_ptr); + if (rc2 == -1) + { + fail (" our: errno=%d (%s)\n", errno, strerror (errno)); + } + else + show (" our: ->%s<-\n", buf2); + + if (one_test_rc1 != -1 && rc2 != -1 && strcmp (one_test_buf1, buf2)) + { + fail ("error: output does not match\n" + "format: ->%s<-\n sys: ->%s<-\n our: ->%s<-\n", + format, one_test_buf1, buf2); + } + else if ( one_test_rc1 != rc2 ) + { + fail ("error: return codes are different: sys_rc=%d our_rc=%d\n", + one_test_rc1, rc2); + } + + free (buf2); +} + +static void +one_test_x2 (const char *format, ...) +{ + va_list arg_ptr; + char *buf2; + + /* Test once more using the bsprintf variant. */ + errno = ENOENT; + va_start (arg_ptr, format); + buf2 = gpgrt_vbsprintf (format, arg_ptr); + va_end (arg_ptr); + if (!buf2) + { + fail (" our(2): errno=%d (%s)\n", errno, strerror (errno)); + } + else if (verbose) + show (" our: ->%s<-\n", buf2); + + if (one_test_rc1 != -1 && buf2 && strcmp (one_test_buf1, buf2)) + { + fail ("error: output does not match\n" + "format(2): ->%s<-\n sys: ->%s<-\n our: ->%s<-\n", + format, one_test_buf1, buf2); + } + es_free (buf2); + + free (one_test_buf1); + one_test_buf1 = NULL; +} + + +#define one_test_0(a) \ + one_test_x0 (a); \ + one_test_x1 (a); \ + one_test_x2 (a) +#define one_test_1(a, b) \ + one_test_x0 (a, b); \ + one_test_x1 (a, b); \ + one_test_x2 (a, b) +#define one_test_2(a, b, c) \ + one_test_x0 (a, b, c); \ + one_test_x1 (a, b, c); \ + one_test_x2 (a, b, c) +#define one_test_3(a, b, c, d) \ + one_test_x0 (a, b, c, d); \ + one_test_x1 (a, b, c, d); \ + one_test_x2 (a, b, c, d) + +static void +run_tests (void) +{ +#ifndef HAVE_VASPRINTF + /* We do not have a system vasprintf. */ + show ("run-tests: disabled due to missing vasprintf.\n"); +#else /*HAVE_VASPRINTF */ + + /*one_test ("%d %% %'d", 17, 19681977);*/ + + one_test_2 ("%d %% %d", 17, 768114563); + one_test_2 ("%d %% %d", 17, -768114563); + + /* Checking thousands is not easy because it depends on the locale. */ + /* one_test_1 ("%'d", 768114563); */ + + one_test_1 ("%d", 17); + one_test_1 ("%4d", 17); + one_test_1 ("%40d", 17); + one_test_1 ("%-d", 17); + one_test_1 ("%-4d", 17); + one_test_1 ("%-140d", 17); + one_test_1 ("%d", -17); + one_test_1 ("%4d", -17); + one_test_1 ("%40d", -17); + one_test_1 ("%-d", -17); + one_test_1 ("%-4d", -17); + one_test_1 ("%-40d", -17); + + one_test_1 ("%+4d", 17); + one_test_1 ("%+4d", -17); + one_test_1 ("%-+4d", 17); + one_test_1 ("%-+4d", -17); + one_test_1 ("% 4d", 17); + one_test_1 ("% 4d", -17); + one_test_1 ("%- +4d", 17); + one_test_1 ("%- +4d", -17); + + one_test_1 ("%.4d", 17); + one_test_1 ("%.0d", 17); + one_test_1 ("%.0d", 0); + one_test_1 ("%.4d", -17); + one_test_1 ("%.0d", -17); + one_test_1 ("%6.4d", 17); + one_test_1 ("%6.4d", -17); + one_test_1 ("%6.0d", 0); + one_test_1 ("%4.6d", 17); + one_test_1 ("%4.6d", -17); + + one_test_1 ("% 4.6d", 17); + one_test_1 ("% 6.0d", 0); + + one_test_1 ("%.4d", 17); + one_test_1 ("%04d", 17); + one_test_1 ("%.4d", -17); + one_test_1 ("%04d", -17); + one_test_1 ("%0.d", 0); + + one_test_2 ("%*d", 7, 42); + one_test_2 ("%*d", -7, 42); + one_test_2 ("%.*d", 7, 42); + one_test_2 ("%.*d", -7, 42); + one_test_3 ("%*.*d", 10, 7, 42); + one_test_3 ("%*.*d", 10, -7, 42); + one_test_3 ("%*.*d", -10, 7, 42); + one_test_3 ("%*.*d", -10, -7, 42); + + one_test_2 ("%*x", 7, 42); + one_test_2 ("%*x", -7, 42); + one_test_2 ("%.*x", 7, 42); + one_test_2 ("%.*x", -7, 42); + one_test_3 ("%*.*x", 10, 7, 42); + one_test_3 ("%*.*x", 10, -7, 42); + one_test_3 ("%*.*x", -10, 7, 42); + one_test_3 ("%*.*x", -10, -7, 42); + one_test_2 ("%#*x", 7, 42); + one_test_2 ("%#*x", -7, 42); + one_test_2 ("%#.*x", 7, 42); + one_test_2 ("%#.*x", -7, 42); + one_test_3 ("%#*.*x", 10, 7, 42); + one_test_3 ("%#*.*x", 10, -7, 42); + one_test_3 ("%#*.*x", -10, 7, 42); + one_test_3 ("%#*.*x", -10, -7, 42); + + one_test_2 ("%*X", 7, 42); + one_test_2 ("%*X", -7, 42); + one_test_2 ("%.*X", 7, 42); + one_test_2 ("%.*X", -7, 42); + one_test_3 ("%*.*X", 10, 7, 42); + one_test_3 ("%*.*X", 10, -7, 42); + one_test_3 ("%*.*X", -10, 7, 42); + one_test_3 ("%*.*X", -10, -7, 42); + one_test_2 ("%#*X", 7, 42); + one_test_2 ("%#*X", -7, 42); + one_test_2 ("%#.*X", 7, 42); + one_test_2 ("%#.*X", -7, 42); + one_test_3 ("%#*.*X", 10, 7, 42); + one_test_3 ("%#*.*X", 10, -7, 42); + one_test_3 ("%#*.*X", -10, 7, 42); + one_test_3 ("%#*.*X", -10, -7, 42); + + one_test_2 ("%*o", 7, 42); + one_test_2 ("%*o", -7, 42); + one_test_2 ("%.*o", 7, 42); + one_test_2 ("%.*o", -7, 42); + one_test_3 ("%*.*o", 10, 7, 42); + one_test_3 ("%*.*o", 10, -7, 42); + one_test_3 ("%*.*o", -10, 7, 42); + one_test_3 ("%*.*o", -10, -7, 42); + one_test_2 ("%#*o", 7, 42); + one_test_2 ("%#*o", -7, 42); + one_test_2 ("%#.*o", 7, 42); + one_test_2 ("%#.*o", -7, 42); + one_test_3 ("%#*.*o", 10, 7, 42); + one_test_3 ("%#*.*o", 10, -7, 42); + one_test_3 ("%#*.*o", -10, 7, 42); + one_test_3 ("%#*.*o", -10, -7, 42); + + one_test_1 ("%s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.0s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.10s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.48s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.49s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.50s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%.51s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%48s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%49s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%50s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%51s", "the quick brown fox jumps over the lazy dogs back"); + one_test_1 ("%-51s", "the quick brown fox jumps over the lazy dogs back"); + + one_test_1 ("/%s=", "CN"); + + one_test_1 ("%f", 3.1415926535); + one_test_1 ("%f", -3.1415926535); + one_test_1 ("%.10f", 3.1415926535); + one_test_1 ("%.2f", 3.1415926535); + one_test_1 ("%.1f", 3.1415926535); + one_test_1 ("%.0f", 3.1415926535); + one_test_1 ("%.20f", 3.1415926535); + one_test_1 ("%10.10f", 3.1415926535); + one_test_1 ("%10.2f", 3.1415926535); + one_test_1 ("%10.1f", 3.1415926535); + one_test_1 ("%10.0f", 3.1415926535); + one_test_1 ("%30.20f", 3.1415926535); + one_test_1 ("%10.10f", -3.1415926535); + one_test_1 ("%10.2f", -3.1415926535); + one_test_1 ("%10.1f", -3.1415926535); + one_test_1 ("%10.0f", -3.1415926535); + one_test_1 ("%30.20f", -3.1415926535); + + one_test_1 ("%-10f", 3.1415926535); + one_test_1 ("%-10.10f", 3.1415926535); + one_test_1 ("%-10.2f", 3.1415926535); + one_test_1 ("%-10.1f", 3.1415926535); + one_test_1 ("%-10.0f", 3.1415926535); + one_test_1 ("%-30.20f", 3.1415926535); + one_test_1 ("%-10f", -3.1415926535); + one_test_1 ("%-10.10f", -3.1415926535); + one_test_1 ("%-10.2f", -3.1415926535); + one_test_1 ("%-10.1f", -3.1415926535); + one_test_1 ("%-10.0f", -3.1415926535); + one_test_1 ("%-30.20f", -3.1415926535); + + one_test_1 ("%#.0f", 3.1415926535); + one_test_1 ("%#10.0f", 3.1415926535); + one_test_1 ("%#10.0f", -3.1415926535); + one_test_1 ("%-#10.0f", 3.1415926535); + one_test_1 ("%-#10.0f", -3.1415926535); + + one_test_1 ("%e", 3.1415926535); + one_test_1 ("%g", 3.1415926535); + + one_test_1 ("%a", 1.0); + one_test_1 ("%a", -1.0); + one_test_1 ("%a", 3.1415926535); + +#ifdef HAVE_LONG_DOUBLE + one_test_1 ("%La", (long double)1.0); + one_test_1 ("%La", (long double)-1.0); + one_test_1 ("%La", (long double)3.1415926535); +#endif + +#ifdef __GLIBC__ + /* "%m" is a glibc extension so this _test_ will only work on such a + system. */ + one_test_0 ("%m"); + one_test_1 ("%d=%m", 17); + one_test_2 ("%2$d:%m:%1$d", 42, 17); +#endif /*__GLIBC__*/ + +#endif /*HAVE_VASPRINTF */ +} + +static void +check_snprintf (void) +{ + char buffer[20]; + int rc, rc2; + size_t tmplen, blen, blen2; + + rc = gpgrt_snprintf (buffer, 0, "%*s", 18, ""); + if (rc != 18) + printf ("rc=%d\n", rc ); + rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 18, ""); + if (rc != 18) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 19, ""); + if (rc != 19) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 20, ""); + if (rc != 20) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + rc = gpgrt_snprintf (buffer, sizeof buffer, "%*s", 21, ""); + if (rc != 21) + printf ("rc=%d, strlen(buffer)=%d\n", rc, (int)strlen (buffer)); + + for (tmplen = 0; tmplen <= sizeof buffer; tmplen++) + { + rc = gpgrt_snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", + 1998, 9, 7, 16, 56, 05); + blen = strlen (buffer); + rc2 = snprintf (buffer, tmplen, "%04d%02d%02dT%02d%02d%02d", + 1998, 9, 7, 16, 56, 05); + blen2 = strlen (buffer); + if (rc != rc2 || blen != blen2) + printf ("snprintf test with len %u gives %d instead of %d (%u,%u)\n", + (unsigned int)tmplen, rc, rc2, + (unsigned int)blen, (unsigned int)blen2); + } +} + + +struct sfstate_s +{ + char *last_result; +}; + +static char * +string_filter (const char *string, int no, void *opaque) +{ + struct sfstate_s *state = opaque; + + free (state->last_result); + if (no == -1) + { + state->last_result = NULL; + return NULL; + } + if (no == 3) + state->last_result = NULL; + else + state->last_result = strdup (string? string : "[==>Niente<==]"); + + return state->last_result; +} + + +static void +check_fprintf_sf (void) +{ + volatile char *nullptr = NULL; /* Avoid compiler warning. */ + struct sfstate_s sfstate = {NULL}; + gpgrt_stream_t stream; + const char *expect; + char *result; + + stream = gpgrt_fopenmem (0, "w+b"); + if (!stream) + die ("fopenmem failed at line %d\n", __LINE__); + + gpgrt_fprintf_sf (stream, string_filter, &sfstate, + "%s a=%d b=%s c=%d d=%.8s null=%s\n", + nullptr, 1, "foo\x01 bar", 2, + "a longer string", nullptr); + expect = "[==>Niente<==] a=1 b=foo\x01 bar c=2 d=a longer null=(null)\n"; + result = stream_to_string (stream); + if (strcmp (result, expect)) + { + show ("expect: '%s'\n", expect); + show ("result: '%s'\n", result); + fail ("fprintf_sf failed at %d\n", __LINE__); + } + free (result); + + gpgrt_fprintf_sf (stream, string_filter, &sfstate, + "a=%d b=%s c=%d d=%.8s e=%s\n", + 1, "foo\n bar", 2, nullptr, ""); + expect = "a=1 b=foo\n bar c=2 d=[==>Nien e=\n"; + result = stream_to_string (stream); + if (strcmp (result, expect)) + { + show ("expect: '%s'\n", expect); + show ("result: '%s'\n", result); + fail ("fprintf_sf failed at %d\n", __LINE__); + } + free (result); + + gpgrt_fclose (stream); +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./" PGM " [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +" --debug Flyswatter\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + setlocale (LC_NUMERIC, ""); + if (!gpg_error_check_version (GPG_ERROR_VERSION)) + { + die ("gpg_error_check_version returned an error"); + errorcount++; + } + + run_tests (); + check_snprintf (); + check_fprintf_sf (); + +#ifdef __GLIBC__ + return !!errorcount; +#else + return 0; +#endif +} diff --git a/libotr/libgpg-error-1.42/tests/t-strerror.c b/libotr/libgpg-error-1.42/tests/t-strerror.c new file mode 100644 index 0000000..9289066 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-strerror.c @@ -0,0 +1,63 @@ +/* t-strerror.c - Regression test. + Copyright (C) 2003 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libgpgme-error; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include <gpg-error.h> + +int +main (int argc, char *argv[]) +{ + if (argc > 1) + { + int i = 1; + while (i + 1 < argc) + { + gpg_error_t err = gpg_err_make (atoi (argv[i]), atoi (argv[i + 1])); + printf ("%s: %s\n", gpg_strsource (err), gpg_strerror (err)); + i += 2; + } + } + else + { + struct + { + gpg_err_source_t src; + gpg_err_code_t code; + } list[] = { { 0, 0 }, { 1, 201 }, { 2, 2 }, { 3, 102 }, + { 4, 100 }, { 5, 99 }, { 6, 110 }, { 7, 7 }, { 8, 888 } }; + int i = 0; + + while (i < sizeof (list) / sizeof (list[0])) + { + gpg_error_t err = gpg_err_make (list[i].src, list[i].code); + printf ("%s: %s\n", gpg_strsource (err), gpg_strerror (err)); + i++; + } + } + return 0; +} diff --git a/libotr/libgpg-error-1.42/tests/t-stringutils.c b/libotr/libgpg-error-1.42/tests/t-stringutils.c new file mode 100644 index 0000000..8879e1a --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-stringutils.c @@ -0,0 +1,395 @@ +/* t-stringutils.c - Check some string utilities + * Copyright (C) 2020 g10 Code GmbH + * + * This file is part of Libgpg-error. + * + * Libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * Libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include <unistd.h> +#ifdef HAVE_STAT +# include <sys/stat.h> +#endif +#include <sys/types.h> +#ifdef HAVE_PWD_H +# include <pwd.h> +#endif +#include <errno.h> +#ifdef HAVE_W32_SYSTEM +# include <windows.h> +#endif + +#define PGM "t-stringutils" +#include "t-common.h" + + +static const char * +my_strusage (int level) +{ + const char *p; + + switch (level) + { + case 9: p = "LGPL-2.1-or-later"; break; + case 11: p = PGM; break; + default: p = NULL; + } + return p; +} + + +const char * +mygethome (void) +{ + static char *home_buffer; + + if (!home_buffer) + { + char *home = getenv("HOME"); + + if(home) + home_buffer = xstrdup (home); +#if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H) + else + { + struct passwd *pwd; + + pwd = getpwuid (getuid()); + if (pwd) + home_buffer = xstrdup (pwd->pw_dir); + } +#endif + } + return home_buffer; +} + + +#ifdef HAVE_W32_SYSTEM +static wchar_t * +utf8_to_wchar (const char *string) +{ + int n; + wchar_t *result; + size_t nbytes; + int cbmultibyte = -1; + + n = MultiByteToWideChar (CP_UTF8, 0, string, cbmultibyte, NULL, 0); + if (n < 0 || (n+1) <= 0) + die ("utf8_to_wchar failed\n"); + nbytes = (size_t)(n+1) * sizeof(*result); + if (nbytes / sizeof(*result) != (n+1)) + die ("utf8_to_wchar failed\n"); + result = xmalloc (nbytes); + n = MultiByteToWideChar (CP_UTF8, 0, string, cbmultibyte, result, n); + if (n < 0) + die ("utf8_to_wchar failed\n"); + return result; + +} + + +static char * +wchar_to_utf8 (const wchar_t *string, size_t length) +{ + int n; + char *result; + + n = WideCharToMultiByte (CP_UTF8, 0, string, length, NULL, 0, NULL, NULL); + if (n < 0 || (n+1) <= 0) + die ("wchar_to_utf8 failed\n"); + + result = xmalloc (n+1); + if (!result) + die ("wchar_to_utf8 failed\n"); + n = WideCharToMultiByte (CP_UTF8, 0, string, length, result, n, NULL, NULL); + if (n < 0) + die ("wchar_to_utf8 failed\n"); + result[n] = 0; + return result; +} +#endif + +static char * +mygetcwd (void) +{ +#ifdef HAVE_W32_SYSTEM + wchar_t wbuffer[MAX_PATH + sizeof(wchar_t)]; + wchar_t *wp; + DWORD wlen; + char *buf, *p; + + wlen = GetCurrentDirectoryW (MAX_PATH, wbuffer); + if (!wlen) + die ("GCDW failed - error code: %d\n", (int)GetLastError ()); + else if (wlen > MAX_PATH) + die ("GCDW failed - wlen too large\n"); + + buf = wchar_to_utf8 (wbuffer, wlen); + + /* Quick test that the reverse works. */ + wp = utf8_to_wchar (buf); + if (wcscmp (wp, wbuffer)) + die ("GCDW: reverse converting failed\n"); + xfree (wp); + + for (p=buf; *p; p++) + if (*p == '\\') + *p = '/'; + return buf; + +#else + char *buffer; + size_t size = 100; + + for (;;) + { + buffer = xmalloc (size+1); + if (getcwd (buffer, size) == buffer) + { + return buffer; + } + xfree (buffer); + if (errno != ERANGE) + die ("error getting current cwd: %s\n", strerror (errno)); + size *= 2; + } +#endif +} + + +static void +check_fnameconcat (void) +{ + char *out; + const char *home = mygethome (); + size_t homelen = home? strlen (home):0; + + out = gpgrt_fnameconcat ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", NULL); + if (out) + fail ("fnameconcat succeeded but should not at line %d\n", __LINE__); + else if (errno != EINVAL) + fail ("fnameconcat return wrong error at line %d\n", __LINE__); + xfree (out); + + out = gpgrt_fnameconcat ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", NULL); + if (out) + fail ("fnameconcat succeeded but should not at line %d\n", __LINE__); + else if (errno != EINVAL) + fail ("fnameconcat return wrong error at line %d\n", __LINE__); + xfree (out); + + out = gpgrt_fnameconcat ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", + "1", "2", NULL); + if (!out || strcmp (out, + "1/2/3/4/5/6/7/8/9/10/" + "1/2/3/4/5/6/7/8/9/10/" + "1/2/3/4/5/6/7/8/9/10/" + "1/2")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("foo", "~/bar", "baz/cde", NULL); + if (!out || strcmp (out, "foo/~/bar/baz/cde")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("foo", "~/bar", "baz/cde/", NULL); + if (!out || strcmp (out, "foo/~/bar/baz/cde/")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("/foo", "~/bar", "baz/cde/", NULL); + if (!out || strcmp (out, "/foo/~/bar/baz/cde/")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("//foo", "~/bar", "baz/cde/", NULL); + if (!out || strcmp (out, "//foo/~/bar/baz/cde/")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("", "~/bar", "baz/cde", NULL); + if (!out || strcmp (out, "/~/bar/baz/cde")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_fnameconcat ("~/foo", "bar", NULL); + if (!out) + fail ("fnameconcat failed at line %d\n", __LINE__); + else if (home) + { + if (strlen (out) < homelen + 7) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strncmp (out, home, homelen)) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strcmp (out+homelen, "/foo/bar")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + } + else + { + if (strcmp (out, "~/foo/bar")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + } + xfree (out); + + out = gpgrt_fnameconcat ("~", "bar", NULL); + if (!out) + fail ("fnameconcat failed at line %d\n", __LINE__); + else if (home) + { + if (strlen (out) < homelen + 3) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strncmp (out, home, homelen)) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strcmp (out+homelen, "/bar")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + } + else + { + if (strcmp (out, "~/bar")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + } + xfree (out); +} + + +static void +check_absfnameconcat (void) +{ + char *out; + char *cwd = mygetcwd (); + size_t cwdlen = strlen (cwd); + + out = gpgrt_absfnameconcat ("foo", "bar", NULL); + if (!out) + fail ("fnameconcat failed at line %d\n", __LINE__); + else if (strlen (out) < cwdlen + 7) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strncmp (out, cwd, cwdlen)) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strcmp (out+cwdlen, "/foo/bar")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_absfnameconcat ("./foo", NULL); + if (!out) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strlen (out) < cwdlen + 5) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strncmp (out, cwd, cwdlen)) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strcmp (out+cwdlen, "/./foo")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + out = gpgrt_absfnameconcat (".", NULL); + if (!out) + fail ("fnameconcat failed at line %d\n", __LINE__); + else if (strlen (out) < cwdlen) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strncmp (out, cwd, cwdlen)) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + else if (strcmp (out+cwdlen, "")) + fail ("fnameconcat failed at line %d (out=%s)\n", __LINE__, out); + xfree (out); + + xfree (cwd); +} + + +static void +check_access (void) +{ + char *cwd = mygetcwd (); + + if (gpgrt_access (cwd, F_OK)) + fail ("gpgrt_access(%s) failed: %s\n", + cwd, gpg_strerror (gpg_error_from_syserror ())); + else + show ("gpgrt_access(%s) succeeded\n", cwd); + + xfree (cwd); +} + + +int +main (int argc, char **argv) +{ + gpgrt_opt_t opts[] = { + ARGPARSE_x ('v', "verbose", NONE, 0, "Print more diagnostics"), + ARGPARSE_s_n('d', "debug", "Flyswatter"), + ARGPARSE_x (501, "pwd", NONE, 0, "Print working directory"), + ARGPARSE_end() + }; + gpgrt_argparse_t pargs = { &argc, &argv, 0 }; + char *cwd; + int opt_pwd = 0; + + gpgrt_set_strusage (my_strusage); + gpgrt_log_set_prefix (gpgrt_strusage (11), GPGRT_LOG_WITH_PREFIX); + + while (gpgrt_argparse (NULL, &pargs, opts)) + { + switch (pargs.r_opt) + { + case 'v': verbose++; break; + case 'd': debug++; break; + case 501: opt_pwd = 1; break; + default : pargs.err = ARGPARSE_PRINT_ERROR; break; + } + } + gpgrt_argparse (NULL, &pargs, NULL); + + cwd = gpgrt_getcwd (); + if (!cwd) + fail ("gpgrt_getcwd returned error: %s\n", + gpg_strerror (gpg_error_from_syserror ())); + else + { + if (opt_pwd) + { + int save_verbose = verbose; + verbose = 1; + show ("getcwd -> '%s'\n", cwd); + verbose = save_verbose; + } + xfree (cwd); + } + + show ("testing string utilities\n"); + + check_fnameconcat (); + check_absfnameconcat (); + check_access (); + + show ("testing string utilities finished\n"); + return !!errorcount; +} diff --git a/libotr/libgpg-error-1.42/tests/t-syserror.c b/libotr/libgpg-error-1.42/tests/t-syserror.c new file mode 100644 index 0000000..a4cb983 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-syserror.c @@ -0,0 +1,87 @@ +/* t-syserror.c - System error specific regression test. + Copyright (C) 2006 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + libgpg-error is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libgpgme-error; if not, write to the Free + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#if HAVE_STDLIB_H +#include <stdlib.h> +#endif +#include <errno.h> + +#include <gpg-error.h> + +int +main (int argc, char *argv[]) +{ + FILE *fp; + int save_errno; + gpg_err_code_t ec; + + (void)argc; + (void)argv; + + fp = fopen ("/does-not-exist/110761/nowhere.foo", "r"); + if (fp) + { + fclose (fp); + fp = fopen (" no this file does not exists foo 4711", "r"); + } + if (fp) + { + fprintf (stderr, "unable to run test\n"); + return 1; + } + save_errno = errno; + + ec = gpg_err_code_from_syserror (); + if (ec != GPG_ERR_ENOENT) + { + fprintf (stderr, "fopen failed with bad code: %d\n", save_errno); + return 1; + } + + if (ec != gpg_err_code_from_errno (save_errno)) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + gpg_err_set_errno (0); + + ec = gpg_err_code_from_syserror (); + if (ec != GPG_ERR_MISSING_ERRNO) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + if ( gpg_err_code_from_errno (0) ) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + + return 0; +} diff --git a/libotr/libgpg-error-1.42/tests/t-version.c b/libotr/libgpg-error-1.42/tests/t-version.c new file mode 100644 index 0000000..d71f360 --- /dev/null +++ b/libotr/libgpg-error-1.42/tests/t-version.c @@ -0,0 +1,178 @@ +/* t-version.c - Check the version info function + * Copyright (C) 2013 g10 Code GmbH + * + * This file is part of libgpg-error. + * + * libgpg-error is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * libgpg-error is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see <https://www.gnu.org/licenses/>. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#define PGM "t-version" +#include "t-common.h" + +static const char *logpfx = PGM; + + +static void +t_gpgrt_cmp_version (void) +{ + struct { int result; int level; const char *a; const char *b; } t[] = { + { 0, 1, "0", "0" }, + { -1, 1, "0", "1" }, + { 1, 1, "1", "0" }, + { -1, 1, "0.0", "0.1" }, + { -1, 1, "0.1", "1.2" }, + { 1, 1, "1.0", "0.9" }, + { -1, 1, "-1.0", "0.9" }, /* A is invalid */ + { 0, 1, "0rc0", "0rc0" }, + { 1, 1, "0rc1", "0rc0" }, + { -1, 1, "0rc1", "0rc2" }, + { 0, 1, "0.rc0", "0.rc0" }, + { 1, 1, "0.rc1", "0.rc0" }, + { -1, 1, "0.rc1", "0.rc2" }, + { 0, 1, "0.rc1", "0.rc1" }, + { -1, 1, "0qc1", "0rc0" }, + { -1, 1, "0.qc1", "0.rc0" }, + { 0, 2, "0.0", "0.0" }, + { -1, 2, "0.1", "0.2" }, + { -1, 2, "3.1", "3.2" }, + { -1, 2, "3.1", "4.0" }, + { 0, 2, "1.1rc0", "1.1rc0" }, + { 1, 2, "1.1rc1", "1.1rc0" }, + { -1, 2, "1.1rc0", "1.1rc1" }, + { 0, 3, "7.0.0", "7.0.0" }, + { -1, 3, "7.0.1", "7.0.2" }, + { -1, 3, "7.3.1", "7.3.2" }, + { -1, 3, "7.3.1", "7.4.0" }, + { 0, 3, "7.1.1rc0", "7.1.1rc0" }, + { 1, 3, "7.1.1rc1", "7.1.1rc0" }, + { -1, 3, "7.1.1rc0", "7.1.1rc1" }, + { 1, 3, "6.0.0", "5.0.0" }, + { 0, 3, "6.0.0", "6.0.0" }, + { 1, 3, "6.0.1", "6.0.0" }, + { 1, 3, "6.1.0", "6.0.0" }, + { 1, 3, "6.2.1", "6.2.0" }, + { -1, 3, "6.2.1", "6.2.2" }, + { -1, 3, "6.0.0", "6.0.2" }, + { -1, 3, "6.0.0", "6.1.0" }, + { -1, 3, "6.2.0", "6.2.1" }, + { 1, 3, "6.0.0-beta1", "6.0.0-beta0" }, + { 0, 3, "6.0.0-beta2", "6.0.0-beta2" }, + { 1, 3, "6.0.0-beta20", "6.0.0-beta19" }, + { -1, 3, "6.0.0-beta1", "6.0.0-beta2" }, + { 1, 3, "6.0.0-beta2", "6.0.0-beta1" }, + { -1, 3, "6.0.0-beta20", "6.0.0-beta21" }, + { 0,13, "6.0.0-beta1", "6.0.0-beta0" }, + { 0,13, "6.0.0-beta2", "6.0.0-beta2" }, + { 0,13, "6.0.0-beta20", "6.0.0-beta19" }, + { 0,13, "6.0.0-beta1", "6.0.0-beta2" }, + { 0,13, "6.0.0-beta2", "6.0.0-beta1" }, + { 0,13, "6.0.0-beta20", "6.0.0-beta21" } + }; + int i; + int result, expected; + + for (i=0; i < DIM (t); i++) + { + expected = t[i].result; + result = gpgrt_cmp_version (t[i].a, t[i].b, t[i].level); + if (result != expected) + fail ("test %d failed: cmp('%s','%s',%d) = %d expected %d", + i, t[i].a, t[i].b, t[i].level, result, expected); + } + for (i=0; i < DIM (t); i++) + { + expected = 0 - t[i].result; + result = gpgrt_cmp_version (t[i].a, t[i].b, -t[i].level); + if (result != expected) + fail ("test %d-rev failed: cmp('%s','%s',%d) = %d expected %d", + i, t[i].a, t[i].b, -t[i].level, result, expected); + } +} + + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./version [options]\n" +"\n" +"Options:\n" +" --verbose Show what is going on\n" +); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + t_gpgrt_cmp_version (); + + if (!gpg_error_check_version (GPG_ERROR_VERSION)) + { + fprintf (stderr, "%s: gpg_error_check_version returned an error\n", + logpfx); + errorcount++; + } + if (!gpg_error_check_version ("1.10")) + { + fprintf (stderr, "%s: gpg_error_check_version returned an " + "error for an old version\n", logpfx); + errorcount++; + } + if (gpg_error_check_version ("15.0")) + { + fprintf (stderr, "%s: gpg_error_check_version did not return an error" + " for a newer version\n", logpfx); + errorcount++; + show ("\n"); /* Reference this function to silence gcc. */ + } + if (verbose || errorcount) + { + printf ("Version from header: %s (0x%06x)\n", + GPG_ERROR_VERSION, GPG_ERROR_VERSION_NUMBER); + printf ("Version from binary: %s\n", gpg_error_check_version (NULL)); + printf ("Copyright blurb ...:%s\n", gpg_error_check_version ("\x01\x01")); + } + + return errorcount ? 1 : 0; +} |