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 16358-a11f489) Lines: 31 31 100.0 %
Date: 2014-04-11 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                 :    2089372 : resiu(GEN y, ulong x)
      18                 :            : {
      19                 :    2089372 :   return mpn_mod_1(LIMBS(y), NLIMBS(y), x);
      20                 :            : }
      21                 :            : 
      22                 :            : GEN
      23                 :   45564469 : gcdii(GEN a, GEN b)
      24                 :            : {
      25                 :            :   long v, w;
      26                 :            :   pari_sp av;
      27                 :            :   GEN t;
      28                 :            : 
      29      [ +  +  + ]:   45564469 :   switch (absi_cmp(a,b))
      30                 :            :   {
      31                 :   11065963 :     case 0: return absi(a);
      32                 :    8615553 :     case -1: swap(a,b);
      33                 :            :   }
      34         [ +  + ]:   34498506 :   if (!signe(b)) return absi(a);
      35                 :            :   /* here |a|>|b|>0. Try single precision first */
      36         [ +  + ]:   14506735 :   if (lgefint(a)==3)
      37                 :   10331281 :     return igcduu((ulong)a[2], (ulong)b[2]);
      38         [ +  + ]:    4175454 :   if (lgefint(b)==3)
      39                 :            :   {
      40                 :    2089372 :     ulong u = resiu(a,(ulong)b[2]);
      41         [ +  + ]:    2089372 :     if (!u) return absi(b);
      42                 :    1123001 :     return igcduu((ulong)b[2], u);
      43                 :            :   }
      44                 :            :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      45                 :    2086082 :   av = avma; (void)new_chunk(lgefint(b)+1); /* HACK */
      46                 :    2086082 :   t = remii(a,b);
      47         [ +  + ]:    2086082 :   if (!signe(t)) { avma=av; return absi(b); }
      48                 :            : 
      49                 :    1582902 :   a = b; b = t;
      50                 :    1582902 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      51                 :    1582902 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      52         [ +  + ]:    1582902 :   if (w < v) v = w;
      53      [ +  +  + ]:    1582902 :   switch(absi_cmp(a,b))
      54                 :            :   {
      55                 :      58724 :     case  0: avma=av; a=shifti(a,v); return a;
      56                 :     292411 :     case -1: swap(a,b);
      57                 :            :   }
      58         [ +  + ]:    1524178 :   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                 :    1512888 :   GEN res= cgeti(lgefint(a)+1);
      66                 :    1512888 :   GEN ca = icopy_ef(a,lgefint(a)+1);
      67                 :    1512888 :   GEN cb = icopy_ef(b,lgefint(b)+1);
      68                 :    1512888 :   long l = mpn_gcd(LIMBS(res), LIMBS(ca), NLIMBS(ca), LIMBS(cb), NLIMBS(cb));
      69                 :    1512888 :   res[1] = evalsigne(1)|evallgefint(l+2);
      70                 :    1512888 :   avma=av;
      71                 :   45564469 :   return shifti(res,v);
      72                 :            :   }
      73                 :            : }

Generated by: LCOV version 1.9