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) Coverage Total Hit
Test: PARI/GP v2.18.1 lcov report (development 31041-bd73e9fcdd) Lines: 98.6 % 73 72
Test Date: 2026-07-22 22:45:42 Functions: 100.0 % 17 17
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      4488150 : mtsingle_queue_get(struct mt_state *mt, long *workid, long *pending)
      22              : {
      23      4488150 :   GEN done = mt->pending;
      24      4488150 :   if (workid) *workid = mt->workid;
      25      4488150 :   mt->pending = NULL; *pending = 0;
      26      4488150 :   return done;
      27              : }
      28              : 
      29              : static int single_is_thread = 0;
      30              : static long single_trace_level = 0;
      31              : 
      32              : static void
      33      4488176 : mtsingle_queue_submit(struct mt_state *mt, long workid, GEN work)
      34              : {
      35      4488176 :   int is_thread = single_is_thread;
      36      4488176 :   single_is_thread = 1;
      37      4488176 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      38      4488150 :   single_is_thread = is_thread;
      39      4488150 :   mt->workid = workid;
      40      4488150 : }
      41              : 
      42              : static void
      43      1040552 : mtsingle_queue_end(void) {  }
      44              : 
      45              : static GEN
      46       250350 : mtsequential_queue_get(struct mt_state *mt, long *workid, long *pending)
      47              : {
      48       250350 :   GEN done = mt->pending;
      49       250350 :   if (workid) *workid = mt->workid;
      50       250350 :   mt->pending = NULL; *pending = 0;
      51       250350 :   return done;
      52              : }
      53              : 
      54              : static void
      55       250395 : mtsequential_queue_submit(struct mt_state *mt, long workid, GEN work)
      56              : {
      57       250395 :   mt->pending = work? closure_callgenvec(mt->worker, work): NULL;
      58       250345 :   mt->workid = workid;
      59       250345 : }
      60              : 
      61              : static void
      62        50403 : mtsequential_queue_end(void) {  }
      63              : 
      64              : int
      65    217745362 : mtsingle_is_thread(void) { return single_is_thread; }
      66              : 
      67              : void
      68        13111 : mtsingle_err_recover(long er)
      69              : {
      70        13111 :   if (single_is_thread)
      71              :   {
      72           18 :     if (er) evalstate_set_trace(single_trace_level);
      73           18 :     single_is_thread = 0;
      74              :   }
      75        13111 : }
      76              : 
      77              : void
      78      1040578 : mtsingle_queue_start(struct pari_mt *pt, GEN worker)
      79              : {
      80      1040578 :   pt->get = mtsingle_queue_get;
      81      1040578 :   pt->submit = mtsingle_queue_submit;
      82      1040578 :   pt->end = mtsingle_queue_end;
      83      1040578 :   pt->mt.worker = worker;
      84      1040578 :   pt->mt.pending = NULL;
      85      1040578 :   single_trace_level = evalstate_get_trace();
      86      1040578 : }
      87              : 
      88              : void
      89        50410 : mtsequential_queue_start(struct pari_mt *pt, GEN worker)
      90              : {
      91        50410 :   pt->get = mtsequential_queue_get;
      92        50410 :   pt->submit = mtsequential_queue_submit;
      93        50410 :   pt->end = mtsequential_queue_end;
      94        50410 :   pt->mt.worker = worker;
      95        50410 :   pt->mt.pending = NULL;
      96        50410 : }
      97              : 
      98              : void
      99      1156789 : mt_queue_end(struct pari_mt *pt) { pt->end(); }
     100              : 
     101              : void
     102      5553575 : mt_queue_submit(struct pari_mt *pt, long workid, GEN work)
     103      5553575 : { pt->submit(&pt->mt, workid, work); }
     104              : 
     105              : GEN
     106      5553504 : mt_queue_get(struct pari_mt *pt, long *workid, long *pending)
     107      5553504 : { 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      1432371 : mtstate_save(struct pari_mtstate *mt)
     115              : {
     116      1432371 :   if (mt_is_parallel())
     117              :   {
     118          171 :     mt->is_thread = 0;
     119          171 :     mt->trace_level = 0;
     120          171 :     mt->pending_threads = 1;
     121              :   } else
     122              :   {
     123      1432200 :     mt->is_thread = single_is_thread;
     124      1432200 :     mt->trace_level = single_trace_level;
     125      1432200 :     mt->pending_threads = 0;
     126              :   }
     127      1432371 : }
     128              : 
     129              : void
     130        56415 : mtstate_restore(struct pari_mtstate *mt)
     131              : {
     132        56415 :   if (!mt_is_parallel())
     133              :   {
     134        56406 :     single_is_thread = mt->is_thread;
     135        56406 :     single_trace_level = mt->trace_level;
     136              :   }
     137        56415 :   if (!mt->pending_threads && mt_is_parallel())
     138            7 :     mt_queue_reset();
     139        56415 : }
     140              : 
     141              : void
     142          452 : mtstate_reset(void)
     143              : {
     144          452 :   single_is_thread = 0;
     145          452 :   single_trace_level = 0;
     146          452 :   if (mt_is_parallel())
     147            0 :     mt_queue_reset();
     148          452 : }
        

Generated by: LCOV version 2.0-1