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