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 to exceed 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.14.0 lcov report (development 27095-7e0f67a20c) Lines: 34 34 100.0 %
Date: 2021-11-29 07:04:58 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; either version 2 of the License, or (at your option) any later
       9             : version. It is distributed in the hope that it will be useful, but WITHOUT
      10             : ANY WARRANTY WHATSOEVER.
      11             : 
      12             : Check the License for details. You should have received a copy of it, along
      13             : with the package; see the file 'COPYING'. If not, write to the Free Software
      14             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      15             : 
      16             : /* This file originally adapted from gmp-3.1.1 (from T. Granlund), files
      17             :  * longlong.h and gmp-impl.h
      18             : 
      19             :   Copyright (C) 2000 Free Software Foundation, Inc. */
      20             : 
      21             : #undef  LOCAL_HIREMAINDER
      22             : #define LOCAL_HIREMAINDER
      23             : extern ulong hiremainder;
      24             : 
      25             : #if !defined(INLINE)
      26             : extern long divll(ulong x, ulong y);
      27             : #else
      28             : 
      29             : #define __GLUE(hi, lo) (((hi) << BITS_IN_HALFULONG) | (lo))
      30             : #define __SPLIT(a, b, c) b = HIGHWORD(a); c = LOWWORD(a)
      31             : #define __LDIV(a, b, q, r) q = a / b; r = a - q*b
      32             : extern ulong hiremainder;
      33             : 
      34             : /* divide (hiremainder * 2^BITS_IN_LONG + n0) by d; assume hiremainder < d.
      35             :  * Return quotient, set hiremainder to remainder */
      36             : 
      37             : #if defined(__GNUC__) && !defined(DISABLE_INLINE)
      38             : #undef LOCAL_HIREMAINDER
      39             : #define LOCAL_HIREMAINDER ulong hiremainder
      40             : 
      41             : #define divll(n0, d)                                                    \
      42             : __extension__ ({                                                        \
      43             :   ulong __d1, __d0, __q1, __q0, __r1, __r0, __m, __n1, __n0;            \
      44             :   ulong __k, __d;                                                       \
      45             :                                                                         \
      46             :   __n1 = hiremainder; __n0 = n0; __d = d;                               \
      47             :   if (__n1 == 0)                                                        \
      48             :   { /* Only one division needed */                                      \
      49             :     __LDIV(__n0, __d, __q1, hiremainder);                               \
      50             :   }                                                                     \
      51             :   else if (__d < LOWMASK)                                               \
      52             :   { /* Two half-word divisions  */                                      \
      53             :     __n1 = __GLUE(__n1, HIGHWORD(__n0));                                \
      54             :     __LDIV(__n1, __d, __q1, __r1);                                      \
      55             :     __n1 = __GLUE(__r1,  LOWWORD(__n0));                                \
      56             :     __LDIV(__n1, __d, __q0, hiremainder);                               \
      57             :     __q1 = __GLUE(__q1, __q0);                                          \
      58             :   }                                                                     \
      59             :   else                                                                  \
      60             :   { /* General case */                                                  \
      61             :     if (__d & HIGHBIT)                                                  \
      62             :     {                                                                   \
      63             :       __k = 0; __SPLIT(__d, __d1, __d0);                                \
      64             :     }                                                                   \
      65             :     else                                                                \
      66             :     {                                                                   \
      67             :       __k = bfffo(__d);                                                 \
      68             :       __n1 = (__n1 << __k) | (__n0 >> (BITS_IN_LONG - __k));            \
      69             :       __n0 <<= __k;                                                     \
      70             :       __d = __d << __k; __SPLIT(__d, __d1, __d0);                       \
      71             :     }                                                                   \
      72             :     __LDIV(__n1, __d1, __q1, __r1);                                     \
      73             :     __m =  __q1 * __d0;                                                 \
      74             :     __r1 = __GLUE(__r1, HIGHWORD(__n0));                                  \
      75             :     if (__r1 < __m)                                                        \
      76             :     {                                                                        \
      77             :       __q1--, __r1 += __d;                                                \
      78             :       if (__r1 >= __d) /* we didn't get carry when adding to __r1 */    \
      79             :         if (__r1 < __m)        __q1--, __r1 += __d;                                \
      80             :     }                                                                        \
      81             :     __r1 -= __m;                                                        \
      82             :     __LDIV(__r1, __d1, __q0, __r0);                                     \
      83             :     __m =  __q0 * __d0;                                                  \
      84             :     __r0 = __GLUE(__r0, LOWWORD(__n0));                                   \
      85             :     if (__r0 < __m)                                                        \
      86             :     {                                                                        \
      87             :       __q0--, __r0 += __d;                                                \
      88             :       if (__r0 >= __d)                                                        \
      89             :         if (__r0 < __m)        __q0--, __r0 += __d;                                \
      90             :     }                                                                        \
      91             :     hiremainder = (__r0 - __m) >> __k;                                        \
      92             :     __q1 = __GLUE(__q1, __q0);                                                 \
      93             :   }                                                                           \
      94             :   __q1;                                                                        \
      95             : })
      96             : 
      97             : #else /* __GNUC__ */
      98             : 
      99             : INLINE long
     100   925016465 : divll(ulong n0, ulong d)
     101             : {
     102             :   ulong __d1, __d0, __q1, __q0, __r1, __r0, __m, __n1, __n0;
     103             :   ulong __k, __d;
     104             : 
     105   925016465 :   __n1 = hiremainder; __n0 = n0; __d = d;
     106             : 
     107   925016465 :   if (__n1 == 0)
     108             :   { /* Only one division needed */
     109   469200868 :     __LDIV(__n0, __d, __q1, hiremainder);
     110             :   }
     111   455815597 :   else if (__d < LOWMASK)
     112             :   { /* Two half-word divisions  */
     113    15130916 :     __n1 = __GLUE(__n1, HIGHWORD(__n0));
     114    15130916 :     __LDIV(__n1, __d, __q1, __r1);
     115    15130916 :     __n1 = __GLUE(__r1,  LOWWORD(__n0));
     116    15130916 :     __LDIV(__n1, __d, __q0, hiremainder);
     117    15130916 :     __q1 = __GLUE(__q1, __q0);
     118             :   }
     119             :   else
     120             :   { /* General case */
     121   440684681 :     if (__d & HIGHBIT)
     122             :     {
     123   429300097 :       __k = 0; __SPLIT(__d, __d1, __d0);
     124             :     }
     125             :     else
     126             :     {
     127    11384584 :       __k = bfffo(__d);
     128    11384584 :       __n1 = (__n1 << __k) | (__n0 >> (BITS_IN_LONG - __k));
     129    11384584 :       __n0 = __n0 << __k;
     130    11384584 :       __d = __d << __k; __SPLIT(__d, __d1, __d0);
     131             :     }
     132   440684681 :     __LDIV(__n1, __d1, __q1, __r1);
     133   440684681 :     __m =  __q1 * __d0;
     134   440684681 :     __r1 = __GLUE(__r1, HIGHWORD(__n0));
     135   440684681 :     if (__r1 < __m)
     136             :       {
     137    75316509 :         __q1--, __r1 += __d;
     138    75316509 :         if (__r1 >= __d) /* we didn't get carry when adding to __r1 */
     139    61689911 :           if (__r1 < __m) __q1--, __r1 += __d;
     140             :       }
     141   440684681 :     __r1 -= __m;
     142   440684681 :     __LDIV(__r1, __d1, __q0, __r0);
     143   440684681 :     __m =  __q0 * __d0;
     144   440684681 :     __r0 = __GLUE(__r0, LOWWORD(__n0));
     145   440684681 :     if (__r0 < __m)
     146             :       {
     147    73870205 :         __q0--, __r0 += __d;
     148    73870205 :         if (__r0 >= __d)
     149    54751550 :           if (__r0 < __m) __q0--, __r0 += __d;
     150             :       }
     151   440684681 :     hiremainder = (__r0 - __m) >> __k;
     152   440684681 :     __q1 = __GLUE(__q1, __q0);
     153             :   }
     154   925016465 :   return __q1;
     155             : }
     156             : 
     157             : #endif /* __GNUC__ */
     158             : 
     159             : #endif

Generated by: LCOV version 1.13