|
Packit |
d7e8d0 |
/* t-thread-verify.c - Regression test.
|
|
Packit |
d7e8d0 |
Copyright (C) 2015 by Bundesamt für Sicherheit in der Informationstechnik
|
|
Packit |
d7e8d0 |
Software engineering by Intevation GmbH
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
This file is part of GPGME.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME is free software; you can redistribute it and/or modify it
|
|
Packit |
d7e8d0 |
under the terms of the GNU Lesser General Public License as
|
|
Packit |
d7e8d0 |
published by the Free Software Foundation; either version 2.1 of
|
|
Packit |
d7e8d0 |
the License, or (at your option) any later version.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
GPGME is distributed in the hope that it will be useful, but
|
|
Packit |
d7e8d0 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
d7e8d0 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
d7e8d0 |
Lesser General Public License for more details.
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
d7e8d0 |
License along with this program; if not, write to the Free Software
|
|
Packit |
d7e8d0 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
Packit |
d7e8d0 |
02111-1307, USA. */
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
d7e8d0 |
#include <config.h>
|
|
Packit |
d7e8d0 |
#endif
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <stdlib.h>
|
|
Packit |
d7e8d0 |
#include <stdio.h>
|
|
Packit |
d7e8d0 |
#include <string.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <gpgme.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include <pthread.h>
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#include "t-support.h"
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
#define THREAD_COUNT 10
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
void *
|
|
Packit |
d7e8d0 |
start_keylist (void *arg)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_error_t err;
|
|
Packit |
d7e8d0 |
gpgme_ctx_t ctx;
|
|
Packit |
d7e8d0 |
gpgme_key_t key;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
(void) arg;
|
|
Packit |
d7e8d0 |
err = gpgme_new (&ctx;;
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
err = gpgme_op_keylist_start (ctx, NULL, 0);
|
|
Packit |
d7e8d0 |
fail_if_err (err);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
while (!(err = gpgme_op_keylist_next (ctx, &key)))
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
gpgme_key_unref (key);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
gpgme_release (ctx);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
return NULL;
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
int
|
|
Packit |
d7e8d0 |
main (int argc, char *argv[])
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
int i;
|
|
Packit |
d7e8d0 |
pthread_t keylist_threads[THREAD_COUNT];
|
|
Packit |
d7e8d0 |
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
(void)argc;
|
|
Packit |
d7e8d0 |
(void)argv;
|
|
Packit |
d7e8d0 |
|
|
Packit |
d7e8d0 |
for (i = 0; i < THREAD_COUNT; i++)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
if (pthread_create(&keylist_threads[i], NULL, start_keylist, NULL))
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
fprintf(stderr, "%s:%i: failed to create threads \n",
|
|
Packit |
d7e8d0 |
__FILE__, __LINE__);
|
|
Packit |
d7e8d0 |
exit(1);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
for (i = 0; i < THREAD_COUNT; i++)
|
|
Packit |
d7e8d0 |
{
|
|
Packit |
d7e8d0 |
pthread_join (keylist_threads[i], NULL);
|
|
Packit |
d7e8d0 |
}
|
|
Packit |
d7e8d0 |
return 0;
|
|
Packit |
d7e8d0 |
}
|