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