diff options
author | Marcus Brinkmann <[email protected]> | 2003-01-30 11:54:23 +0000 |
---|---|---|
committer | Marcus Brinkmann <[email protected]> | 2003-01-30 11:54:23 +0000 |
commit | fdbee6b2113f2b8bd45bd481e2c8848ea4d99a7c (patch) | |
tree | 2c44f8a243b009e24312814355683c93c1938e25 /tests/t-engine-info.c | |
parent | 2003-01-29 Marcus Brinkmann <[email protected]> (diff) | |
download | gpgme-fdbee6b2113f2b8bd45bd481e2c8848ea4d99a7c.tar.gz gpgme-fdbee6b2113f2b8bd45bd481e2c8848ea4d99a7c.zip |
doc/
2003-01-30 Marcus Brinkmann <[email protected]>
* gpgme.texi (Engine Information): Rewritten.
gpgme/
2003-01-30 Marcus Brinkmann <[email protected]>
* gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO.
* gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO.
(gpgme_get_protocol_name): New function.
* engine-backend.h (struct engine_ops): New member
get_req_version, remove member check_version.
* engine.h (_gpgme_Engine_get_version): New prototype.
* rungpg.c (gpg_get_req_version): New function.
(gpg_check_version): Function removed.
(_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove
gpg_check_version.
* engine-gpgsm.c (gpgsm_get_req_version): New function.
(gpgsm_check_version): Function removed.
(_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove
gpgsm_check_version.
* engine.c: Include ops.h.
(_gpgme_engine_get_req_version): New function.
(gpgme_engine_check_version): Rewritten.
* version.c (gpgme_get_engine_info): Rewritten.
* gpgme.h (gpgme_engine_info): New structure.
(GpgmeEngineInfo): New type.
tests/
2003-01-30 Marcus Brinkmann <[email protected]>
* Makefile.am (TESTS): Add t-engine-info.
* t-engine-info.c: New file.
* gpg/t-encrypt.c (main): Don't print engine info.
* gpg/t-eventloop.c (main): Likewise.
* gpg/t-encrypt-sign.c (main): Likewise.
* gpgsm/t-encrypt.c (main): Likewise.
Diffstat (limited to 'tests/t-engine-info.c')
-rw-r--r-- | tests/t-engine-info.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c new file mode 100644 index 00000000..e4d0eda9 --- /dev/null +++ b/tests/t-engine-info.c @@ -0,0 +1,92 @@ +/* t-engine-info.c - Regression test for gpgme_get_engine_info. + Copyright (C) 2003 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 General Public License as published by + the Free Software Foundation; either version 2 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <gpgme.h> + + +#define fail_if_err(err) \ + do \ + { \ + if (err) \ + { \ + fprintf (stderr, "%s:%d: GpgmeError %s\n", \ + __FILE__, __LINE__, gpgme_strerror (err)); \ + exit (1); \ + } \ + } \ + while (0) + + +void +check_engine_info (GpgmeEngineInfo info, GpgmeProtocol protocol, + const char *path, const char *req_version) +{ + if (info->protocol != protocol) + { + fprintf (stderr, "Unexpected protocol %i (expected %i instead)\n", + info->protocol, protocol); + exit (1); + } + if (strcmp (info->path, path)) + { + fprintf (stderr, "Unexpected path to executable %s (expected %s instead)", + info->path, path); + exit (1); + } + if (strcmp (info->req_version, req_version)) + { + fprintf (stderr, "Unexpected required version %s (expected %s instead)", + info->req_version, req_version); + exit (1); + } +} + + +int +main (int argc, char **argv ) +{ + GpgmeEngineInfo info; + GpgmeError err; + + err = gpgme_get_engine_info (&info); + fail_if_err (err); + + check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); + + info = info->next; +#ifdef GPGSM_PATH + check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); +#else + if (info) + { + fprintf (stderr, "Unexpected engine info.\n"); + exit (1); + } +#endif + + return 0; +} |