LCOV - code coverage report
Current view: top level - tests - version.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 27 44.4 %
Date: 2016-09-12 12:21:44 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* version.c - Check the version info fucntions
       2             :    Copyright (C) 2013 g10 Code GmbH
       3             : 
       4             :    This file is part of Assuan.
       5             : 
       6             :    Assuan is free software; you can redistribute it and/or modify it
       7             :    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             :    Assuan is distributed in the hope that it will be useful, but
      12             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :    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, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifdef HAVE_CONFIG_H
      21             : #include <config.h>
      22             : #endif
      23             : 
      24             : #include <stdio.h>
      25             : #include <stdlib.h>
      26             : #include <string.h>
      27             : #include <assert.h>
      28             : 
      29             : #include "../src/assuan.h"
      30             : #include "common.h"
      31             : 
      32             : 
      33             : /*
      34             : 
      35             :      M A I N
      36             : 
      37             : */
      38             : int
      39           1 : main (int argc, char **argv)
      40             : {
      41           1 :   int last_argc = -1;
      42             : 
      43           1 :   if (argc)
      44             :     {
      45           1 :       log_set_prefix (*argv);
      46           1 :       argc--; argv++;
      47             :     }
      48           2 :   while (argc && last_argc != argc )
      49             :     {
      50           0 :       last_argc = argc;
      51           0 :       if (!strcmp (*argv, "--help"))
      52             :         {
      53           0 :           puts (
      54             : "usage: ./version [options]\n"
      55             : "\n"
      56             : "Options:\n"
      57             : "  --verbose      Show what is going on\n"
      58             : );
      59           0 :           exit (0);
      60             :         }
      61           0 :       if (!strcmp (*argv, "--verbose"))
      62             :         {
      63           0 :           verbose = 1;
      64           0 :           argc--; argv++;
      65             :         }
      66           0 :       else if (!strcmp (*argv, "--debug"))
      67             :         {
      68           0 :           verbose = debug = 1;
      69           0 :           argc--; argv++;
      70             :         }
      71             :     }
      72             : 
      73           1 :   assuan_set_assuan_log_prefix (log_prefix);
      74             : 
      75           1 :   if (!assuan_check_version (ASSUAN_VERSION))
      76           0 :     log_error ("assuan_check_version returned an error\n");
      77           1 :   if (!assuan_check_version ("2.0.99"))
      78           0 :     log_error ("assuan_check_version returned an error for an old version\n");
      79           1 :   if (assuan_check_version ("15"))
      80           0 :     log_error ("assuan_check_version did not returned an error"
      81             :                " for a newer version\n");
      82           1 :   if (verbose || errorcount)
      83             :     {
      84           0 :       log_info ("Version from header: %s (0x%06x)\n",
      85             :                 ASSUAN_VERSION, ASSUAN_VERSION_NUMBER);
      86           0 :       log_info ("Version from binary: %s \n", assuan_check_version (NULL));
      87             :     }
      88             : 
      89           1 :   return errorcount ? 1 : 0;
      90             : }

Generated by: LCOV version 1.11