openssl/test
Alexander Zhirov 585e25c655 v1.1.1t 2023-05-10 01:08:48 +03:00
..
certs v1.1.1t 2023-05-10 01:08:48 +03:00
ct v1.1.1t 2023-05-10 01:08:48 +03:00
d2i-tests v1.1.1t 2023-05-10 01:08:48 +03:00
ocsp-tests v1.1.1t 2023-05-10 01:08:48 +03:00
ossl_shim v1.1.1t 2023-05-10 01:08:48 +03:00
recipes v1.1.1t 2023-05-10 01:08:48 +03:00
smime-certs v1.1.1t 2023-05-10 01:08:48 +03:00
ssl-tests v1.1.1t 2023-05-10 01:08:48 +03:00
testutil v1.1.1t 2023-05-10 01:08:48 +03:00
CAss.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
CAssdh.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
CAssdsa.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
CAssrsa.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
CAtsa.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
P1ss.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
P2ss.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
README v1.1.1t 2023-05-10 01:08:48 +03:00
README.external v1.1.1t 2023-05-10 01:08:48 +03:00
README.ssltest.md v1.1.1t 2023-05-10 01:08:48 +03:00
Sssdsa.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
Sssrsa.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
Uss.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
aborttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
afalgtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
asn1_decode_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
asn1_encode_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
asn1_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
asn1_string_table_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
asn1_time_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
asynciotest.c v1.1.1t 2023-05-10 01:08:48 +03:00
asynctest.c v1.1.1t 2023-05-10 01:08:48 +03:00
bad_dtls_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
bftest.c v1.1.1t 2023-05-10 01:08:48 +03:00
bio_callback_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
bio_enc_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
bio_memleak_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
bioprinttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
bntest.c v1.1.1t 2023-05-10 01:08:48 +03:00
bntests.pl v1.1.1t 2023-05-10 01:08:48 +03:00
build.info v1.1.1t 2023-05-10 01:08:48 +03:00
casttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
chacha_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
cipher_overhead_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
cipherbytes_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
cipherlist_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ciphername_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
clienthellotest.c v1.1.1t 2023-05-10 01:08:48 +03:00
cmactest.c v1.1.1t 2023-05-10 01:08:48 +03:00
cms-examples.pl v1.1.1t 2023-05-10 01:08:48 +03:00
cmsapitest.c v1.1.1t 2023-05-10 01:08:48 +03:00
conf_include_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
constant_time_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
crltest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ct_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ctype_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
curve448_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
d2i_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
dane-cross.in v1.1.1t 2023-05-10 01:08:48 +03:00
danetest.c v1.1.1t 2023-05-10 01:08:48 +03:00
danetest.in v1.1.1t 2023-05-10 01:08:48 +03:00
danetest.pem v1.1.1t 2023-05-10 01:08:48 +03:00
data.bin v1.1.1t 2023-05-10 01:08:48 +03:00
destest.c v1.1.1t 2023-05-10 01:08:48 +03:00
dhtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
drbg_cavs_data.c v1.1.1t 2023-05-10 01:08:48 +03:00
drbg_cavs_data.h v1.1.1t 2023-05-10 01:08:48 +03:00
drbg_cavs_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
drbgtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
drbgtest.h v1.1.1t 2023-05-10 01:08:48 +03:00
dsa_no_digest_size_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
dsatest.c v1.1.1t 2023-05-10 01:08:48 +03:00
dtls_mtu_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
dtlstest.c v1.1.1t 2023-05-10 01:08:48 +03:00
dtlsv1listentest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ec_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ecdsatest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ecdsatest.h v1.1.1t 2023-05-10 01:08:48 +03:00
ecstresstest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ectest.c v1.1.1t 2023-05-10 01:08:48 +03:00
enginetest.c v1.1.1t 2023-05-10 01:08:48 +03:00
errtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
evp_extra_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
evp_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
evp_test.h v1.1.1t 2023-05-10 01:08:48 +03:00
exdatatest.c v1.1.1t 2023-05-10 01:08:48 +03:00
exptest.c v1.1.1t 2023-05-10 01:08:48 +03:00
fatalerrtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
generate_buildtest.pl v1.1.1t 2023-05-10 01:08:48 +03:00
generate_ssl_tests.pl v1.1.1t 2023-05-10 01:08:48 +03:00
gmdifftest.c v1.1.1t 2023-05-10 01:08:48 +03:00
gosttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
handshake_helper.c v1.1.1t 2023-05-10 01:08:48 +03:00
handshake_helper.h v1.1.1t 2023-05-10 01:08:48 +03:00
hmactest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ideatest.c v1.1.1t 2023-05-10 01:08:48 +03:00
igetest.c v1.1.1t 2023-05-10 01:08:48 +03:00
lhash_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
md2test.c v1.1.1t 2023-05-10 01:08:48 +03:00
mdc2_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
mdc2test.c v1.1.1t 2023-05-10 01:08:48 +03:00
memleaktest.c v1.1.1t 2023-05-10 01:08:48 +03:00
modes_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ocspapitest.c v1.1.1t 2023-05-10 01:08:48 +03:00
packettest.c v1.1.1t 2023-05-10 01:08:48 +03:00
pbelutest.c v1.1.1t 2023-05-10 01:08:48 +03:00
pemtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
pkcs7-1.pem v1.1.1t 2023-05-10 01:08:48 +03:00
pkcs7.pem v1.1.1t 2023-05-10 01:08:48 +03:00
pkey_meth_kdf_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
pkey_meth_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
pkits-test.pl v1.1.1t 2023-05-10 01:08:48 +03:00
poly1305_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
rc2test.c v1.1.1t 2023-05-10 01:08:48 +03:00
rc4test.c v1.1.1t 2023-05-10 01:08:48 +03:00
rc5test.c v1.1.1t 2023-05-10 01:08:48 +03:00
rdrand_sanitytest.c v1.1.1t 2023-05-10 01:08:48 +03:00
recordlentest.c v1.1.1t 2023-05-10 01:08:48 +03:00
rsa_complex.c v1.1.1t 2023-05-10 01:08:48 +03:00
rsa_mp_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
rsa_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
run_tests.pl v1.1.1t 2023-05-10 01:08:48 +03:00
sanitytest.c v1.1.1t 2023-05-10 01:08:48 +03:00
secmemtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
serverinfo.pem v1.1.1t 2023-05-10 01:08:48 +03:00
serverinfo2.pem v1.1.1t 2023-05-10 01:08:48 +03:00
servername_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
session.pem v1.1.1t 2023-05-10 01:08:48 +03:00
shibboleth.pfx v1.1.1t 2023-05-10 01:08:48 +03:00
shlibloadtest.c v1.1.1t 2023-05-10 01:08:48 +03:00
siphash_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
sm2_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
sm4_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
smcont.txt v1.1.1t 2023-05-10 01:08:48 +03:00
srptest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_cert_table_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_ctx_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test.tmpl v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test_ctx.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test_ctx.h v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test_ctx_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssl_test_ctx_test.conf v1.1.1t 2023-05-10 01:08:48 +03:00
sslapitest.c v1.1.1t 2023-05-10 01:08:48 +03:00
sslbuffertest.c v1.1.1t 2023-05-10 01:08:48 +03:00
sslcorrupttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssltest_old.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssltestlib.c v1.1.1t 2023-05-10 01:08:48 +03:00
ssltestlib.h v1.1.1t 2023-05-10 01:08:48 +03:00
stack_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
sysdefault.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
sysdefaulttest.c v1.1.1t 2023-05-10 01:08:48 +03:00
test.cnf v1.1.1t 2023-05-10 01:08:48 +03:00
test_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
testcrl.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testdsa.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testdsapub.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testec-p256.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testecpub-p256.pem v1.1.1t 2023-05-10 01:08:48 +03:00
tested448.pem v1.1.1t 2023-05-10 01:08:48 +03:00
tested448pub.pem v1.1.1t 2023-05-10 01:08:48 +03:00
tested25519.pem v1.1.1t 2023-05-10 01:08:48 +03:00
tested25519pub.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testp7.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testreq2.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testrsa.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testrsa_withattrs.der v1.1.1t 2023-05-10 01:08:48 +03:00
testrsa_withattrs.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testrsapub.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testsid.pem v1.1.1t 2023-05-10 01:08:48 +03:00
testutil.h v1.1.1t 2023-05-10 01:08:48 +03:00
testx509.pem v1.1.1t 2023-05-10 01:08:48 +03:00
threadstest.c v1.1.1t 2023-05-10 01:08:48 +03:00
time_offset_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
tls13ccstest.c v1.1.1t 2023-05-10 01:08:48 +03:00
tls13encryptiontest.c v1.1.1t 2023-05-10 01:08:48 +03:00
tls13secretstest.c v1.1.1t 2023-05-10 01:08:48 +03:00
uitest.c v1.1.1t 2023-05-10 01:08:48 +03:00
v3-cert1.pem v1.1.1t 2023-05-10 01:08:48 +03:00
v3-cert2.pem v1.1.1t 2023-05-10 01:08:48 +03:00
v3ext.c v1.1.1t 2023-05-10 01:08:48 +03:00
v3nametest.c v1.1.1t 2023-05-10 01:08:48 +03:00
verify_extra_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
versions.c v1.1.1t 2023-05-10 01:08:48 +03:00
wpackettest.c v1.1.1t 2023-05-10 01:08:48 +03:00
x509_check_cert_pkey_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
x509_dup_cert_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
x509_internal_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
x509_time_test.c v1.1.1t 2023-05-10 01:08:48 +03:00
x509aux.c v1.1.1t 2023-05-10 01:08:48 +03:00

README

How to add recipes
==================

For any test that you want to perform, you write a script located in
test/recipes/, named {nn}-test_{name}.t, where {nn} is a two digit number and
{name} is a unique name of your choice.

Please note that if a test involves a new testing executable, you will need to
do some additions in test/Makefile.  More on this later.


Naming conventions
=================

A test executable is named test/{name}test.c

A test recipe is named test/recipes/{nn}-test_{name}.t, where {nn} is a two
digit number and {name} is a unique name of your choice.

The number {nn} is (somewhat loosely) grouped as follows:

00-04  sanity, internal and essential API tests
05-09  individual symmetric cipher algorithms
10-14  math (bignum)
15-19  individual asymmetric cipher algorithms
20-24  openssl commands (some otherwise not tested)
25-29  certificate forms, generation and verification
30-35  engine and evp
60-79  APIs
   70  PACKET layer
80-89  "larger" protocols (CA, CMS, OCSP, SSL, TSA)
90-98  misc
99     most time consuming tests [such as test_fuzz]


A recipe that just runs a test executable
=========================================

A script that just runs a program looks like this:

    #! /usr/bin/perl

    use OpenSSL::Test::Simple;

    simple_test("test_{name}", "{name}test", "{name}");

{name} is the unique name you have chosen for your test.

The second argument to `simple_test' is the test executable, and `simple_test'
expects it to be located in test/

For documentation on OpenSSL::Test::Simple, do
`perldoc util/perl/OpenSSL/Test/Simple.pm'.


A recipe that runs a more complex test
======================================

For more complex tests, you will need to read up on Test::More and
OpenSSL::Test.  Test::More is normally preinstalled, do `man Test::More' for
documentation.  For OpenSSL::Test, do `perldoc util/perl/OpenSSL/Test.pm'.

A script to start from could be this:

    #! /usr/bin/perl

    use strict;
    use warnings;
    use OpenSSL::Test;

    setup("test_{name}");

    plan tests => 2;                # The number of tests being performed

    ok(test1, "test1");
    ok(test2, "test1");

    sub test1
    {
        # test feature 1
    }

    sub test2
    {
        # test feature 2
    }


Changes to test/build.info
==========================

Whenever a new test involves a new test executable you need to do the
following (at all times, replace {NAME} and {name} with the name of your
test):

* add {name} to the list of programs under PROGRAMS_NO_INST

* create a three line description of how to build the test, you will have
to modify the include paths and source files if you don't want to use the
basic test framework:

    SOURCE[{name}]={name}.c
    INCLUDE[{name}]=.. ../include
    DEPEND[{name}]=../libcrypto libtestutil.a

Generic form of C test executables
==================================

    #include "testutil.h"

    static int my_test(void)
    {
        int testresult = 0;                 /* Assume the test will fail    */
        int observed;

        observed = function();              /* Call the code under test     */
        if (!TEST_int_eq(observed, 2))      /* Check the result is correct  */
            goto end;                       /* Exit on failure - optional   */

        testresult = 1;                     /* Mark the test case a success */
    end:
        cleanup();                          /* Any cleanup you require      */
        return testresult;
    }

    int setup_tests(void)
    {
        ADD_TEST(my_test);                  /* Add each test separately     */
        return 1;                           /* Indicate success             */
    }

You should use the TEST_xxx macros provided by testutil.h to test all failure
conditions.  These macros produce an error message in a standard format if the
condition is not met (and nothing if the condition is met).  Additional
information can be presented with the TEST_info macro that takes a printf
format string and arguments.  TEST_error is useful for complicated conditions,
it also takes a printf format string and argument.  In all cases the TEST_xxx
macros are guaranteed to evaluate their arguments exactly once.  This means
that expressions with side effects are allowed as parameters.  Thus,

    if (!TEST_ptr(ptr = OPENSSL_malloc(..)))

works fine and can be used in place of:

    ptr = OPENSSL_malloc(..);
    if (!TEST_ptr(ptr))

The former produces a more meaningful message on failure than the latter.