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.8.0 lcov report (development 19230-c71492b) Lines: 31 31 100.0 %
Date: 2016-07-30 07:10:28 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     8810730 : resiu(GEN y, ulong x)
      18             : {
      19     8810730 :   return mpn_mod_1(LIMBS(y), NLIMBS(y), x);
      20             : }
      21             : 
      22             : GEN
      23   150430771 : gcdii(GEN a, GEN b)
      24             : {
      25             :   long v, w;
      26             :   pari_sp av;
      27             :   GEN t;
      28             : 
      29   150430771 :   switch (absi_cmp(a,b))
      30             :   {
      31    23604889 :     case 0: return absi(a);
      32    39253061 :     case -1: swap(a,b);
      33             :   }
      34   126825878 :   if (!signe(b)) return absi(a);
      35             :   /* here |a|>|b|>0. Try single precision first */
      36    86103814 :   if (lgefint(a)==3)
      37    67226004 :     return igcduu((ulong)a[2], (ulong)b[2]);
      38    18877810 :   if (lgefint(b)==3)
      39             :   {
      40     8810730 :     ulong u = resiu(a,(ulong)b[2]);
      41     8810730 :     if (!u) return absi(b);
      42     6303216 :     return igcduu((ulong)b[2], u);
      43             :   }
      44             :   /* larger than gcd: "avma=av" gerepile (erasing t) is valid */
      45    10067080 :   av = avma; (void)new_chunk(lgefint(b)+1); /* HACK */
      46    10067078 :   t = remii(a,b);
      47    10067083 :   if (!signe(t)) { avma=av; return absi(b); }
      48             : 
      49     8297344 :   a = b; b = t;
      50     8297344 :   v = vali(a); a = shifti(a,-v); setabssign(a);
      51     8297329 :   w = vali(b); b = shifti(b,-w); setabssign(b);
      52     8297331 :   if (w < v) v = w;
      53     8297331 :   switch(absi_cmp(a,b))
      54             :   {
      55      130470 :     case  0: avma=av; a=shifti(a,v); return a;
      56     1685456 :     case -1: swap(a,b);
      57             :   }
      58     8166857 :   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     7874838 :   GEN res= cgeti(lgefint(a)+1);
      66     7874834 :   GEN ca = icopy_ef(a,lgefint(a)+1);
      67     7874821 :   GEN cb = icopy_ef(b,lgefint(b)+1);
      68     7874834 :   long l = mpn_gcd(LIMBS(res), LIMBS(ca), NLIMBS(ca), LIMBS(cb), NLIMBS(cb));
      69     7874869 :   res[1] = evalsigne(1)|evallgefint(l+2);
      70     7874869 :   avma=av;
      71     7874869 :   return shifti(res,v);
      72             :   }
      73             : }

Generated by: LCOV version 1.11