Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux1.fr machine (x86_64 architecture), and agregate them in the final report:

The target is 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - gp - whatnow.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 16358-a11f489) Lines: 37 40 92.5 %
Date: 2014-04-11 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 29 34 85.3 %

           Branch data     Line data    Source code
       1                 :            : /* Copyright (C) 2000  The PARI group.
       2                 :            : 
       3                 :            : This file is part of the PARI/GP package.
       4                 :            : 
       5                 :            : PARI/GP is free software; you can redistribute it and/or modify it under the
       6                 :            : terms of the GNU General Public License as published by the Free Software
       7                 :            : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       8                 :            : ANY WARRANTY WHATSOEVER.
       9                 :            : 
      10                 :            : Check the License for details. You should have received a copy of it, along
      11                 :            : with the package; see the file 'COPYING'. If not, write to the Free Software
      12                 :            : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      13                 :            : 
      14                 :            : #include "pari.h"
      15                 :            : #include "paripriv.h"
      16                 :            : #include "gp.h"
      17                 :            : 
      18                 :            : typedef struct whatnow_t
      19                 :            : {
      20                 :            :   const char *name, *oldarg, *newarg;
      21                 :            : } whatnow_t;
      22                 :            : 
      23                 :            : #define SAME NULL
      24                 :            : #define REMOV (char *)1L
      25                 :            : #define _REMOV {REMOV,NULL,NULL}
      26                 :            : #define _SAME  {SAME,NULL,NULL}
      27                 :            : 
      28                 :            : #include "whatnow.h"
      29                 :            : 
      30                 :            : static void
      31                 :         20 : msg(PariOUT *out, const char *s)
      32                 :            : {
      33                 :         20 :   out_term_color(out, c_HELP);
      34                 :         20 :   out_print_text(out, s);
      35                 :         20 :   out_putc(out, '\n');
      36                 :         20 :   out_term_color(out, c_NONE);
      37                 :         20 : }
      38                 :            : /* If flag = 0 (default): check if s existed in 1.39.15 and print verbosely
      39                 :            :  * the answer.
      40                 :            :  * Else: return 1 if function changed, 0 otherwise, and print help message
      41                 :            :  * plus the above. */
      42                 :            : int
      43                 :         35 : whatnow(PariOUT *out, const char *s, int flag)
      44                 :            : {
      45                 :            :   int n;
      46                 :            :   const char *def;
      47                 :            :   whatnow_t wp;
      48                 :            :   entree *ep;
      49                 :            : 
      50 [ +  + ][ +  - ]:         35 :   if (flag && s[0] && !s[1]) return 0; /* special case "i" and "o" */
                 [ -  + ]
      51                 :         35 :   n = 0;
      52                 :            :   do
      53                 :      14545 :     def = (oldfonctions[n++]).name;
      54 [ +  + ][ +  + ]:      14545 :   while (def && strcmp(def,s));
      55         [ +  + ]:         35 :   if (!def)
      56                 :            :   {
      57                 :         20 :     int m = 0;
      58                 :            :     do
      59                 :        650 :       def = (functions_oldgp[m++]).name;
      60 [ +  + ][ +  + ]:        650 :     while (def && strcmp(def,s));
      61                 :         20 :     n += m - 1;
      62                 :            :   }
      63                 :            :   /* Above linear search is slow, esp. if the symbol is not found. BUT no
      64                 :            :    * point in wasting time by preallocating [ or autoloading ] a hashtable:
      65                 :            :    * whatnow() is never used in a case where speed would be necessary */
      66         [ +  + ]:         35 :   if (!def)
      67                 :            :   {
      68         [ +  + ]:         15 :     if (!flag)
      69                 :          5 :       msg(out, "As far as I can recall, this function never existed");
      70                 :         15 :     return 0;
      71                 :            :   }
      72                 :            : 
      73                 :         20 :   wp = whatnowlist[n-1]; def = wp.name;
      74         [ +  + ]:         20 :   if (def == SAME)
      75                 :            :   {
      76         [ +  - ]:          5 :     if (!flag)
      77                 :          5 :       msg(out, "This function did not change");
      78                 :          5 :     return 0;
      79                 :            :   }
      80         [ -  + ]:         15 :   if (flag)
      81                 :            :   {
      82                 :          0 :     out_term_color(out, c_NONE);
      83                 :          0 :     out_print_text(out, "\nA function with that name existed in GP-1.39.15; to run in backward compatibility mode, type \"default(compatible,3)\", or set \"compatible = 3\" in your GPRC file.");
      84                 :          0 :     out_putc(out, '\n');
      85                 :            :   }
      86                 :            : 
      87         [ +  + ]:         15 :   if (def == REMOV)
      88                 :            :   {
      89                 :          5 :     msg(out, "This function was suppressed");
      90                 :          5 :     return 0;
      91                 :            :   }
      92         [ +  + ]:         10 :   if (!strcmp(def,"x*y")) ep = NULL;
      93                 :            :   else {
      94                 :          5 :     ep = is_entry(wp.name);
      95         [ -  + ]:          5 :     if (!ep) pari_err_BUG("whatnow");
      96                 :            :   }
      97                 :         10 :   out_puts(out, "New syntax: ");
      98                 :         10 :   out_term_color(out, c_ERR);
      99                 :         10 :   out_printf(out, "%s%s ===> %s%s\n\n", s, wp.oldarg, wp.name, wp.newarg);
     100         [ +  + ]:         10 :   if (ep) msg(out, ep->help);
     101                 :         35 :   out_term_color(out, c_NONE); return 1;
     102                 :            : }

Generated by: LCOV version 1.9