diff options
Diffstat (limited to 'tests/t-engine-info.c')
-rw-r--r-- | tests/t-engine-info.c | 112 |
1 files changed, 76 insertions, 36 deletions
diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c index ec2e1e8..53f5b2f 100644 --- a/tests/t-engine-info.c +++ b/tests/t-engine-info.c @@ -28,6 +28,12 @@ #include <gpgme.h> +#define PGM "t-engine-info" + +static int verbose; + + + #define fail_if_err(err) \ do \ @@ -41,54 +47,88 @@ } \ while (0) - -void -check_engine_info (gpgme_engine_info_t info, gpgme_protocol_t protocol, - const char *file_name, 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->file_name, file_name)) - { - fprintf (stderr, "Unexpected file name to executable %s (expected %s instead)\n", - info->file_name, file_name); - exit (1); - } - if (strcmp (info->req_version, req_version)) - { - fprintf (stderr, "Unexpected required version %s (expected %s instead)\n", - info->req_version, req_version); - exit (1); - } -} - int main (int argc, char **argv ) { + int last_argc = -1; gpgme_engine_info_t info; gpgme_error_t err; - gpgme_check_version (NULL); - err = gpgme_get_engine_info (&info); - fail_if_err (err); + if (argc) + { argc--; argv++; } - check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--")) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--help")) + { + fputs ("usage: " PGM " [options]\n" + "Options:\n" + " --set-global-flag KEY VALUE\n", + stdout); + exit (0); + } + else if (!strcmp (*argv, "--verbose")) + { + verbose++; + argc--; argv++; + } + else if (!strcmp (*argv, "--set-global-flag")) + { + argc--; argv++; + if (argc < 2) + { + fprintf (stderr, PGM ": not enough arguments for option\n"); + exit (1); + } + if (gpgme_set_global_flag (argv[0], argv[1])) + { + fprintf (stderr, PGM ": gpgme_set_global_flag failed\n"); + exit (1); + } + argc--; argv++; + argc--; argv++; + } + else if (!strncmp (*argv, "--", 2)) + { + fprintf (stderr, PGM ": unknown option '%s'\n", *argv); + exit (1); + } + } - info = info->next; -#ifdef GPGSM_PATH - check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); -#else - if (info) + if (argc) { - fprintf (stderr, "Unexpected engine info.\n"); + fprintf (stderr, PGM ": unexpected arguments\n"); exit (1); } -#endif + + gpgme_check_version (NULL); + + { + const char *keys[] = {"homedir", "agent-socket", "uiserver-socket", + "gpgconf-name", "gpg-name", "gpgsm-name", + "g13-name", NULL }; + const char *s; + int i; + + for (i=0; keys[i]; i++) + if ((s = gpgme_get_dirinfo (keys[i]))) + fprintf (stderr, "dirinfo: %s='%s'\n", keys[i], s); + } + + err = gpgme_get_engine_info (&info); + fail_if_err (err); + + for (; info; info = info->next) + fprintf (stdout, "protocol=%d engine='%s' v='%s' (min='%s') home='%s'\n", + info->protocol, info->file_name, info->version, info->req_version, + info->home_dir? info->home_dir : "[default]"); return 0; } |