From 150a2f9e4e5afe359fec2bbb017f6d0cfa7ca4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 14 Aug 2023 11:39:27 +0200 Subject: [PATCH] tests: Support offline mode in run-import * tests/run-import.c (show_usage): New option --offline. (main): Parse new option. Set offline mode accordingly. -- This allows testing gpgme_op_import with (and without) offline mode. GnuPG-bug-id: 6648 --- tests/run-import.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/run-import.c b/tests/run-import.c index 931a8d6e..b0320ef8 100644 --- a/tests/run-import.c +++ b/tests/run-import.c @@ -46,6 +46,7 @@ show_usage (int ex) " --verbose run in verbose mode\n" " --openpgp use the OpenPGP protocol (default)\n" " --cms use the CMS protocol\n" + " --offline use offline mode\n" " --key-origin use the specified key origin\n" " --url import from given URLs\n" " -0 URLs are delimited by a nul\n" @@ -66,6 +67,7 @@ main (int argc, char **argv) gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP; char *import_filter = NULL; char *key_origin = NULL; + int offline = 0; if (argc) { argc--; argv++; } @@ -120,6 +122,11 @@ main (int argc, char **argv) key_origin = strdup (*argv); argc--; argv++; } + else if (!strcmp (*argv, "--offline")) + { + offline = 1; + argc--; argv++; + } else if (!strncmp (*argv, "--", 2)) show_usage (1); @@ -134,6 +141,8 @@ main (int argc, char **argv) fail_if_err (err); gpgme_set_protocol (ctx, protocol); + gpgme_set_offline (ctx, offline); + if (import_filter) { err = gpgme_set_ctx_flag (ctx, "import-filter", import_filter);