From fdbee6b2113f2b8bd45bd481e2c8848ea4d99a7c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 30 Jan 2003 11:54:23 +0000 Subject: doc/ 2003-01-30 Marcus Brinkmann * gpgme.texi (Engine Information): Rewritten. gpgme/ 2003-01-30 Marcus Brinkmann * gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO. * gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO. (gpgme_get_protocol_name): New function. * engine-backend.h (struct engine_ops): New member get_req_version, remove member check_version. * engine.h (_gpgme_Engine_get_version): New prototype. * rungpg.c (gpg_get_req_version): New function. (gpg_check_version): Function removed. (_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove gpg_check_version. * engine-gpgsm.c (gpgsm_get_req_version): New function. (gpgsm_check_version): Function removed. (_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove gpgsm_check_version. * engine.c: Include ops.h. (_gpgme_engine_get_req_version): New function. (gpgme_engine_check_version): Rewritten. * version.c (gpgme_get_engine_info): Rewritten. * gpgme.h (gpgme_engine_info): New structure. (GpgmeEngineInfo): New type. tests/ 2003-01-30 Marcus Brinkmann * Makefile.am (TESTS): Add t-engine-info. * t-engine-info.c: New file. * gpg/t-encrypt.c (main): Don't print engine info. * gpg/t-eventloop.c (main): Likewise. * gpg/t-encrypt-sign.c (main): Likewise. * gpgsm/t-encrypt.c (main): Likewise. --- tests/ChangeLog | 9 +++++ tests/Makefile.am | 2 +- tests/gpg/t-encrypt-sign.c | 38 +++++++++---------- tests/gpg/t-encrypt.c | 38 +++++++++---------- tests/gpg/t-eventloop.c | 38 +++++++++---------- tests/gpgsm/t-encrypt.c | 38 +++++++++---------- tests/t-engine-info.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 174 insertions(+), 81 deletions(-) create mode 100644 tests/t-engine-info.c (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 1ca88b52..425884b9 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,12 @@ +2003-01-30 Marcus Brinkmann + + * Makefile.am (TESTS): Add t-engine-info. + * t-engine-info.c: New file. + * gpg/t-encrypt.c (main): Don't print engine info. + * gpg/t-eventloop.c (main): Likewise. + * gpg/t-encrypt-sign.c (main): Likewise. + * gpgsm/t-encrypt.c (main): Likewise. + 2002-12-24 Marcus Brinkmann * gpgsm/t-verify.c (main): Adjust caller of gpgme_op_verify. diff --git a/tests/Makefile.am b/tests/Makefile.am index b3679179..aa1da798 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,7 +21,7 @@ TESTS_ENVIRONMENT = GNUPGHOME=. -TESTS = t-version t-data +TESTS = t-version t-data t-engine-info EXTRA_DIST = t-data-1.txt t-data-2.txt diff --git a/tests/gpg/t-encrypt-sign.c b/tests/gpg/t-encrypt-sign.c index 1517db0f..dfd54bed 100644 --- a/tests/gpg/t-encrypt-sign.c +++ b/tests/gpg/t-encrypt-sign.c @@ -1,23 +1,22 @@ /* t-encrypt-sign.c - regression test - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include @@ -94,7 +93,6 @@ main (int argc, char **argv ) err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); fail_if_err (err); - puts ( gpgme_get_engine_info() ); do { err = gpgme_new (&ctx); diff --git a/tests/gpg/t-encrypt.c b/tests/gpg/t-encrypt.c index 14a407d9..fa55fd6f 100644 --- a/tests/gpg/t-encrypt.c +++ b/tests/gpg/t-encrypt.c @@ -1,23 +1,22 @@ /* t-encrypt.c - regression test - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include @@ -74,7 +73,6 @@ main (int argc, char **argv) err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); fail_if_err (err); - puts ( gpgme_get_engine_info() ); do { err = gpgme_new (&ctx); diff --git a/tests/gpg/t-eventloop.c b/tests/gpg/t-eventloop.c index 887de64c..71998bdb 100644 --- a/tests/gpg/t-eventloop.c +++ b/tests/gpg/t-eventloop.c @@ -1,23 +1,22 @@ /* t-eventloop.c - regression test - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include @@ -205,7 +204,6 @@ main (int argc, char *argv[]) err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); fail_if_err (err); - puts (gpgme_get_engine_info ()); do { diff --git a/tests/gpgsm/t-encrypt.c b/tests/gpgsm/t-encrypt.c index 49996858..a6f80a4f 100644 --- a/tests/gpgsm/t-encrypt.c +++ b/tests/gpgsm/t-encrypt.c @@ -1,23 +1,22 @@ /* t-encrypt.c - regression test - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include @@ -92,7 +91,6 @@ main (int argc, char **argv ) err = gpgme_engine_check_version (GPGME_PROTOCOL_CMS); fail_if_err (err); - puts ( gpgme_get_engine_info() ); do { err = gpgme_new (&ctx); diff --git a/tests/t-engine-info.c b/tests/t-engine-info.c new file mode 100644 index 00000000..e4d0eda9 --- /dev/null +++ b/tests/t-engine-info.c @@ -0,0 +1,92 @@ +/* t-engine-info.c - Regression test for gpgme_get_engine_info. + Copyright (C) 2003 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + + +#define fail_if_err(err) \ + do \ + { \ + if (err) \ + { \ + fprintf (stderr, "%s:%d: GpgmeError %s\n", \ + __FILE__, __LINE__, gpgme_strerror (err)); \ + exit (1); \ + } \ + } \ + while (0) + + +void +check_engine_info (GpgmeEngineInfo info, GpgmeProtocol protocol, + const char *path, 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->path, path)) + { + fprintf (stderr, "Unexpected path to executable %s (expected %s instead)", + info->path, path); + exit (1); + } + if (strcmp (info->req_version, req_version)) + { + fprintf (stderr, "Unexpected required version %s (expected %s instead)", + info->req_version, req_version); + exit (1); + } +} + + +int +main (int argc, char **argv ) +{ + GpgmeEngineInfo info; + GpgmeError err; + + err = gpgme_get_engine_info (&info); + fail_if_err (err); + + check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); + + info = info->next; +#ifdef GPGSM_PATH + check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); +#else + if (info) + { + fprintf (stderr, "Unexpected engine info.\n"); + exit (1); + } +#endif + + return 0; +} -- cgit v1.2.3