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/gmp - gcd.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 17242-6994acc) Lines: 31 31 100.0 %
Date: 2014-12-22 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 20 100.0 %

           Branch data     Line data    Source code
       1                 :            : #line 2 "../src/kernel/gmp/gcd.c"
       2                 :            : /* Copyright (C) 2000-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                 :    4777781 : resiu(GEN y, ulong x)
      18                 :            : {
      19                 :    4777781 :   return mpn_mod_1(LIMBS(y), NLIMBS(y), x);
      20                 :            : }
      21                 :            : 
      22                 :            : GEN
      23                 :  104859301 : gcdii(GEN a, GEN b)
      24                 :            : {
      25                 :            :   long v, w;
      26                 :            :   pari_sp av;
      27                 :            :   GEN t;
      28                 :            : 
      29      [ +  +  + ]:  104859301 :   switch (absi_cmp(a,b))
      30                 :            :   {
      31                 :   22330089 :     case 0: return absi(a);
      32                 :   24318155 :     case -1: swap(a,b);
      33                 :            :   }
      34         [ +  + ]:   82529212 :   if (!signe(b)) return absi(a);
      35                 :            :   /* here |a|>|b|>0. Try single precision first */
      36         [ +  + ]:   42177553 :   if (lgefint(a)==3)
      37                 :   32212691 :     return igcduu((ulong)a[2], (ulong)b[2]);
      38         [ +  + ]:    9964862 :   if (lgefint(b)==3)
      39                 :            :   {
      40                 :    4777781 :     ulong u = resiu(a,(ulong)b[2]);
      41         [ +  + ]:    4777781 :     if (!u) return absi(b);
      42                 :    3079075 :     return igcduu((ulong)b[2], u);
      43                 :            :   }
      44                 :            :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      45                 :    5187081 :   av = avma; (void)new_chunk(lgefint(b)+1); /* HACK */
      46                 :    5187081 :   t = remii(a,b);
      47         [ +  + ]:    5187081 :   if (!signe(t)) { avma=av; return absi(b); }
      48                 :            : 
      49                 :    4042100 :   a = b; b = t;
      50                 :    4042100 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      51                 :    4042100 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      52         [ +  + ]:    4042100 :   if (w < v) v = w;
      53      [ +  +  + ]:    4042100 :   switch(absi_cmp(a,b))
      54                 :            :   {
      55                 :     119902 :     case  0: avma=av; a=shifti(a,v); return a;
      56                 :     897168 :     case -1: swap(a,b);
      57                 :            :   }
      58         [ +  + ]:    3922198 :   if (is_pm1(b)) { avma=av; return int2n(v); }
      59                 :            :  {
      60                 :            :   /* general case */
      61                 :            :   /*This serve two purposes: 1) mpn_gcd destroy its input and need an extra
      62                 :            :    * limb 2) this allows us to use icopy instead of gerepile later.  NOTE: we
      63                 :            :    * must put u before d else the final icopy could fail.
      64                 :            :    */
      65                 :    3895766 :   GEN res= cgeti(lgefint(a)+1);
      66                 :    3895766 :   GEN ca = icopy_ef(a,lgefint(a)+1);
      67                 :    3895766 :   GEN cb = icopy_ef(b,lgefint(b)+1);
      68                 :    3895766 :   long l = mpn_gcd(LIMBS(res), LIMBS(ca), NLIMBS(ca), LIMBS(cb), NLIMBS(cb));
      69                 :    3895766 :   res[1] = evalsigne(1)|evallgefint(l+2);
      70                 :    3895766 :   avma=av;
      71                 :  104859301 :   return shifti(res,v);
      72                 :            :   }
      73                 :            : }

Generated by: LCOV version 1.9