File: README.md

package info (click to toggle)
primecount 8.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,648 kB
  • sloc: cpp: 21,887; ansic: 121; sh: 100; makefile: 89
file content (36 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# primecount testing

Run the commands below from the primecount root directory.

```bash
cmake . -DBUILD_TESTS=ON
cmake --build . --parallel
ctest
```

# Test in debug mode

When hacking on primecount's source code, it is best to run its test suite
in debug mode i.e. ```-DCMAKE_BUILD_TYPE=Debug``` because this enables
extensive (but slow) runtime assertions. In case an assertion is triggered,
the file name and line number where the error occurred will be printed to
the screen. This helps to quickly identify newly introduced bugs.

```bash
# Run commands from primecount root directory
cmake . -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-O1 -Wall -Wextra -pedantic" -DCMAKE_C_FLAGS="-O1 -Wall -Wextra -pedantic"
cmake --build . --parallel
ctest --output-on-failure
```

# Test using GCC/Clang sanitizers

Running primecount's test suite with sanitizers enabled is also very useful
as this helps find undefined behavior bugs and data races.

```bash
# Run commands from primecount root directory
cmake . -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -Wall -Wextra -pedantic" -DCMAKE_C_FLAGS="-g -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -Wall -Wextra -pedantic"
cmake --build . --parallel
ctest --output-on-failure
```