upload -> upload-tarballs
[gnutls.git] / tests / simple.c
blob8a9481376a9e1a67946f1cb2ee73ffe5f4b4ad8d
1 /*
2 * Copyright (C) 2004-2012 Free Software Foundation, Inc.
4 * Author: Simon Josefsson
6 * This file is part of GnuTLS.
8 * GnuTLS is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * GnuTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GnuTLS; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include <stdio.h>
29 #include "utils.h"
31 void
32 doit (void)
34 if (debug)
36 printf ("GnuTLS header version %s.\n", GNUTLS_VERSION);
37 printf ("GnuTLS library version %s.\n", gnutls_check_version (NULL));
40 if (!gnutls_check_version (GNUTLS_VERSION))
41 fail ("gnutls_check_version ERROR\n");
44 const gnutls_pk_algorithm_t *algs;
45 size_t i;
46 int pk;
48 algs = gnutls_pk_list ();
49 if (!algs)
50 fail ("gnutls_pk_list return NULL\n");
52 for (i = 0; algs[i]; i++)
54 if (debug)
55 printf ("pk_list[%d] = %d = %s = %d\n", (int) i, algs[i],
56 gnutls_pk_algorithm_get_name (algs[i]),
57 gnutls_pk_get_id (gnutls_pk_algorithm_get_name (algs[i])));
58 if (gnutls_pk_get_id (gnutls_pk_algorithm_get_name (algs[i]))
59 != algs[i])
60 fail ("gnutls_pk id's doesn't match\n");
63 pk = gnutls_pk_get_id ("foo");
64 if (pk != GNUTLS_PK_UNKNOWN)
65 fail ("gnutls_pk unknown test failed (%d)\n", pk);
67 if (debug)
68 success ("gnutls_pk_list ok\n");
72 const gnutls_sign_algorithm_t *algs;
73 size_t i;
74 int pk;
76 algs = gnutls_sign_list ();
77 if (!algs)
78 fail ("gnutls_sign_list return NULL\n");
80 for (i = 0; algs[i]; i++)
82 if (debug)
83 printf ("sign_list[%d] = %d = %s = %d\n", (int) i, algs[i],
84 gnutls_sign_algorithm_get_name (algs[i]),
85 gnutls_sign_get_id (gnutls_sign_algorithm_get_name
86 (algs[i])));
87 if (gnutls_sign_get_id (gnutls_sign_algorithm_get_name (algs[i])) !=
88 algs[i])
89 fail ("gnutls_sign id's doesn't match\n");
92 pk = gnutls_sign_get_id ("foo");
93 if (pk != GNUTLS_PK_UNKNOWN)
94 fail ("gnutls_sign unknown test failed (%d)\n", pk);
96 if (debug)
97 success ("gnutls_sign_list ok\n");