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 - mt - mt.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.18.1 lcov report (development 30530-11e908049b) Lines: 72 73 98.6 %
Date: 2025-10-13 09:22:58 Functions: 17 17 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* $Id$
       2             : 
       3             : Copyright (C) 2013  The PARI group.
       4             : 
       5             : This file is part of the PARI/GP package.
       6             : 
       7             : PARI/GP is free software; you can redistribute it and/or modify it under the
       8             : terms of the GNU General Public License as published by the Free Software
       9             : Foundation; either version 2 of the License, or (at your option) any later
      10             : version. It is distributed in the hope that it will be useful, but WITHOUT
      11             : ANY WARRANTY WHATSOEVER.
      12             : 
      13             : Check the License for details. You should have received a copy of it, along
      14             : with the package; see the file 'COPYING'. If not, write to the Free Software
      15             : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
      16             : #include "pari.h"
      17             : #include "paripriv.h"
      18             : #include "mt.h"
      19             : 
      20             : static GEN
      21     3964852 : mtsingle_queue_get(struct mt_state *mt, long *workid, long *pending)
      22             : {
      23     3964852 :   GEN done = mt->pending;
      24     3964852 :   if (workid) *workid = mt->workid;
      25     3964852 :   mt->pending = NULL; *pending = 0;
      26     3964852 :   return done;
      27             : }
      28             : 
      29             : static int single_is_thread = 0;
      30             : static long single_trace_level = 0;
      31             : 
      32             : static void
      33     3964878 : mtsingle_queue_submit(struct mt_state *mt, long workid, GEN work)
      34             : {
      35     3964878 :   int is_thread = single_is_thread;
      36     3964878 :   single_is_thread = 1;
      37     3964878 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      38     3964852 :   single_is_thread = is_thread;
      39     3964852 :   mt->workid = workid;
      40     3964852 : }
      41             : 
      42             : static void
      43      968337 : mtsingle_queue_end(void) {  }
      44             : 
      45             : static GEN
      46      214906 : mtsequential_queue_get(struct mt_state *mt, long *workid, long *pending)
      47             : {
      48      214906 :   GEN done = mt->pending;
      49      214906 :   if (workid) *workid = mt->workid;
      50      214906 :   mt->pending = NULL; *pending = 0;
      51      214906 :   return done;
      52             : }
      53             : 
      54             : static void
      55      215000 : mtsequential_queue_submit(struct mt_state *mt, long workid, GEN work)
      56             : {
      57      215000 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      58      214903 :   mt->workid = workid;
      59      214903 : }
      60             : 
      61             : static void
      62       42389 : mtsequential_queue_end(void) {  }
      63             : 
      64             : int
      65   217328011 : mtsingle_is_thread(void) { return single_is_thread; }
      66             : 
      67             : void
      68       13056 : mtsingle_err_recover(long er)
      69             : {
      70       13056 :   if (single_is_thread)
      71             :   {
      72          18 :     if (er) evalstate_set_trace(single_trace_level);
      73          18 :     single_is_thread = 0;
      74             :   }
      75       13056 : }
      76             : 
      77             : void
      78      968363 : mtsingle_queue_start(struct pari_mt *pt, GEN worker)
      79             : {
      80      968363 :   pt->get = mtsingle_queue_get;
      81      968363 :   pt->submit = mtsingle_queue_submit;
      82      968363 :   pt->end = mtsingle_queue_end;
      83      968363 :   pt->mt.worker = worker;
      84      968363 :   pt->mt.pending = NULL;
      85      968363 :   single_trace_level = evalstate_get_trace();
      86      968363 : }
      87             : 
      88             : void
      89       42395 : mtsequential_queue_start(struct pari_mt *pt, GEN worker)
      90             : {
      91       42395 :   pt->get = mtsequential_queue_get;
      92       42395 :   pt->submit = mtsequential_queue_submit;
      93       42395 :   pt->end = mtsequential_queue_end;
      94       42395 :   pt->mt.worker = worker;
      95       42395 :   pt->mt.pending = NULL;
      96       42395 : }
      97             : 
      98             : void
      99     1073950 : mt_queue_end(struct pari_mt *pt) { pt->end(); }
     100             : 
     101             : void
     102     4910655 : mt_queue_submit(struct pari_mt *pt, long workid, GEN work)
     103     4910655 : { pt->submit(&pt->mt, workid, work); }
     104             : 
     105             : GEN
     106     4910545 : mt_queue_get(struct pari_mt *pt, long *workid, long *pending)
     107     4910545 : { return pt->get(&pt->mt, workid, pending); }
     108             : 
     109             : void
     110          87 : mt_queue_start(struct pari_mt *pt, GEN worker)
     111          87 : { return mt_queue_start_lim(pt, worker, 0); }
     112             : 
     113             : void
     114     1430077 : mtstate_save(struct pari_mtstate *mt)
     115             : {
     116     1430077 :   if (mt_is_parallel())
     117             :   {
     118         176 :     mt->is_thread = 0;
     119         176 :     mt->trace_level = 0;
     120         176 :     mt->pending_threads = 1;
     121             :   } else
     122             :   {
     123     1429901 :     mt->is_thread = single_is_thread;
     124     1429901 :     mt->trace_level = single_trace_level;
     125     1429901 :     mt->pending_threads = 0;
     126             :   }
     127     1430077 : }
     128             : 
     129             : void
     130       56360 : mtstate_restore(struct pari_mtstate *mt)
     131             : {
     132       56360 :   if (!mt_is_parallel())
     133             :   {
     134       56351 :     single_is_thread = mt->is_thread;
     135       56351 :     single_trace_level = mt->trace_level;
     136             :   }
     137       56360 :   if (!mt->pending_threads && mt_is_parallel())
     138           7 :     mt_queue_reset();
     139       56360 : }
     140             : 
     141             : void
     142         445 : mtstate_reset(void)
     143             : {
     144         445 :   single_is_thread = 0;
     145         445 :   single_trace_level = 0;
     146         445 :   if (mt_is_parallel())
     147           0 :     mt_queue_reset();
     148         445 : }

Generated by: LCOV version 1.16