Matt Caswell c3a48c7b1d Add a test for CT in TLSv1.3 7 years ago
..
certs 9bf45ba4ca Add certificates with PSS signatures 7 years ago
ct 8c6afbc55c Verify SCT signatures 8 years ago
d2i-tests a378a46985 add test for CVE-2016-7053 8 years ago
ocsp-tests 30c278aa6b Fix OCSP checking. 12 years ago
ossl_shim 69687aa829 More typo fixes 7 years ago
recipes c3a48c7b1d Add a test for CT in TLSv1.3 7 years ago
smime-certs 6025001707 spelling fixes, just comments and readme. 8 years ago
ssl-tests c649d10d3f TLS1.3 Padding 7 years ago
testlib 11ba87f2ff Ensure s_client sends an SNI extension by default 7 years ago
testutil ee6b68ce4c Fix a stack smash 7 years ago
CAss.cnf a7be5759cf RT3809: basicConstraints is critical 8 years ago
CAssdh.cnf 58964a4922 Import of old SSLeay release: SSLeay 0.9.0b 26 years ago
CAssdsa.cnf 58964a4922 Import of old SSLeay release: SSLeay 0.9.0b 26 years ago
CAssrsa.cnf 58964a4922 Import of old SSLeay release: SSLeay 0.9.0b 26 years ago
CAtsa.cnf f0ef20bf38 Added support for ESSCertIDv2 7 years ago
P1ss.cnf fec669388c Use 2K RSA and SHA256 in tests 9 years ago
P2ss.cnf fec669388c Use 2K RSA and SHA256 in tests 9 years ago
README 4db40c94c3 Refactor the test framework testutil 7 years ago
README.external 483bc2dcd3 Fix formatting of PYCA external test instructions 7 years ago
README.ssltest.md f15b50c4cb Add ExpectedServerCANames 7 years ago
Sssdsa.cnf 58964a4922 Import of old SSLeay release: SSLeay 0.9.0b 26 years ago
Sssrsa.cnf 58964a4922 Import of old SSLeay release: SSLeay 0.9.0b 26 years ago
Uss.cnf cb0585c2cb Create DSA and ECDSA certificates. 9 years ago
aborttest.c 440e5d805f Copyright consolidation 02/10 8 years ago
afalgtest.c 5c8e9d531b [squash]Build works with/out NO_ENGINE and NO_AFALG 7 years ago
asn1_encode_test.c 1ff86c5efa test/asn1_encode_test.c: test "next negative minimum" corner case. 7 years ago
asn1_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
asynciotest.c a9c6d22105 Adapt all test programs 7 years ago
asynctest.c a0f44a34d2 asynctest: don't depend on apps 7 years ago
bad_dtls_test.c a9c6d22105 Adapt all test programs 7 years ago
bftest.c a9c6d22105 Adapt all test programs 7 years ago
bio_enc_test.c a9c6d22105 Adapt all test programs 7 years ago
bioprinttest.c 0918b94c9c testutil: Remove test_puts_std{out,err}, they are superfluous 7 years ago
bntest.c 30bea14be6 Convert bntest to TEST_ framework 7 years ago
bntests.pl 8d1ebff41c Make bntest be (mostly) file-based. 8 years ago
bntests.txt 383e9ade2b bntests.txt: add a couple of checks of possibly negative zero 7 years ago
build.info 0e534337b2 Update igetest to use the test framework. 7 years ago
casttest.c a9c6d22105 Adapt all test programs 7 years ago
chacha_internal_test.c f44903a428 Address some -Wold-style-declaration warnings 7 years ago
cipher_overhead_test.c a9c6d22105 Adapt all test programs 7 years ago
cipherbytes_test.c a9c6d22105 Adapt all test programs 7 years ago
cipherlist_test.c a9c6d22105 Adapt all test programs 7 years ago
clienthellotest.c 8f3f9623a4 Fix a pedantic gcc-7 warning. 7 years ago
cms-examples.pl e0a651945c Copyright consolidation: perl files 8 years ago
constant_time_test.c a9c6d22105 Adapt all test programs 7 years ago
crltest.c f5a140f7e9 Refactor crltest.c to separate the test cases into individual functions. 7 years ago
ct_test.c a9c6d22105 Adapt all test programs 7 years ago
d2i_test.c a9c6d22105 Adapt all test programs 7 years ago
danetest.c 1f9d203dac Convert danetest, ssl_test_ctx_test 7 years ago
danetest.in 5ae4ceb92c Perform DANE-EE(3) name checks by default 8 years ago
danetest.pem 170b735820 DANE support for X509_verify_cert() 9 years ago
destest.c a9c6d22105 Adapt all test programs 7 years ago
dhtest.c a9c6d22105 Adapt all test programs 7 years ago
dsatest.c a9c6d22105 Adapt all test programs 7 years ago
dtls_mtu_test.c 8ed9a26616 Convert dtls_mtu_test, dtlsv1listentest 7 years ago
dtlstest.c a9c6d22105 Adapt all test programs 7 years ago
dtlsv1listentest.c 8ed9a26616 Convert dtls_mtu_test, dtlsv1listentest 7 years ago
ecdsatest.c a9c6d22105 Adapt all test programs 7 years ago
ectest.c 2f0ca54c32 Remove some obsolete/obscure internal define switches: 7 years ago
enginetest.c a9c6d22105 Adapt all test programs 7 years ago
evp_extra_test.c aa24cd1bfb Fix no-ec 7 years ago
evp_test.c d91b7423af evp_test.c: Add PrivPubKeyPair tests 7 years ago
evptests.txt 9a837f220a Ensure blank lines between tests. 7 years ago
exdatatest.c a9c6d22105 Adapt all test programs 7 years ago
exptest.c 58e754fcb8 Convert modular exponentiation tests to new framework 7 years ago
generate_buildtest.pl 5cdad22f3e Move the building of test/buildtest_*. to be done unconditionally 8 years ago
generate_ssl_tests.pl 9f48bbacd8 Reorganize SSL test structures 8 years ago
gmdifftest.c 208d721a00 TAPify testutil 7 years ago
handshake_helper.c 561f6f1ed2 Address review feedback for the SCTP changes 7 years ago
handshake_helper.h f15b50c4cb Add ExpectedServerCANames 7 years ago
hmactest.c a9c6d22105 Adapt all test programs 7 years ago
ideatest.c a9c6d22105 Adapt all test programs 7 years ago
igetest.c 0e534337b2 Update igetest to use the test framework. 7 years ago
lhash_test.c a9c6d22105 Adapt all test programs 7 years ago
md2test.c a9c6d22105 Adapt all test programs 7 years ago
mdc2_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
mdc2test.c a9c6d22105 Adapt all test programs 7 years ago
memleaktest.c 789dfc478e Update secmemtest and memeleaktest to use the test infrastructure. 7 years ago
modes_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
packettest.c a9c6d22105 Adapt all test programs 7 years ago
pbelutest.c a9c6d22105 Adapt all test programs 7 years ago
pkcs7-1.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
pkcs7.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
pkey_meth_test.c a9c6d22105 Adapt all test programs 7 years ago
pkits-test.pl 609b0852e4 Remove trailing whitespace from some files. 8 years ago
poly1305_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
randtest.c a9c6d22105 Adapt all test programs 7 years ago
rc2test.c a9c6d22105 Adapt all test programs 7 years ago
rc4test.c a9c6d22105 Adapt all test programs 7 years ago
rc5test.c a9c6d22105 Adapt all test programs 7 years ago
recordlentest.c a9c6d22105 Adapt all test programs 7 years ago
rsa_test.c a9c6d22105 Adapt all test programs 7 years ago
run_tests.pl e5fd8ca43b Make it possible to select or deselect test groups by number 7 years ago
sanitytest.c a9c6d22105 Adapt all test programs 7 years ago
secmemtest.c a9c6d22105 Adapt all test programs 7 years ago
serverinfo.pem c655f40ed2 Require ServerInfo PEMs to be named "BEGIN SERVERINFO FOR"... 11 years ago
serverinfo2.pem b878afae4b Add a SERVERINFOV2 format test file 7 years ago
session.pem 6bc6ca623b Add tests for the padding extension 7 years ago
sha1test.c a9c6d22105 Adapt all test programs 7 years ago
sha256t.c a9c6d22105 Adapt all test programs 7 years ago
sha512t.c a9c6d22105 Adapt all test programs 7 years ago
shibboleth.pfx 70bf33d182 Add PKCS#12 UTF-8 interoperability test. 8 years ago
shlibloadtest.c 586b79d888 Fix no-dso (shlibloadtest) 8 years ago
siphash_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
smcont.txt 382bb0b294 test/smcont.txt: trigger assertion in bio_enc.c. 8 years ago
srptest.c b6e3250671 Fix unit-tests when no-srp configured 7 years ago
ssl_test.c a9c6d22105 Adapt all test programs 7 years ago
ssl_test.tmpl f4941736a9 test/ssl_test.tmpl: make it work with elderly perl. 8 years ago
ssl_test_ctx.c 83964ca0da Add support to test_ssl_new for testing with DTLS over SCTP 7 years ago
ssl_test_ctx.h 83964ca0da Add support to test_ssl_new for testing with DTLS over SCTP 7 years ago
ssl_test_ctx_test.c 1f9d203dac Convert danetest, ssl_test_ctx_test 7 years ago
ssl_test_ctx_test.conf 439db0c97b Add compression tests 7 years ago
sslapitest.c cf10df81e1 Fix ISO C function/object pointer issue 7 years ago
sslcorrupttest.c a9c6d22105 Adapt all test programs 7 years ago
ssltest_old.c 69687aa829 More typo fixes 7 years ago
ssltestlib.c 8ed9a26616 Convert dtls_mtu_test, dtlsv1listentest 7 years ago
ssltestlib.h 8e2236eff8 Let test handshakes stop on certain errors 7 years ago
stack_test.c a9c6d22105 Adapt all test programs 7 years ago
test.cnf fec669388c Use 2K RSA and SHA256 in tests 9 years ago
test_test.c ee6b68ce4c Fix a stack smash 7 years ago
testcrl.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
testdsa.pem 79a578b902 Add private/public key conversion tests 9 years ago
testdsapub.pem 79a578b902 Add private/public key conversion tests 9 years ago
testec-p256.pem 79a578b902 Add private/public key conversion tests 9 years ago
testecpub-p256.pem 79a578b902 Add private/public key conversion tests 9 years ago
testp7.pem dcb1ef5c22 Change PKCS#7 test data to take account of removal of 24 years ago
testreq2.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
testrsa.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
testrsapub.pem 79a578b902 Add private/public key conversion tests 9 years ago
testsid.pem 45f55f6a5b Remove SSLv2 support 10 years ago
testutil.h 68e49bf223 testutil: Add OpenSSL error stack printing wrapper TEST_openssl_errors 7 years ago
testx509.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
threadstest.c a9c6d22105 Adapt all test programs 7 years ago
time_offset_test.c 20ee2bf138 Fix time offset calculation. 7 years ago
tls13encryptiontest.c a9c6d22105 Adapt all test programs 7 years ago
tls13secretstest.c a9c6d22105 Adapt all test programs 7 years ago
uitest.c a9c6d22105 Adapt all test programs 7 years ago
v3-cert1.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
v3-cert2.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 26 years ago
v3ext.c a9c6d22105 Adapt all test programs 7 years ago
v3nametest.c a9c6d22105 Adapt all test programs 7 years ago
verify_extra_test.c a9c6d22105 Adapt all test programs 7 years ago
wpackettest.c f44903a428 Address some -Wold-style-declaration warnings 7 years ago
x509_dup_cert_test.c a9c6d22105 Adapt all test programs 7 years ago
x509_internal_test.c a9c6d22105 Adapt all test programs 7 years ago
x509_time_test.c a9c6d22105 Adapt all test programs 7 years ago
x509aux.c a9c6d22105 Adapt all test programs 7 years ago

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 test/testlib/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 test/testlib/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_equal(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;
}

void register_tests(void)
{
ADD_TEST(my_test); /* Add each test separately */
}

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.