tests: Add repeat argument to run-verify

* tests/run-verify.c (main): Add repeat argument.

--
This helps reproducing rare / random crashes.
This commit is contained in:
Andre Heinecke 2018-10-29 16:33:04 +01:00
parent 8f27511862
commit 681525be00
No known key found for this signature in database
GPG Key ID: 2978E9D40CBABA5C

View File

@ -230,6 +230,7 @@ show_usage (int ex)
" --openpgp use the OpenPGP protocol (default)\n"
" --cms use the CMS protocol\n"
" --sender MBOX use MBOX as sender address\n"
" --repeat N repeat the operation N times\n"
" --auto-key-retrieve\n"
, stderr);
exit (ex);
@ -241,17 +242,11 @@ main (int argc, char **argv)
{
int last_argc = -1;
const char *s;
gpgme_error_t err;
gpgme_ctx_t ctx;
gpgme_protocol_t protocol = GPGME_PROTOCOL_OpenPGP;
FILE *fp_sig = NULL;
gpgme_data_t sig = NULL;
FILE *fp_msg = NULL;
gpgme_data_t msg = NULL;
gpgme_verify_result_t result;
int print_status = 0;
const char *sender = NULL;
int auto_key_retrieve = 0;
int repeats = 1;
if (argc)
{ argc--; argv++; }
@ -294,6 +289,14 @@ main (int argc, char **argv)
sender = *argv;
argc--; argv++;
}
else if (!strcmp (*argv, "--repeat"))
{
argc--; argv++;
if (!argc)
show_usage (1);
repeats = atoi (*argv);
argc--; argv++;
}
else if (!strcmp (*argv, "--auto-key-retrieve"))
{
auto_key_retrieve = 1;
@ -308,6 +311,23 @@ main (int argc, char **argv)
if (argc < 1 || argc > 2)
show_usage (1);
init_gpgme (protocol);
for (int i = 0; i < repeats; i++)
{
gpgme_error_t err;
gpgme_ctx_t ctx;
FILE *fp_sig = NULL;
gpgme_data_t sig = NULL;
FILE *fp_msg = NULL;
gpgme_data_t msg = NULL;
gpgme_verify_result_t result;
if (repeats > 1)
{
printf ("Repeat: %i\n", i);
}
fp_sig = fopen (argv[0], "rb");
if (!fp_sig)
{
@ -328,8 +348,6 @@ main (int argc, char **argv)
}
}
init_gpgme (protocol);
err = gpgme_new (&ctx);
fail_if_err (err);
gpgme_set_protocol (ctx, protocol);
@ -390,5 +408,11 @@ main (int argc, char **argv)
gpgme_data_release (sig);
gpgme_release (ctx);
if (fp_msg)
fclose (fp_msg);
if (fp_sig)
fclose (fp_sig);
}
return 0;
}