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:
- with GMP kernel
- with GMP kernel using --mt=pthread
- with native kernel, including micro-assembler code
- with native kernel, without micro-assembler
- with native kernel, without micro-assembler, disabling GCC extensions
(DISABLE_INLINE)
- with GMP kernel, emulating an
x86_32
architecture at
Configure time via setarch
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 |
|
|
|
|
Line data Source code
1 : /* Copyright (C) 2017 The PARI group.
2 :
3 : This file is part of the PARI/GP package.
4 :
5 : PARI/GP is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU General Public License as published by the Free Software
7 : Foundation; either version 2 of the License, or (at your option) any later
8 : version. It is distributed in the hope that it will be useful, but WITHOUT
9 : ANY WARRANTY WHATSOEVER.
10 :
11 : Check the License for details. You should have received a copy of it, along
12 : with the package; see the file 'COPYING'. If not, write to the Free Software
13 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
14 :
15 : #include "pari.h"
16 : #include "paripriv.h"
17 :
18 : void
19 168 : forksubset_init(forsubset_t *T, long n, long k)
20 : {
21 168 : T->all = 0;
22 168 : T->first = 1;
23 168 : T->n = n;
24 168 : T->k = k;
25 168 : T->v = identity_perm(k);
26 168 : }
27 :
28 : void
29 70 : forallsubset_init(forsubset_t *T, long n)
30 : {
31 70 : T->all = 1;
32 70 : T->first = 1;
33 70 : T->n = n;
34 70 : T->k = 0;
35 70 : T->v = vecsmalltrunc_init(n + 1);
36 70 : }
37 :
38 : static GEN
39 1470 : forksubset_next(forsubset_t *T)
40 : {
41 1470 : GEN v = T->v;
42 1470 : long i, n = T->n, k = T->k;
43 :
44 1470 : if (T->first) { T->first = 0; return (k >= 0 && k <= n) ? v: NULL; }
45 1232 : if (k <= 0 || k >= n) return NULL;
46 :
47 1036 : if (v[k] < n) { v[k]++; return v; }
48 847 : for (i = k - 1; i >= 1 && v[i+1] == v[i] + 1; i--);
49 518 : if (i == 0) return NULL;
50 :
51 329 : v[i]++;
52 784 : for (; i < k; i++) v[i+1] = v[i] + 1;
53 329 : return v;
54 : }
55 : static GEN
56 854 : forallsubset_next(forsubset_t *T)
57 : {
58 : long i;
59 :
60 854 : if (forksubset_next(T)) return T->v;
61 238 : else if (T->k < T->n)
62 : {
63 168 : (T->k)++;
64 168 : setlg(T->v, T->k+1);
65 588 : for (i = 1; i <= T->k; i++) (T->v)[i] = i;
66 168 : return T->v;
67 : }
68 70 : return NULL;
69 : }
70 : GEN
71 1470 : forsubset_next(forsubset_t *T)
72 1470 : { return T->all? forallsubset_next(T): forksubset_next(T); }
73 : void
74 245 : forsubset_init(forsubset_t *T, GEN nk)
75 : {
76 245 : switch(typ(nk))
77 : {
78 70 : case t_INT: forallsubset_init(T, itos(nk)); return;
79 168 : case t_VEC:
80 168 : if (lg(nk) == 3)
81 : {
82 168 : GEN n = gel(nk,1), k = gel(nk,2);
83 168 : if (typ(n) == t_INT && typ(k) == t_INT)
84 168 : return forksubset_init(T, itos(n),itos(k));
85 : }
86 : default:
87 7 : pari_err_TYPE("forsubset", nk);
88 : }
89 : }
90 : void
91 245 : forsubset0(GEN nk, GEN code)
92 : {
93 245 : pari_sp av = avma;
94 : forsubset_t T;
95 245 : void *E = (void*)code;
96 : GEN v;
97 245 : push_lex(gen_0, code);
98 245 : forsubset_init(&T, nk);
99 1470 : while ((v = forsubset_next(&T)))
100 1232 : if (gp_evalvoid(E, v)) break;
101 238 : pop_lex(1); set_avma(av);
102 238 : }
|