From b4eddd304269da30d29fc1a272237e706773ea2e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 17 Sep 2001 10:36:05 +0000 Subject: Fixed a keylisting bug --- tests/t-keylist.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/t-keylist.c') diff --git a/tests/t-keylist.c b/tests/t-keylist.c index aa82a5b6..9a81c120 100644 --- a/tests/t-keylist.c +++ b/tests/t-keylist.c @@ -94,6 +94,34 @@ doit ( GpgmeCtx ctx, const char *pattern ) } +/* + * Check that there are no problems when we are using two context for + * listing keys. + */ +static void +check_two_contexts (void) +{ + GpgmeError err; + GpgmeCtx ctx1, ctx2; + GpgmeKey key; + + err = gpgme_new(&ctx1); fail_if_err (err); + err = gpgme_op_keylist_start(ctx1, "", 1); fail_if_err (err); + err = gpgme_new(&ctx2); fail_if_err (err); + err = gpgme_op_keylist_start(ctx2, "", 1); fail_if_err (err); + + while ( (err=gpgme_op_keylist_next(ctx2, &key)) != GPGME_EOF) { + gpgme_key_release (key); + } + if (err != GPGME_EOF) + fail_if_err (err); + while ( (err=gpgme_op_keylist_next(ctx1, &key)) != GPGME_EOF) { + gpgme_key_release (key); + } + if (err != GPGME_EOF) + fail_if_err (err); +} + int main (int argc, char **argv ) { @@ -112,6 +140,9 @@ main (int argc, char **argv ) } pattern = argc? *argv : NULL; + err = gpgme_check_engine(); + fail_if_err (err); + err = gpgme_new (&ctx); fail_if_err (err); gpgme_set_keylist_mode (ctx, 1); /* no validity calculation */ @@ -121,6 +152,8 @@ main (int argc, char **argv ) } while ( loop ); gpgme_release (ctx); + check_two_contexts (); + return 0; } -- cgit v1.2.3