diff options
| author | NIIBE Yutaka <[email protected]> | 2026-05-15 09:45:08 +0200 |
|---|---|---|
| committer | NIIBE Yutaka <[email protected]> | 2026-05-15 09:45:08 +0200 |
| commit | 45ccb2fa0ee4613a5327a8d7cddd060be4fbeec1 (patch) | |
| tree | 109da59c55810609d5a7d453adffde4b28953b96 | |
| parent | w32:tests: Fix Makefiles and start-stop-agent for EXEEXT. (diff) | |
| download | gpgme-45ccb2fa0ee4613a5327a8d7cddd060be4fbeec1.tar.gz gpgme-45ccb2fa0ee4613a5327a8d7cddd060be4fbeec1.zip | |
w32:tests: Use pinentry executable instead of script.
* tests/gpg/pinentry: Remove.
* tests/gpg/pinentry.c: New.
* tests/gpg/Makefile.am (EXTRA_DIST): Remove pinentry script.
(noinst_PROGRAMS): Add pinentry executable and its rules to build.
* tests/json/Makefile.am (gpg-agent.conf): Use pinentry executable.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
| -rw-r--r-- | tests/gpg/Makefile.am | 8 | ||||
| -rwxr-xr-x | tests/gpg/pinentry | 22 | ||||
| -rw-r--r-- | tests/gpg/pinentry.c | 47 | ||||
| -rw-r--r-- | tests/json/Makefile.am | 2 |
4 files changed, 55 insertions, 24 deletions
diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am index 4ceb6102..a6c76666 100644 --- a/tests/gpg/Makefile.am +++ b/tests/gpg/Makefile.am @@ -61,7 +61,7 @@ private_keys = \ EXTRA_DIST = initial.test final.test \ pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \ cipher-3.asc cipher-no-sig.asc \ - geheim.txt pubkey-1.asc seckey-1.asc pinentry $(private_keys) \ + geheim.txt pubkey-1.asc seckey-1.asc $(private_keys) \ gpg.conf.in ownertrust.txt BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \ @@ -91,6 +91,7 @@ endif noinst_PROGRAMS = $(c_tests) $(tests_skipped) +noinst_PROGRAMS += pinentry$(EXEEXT) clean-local: -$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop @@ -122,5 +123,10 @@ gpg-agent.conf: # smartcard reader (error might be: Unusable secret key) echo disable-scdaemon >> ./gpg-agent.conf +pinentry.o: $(srcdir)/pinentry.c + $(CC) $(CFLAGS) -c $(srcdir)/pinentry.c + +pinentry$(EXEEXT): pinentry.o + $(CC) -o $@ pinentry.o # end-of-file diff --git a/tests/gpg/pinentry b/tests/gpg/pinentry deleted file mode 100755 index b12caae2..00000000 --- a/tests/gpg/pinentry +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh -# Dummy pinentry -# -# Copyright 2008 g10 Code GmbH -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This file 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. - -echo OK Your orders please - -while read cmd; do - case $cmd in - GETPIN) echo D abc; echo OK;; - *) echo OK;; - esac -done diff --git a/tests/gpg/pinentry.c b/tests/gpg/pinentry.c new file mode 100644 index 00000000..be5d3b35 --- /dev/null +++ b/tests/gpg/pinentry.c @@ -0,0 +1,47 @@ +/* pinentry.c - Dummy pinentry program for testing + * Copyright (C) 2026 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 <https://gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include <stdio.h> +#include <string.h> + +#define MAX_LINE 256 + +int +main (int argc, const char *argv[]) +{ + char line[MAX_LINE+1]; + + (void)argc; + (void)argv; + puts ("OK Your orders please"); + fflush (stdout); + while (fgets (line, sizeof (line), stdin)) + { + if (strncmp (line, "GETPIN", 6) == 0) + puts ("D abc"); + else if (strncmp (line, "BYE", 3) == 0) + break; + puts ("OK"); + fflush (stdout); + } + puts ("OK closing connection"); + fflush (stdout); + return 0; +} diff --git a/tests/json/Makefile.am b/tests/json/Makefile.am index 5f34b849..863b0683 100644 --- a/tests/json/Makefile.am +++ b/tests/json/Makefile.am @@ -110,7 +110,7 @@ gpg-agent.conf: # This is required for gpg2, which does not support command fd for the # passphrase. disable-scdaemon is required so that we don't try using # a key from a smartcard reader (error might be: Unusable secret key) - echo pinentry-program $(abs_srcdir)/../gpg/pinentry > ./gpg-agent.conf + echo pinentry-program $(abs_builddir)/../gpg/pinentry$(EXEEXT) > ./gpg-agent.conf echo disable-scdaemon >> ./gpg-agent.conf |
