xref: /freebsd-src/crypto/openssl/test/README.md (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy SchubertUsing OpenSSL Tests
2*e0c4386eSCy Schubert===================
3*e0c4386eSCy Schubert
4*e0c4386eSCy SchubertAfter a successful build, and before installing, the libraries should be tested.
5*e0c4386eSCy SchubertRun:
6*e0c4386eSCy Schubert
7*e0c4386eSCy Schubert    $ make test                                      # Unix
8*e0c4386eSCy Schubert    $ mms test                                       ! OpenVMS
9*e0c4386eSCy Schubert    $ nmake test                                     # Windows
10*e0c4386eSCy Schubert
11*e0c4386eSCy Schubert**Warning:** you MUST run the tests from an unprivileged account
12*e0c4386eSCy Schubert(or disable your privileges temporarily if your platform allows it).
13*e0c4386eSCy Schubert
14*e0c4386eSCy SchubertIf some tests fail, take a look at the section Test Failures below.
15*e0c4386eSCy Schubert
16*e0c4386eSCy SchubertTest Failures
17*e0c4386eSCy Schubert-------------
18*e0c4386eSCy Schubert
19*e0c4386eSCy SchubertIf some tests fail, look at the output.  There may be reasons for the failure
20*e0c4386eSCy Schubertthat isn't a problem in OpenSSL itself (like an OS malfunction or a Perl issue).
21*e0c4386eSCy SchubertYou may want increased verbosity, that can be accomplished like this:
22*e0c4386eSCy Schubert
23*e0c4386eSCy SchubertFull verbosity, showing full output of all successful and failed test cases
24*e0c4386eSCy Schubert(`make` macro `VERBOSE` or `V`):
25*e0c4386eSCy Schubert
26*e0c4386eSCy Schubert    $ make V=1 test                                  # Unix
27*e0c4386eSCy Schubert    $ mms /macro=(V=1) test                          ! OpenVMS
28*e0c4386eSCy Schubert    $ nmake V=1 test                                 # Windows
29*e0c4386eSCy Schubert
30*e0c4386eSCy SchubertVerbosity on failed (sub-)tests only
31*e0c4386eSCy Schubert(`VERBOSE_FAILURE` or `VF` or `REPORT_FAILURES`):
32*e0c4386eSCy Schubert
33*e0c4386eSCy Schubert    $ make test VF=1
34*e0c4386eSCy Schubert
35*e0c4386eSCy SchubertVerbosity on failed (sub-)tests, in addition progress on succeeded (sub-)tests
36*e0c4386eSCy Schubert(`VERBOSE_FAILURE_PROGRESS` or `VFP` or `REPORT_FAILURES_PROGRESS`):
37*e0c4386eSCy Schubert
38*e0c4386eSCy Schubert    $ make test VFP=1
39*e0c4386eSCy Schubert
40*e0c4386eSCy SchubertIf you want to run just one or a few specific tests, you can use
41*e0c4386eSCy Schubertthe make variable TESTS to specify them, like this:
42*e0c4386eSCy Schubert
43*e0c4386eSCy Schubert    $ make TESTS='test_rsa test_dsa' test            # Unix
44*e0c4386eSCy Schubert    $ mms/macro="TESTS=test_rsa test_dsa" test       ! OpenVMS
45*e0c4386eSCy Schubert    $ nmake TESTS="test_rsa test_dsa" test           # Windows
46*e0c4386eSCy Schubert
47*e0c4386eSCy SchubertAnd of course, you can combine (Unix examples shown):
48*e0c4386eSCy Schubert
49*e0c4386eSCy Schubert    $ make test TESTS='test_rsa test_dsa' VF=1
50*e0c4386eSCy Schubert    $ make test TESTS="test_cmp_*" VFP=1
51*e0c4386eSCy Schubert
52*e0c4386eSCy SchubertYou can find the list of available tests like this:
53*e0c4386eSCy Schubert
54*e0c4386eSCy Schubert    $ make list-tests                                # Unix
55*e0c4386eSCy Schubert    $ mms list-tests                                 ! OpenVMS
56*e0c4386eSCy Schubert    $ nmake list-tests                               # Windows
57*e0c4386eSCy Schubert
58*e0c4386eSCy SchubertHave a look at the manual for the perl module Test::Harness to
59*e0c4386eSCy Schubertsee what other HARNESS_* variables there are.
60*e0c4386eSCy Schubert
61*e0c4386eSCy SchubertTo report a bug please open an issue on GitHub, at
62*e0c4386eSCy Schubert<https://github.com/openssl/openssl/issues>.
63*e0c4386eSCy Schubert
64*e0c4386eSCy SchubertFor more details on how the `make` variables `TESTS` can be used,
65*e0c4386eSCy Schubertsee section Running Selected Tests below.
66*e0c4386eSCy Schubert
67*e0c4386eSCy SchubertRunning Selected Tests
68*e0c4386eSCy Schubert----------------------
69*e0c4386eSCy Schubert
70*e0c4386eSCy SchubertThe `make` variable `TESTS` supports a versatile set of space separated tokens
71*e0c4386eSCy Schubertwith which you can specify a set of tests to be performed.  With a "current
72*e0c4386eSCy Schubertset of tests" in mind, initially being empty, here are the possible tokens:
73*e0c4386eSCy Schubert
74*e0c4386eSCy Schubert     alltests      The current set of tests becomes the whole set of available
75*e0c4386eSCy Schubert                   tests (as listed when you do 'make list-tests' or similar).
76*e0c4386eSCy Schubert
77*e0c4386eSCy Schubert     xxx           Adds the test 'xxx' to the current set of tests.
78*e0c4386eSCy Schubert
79*e0c4386eSCy Schubert    -xxx           Removes 'xxx' from the current set of tests.  If this is the
80*e0c4386eSCy Schubert                   first token in the list, the current set of tests is first
81*e0c4386eSCy Schubert                   assigned the whole set of available tests, effectively making
82*e0c4386eSCy Schubert                   this token equivalent to TESTS="alltests -xxx".
83*e0c4386eSCy Schubert
84*e0c4386eSCy Schubert     nn            Adds the test group 'nn' (which is a number) to the current
85*e0c4386eSCy Schubert                   set of tests.
86*e0c4386eSCy Schubert
87*e0c4386eSCy Schubert    -nn            Removes the test group 'nn' from the current set of tests.
88*e0c4386eSCy Schubert                   If this is the first token in the list, the current set of
89*e0c4386eSCy Schubert                   tests is first assigned the whole set of available tests,
90*e0c4386eSCy Schubert                   effectively making this token equivalent to
91*e0c4386eSCy Schubert                   TESTS="alltests -xxx".
92*e0c4386eSCy Schubert
93*e0c4386eSCy SchubertAlso, all tokens except for "alltests" may have wildcards, such as *.
94*e0c4386eSCy Schubert(on Unix and Windows, BSD style wildcards are supported, while on VMS,
95*e0c4386eSCy Schubertit's VMS style wildcards)
96*e0c4386eSCy Schubert
97*e0c4386eSCy Schubert### Examples
98*e0c4386eSCy Schubert
99*e0c4386eSCy SchubertRun all tests except for the fuzz tests:
100*e0c4386eSCy Schubert
101*e0c4386eSCy Schubert    $ make TESTS='-test_fuzz*' test
102*e0c4386eSCy Schubert
103*e0c4386eSCy Schubertor, if you want to be explicit:
104*e0c4386eSCy Schubert
105*e0c4386eSCy Schubert    $ make TESTS='alltests -test_fuzz*' test
106*e0c4386eSCy Schubert
107*e0c4386eSCy SchubertRun all tests that have a name starting with "test_ssl" but not those
108*e0c4386eSCy Schubertstarting with "test_ssl_":
109*e0c4386eSCy Schubert
110*e0c4386eSCy Schubert    $ make TESTS='test_ssl* -test_ssl_*' test
111*e0c4386eSCy Schubert
112*e0c4386eSCy SchubertRun only test group 10:
113*e0c4386eSCy Schubert
114*e0c4386eSCy Schubert    $ make TESTS='10' test
115*e0c4386eSCy Schubert
116*e0c4386eSCy SchubertRun all tests except the slow group (group 99):
117*e0c4386eSCy Schubert
118*e0c4386eSCy Schubert    $ make TESTS='-99' test
119*e0c4386eSCy Schubert
120*e0c4386eSCy SchubertRun all tests in test groups 80 to 99 except for tests in group 90:
121*e0c4386eSCy Schubert
122*e0c4386eSCy Schubert    $ make TESTS='[89]? -90' test
123*e0c4386eSCy Schubert
124*e0c4386eSCy SchubertTo run specific fuzz tests you can use for instance:
125*e0c4386eSCy Schubert
126*e0c4386eSCy Schubert    $ make test TESTS='test_fuzz_cmp test_fuzz_cms'
127*e0c4386eSCy Schubert
128*e0c4386eSCy SchubertTo stochastically verify that the algorithm that produces uniformly distributed
129*e0c4386eSCy Schubertrandom numbers is operating correctly (with a false positive rate of 0.01%):
130*e0c4386eSCy Schubert
131*e0c4386eSCy Schubert    $ ./util/wrap.sh test/bntest -stochastic
132*e0c4386eSCy Schubert
133*e0c4386eSCy SchubertRunning Tests in Parallel
134*e0c4386eSCy Schubert-------------------------
135*e0c4386eSCy Schubert
136*e0c4386eSCy SchubertBy default the test harness will execute the selected tests sequentially.
137*e0c4386eSCy SchubertDepending on the platform characteristics, running more than one test job in
138*e0c4386eSCy Schubertparallel may speed up test execution.
139*e0c4386eSCy SchubertThis can be requested by setting the `HARNESS_JOBS` environment variable to a
140*e0c4386eSCy Schubertpositive integer value. This specifies the maximum number of test jobs to run in
141*e0c4386eSCy Schubertparallel.
142*e0c4386eSCy Schubert
143*e0c4386eSCy SchubertDepending on the Perl version different strategies could be adopted to select
144*e0c4386eSCy Schubertwhich test recipes can be run in parallel.  In recent versions of Perl, unless
145*e0c4386eSCy Schubertspecified otherwise, any task can be run in parallel. Consult the documentation
146*e0c4386eSCy Schubertfor `TAP::Harness` to know more.
147*e0c4386eSCy Schubert
148*e0c4386eSCy SchubertTo run up to four tests in parallel at any given time:
149*e0c4386eSCy Schubert
150*e0c4386eSCy Schubert    $ make HARNESS_JOBS=4 test
151*e0c4386eSCy Schubert
152*e0c4386eSCy SchubertRandomisation of Test Ordering
153*e0c4386eSCy Schubert------------------------------
154*e0c4386eSCy Schubert
155*e0c4386eSCy SchubertBy default, the test harness will execute tests in the order they were added.
156*e0c4386eSCy SchubertBy setting the `OPENSSL_TEST_RAND_ORDER` environment variable to zero, the
157*e0c4386eSCy Schuberttest ordering will be randomised.  If a randomly ordered test fails, the
158*e0c4386eSCy Schubertseed value used will be reported.  Setting the `OPENSSL_TEST_RAND_ORDER`
159*e0c4386eSCy Schubertenvironment variable to this value will rerun the tests in the same
160*e0c4386eSCy Schubertorder.  This assures repeatability of randomly ordered test runs.
161*e0c4386eSCy SchubertThis repeatability is independent of the operating system, processor or
162*e0c4386eSCy Schubertplatform used.
163*e0c4386eSCy Schubert
164*e0c4386eSCy SchubertTo randomise the test ordering:
165*e0c4386eSCy Schubert
166*e0c4386eSCy Schubert    $ make OPENSSL_TEST_RAND_ORDER=0 test
167*e0c4386eSCy Schubert
168*e0c4386eSCy SchubertTo run the tests using the order defined by the random seed `42`:
169*e0c4386eSCy Schubert
170*e0c4386eSCy Schubert    $ make OPENSSL_TEST_RAND_ORDER=42 test
171