* gpg/t-support.h (DIM): Added.

* gpg/t-verify.c (check_result): Rewrote test for notations
because the order of notaions is not guaranteed.

* gpgsm/t-support.h (fail_if_err): Also print the numeric values.
This commit is contained in:
Werner Koch 2003-11-19 15:15:33 +00:00
parent 7fab1937f8
commit 82cb03cc83
5 changed files with 73 additions and 24 deletions

View File

@ -1,3 +1,12 @@
2003-11-19 Werner Koch <wk@gnupg.org>
* gpg/t-support.h (DIM): Added.
* gpg/t-verify.c (check_result): Rewrote test for notations
because the order of notaions is not guaranteed.
* gpgsm/t-support.h (fail_if_err): Also print the numeric values.
2003-10-06 Marcus Brinkmann <marcus@g10code.de> 2003-10-06 Marcus Brinkmann <marcus@g10code.de>
* gpg/t-eventloop.c: Include <sys/types.h> for old systems. * gpg/t-eventloop.c: Include <sys/types.h> for old systems.

View File

@ -25,6 +25,10 @@
#include <gpgme.h> #include <gpgme.h>
#ifndef DIM
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
#endif
#define fail_if_err(err) \ #define fail_if_err(err) \
do \ do \
{ \ { \

View File

@ -85,8 +85,9 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr,
} }
if (sig->summary != summary) if (sig->summary != summary)
{ {
fprintf (stderr, "%s:%i: Unexpected signature summary: 0x%x\n", fprintf (stderr, "%s:%i: Unexpected signature summary: "
__FILE__, __LINE__, sig->summary); "want=0x%x have=0x%x\n",
__FILE__, __LINE__, summary, sig->summary);
exit (1); exit (1);
} }
if (strcmp (sig->fpr, fpr)) if (strcmp (sig->fpr, fpr))
@ -103,24 +104,56 @@ check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr,
} }
if (notation) if (notation)
{ {
if (!sig->notations static struct {
|| strcmp (sig->notations->name, "bar") const char *name;
|| strcmp (sig->notations->value, "\xc3\xb6\xc3\xa4\xc3\xbc\xc3\x9f" const char *value;
" das waren Umlaute und jetzt ein prozent%-Zeichen") int seen;
|| !sig->notations->next } expected_notations[] = {
|| strcmp (sig->notations->next->name, "foobar.1") { "bar",
|| strcmp (sig->notations->next->value, "\xc3\xb6\xc3\xa4\xc3\xbc\xc3\x9f"
"this is a notation data with 2 lines") " das waren Umlaute und jetzt ein prozent%-Zeichen" },
|| !sig->notations->next->next { "foobar.1",
|| sig->notations->next->next->name != NULL "this is a notation data with 2 lines" },
|| strcmp (sig->notations->next->next->value, { NULL,
"http://www.gu.org/policy/") "http://www.gu.org/policy/" }
|| sig->notations->next->next->next) };
{ int i;
fprintf (stderr, "%s:%i: Unexpected notation data\n", gpgme_sig_notation_t r;
__FILE__, __LINE__);
exit (1); for (i=0; i < DIM(expected_notations); i++ )
} expected_notations[i].seen = 0;
for (r = sig->notations; r; r = r->next)
{
int any = 0;
for (i=0; i < DIM(expected_notations); i++)
{
if ( ((r->name && expected_notations[i].name
&& !strcmp (r->name, expected_notations[i].name))
|| (!r->name && !expected_notations[i].name))
&& r->value
&& !strcmp (r->value, expected_notations[i].value))
{
expected_notations[i].seen++;
any++;
}
}
if (!any)
{
fprintf (stderr, "%s:%i: Unexpected notation data\n",
__FILE__, __LINE__);
exit (1);
}
}
for (i=0; i < DIM(expected_notations); i++ )
{
if (expected_notations[i].seen != 1)
{
fprintf (stderr, "%s:%i: Missing or duplicate notation data\n",
__FILE__, __LINE__);
exit (1);
}
}
} }
if (sig->wrong_key_usage) if (sig->wrong_key_usage)
{ {

View File

@ -30,9 +30,10 @@
{ \ { \
if (err) \ if (err) \
{ \ { \
fprintf (stderr, "%s:%d: %s: %s\n", \ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \
__FILE__, __LINE__, gpg_strsource (err), \ __FILE__, __LINE__, gpg_strsource (err), \
gpg_strerror (err)); \ gpg_strerror (err), \
gpg_err_source (err), gpg_err_code (err)); \
exit (1); \ exit (1); \
} \ } \
} \ } \

View File

@ -57,8 +57,9 @@ check_result (gpgme_verify_result_t result, int summary, char *fpr,
} }
if (sig->summary != summary) if (sig->summary != summary)
{ {
fprintf (stderr, "%s:%i: Unexpected signature summary: 0x%x\n", fprintf (stderr, "%s:%i: Unexpected signature summary: "
__FILE__, __LINE__, sig->summary); "want=0x%x have=0x%x\n",
__FILE__, __LINE__, summary, sig->summary);
exit (1); exit (1);
} }
if (strcmp (sig->fpr, fpr)) if (strcmp (sig->fpr, fpr))
@ -119,6 +120,7 @@ main (int argc, char **argv)
fail_if_err (err); fail_if_err (err);
err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0); err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0);
fail_if_err (err); fail_if_err (err);
err = gpgme_op_verify (ctx, sig, text, NULL); err = gpgme_op_verify (ctx, sig, text, NULL);
fail_if_err (err); fail_if_err (err);
result = gpgme_op_verify_result (ctx); result = gpgme_op_verify_result (ctx);