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 - divll.h (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 19352-1b11b25) Lines: 34 34 100.0 %
Date: 2016-08-25 06:11:27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #line 2 "../src/kernel/none/divll.h"
       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             : /* This file originally adapted from gmp-3.1.1 (from T. Granlund), files
      16             :  * longlong.h and gmp-impl.h
      17             : 
      18             :   Copyright (C) 2000 Free Software Foundation, Inc. */
      19             : 
      20             : #undef  LOCAL_HIREMAINDER
      21             : #define LOCAL_HIREMAINDER
      22             : extern ulong hiremainder;
      23             : 
      24             : #if !defined(INLINE)
      25             : extern long divll(ulong x, ulong y);
      26             : #else
      27             : 
      28             : #define __GLUE(hi, lo) (((hi) << BITS_IN_HALFULONG) | (lo))
      29             : #define __SPLIT(a, b, c) b = HIGHWORD(a); c = LOWWORD(a)
      30             : #define __LDIV(a, b, q, r) q = a / b; r = a - q*b
      31             : extern ulong hiremainder;
      32             : 
      33             : /* divide (hiremainder * 2^BITS_IN_LONG + n0) by d; assume hiremainder < d.
      34             :  * Return quotient, set hiremainder to remainder */
      35             : 
      36             : #if defined(__GNUC__) && !defined(DISABLE_INLINE)
      37             : #undef LOCAL_HIREMAINDER
      38             : #define LOCAL_HIREMAINDER register ulong hiremainder
      39             : 
      40             : #define divll(n0, d)                                                    \
      41             : __extension__ ({                                                        \
      42             :   ulong __d1, __d0, __q1, __q0, __r1, __r0, __m, __n1, __n0;            \
      43             :   ulong __k, __d;                                                       \
      44             :                                                                         \
      45             :   __n1 = hiremainder; __n0 = n0; __d = d;                               \
      46             :   if (__n1 == 0)                                                        \
      47             :   { /* Only one division needed */                                      \
      48             :     __LDIV(__n0, __d, __q1, hiremainder);                               \
      49             :   }                                                                     \
      50             :   else if (__d < LOWMASK)                                               \
      51             :   { /* Two half-word divisions  */                                      \
      52             :     __n1 = __GLUE(__n1, HIGHWORD(__n0));                                \
      53             :     __LDIV(__n1, __d, __q1, __r1);                                      \
      54             :     __n1 = __GLUE(__r1,  LOWWORD(__n0));                                \
      55             :     __LDIV(__n1, __d, __q0, hiremainder);                               \
      56             :     __q1 = __GLUE(__q1, __q0);                                          \
      57             :   }                                                                     \
      58             :   else                                                                  \
      59             :   { /* General case */                                                  \
      60             :     if (__d & HIGHBIT)                                                  \
      61             :     {                                                                   \
      62             :       __k = 0; __SPLIT(__d, __d1, __d0);                                \
      63             :     }                                                                   \
      64             :     else                                                                \
      65             :     {                                                                   \
      66             :       __k = bfffo(__d);                                                 \
      67             :       __n1 = (__n1 << __k) | (__n0 >> (BITS_IN_LONG - __k));            \
      68             :       __n0 <<= __k;                                                     \
      69             :       __d = __d << __k; __SPLIT(__d, __d1, __d0);                       \
      70             :     }                                                                   \
      71             :     __LDIV(__n1, __d1, __q1, __r1);                                     \
      72             :     __m =  __q1 * __d0;                                                 \
      73             :     __r1 = __GLUE(__r1, HIGHWORD(__n0));                                  \
      74             :     if (__r1 < __m)                                                        \
      75             :     {                                                                        \
      76             :       __q1--, __r1 += __d;                                                \
      77             :       if (__r1 >= __d) /* we didn't get carry when adding to __r1 */    \
      78             :         if (__r1 < __m)        __q1--, __r1 += __d;                                \
      79             :     }                                                                        \
      80             :     __r1 -= __m;                                                        \
      81             :     __LDIV(__r1, __d1, __q0, __r0);                                     \
      82             :     __m =  __q0 * __d0;                                                  \
      83             :     __r0 = __GLUE(__r0, LOWWORD(__n0));                                   \
      84             :     if (__r0 < __m)                                                        \
      85             :     {                                                                        \
      86             :       __q0--, __r0 += __d;                                                \
      87             :       if (__r0 >= __d)                                                        \
      88             :         if (__r0 < __m)        __q0--, __r0 += __d;                                \
      89             :     }                                                                        \
      90             :     hiremainder = (__r0 - __m) >> __k;                                        \
      91             :     __q1 = __GLUE(__q1, __q0);                                                 \
      92             :   }                                                                           \
      93             :   __q1;                                                                        \
      94             : })
      95             : 
      96             : #else /* __GNUC__ */
      97             : 
      98             : INLINE long
      99   699480726 : divll(ulong n0, ulong d)
     100             : {
     101             :   ulong __d1, __d0, __q1, __q0, __r1, __r0, __m, __n1, __n0;
     102             :   ulong __k, __d;
     103             : 
     104   699480726 :   __n1 = hiremainder; __n0 = n0; __d = d;
     105             : 
     106   699480726 :   if (__n1 == 0)
     107             :   { /* Only one division needed */
     108   244805290 :     __LDIV(__n0, __d, __q1, hiremainder);
     109             :   }
     110   454675436 :   else if (__d < LOWMASK)
     111             :   { /* Two half-word divisions  */
     112    45351475 :     __n1 = __GLUE(__n1, HIGHWORD(__n0));
     113    45351475 :     __LDIV(__n1, __d, __q1, __r1);
     114    45351475 :     __n1 = __GLUE(__r1,  LOWWORD(__n0));
     115    45351475 :     __LDIV(__n1, __d, __q0, hiremainder);
     116    45351475 :     __q1 = __GLUE(__q1, __q0);
     117             :   }
     118             :   else
     119             :   { /* General case */
     120   409323961 :     if (__d & HIGHBIT)
     121             :     {
     122   383175361 :       __k = 0; __SPLIT(__d, __d1, __d0);
     123             :     }
     124             :     else
     125             :     {
     126    26148600 :       __k = bfffo(__d);
     127    26148600 :       __n1 = (__n1 << __k) | (__n0 >> (BITS_IN_LONG - __k));
     128    26148600 :       __n0 = __n0 << __k;
     129    26148600 :       __d = __d << __k; __SPLIT(__d, __d1, __d0);
     130             :     }
     131   409323961 :     __LDIV(__n1, __d1, __q1, __r1);
     132   409323961 :     __m =  __q1 * __d0;
     133   409323961 :     __r1 = __GLUE(__r1, HIGHWORD(__n0));
     134   409323961 :     if (__r1 < __m)
     135             :       {
     136    70389185 :         __q1--, __r1 += __d;
     137    70389185 :         if (__r1 >= __d) /* we didn't get carry when adding to __r1 */
     138    60895031 :           if (__r1 < __m) __q1--, __r1 += __d;
     139             :       }
     140   409323961 :     __r1 -= __m;
     141   409323961 :     __LDIV(__r1, __d1, __q0, __r0);
     142   409323961 :     __m =  __q0 * __d0;
     143   409323961 :     __r0 = __GLUE(__r0, LOWWORD(__n0));
     144   409323961 :     if (__r0 < __m)
     145             :       {
     146    38934859 :         __q0--, __r0 += __d;
     147    38934859 :         if (__r0 >= __d)
     148    28473523 :           if (__r0 < __m) __q0--, __r0 += __d;
     149             :       }
     150   409323961 :     hiremainder = (__r0 - __m) >> __k;
     151   409323961 :     __q1 = __GLUE(__q1, __q0);
     152             :   }
     153   699480726 :   return __q1;
     154             : }
     155             : 
     156             : #endif /* __GNUC__ */
     157             : 
     158             : #endif

Generated by: LCOV version 1.11