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-bordeaux.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.10.0 lcov report (development 19832-7f23dbb) Lines: 56 56 100.0 %
Date: 2016-12-08 05:49:22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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     6698649 : resiu(GEN y, ulong x)
      18             : {
      19     6698649 :   long i, ly = lgefint(y);
      20     6698649 :   ulong xi = get_Fl_red(x);
      21             :   LOCAL_HIREMAINDER;
      22             : 
      23     6698649 :   hiremainder = 0;
      24     6698649 :   for (i=2; i<ly; i++) (void)divll_pre(y[i],x,xi);
      25     6698649 :   return hiremainder;
      26             : }
      27             : 
      28             : /* Assume x>y>0, both of them odd. return x-y if x=y mod 4, x+y otherwise */
      29             : static void
      30   597109320 : gcd_plus_minus(GEN x, GEN y, GEN res)
      31             : {
      32   597109320 :   pari_sp av = avma;
      33   597109320 :   long lx = lgefint(x)-1;
      34   597109320 :   long ly = lgefint(y)-1, lt,m,i;
      35             :   GEN t;
      36             : 
      37   597109320 :   if ((x[lx]^y[ly]) & 3) /* x != y mod 4*/
      38   298877535 :     t = addiispec(x+2,y+2,lx-1,ly-1);
      39             :   else
      40   298231785 :     t = subiispec(x+2,y+2,lx-1,ly-1);
      41             : 
      42   597109320 :   lt = lgefint(t)-1; while (!t[lt]) lt--;
      43   597109320 :   m = vals(t[lt]); lt++;
      44   597109320 :   if (m == 0) /* 2^32 | t */
      45             :   {
      46        7482 :     for (i = 2; i < lt; i++) res[i] = t[i];
      47             :   }
      48   597101838 :   else if (t[2] >> m)
      49             :   {
      50   565605423 :     shift_right(res,t, 2,lt, 0,m);
      51             :   }
      52             :   else
      53             :   {
      54    31496415 :     lt--; t++;
      55    31496415 :     shift_right(res,t, 2,lt, t[1],m);
      56             :   }
      57   597109320 :   res[1] = evalsigne(1)|evallgefint(lt);
      58   597109320 :   avma = av;
      59   597109320 : }
      60             : 
      61             : /* uses modified right-shift binary algorithm now --GN 1998Jul23 */
      62             : GEN
      63   107682839 : gcdii(GEN a, GEN b)
      64             : {
      65             :   long v, w;
      66             :   pari_sp av;
      67             :   GEN t, p1;
      68             : 
      69   107682839 :   switch (abscmpii(a,b))
      70             :   {
      71    15164190 :     case 0: return absi(a);
      72    28574408 :     case -1: t=b; b=a; a=t;
      73             :   }
      74    92518649 :   if (!signe(b)) return absi(a);
      75             :   /* here |a|>|b|>0. Try single precision first */
      76    64380947 :   if (lgefint(a)==3)
      77    51099104 :     return igcduu((ulong)a[2], (ulong)b[2]);
      78    13281843 :   if (lgefint(b)==3)
      79             :   {
      80     6698649 :     ulong u = resiu(a,(ulong)b[2]);
      81     6698649 :     if (!u) return absi(b);
      82     5066775 :     return igcduu((ulong)b[2], u);
      83             :   }
      84             : 
      85             :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      86     6583194 :   av = avma; (void)new_chunk(lgefint(b)); /* HACK */
      87     6583194 :   t = remii(a,b);
      88     6583194 :   if (!signe(t)) { avma=av; return absi(b); }
      89             : 
      90     5500608 :   a = b; b = t;
      91     5500608 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      92     5500608 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      93     5500608 :   if (w < v) v = w;
      94     5500608 :   switch(abscmpii(a,b))
      95             :   {
      96       77733 :     case  0: avma=av; a=shifti(a,v); return a;
      97     1250559 :     case -1: p1=b; b=a; a=p1;
      98             :   }
      99     5422875 :   if (is_pm1(b)) { avma=av; return int2n(v); }
     100             : 
     101             :   /* we have three consecutive memory locations: a,b,t.
     102             :    * All computations are done in place */
     103             : 
     104             :   /* a and b are odd now, and a>b>1 */
     105   606974928 :   while (lgefint(a) > 3)
     106             :   {
     107             :     /* if a=b mod 4 set t=a-b, otherwise t=a+b, then strip powers of 2 */
     108             :     /* so that t <= (a+b)/4 < a/2 */
     109   597109320 :     gcd_plus_minus(a,b, t);
     110   597109320 :     if (is_pm1(t)) { avma=av; return int2n(v); }
     111   596966190 :     switch(abscmpii(t,b))
     112             :     {
     113   382297497 :       case -1: p1 = a; a = b; b = t; t = p1; break;
     114   214177119 :       case  1: p1 = a; a = t; t = p1; break;
     115      491574 :       case  0: avma = av; b=shifti(b,v); return b;
     116             :     }
     117             :   }
     118             :   {
     119     4615452 :     long r[] = {evaltyp(t_INT)|_evallg(3), evalsigne(1)|evallgefint(3), 0};
     120     4615452 :     r[2] = (long) gcduodd((ulong)b[2], (ulong)a[2]);
     121     4615452 :     avma = av; return shifti(r,v);
     122             :   }
     123             : }

Generated by: LCOV version 1.11