LCOV - code coverage report
Current view: top level - tests - version.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 31 32.3 %
Date: 2017-03-02 16:44:37 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* version.c  -  This version test should be run first.
       2             :    Copyright (C) 2007 Free Software Foundation, Inc.
       3             : 
       4             :    This file is part of Libgcrypt.
       5             : 
       6             :    Libgcrypt is free software; you can redistribute it and/or modify
       7             :    it under the terms of the GNU Lesser General Public License as
       8             :    published by the Free Software Foundation; either version 2.1 of
       9             :    the License, or (at your option) any later version.
      10             : 
      11             :    Libgcrypt is distributed in the hope that it will be useful,
      12             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :    GNU Lesser General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU Lesser General Public
      17             :    License along with this program; if not, write to the Free Software
      18             :    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
      19             :    USA.  */
      20             : 
      21             : /* This test should be run first because due to a failing config.links
      22             :    script or bad configure parameters the just build libgcrypt may
      23             :    crash in case MPI function for specific CPU revisions have been
      24             :    enabled.  Running this test first will print out information so to
      25             :    make it easier to figure out the problem. */
      26             : 
      27             : 
      28             : #ifdef HAVE_CONFIG_H
      29             : #include <config.h>
      30             : #endif
      31             : #include <stdio.h>
      32             : #include <stdlib.h>
      33             : #include <string.h>
      34             : #include <stdarg.h>
      35             : 
      36             : #include "../src/gcrypt-int.h"
      37             : 
      38             : #define PGM "version"
      39             : #include "t-common.h"
      40             : 
      41             : 
      42             : int
      43           1 : main (int argc, char **argv)
      44             : {
      45           1 :   int last_argc = -1;
      46             : 
      47           1 :   if (argc)
      48           1 :     { argc--; argv++; }
      49             : 
      50           2 :   while (argc && last_argc != argc )
      51             :     {
      52           0 :       last_argc = argc;
      53           0 :       if (!strcmp (*argv, "--"))
      54             :         {
      55           0 :           argc--; argv++;
      56           0 :           break;
      57             :         }
      58           0 :       else if (!strcmp (*argv, "--verbose"))
      59             :         {
      60           0 :           verbose++;
      61           0 :           argc--; argv++;
      62             :         }
      63           0 :       else if (!strcmp (*argv, "--debug"))
      64             :         {
      65             :           /* Dummy option */
      66           0 :           argc--; argv++;
      67             :         }
      68           0 :       else if (!strcmp (*argv, "--disable-hwf"))
      69             :         {
      70           0 :           argc--;
      71           0 :           argv++;
      72           0 :           if (argc)
      73             :             {
      74           0 :               if (gcry_control (GCRYCTL_DISABLE_HWF, *argv, NULL))
      75           0 :                 fprintf (stderr,
      76             :                         PGM
      77             :                         ": unknown hardware feature '%s' - option ignored\n",
      78             :                         *argv);
      79           0 :               argc--;
      80           0 :               argv++;
      81             :             }
      82             :         }
      83             :     }
      84             : 
      85           1 :   xgcry_control (GCRYCTL_SET_VERBOSITY, (int)verbose);
      86             : 
      87           1 :   xgcry_control (GCRYCTL_DISABLE_SECMEM, 0);
      88           1 :   if (strcmp (GCRYPT_VERSION, gcry_check_version (NULL)))
      89             :     {
      90           0 :       int oops = !gcry_check_version (GCRYPT_VERSION);
      91           0 :       fprintf (stderr, PGM ": %sversion mismatch; pgm=%s, library=%s\n",
      92             :                oops? "":"warning: ", GCRYPT_VERSION, gcry_check_version (NULL));
      93           0 :       if (oops)
      94           0 :         exit (1);
      95             :     }
      96             : 
      97           1 :   xgcry_control (GCRYCTL_PRINT_CONFIG, NULL);
      98             : 
      99           1 :   return 0;
     100             : }

Generated by: LCOV version 1.13