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 - kernel/none - gcd.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 16624-25b9976) Lines: 55 55 100.0 %
Date: 2014-06-24 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 67 69 97.1 %

           Branch data     Line data    Source code
       1                 :            : #line 2 "../src/kernel/none/gcd.c"
       2                 :            : /* Copyright (C) 2003  The PARI group.
       3                 :            : 
       4                 :            : This file is part of the PARI/GP package.
       5                 :            : 
       6                 :            : PARI/GP is free software; you can redistribute it and/or modify it under the
       7                 :            : terms of the GNU General Public License as published by the Free Software
       8                 :            : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       9                 :            : ANY WARRANTY WHATSOEVER.
      10                 :            : 
      11                 :            : Check the License for details. You should have received a copy of it, along
      12                 :            : with the package; see the file 'COPYING'. If not, write to the Free Software
      13                 :            : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14                 :            : 
      15                 :            : /* assume y > x > 0. return y mod x */
      16                 :            : static ulong
      17                 :    2769840 : resiu(GEN y, ulong x)
      18                 :            : {
      19                 :    2769840 :   long i, ly = lgefint(y);
      20                 :            :   LOCAL_HIREMAINDER;
      21                 :            : 
      22                 :    2769840 :   hiremainder = 0;
      23 [ +  + ][ +  + ]:   12324636 :   for (i=2; i<ly; i++) (void)divll(y[i],x);
         [ +  + ][ +  + ]
         [ +  - ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
            [ +  + ][ + ]
      24                 :    2769840 :   return hiremainder;
      25                 :            : }
      26                 :            : 
      27                 :            : /* Assume x>y>0, both of them odd. return x-y if x=y mod 4, x+y otherwise */
      28                 :            : static void
      29                 :   85229148 : gcd_plus_minus(GEN x, GEN y, GEN res)
      30                 :            : {
      31                 :   85229148 :   pari_sp av = avma;
      32                 :   85229148 :   long lx = lgefint(x)-1;
      33                 :   85229148 :   long ly = lgefint(y)-1, lt,m,i;
      34                 :            :   GEN t;
      35                 :            : 
      36         [ +  + ]:   85229148 :   if ((x[lx]^y[ly]) & 3) /* x != y mod 4*/
      37                 :   42866583 :     t = addiispec(x+2,y+2,lx-1,ly-1);
      38                 :            :   else
      39                 :   42362565 :     t = subiispec(x+2,y+2,lx-1,ly-1);
      40                 :            : 
      41         [ +  + ]:   85229820 :   lt = lgefint(t)-1; while (!t[lt]) lt--;
      42                 :   85229148 :   m = vals(t[lt]); lt++;
      43         [ +  + ]:   85229148 :   if (m == 0) /* 2^32 | t */
      44                 :            :   {
      45         [ +  + ]:          6 :     for (i = 2; i < lt; i++) res[i] = t[i];
      46                 :            :   }
      47         [ +  + ]:   85229145 :   else if (t[2] >> m)
      48                 :            :   {
      49                 :   80158944 :     shift_right(res,t, 2,lt, 0,m);
      50                 :            :   }
      51                 :            :   else
      52                 :            :   {
      53                 :    5070201 :     lt--; t++;
      54                 :    5070201 :     shift_right(res,t, 2,lt, t[1],m);
      55                 :            :   }
      56                 :   85229148 :   res[1] = evalsigne(1)|evallgefint(lt);
      57                 :   85229148 :   avma = av;
      58                 :   85229148 : }
      59                 :            : 
      60                 :            : /* uses modified right-shift binary algorithm now --GN 1998Jul23 */
      61                 :            : GEN
      62                 :   67300083 : gcdii(GEN a, GEN b)
      63                 :            : {
      64                 :            :   long v, w;
      65                 :            :   pari_sp av;
      66                 :            :   GEN t, p1;
      67                 :            : 
      68      [ +  +  + ]:   67300083 :   switch (absi_cmp(a,b))
      69                 :            :   {
      70                 :   15849222 :     case 0: return absi(a);
      71                 :   13551012 :     case -1: t=b; b=a; a=t;
      72                 :            :   }
      73         [ +  + ]:   51450861 :   if (!signe(b)) return absi(a);
      74                 :            :   /* here |a|>|b|>0. Try single precision first */
      75         [ +  + ]:   22721535 :   if (lgefint(a)==3)
      76                 :   17578443 :     return igcduu((ulong)a[2], (ulong)b[2]);
      77         [ +  + ]:    5143092 :   if (lgefint(b)==3)
      78                 :            :   {
      79                 :    2769840 :     ulong u = resiu(a,(ulong)b[2]);
      80         [ +  + ]:    2769840 :     if (!u) return absi(b);
      81                 :    1592136 :     return igcduu((ulong)b[2], u);
      82                 :            :   }
      83                 :            : 
      84                 :            :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      85                 :    2373252 :   av = avma; (void)new_chunk(lgefint(b)); /* HACK */
      86                 :    2373252 :   t = remii(a,b);
      87         [ +  + ]:    2373252 :   if (!signe(t)) { avma=av; return absi(b); }
      88                 :            : 
      89                 :    1628016 :   a = b; b = t;
      90                 :    1628016 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      91                 :    1628016 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      92         [ +  + ]:    1628016 :   if (w < v) v = w;
      93      [ +  +  + ]:    1628016 :   switch(absi_cmp(a,b))
      94                 :            :   {
      95                 :      72936 :     case  0: avma=av; a=shifti(a,v); return a;
      96                 :     286065 :     case -1: p1=b; b=a; a=p1;
      97                 :            :   }
      98         [ +  + ]:    1555080 :   if (is_pm1(b)) { avma=av; return int2n(v); }
      99                 :            : 
     100                 :            :   /* we have three consecutive memory locations: a,b,t.
     101                 :            :    * All computations are done in place */
     102                 :            : 
     103                 :            :   /* a and b are odd now, and a>b>1 */
     104         [ +  + ]:   86496108 :   while (lgefint(a) > 3)
     105                 :            :   {
     106                 :            :     /* if a=b mod 4 set t=a-b, otherwise t=a+b, then strip powers of 2 */
     107                 :            :     /* so that t <= (a+b)/4 < a/2 */
     108                 :   85229148 :     gcd_plus_minus(a,b, t);
     109         [ +  + ]:   85229148 :     if (is_pm1(t)) { avma=av; return int2n(v); }
     110   [ +  +  +  - ]:   85228527 :     switch(absi_cmp(t,b))
     111                 :            :     {
     112                 :   56213088 :       case -1: p1 = a; a = b; b = t; t = p1; break;
     113                 :   28744335 :       case  1: p1 = a; a = t; t = p1; break;
     114                 :     271104 :       case  0: avma = av; b=shifti(b,v); return b;
     115                 :            :     }
     116                 :            :   }
     117                 :            :   {
     118                 :    1266960 :     long r[] = {evaltyp(t_INT)|_evallg(3), evalsigne(1)|evallgefint(3), 0};
     119                 :    1266960 :     r[2] = (long) gcduodd((ulong)b[2], (ulong)a[2]);
     120                 :   67300083 :     avma = av; return shifti(r,v);
     121                 :            :   }
     122                 :            : }

Generated by: LCOV version 1.9