xref: /freebsd-src/crypto/openssl/NOTES-VALGRIND.md (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre ProncheryNotes on Valgrind
2*b077aed3SPierre Pronchery=================
3*b077aed3SPierre Pronchery
4*b077aed3SPierre ProncheryValgrind is a test harness that includes many tools such as memcheck,
5*b077aed3SPierre Proncherywhich is commonly used to check for memory leaks, etc. The default tool
6*b077aed3SPierre Proncheryrun by Valgrind is memcheck. There are other tools available, but this
7*b077aed3SPierre Proncherywill focus on memcheck.
8*b077aed3SPierre Pronchery
9*b077aed3SPierre ProncheryValgrind runs programs in a virtual machine, this means OpenSSL unit
10*b077aed3SPierre Proncherytests run under Valgrind will take longer than normal.
11*b077aed3SPierre Pronchery
12*b077aed3SPierre ProncheryRequirements
13*b077aed3SPierre Pronchery------------
14*b077aed3SPierre Pronchery
15*b077aed3SPierre Pronchery1. Platform supported by Valgrind
16*b077aed3SPierre Pronchery   See <http://valgrind.org/info/platforms.html>
17*b077aed3SPierre Pronchery2. Valgrind installed on the platform
18*b077aed3SPierre Pronchery   See <http://valgrind.org/downloads/current.html>
19*b077aed3SPierre Pronchery3. OpenSSL compiled
20*b077aed3SPierre Pronchery   See [INSTALL.md](INSTALL.md)
21*b077aed3SPierre Pronchery
22*b077aed3SPierre ProncheryRunning Tests
23*b077aed3SPierre Pronchery-------------
24*b077aed3SPierre Pronchery
25*b077aed3SPierre ProncheryTest behavior can be modified by adjusting environment variables.
26*b077aed3SPierre Pronchery
27*b077aed3SPierre Pronchery`EXE_SHELL`
28*b077aed3SPierre Pronchery
29*b077aed3SPierre ProncheryThis variable is used to specify the shell used to execute OpenSSL test
30*b077aed3SPierre Proncheryprograms. The default wrapper (`util/wrap.pl`) initializes the environment
31*b077aed3SPierre Proncheryto allow programs to find shared libraries. The variable can be modified
32*b077aed3SPierre Proncheryto specify a different executable environment.
33*b077aed3SPierre Pronchery
34*b077aed3SPierre Pronchery    EXE_SHELL=\
35*b077aed3SPierre Pronchery    "`/bin/pwd`/util/wrap.pl valgrind --error-exitcode=1 --leak-check=full -q"
36*b077aed3SPierre Pronchery
37*b077aed3SPierre ProncheryThis will start up Valgrind with the default checker (`memcheck`).
38*b077aed3SPierre ProncheryThe `--error-exitcode=1` option specifies that Valgrind should exit with an
39*b077aed3SPierre Proncheryerror code of 1 when memory leaks occur.
40*b077aed3SPierre ProncheryThe `--leak-check=full` option specifies extensive memory checking.
41*b077aed3SPierre ProncheryThe `-q` option prints only error messages.
42*b077aed3SPierre ProncheryAdditional Valgrind options may be added to the `EXE_SHELL` variable.
43*b077aed3SPierre Pronchery
44*b077aed3SPierre Pronchery`OPENSSL_ia32cap`
45*b077aed3SPierre Pronchery
46*b077aed3SPierre ProncheryThis variable controls the processor-specific code on Intel processors.
47*b077aed3SPierre ProncheryBy default, OpenSSL will attempt to figure out the capabilities of a
48*b077aed3SPierre Proncheryprocessor, and use it to its fullest capability. This variable can be
49*b077aed3SPierre Proncheryused to control what capabilities OpenSSL uses.
50*b077aed3SPierre Pronchery
51*b077aed3SPierre ProncheryAs of valgrind-3.15.0 on Linux/x86_64, instructions up to AVX2 are
52*b077aed3SPierre Proncherysupported. Setting the following disables instructions beyond AVX2:
53*b077aed3SPierre Pronchery
54*b077aed3SPierre Pronchery`OPENSSL_ia32cap=":0"`
55*b077aed3SPierre Pronchery
56*b077aed3SPierre ProncheryThis variable may need to be set to something different based on the
57*b077aed3SPierre Proncheryprocessor and Valgrind version you are running tests on. More information
58*b077aed3SPierre Proncherymay be found in [doc/man3/OPENSSL_ia32cap.pod](doc/man3/OPENSSL_ia32cap.pod).
59*b077aed3SPierre Pronchery
60*b077aed3SPierre ProncheryAdditional variables (such as `VERBOSE` and `TESTS`) are described in the
61*b077aed3SPierre Proncheryfile [test/README.md](test/README.md).
62*b077aed3SPierre Pronchery
63*b077aed3SPierre ProncheryExample command line:
64*b077aed3SPierre Pronchery
65*b077aed3SPierre Pronchery    $ make test EXE_SHELL="`/bin/pwd`/util/wrap.pl valgrind --error-exitcode=1 \
66*b077aed3SPierre Pronchery        --leak-check=full -q" OPENSSL_ia32cap=":0"
67*b077aed3SPierre Pronchery
68*b077aed3SPierre ProncheryIf an error occurs, you can then run the specific test via the `TESTS` variable
69*b077aed3SPierre Proncherywith the `VERBOSE` or `VF` or `VFP` options to gather additional information.
70*b077aed3SPierre Pronchery
71*b077aed3SPierre Pronchery    $ make test VERBOSE=1 TESTS=test_test EXE_SHELL="`/bin/pwd`/util/wrap.pl \
72*b077aed3SPierre Pronchery       valgrind --error-exitcode=1 --leak-check=full -q" OPENSSL_ia32cap=":0"
73