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/gmp - gcd.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.10.0 lcov report (development 19834-0e97742) Lines: 31 31 100.0 %
Date: 2016-12-09 05:49:11 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          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     9646265 : resiu(GEN y, ulong x)
      18             : {
      19     9646265 :   return mpn_mod_1(LIMBS(y), NLIMBS(y), x);
      20             : }
      21             : 
      22             : GEN
      23   146047737 : gcdii(GEN a, GEN b)
      24             : {
      25             :   long v, w;
      26             :   pari_sp av;
      27             :   GEN t;
      28             : 
      29   146047737 :   switch (abscmpii(a,b))
      30             :   {
      31    20991366 :     case 0: return absi(a);
      32    38209924 :     case -1: swap(a,b);
      33             :   }
      34   125056373 :   if (!signe(b)) return absi(a);
      35             :   /* here |a|>|b|>0. Try single precision first */
      36    86246518 :   if (lgefint(a)==3)
      37    66347125 :     return igcduu((ulong)a[2], (ulong)b[2]);
      38    19899393 :   if (lgefint(b)==3)
      39             :   {
      40     9646265 :     ulong u = resiu(a,(ulong)b[2]);
      41     9646265 :     if (!u) return absi(b);
      42     6975818 :     return igcduu((ulong)b[2], u);
      43             :   }
      44             :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      45    10253128 :   av = avma; (void)new_chunk(lgefint(b)+1); /* HACK */
      46    10253126 :   t = remii(a,b);
      47    10253134 :   if (!signe(t)) { avma=av; return absi(b); }
      48             : 
      49     8687979 :   a = b; b = t;
      50     8687979 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      51     8687960 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      52     8687956 :   if (w < v) v = w;
      53     8687956 :   switch(abscmpii(a,b))
      54             :   {
      55      113124 :     case  0: avma=av; a=shifti(a,v); return a;
      56     1996385 :     case -1: swap(a,b);
      57             :   }
      58     8574827 :   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     8312346 :   GEN res= cgeti(lgefint(a)+1);
      66     8312346 :   GEN ca = icopy_ef(a,lgefint(a)+1);
      67     8312342 :   GEN cb = icopy_ef(b,lgefint(b)+1);
      68     8312344 :   long l = mpn_gcd(LIMBS(res), LIMBS(ca), NLIMBS(ca), LIMBS(cb), NLIMBS(cb));
      69     8312379 :   res[1] = evalsigne(1)|evallgefint(l+2);
      70     8312379 :   avma=av;
      71     8312379 :   return shifti(res,v);
      72             :   }
      73             : }

Generated by: LCOV version 1.11