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.14.0 lcov report (development 26099-280a43a7d3) Lines: 49 50 98.0 %
Date: 2021-01-28 06:10:50 Functions: 13 13 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      800667 : mtsingle_queue_get(struct mt_state *mt, long *workid, long *pending)
      22             : {
      23      800667 :   GEN done = mt->pending;
      24      800667 :   if (workid) *workid = mt->workid;
      25      800667 :   mt->pending = NULL; *pending = 0;
      26      800667 :   return done;
      27             : }
      28             : 
      29             : static int single_is_thread = 0;
      30             : static long single_trace_level = 0;
      31             : 
      32             : static void
      33      800682 : mtsingle_queue_submit(struct mt_state *mt, long workid, GEN work)
      34             : {
      35      800682 :   single_is_thread = 1;
      36      800682 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      37      800668 :   single_is_thread = 0;
      38      800668 :   mt->workid = workid;
      39      800668 : }
      40             : 
      41             : static void
      42      156216 : mtsingle_queue_end(void) {  }
      43             : 
      44             : int
      45   166877244 : mtsingle_is_thread(void) { return single_is_thread; }
      46             : 
      47             : void
      48        8521 : mtsingle_err_recover(long er)
      49             : {
      50             :   (void) er;
      51        8521 :   if (single_is_thread)
      52             :   {
      53          18 :     evalstate_set_trace(single_trace_level);
      54          18 :     single_is_thread = 0;
      55             :   }
      56        8521 : }
      57             : 
      58             : void
      59      156234 : mtsingle_queue_start(struct pari_mt *pt, GEN worker)
      60             : {
      61      156234 :   pt->get = mtsingle_queue_get;
      62      156234 :   pt->submit = mtsingle_queue_submit;
      63      156234 :   pt->end = mtsingle_queue_end;
      64      156234 :   pt->mt.worker = worker;
      65      156234 :   pt->mt.pending = NULL;
      66      156234 :   single_trace_level = evalstate_get_trace();
      67      156234 : }
      68             : 
      69             : void
      70      178168 : mt_queue_end(struct pari_mt *pt) { pt->end(); }
      71             : 
      72             : void
      73     1164299 : mt_queue_submit(struct pari_mt *pt, long workid, GEN work)
      74     1164299 : { pt->submit(&pt->mt, workid, work); }
      75             : 
      76             : GEN
      77     1164283 : mt_queue_get(struct pari_mt *pt, long *workid, long *pending)
      78     1164283 : { return pt->get(&pt->mt, workid, pending); }
      79             : 
      80             : void
      81          71 : mt_queue_start(struct pari_mt *pt, GEN worker)
      82          71 : { return mt_queue_start_lim(pt, worker, 0); }
      83             : 
      84             : void
      85     1383118 : mtstate_save(struct pari_mtstate *mt)
      86             : {
      87     1383118 :   mt->is_thread = single_is_thread;
      88     1383118 :   mt->trace_level = single_trace_level;
      89     1383118 :   mt->pending_threads = mt_is_parallel();
      90     1383118 : }
      91             : 
      92             : void
      93       44739 : mtstate_restore(struct pari_mtstate *mt)
      94             : {
      95       44739 :   single_is_thread = mt->is_thread;
      96       44739 :   single_trace_level = mt->trace_level;
      97       44739 :   if (!mt->pending_threads && mt_is_parallel())
      98           7 :     mt_queue_reset();
      99       44739 : }
     100             : 
     101             : void
     102         340 : mtstate_reset(void)
     103             : {
     104         340 :   single_is_thread = 0;
     105         340 :   single_trace_level = 0;
     106         340 :   if (mt_is_parallel())
     107           0 :     mt_queue_reset();
     108         340 : }

Generated by: LCOV version 1.13