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.16.2 lcov report (development 29401-b333f5c7d5) Lines: 72 73 98.6 %
Date: 2024-06-19 09:03:24 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     3868382 : mtsingle_queue_get(struct mt_state *mt, long *workid, long *pending)
      22             : {
      23     3868382 :   GEN done = mt->pending;
      24     3868382 :   if (workid) *workid = mt->workid;
      25     3868382 :   mt->pending = NULL; *pending = 0;
      26     3868382 :   return done;
      27             : }
      28             : 
      29             : static int single_is_thread = 0;
      30             : static long single_trace_level = 0;
      31             : 
      32             : static void
      33     3868408 : mtsingle_queue_submit(struct mt_state *mt, long workid, GEN work)
      34             : {
      35     3868408 :   int is_thread = single_is_thread;
      36     3868408 :   single_is_thread = 1;
      37     3868408 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      38     3868382 :   single_is_thread = is_thread;
      39     3868382 :   mt->workid = workid;
      40     3868382 : }
      41             : 
      42             : static void
      43      885669 : mtsingle_queue_end(void) {  }
      44             : 
      45             : static GEN
      46      221878 : mtsequential_queue_get(struct mt_state *mt, long *workid, long *pending)
      47             : {
      48      221878 :   GEN done = mt->pending;
      49      221878 :   if (workid) *workid = mt->workid;
      50      221878 :   mt->pending = NULL; *pending = 0;
      51      221878 :   return done;
      52             : }
      53             : 
      54             : static void
      55      221973 : mtsequential_queue_submit(struct mt_state *mt, long workid, GEN work)
      56             : {
      57      221973 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      58      221880 :   mt->workid = workid;
      59      221880 : }
      60             : 
      61             : static void
      62       41724 : mtsequential_queue_end(void) {  }
      63             : 
      64             : int
      65   216290807 : mtsingle_is_thread(void) { return single_is_thread; }
      66             : 
      67             : void
      68       12300 : mtsingle_err_recover(long er)
      69             : {
      70             :   (void) er;
      71       12300 :   if (single_is_thread)
      72             :   {
      73          18 :     evalstate_set_trace(single_trace_level);
      74          18 :     single_is_thread = 0;
      75             :   }
      76       12300 : }
      77             : 
      78             : void
      79      885695 : mtsingle_queue_start(struct pari_mt *pt, GEN worker)
      80             : {
      81      885695 :   pt->get = mtsingle_queue_get;
      82      885695 :   pt->submit = mtsingle_queue_submit;
      83      885695 :   pt->end = mtsingle_queue_end;
      84      885695 :   pt->mt.worker = worker;
      85      885695 :   pt->mt.pending = NULL;
      86      885695 :   single_trace_level = evalstate_get_trace();
      87      885695 : }
      88             : 
      89             : void
      90       41729 : mtsequential_queue_start(struct pari_mt *pt, GEN worker)
      91             : {
      92       41729 :   pt->get = mtsequential_queue_get;
      93       41729 :   pt->submit = mtsequential_queue_submit;
      94       41729 :   pt->end = mtsequential_queue_end;
      95       41729 :   pt->mt.worker = worker;
      96       41729 :   pt->mt.pending = NULL;
      97       41729 : }
      98             : 
      99             : void
     100      983077 : mt_queue_end(struct pari_mt *pt) { pt->end(); }
     101             : 
     102             : void
     103     4790826 : mt_queue_submit(struct pari_mt *pt, long workid, GEN work)
     104     4790826 : { pt->submit(&pt->mt, workid, work); }
     105             : 
     106             : GEN
     107     4790723 : mt_queue_get(struct pari_mt *pt, long *workid, long *pending)
     108     4790723 : { return pt->get(&pt->mt, workid, pending); }
     109             : 
     110             : void
     111          87 : mt_queue_start(struct pari_mt *pt, GEN worker)
     112          87 : { return mt_queue_start_lim(pt, worker, 0); }
     113             : 
     114             : void
     115     1414962 : mtstate_save(struct pari_mtstate *mt)
     116             : {
     117     1414962 :   if (mt_is_parallel())
     118             :   {
     119         181 :     mt->is_thread = 0;
     120         181 :     mt->trace_level = 0;
     121         181 :     mt->pending_threads = 1;
     122             :   } else
     123             :   {
     124     1414781 :     mt->is_thread = single_is_thread;
     125     1414781 :     mt->trace_level = single_trace_level;
     126     1414781 :     mt->pending_threads = 0;
     127             :   }
     128     1414962 : }
     129             : 
     130             : void
     131       48562 : mtstate_restore(struct pari_mtstate *mt)
     132             : {
     133       48562 :   if (!mt_is_parallel())
     134             :   {
     135       48553 :     single_is_thread = mt->is_thread;
     136       48553 :     single_trace_level = mt->trace_level;
     137             :   }
     138       48562 :   if (!mt->pending_threads && mt_is_parallel())
     139           7 :     mt_queue_reset();
     140       48562 : }
     141             : 
     142             : void
     143         431 : mtstate_reset(void)
     144             : {
     145         431 :   single_is_thread = 0;
     146         431 :   single_trace_level = 0;
     147         431 :   if (mt_is_parallel())
     148           0 :     mt_queue_reset();
     149         431 : }

Generated by: LCOV version 1.16