aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/opassuan/Makefile.am35
-rw-r--r--tests/opassuan/t-command.c121
4 files changed, 164 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index a4f6d4f5..1248a8f2 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-26 Werner Koch <[email protected]>
+
+ * opassuan/: New.
+ * opassuan/Makefile.am: New.
+ * opassuan/t-command.c: New.
+
2008-12-03 Marcus Brinkmann <[email protected]>
* Makefile.am (INCLUDES): Fix path to include file.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 19307f28..dc2b0370 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,8 +15,7 @@
# 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
+# License along with this program; if not, see <http://www.gnu.org/licenses/>.
## Process this file with automake to produce Makefile.in
@@ -40,7 +39,7 @@ gpgtests =
endif
if RUN_GPGSM_TESTS
-gpgsmtests = gpgsm
+gpgsmtests = gpgsm opassuan
else
gpgsmtests =
endif
diff --git a/tests/opassuan/Makefile.am b/tests/opassuan/Makefile.am
new file mode 100644
index 00000000..2446007e
--- /dev/null
+++ b/tests/opassuan/Makefile.am
@@ -0,0 +1,35 @@
+# Copyright (C) 2009 g10 Code GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME 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.
+#
+# GPGME 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 <http://www.gnu.org/licenses/>.
+
+## Process this file with automake to produce Makefile.in
+
+TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO=
+
+noinst_HEADERS =
+TESTS =
+
+EXTRA_DIST =
+
+INCLUDES = -I$(top_builddir)/src
+
+AM_CPPFLAGS = @GPG_ERROR_CFLAGS@
+LDADD = ../../src/libgpgme.la
+
+noinst_PROGRAMS = $(TESTS) t-command
+
+DISTCLEANFILES =
+
diff --git a/tests/opassuan/t-command.c b/tests/opassuan/t-command.c
new file mode 100644
index 00000000..b6a2d904
--- /dev/null
+++ b/tests/opassuan/t-command.c
@@ -0,0 +1,121 @@
+/* t-command.c - Regression test.
+ Copyright (C) 2009 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME 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.
+
+ GPGME 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#include <gpgme.h>
+
+#define fail_if_err(err) \
+ do \
+ { \
+ if (err) \
+ { \
+ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \
+ __FILE__, __LINE__, gpg_strsource (err), \
+ gpg_strerror (err), \
+ gpg_err_source (err), gpg_err_code (err)); \
+ exit (1); \
+ } \
+ } \
+ while (0)
+
+
+static gpg_error_t
+data_cb (void *opaque, const void *data, size_t datalen)
+{
+ printf ("DATA_CB: datalen=%d\n", (int)datalen);
+ return 0;
+}
+
+
+static gpg_error_t
+inq_cb (void *opaque, const char *name, const char *args,
+ gpgme_assuan_sendfnc_t sendfnc,
+ gpgme_assuan_sendfnc_ctx_t sendfnc_value)
+{
+ printf ("INQ_CB: name=`%s' args=`%s'\n", name, args);
+
+ return 0;
+}
+
+
+static gpg_error_t
+status_cb (void *opaque, const char *status, const char *args)
+{
+ printf ("STATUS_CB: status=`%s' args=`%s'\n", status, args);
+ return 0;
+}
+
+
+
+
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_error_t err;
+ gpgme_ctx_t ctx;
+ const char *command;
+
+ gpgme_check_version (NULL);
+#ifndef HAVE_W32_SYSTEM
+ setlocale (LC_ALL, "");
+ gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
+ gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
+#endif
+
+ if (argc)
+ {
+ argc--;
+ argv++;
+ }
+ command = argc? *argv : "NOP";
+
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+
+ err = gpgme_set_protocol (ctx, GPGME_PROTOCOL_ASSUAN);
+ fail_if_err (err);
+
+ err = gpgme_op_assuan_transact (ctx, command,
+ data_cb, NULL,
+ inq_cb, NULL,
+ status_cb, NULL);
+ fail_if_err (err);
+ err = gpgme_op_assuan_result (ctx);
+ if (err)
+ fprintf (stderr, "assuan command `%s' failed: %s <%s> (%d)\n",
+ command, gpg_strerror (err), gpg_strsource (err), err);
+ else
+ fprintf (stderr, "assuan command `%s' succeeded\n", command);
+
+
+ gpgme_release (ctx);
+
+ return 0;
+}
+