Matt Caswell f5afac4bda Update copyright year 3 years ago
..
certs 4957d95208 PEM_X509_INFO_read_bio_ex(): Generalize to allow parsing any type of private key 3 years ago
ct 433deaffce Use .cnf for config files, not .conf 4 years ago
d2i-tests a378a46985 add test for CVE-2016-7053 7 years ago
helpers 3f883c7c83 Replace OSSL_PARAM_BLD_free_params() with OSSL_PARAM_free(). 3 years ago
ocsp-tests 121738d1cb Fix OCSP_basic_verify() cert chain construction in case bs->certs is NULL 6 years ago
recipes f5afac4bda Update copyright year 3 years ago
smime-certs 4333b89f50 Update copyright year 3 years ago
ssl-tests 9afc6c5431 Fix the check for suitable groups and TLSv1.3 3 years ago
testutil f5afac4bda Update copyright year 3 years ago
CAtsa.cnf 23f3993127 Remove RANDFILE settings from configuration files 4 years ago
README-dev.md 036cbb6bbf Rename NOTES*, README*, VERSION, HACKING, LICENSE to .md or .txt 3 years ago
README-external.md cede07dc51 Remove the external BoringSSL test 3 years ago
README.md c678f68a19 test: document the random test ordering env variable 3 years ago
README.ssltest.md 257e9d03b0 Fix issues reported by markdownlint 4 years ago
aborttest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
acvp_test.c af9fb19a47 Fix typos 3 years ago
acvp_test.inc 3a1ee3c199 Drop OPENSSL_NO_RSA everywhere 3 years ago
aesgcmtest.c 4333b89f50 Update copyright year 3 years ago
afalgtest.c e39e295e20 Update copyright year 3 years ago
algorithmid_test.c ddf0d149e2 Rename EVP_PKEY_get0_first_alg_name to EVP_PKEY_get0_type_name 3 years ago
asn1_decode_test.c 22b88fc9c0 Add a test for encoding/decoding using an invalid ASN.1 Template 3 years ago
asn1_dsa_internal_test.c eec0ad10b9 Update copyright year 3 years ago
asn1_encode_test.c 22b88fc9c0 Add a test for encoding/decoding using an invalid ASN.1 Template 3 years ago
asn1_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
asn1_string_table_test.c 275a7b9e5e typo ANS1 -> ASN1 5 years ago
asn1_time_test.c 33388b44b6 Update copyright year 4 years ago
asynciotest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
asynctest.c b425001010 Rename OPENSSL_CTX prefix to OSSL_LIB_CTX 3 years ago
bad_dtls_test.c 92b3e62fdd test: fix coverity 1474468: resource leak 3 years ago
bftest.c 33388b44b6 Update copyright year 4 years ago
bio_callback_test.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
bio_enc_test.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
bio_memleak_test.c 454afd9866 Update copyright year 4 years ago
bio_prefix_text.c 51a7c4b5f2 TEST: Add test recipe and help program to test BIO_f_prefix() 4 years ago
bio_readbuffer_test.c 251c48183b Fix DER reading from stdin for BIO_f_readbuffer 3 years ago
bioprinttest.c c4683009ad TEST: Adjust test/bioprinttest.c to behave like the testutil routines 3 years ago
bn_internal_test.c 8020d79b40 Update copyright year 3 years ago
bn_rand_range.h 5d2f3e4a6c Test of uniformity of BN_rand_range output. 5 years ago
bntest.c eec0ad10b9 Update copyright year 3 years ago
bntests.pl 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
build.info 96d4ec6724 Avoid more MSVC-specific C runtime library functions 3 years ago
ca-and-certs.cnf 4e6e57cfcd Cleanup cert config files for tests 3 years ago
casttest.c 33388b44b6 Update copyright year 4 years ago
chacha_internal_test.c 25f2138b0a Reorganize private crypto header files 4 years ago
cipher_overhead_test.c a28d06f3e9 Update copyright year 3 years ago
cipherbytes_test.c 6ac1cd10ba Fix safestack issues in ssl.h 3 years ago
cipherlist_test.c 3c2bdd7df9 Update copyright year 3 years ago
ciphername_test.c 6ac1cd10ba Fix safestack issues in ssl.h 3 years ago
clienthellotest.c feba11cf2e Handle set_alpn_protos inputs better. 3 years ago
cmactest.c a370ff8daa Add a CMAC test 3 years ago
cmp_asn_test.c 3c2bdd7df9 Update copyright year 3 years ago
cmp_client_test.c 4333b89f50 Update copyright year 3 years ago
cmp_ctx_test.c 1c0eede982 Improve ossl_cmp_build_cert_chain(); publish it as X509_build_chain() 3 years ago
cmp_hdr_test.c 3c2bdd7df9 Update copyright year 3 years ago
cmp_msg_test.c 4333b89f50 Update copyright year 3 years ago
cmp_protect_test.c 1c0eede982 Improve ossl_cmp_build_cert_chain(); publish it as X509_build_chain() 3 years ago
cmp_server_test.c bca7ad6efd Use adapted test_get_libctx() for simpler test setup and better error reporting 3 years ago
cmp_status_test.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
cmp_vfy_test.c 4333b89f50 Update copyright year 3 years ago
cms-examples.pl 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
cmsapitest.c 4333b89f50 Update copyright year 3 years ago
conf_include_test.c f5afac4bda Update copyright year 3 years ago
confdump.c e74e562f1c Fix safestack issues in conf.h 3 years ago
constant_time_test.c 706457b7bd Reorganize local header files 4 years ago
context_internal_test.c f5afac4bda Update copyright year 3 years ago
crltest.c e6623cfbff Fix safestack issues in x509.h 3 years ago
ct_test.c 9d01ac71a0 Fix safestack issues in ct.h 3 years ago
ctype_internal_test.c 25f2138b0a Reorganize private crypto header files 4 years ago
curve448_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
d2i_test.c 33388b44b6 Update copyright year 4 years ago
danetest.c a28d06f3e9 Update copyright year 3 years ago
danetest.in 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
danetest.pem 170b735820 DANE support for X509_verify_cert() 8 years ago
data.bin c150a94857 TEST: Make our test data binary 3 years ago
data2.bin cede07dc51 Remove the external BoringSSL test 3 years ago
default-and-fips.cnf 1cd2c1f857 Update some nits around the FIPS module 4 years ago
default-and-legacy.cnf e2f72313cc test/recipes/30-test_evp.t: Modify to test with different providers 4 years ago
default.cnf e2f72313cc test/recipes/30-test_evp.t: Modify to test with different providers 4 years ago
defltfips_test.c bfa6aaab45 Test that EVP_default_properties_is_fips_enabled() works early 3 years ago
destest.c 33388b44b6 Update copyright year 4 years ago
dhtest.c 89f7ea045b test: fix coverity 1473234 & 1473239: argument cannot be negative 3 years ago
drbgtest.c e494fac705 Fix naming for EVP_RAND_CTX_gettable functions. 3 years ago
dsa_no_digest_size_test.c 33388b44b6 Update copyright year 4 years ago
dsatest.c 3c2bdd7df9 Update copyright year 3 years ago
dtls_mtu_test.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
dtlstest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
dtlsv1listentest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
ec_internal_test.c 32ab57cbb4 Fix external symbols related to ec & sm2 keys 3 years ago
ecdsatest.c 28fd895305 Remove the function EVP_PKEY_set_alias_type 3 years ago
ecdsatest.h ae4186b004 Fix header file include guard names 4 years ago
ecstresstest.c dd6b270618 Remove tab characters from C source files. 4 years ago
ectest.c 3f883c7c83 Replace OSSL_PARAM_BLD_free_params() with OSSL_PARAM_free(). 3 years ago
endecode_test.c ddf0d149e2 Rename EVP_PKEY_get0_first_alg_name to EVP_PKEY_get0_type_name 3 years ago
endecoder_legacy_test.c 69fb52e028 test: fix coverity 1469427: impropery use of negative value 3 years ago
enginetest.c 41bbba5375 EVP: deprecate the EVP_X_meth_ functions. 3 years ago
errtest.c abcca5078f TEST: Adapt test/errtest for the 'no-err' configuration 3 years ago
evp_extra_test.c 6bcbc36985 test: fix double free problems. 3 years ago
evp_extra_test2.c a732a4c329 Add EVP_PKEY_todata() and EVP_PKEY_export() functions. 3 years ago
evp_fetch_prov_test.c f5afac4bda Update copyright year 3 years ago
evp_kdf_test.c 05cdec396b test: adjust tests to include extra argument to KDF derive call 3 years ago
evp_libctx_test.c 2145ba5e83 Implement EVP_PKEY_dup() function 3 years ago
evp_pkey_dparams_test.c a2e145f8db Add necessary checks of OPENSSL_NO_DH, OPENSSL_NO_DSA and OPENSSL_NO_EC 3 years ago
evp_pkey_provided_test.c 3f883c7c83 Replace OSSL_PARAM_BLD_free_params() with OSSL_PARAM_free(). 3 years ago
evp_test.c 7aef200089 TEST: Adapt the EVP test 3 years ago
exdatatest.c 3c2bdd7df9 Update copyright year 3 years ago
exptest.c 3c2bdd7df9 Update copyright year 3 years ago
fatalerrtest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
ffc_internal_test.c 8020d79b40 Update copyright year 3 years ago
filterprov.c b0001d0cf2 provider: add an unquery function to allow providers to clean up. 3 years ago
filterprov.h b0001d0cf2 provider: add an unquery function to allow providers to clean up. 3 years ago
fips-and-base.cnf 39d9be390a Add CLI tests in FIPS configuration 3 years ago
fips.cnf bfa6aaab45 Test that EVP_default_properties_is_fips_enabled() works early 3 years ago
generate_buildtest.pl 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
generate_ssl_tests.pl 33388b44b6 Update copyright year 4 years ago
gmdifftest.c 3c2bdd7df9 Update copyright year 3 years ago
gosttest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
hexstr_test.c 3c2bdd7df9 Update copyright year 3 years ago
hmactest.c 33388b44b6 Update copyright year 4 years ago
http_test.c 2318379119 OSSL_parse_url(): Improve handling of IPv6 addresses 3 years ago
ideatest.c 33388b44b6 Update copyright year 4 years ago
igetest.c 7573fe1af5 Deprecate the AES_ige_*() functions 4 years ago
insta.priv.pem 8d9a4d833f Chunk 11 of CMP contribution to OpenSSL: CMP command-line interface 4 years ago
insta_ca.cert.pem 8d9a4d833f Chunk 11 of CMP contribution to OpenSSL: CMP command-line interface 4 years ago
keymgmt_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
legacy.cnf e2f72313cc test/recipes/30-test_evp.t: Modify to test with different providers 4 years ago
lhash_test.c eec0ad10b9 Update copyright year 3 years ago
mdc2_internal_test.c 33388b44b6 Update copyright year 4 years ago
mdc2test.c 33388b44b6 Update copyright year 4 years ago
memleaktest.c ea7a952c8a test/memleaktest.c: Modify for use with address/leak sanitizer 4 years ago
modes_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
moduleloadtest.c 3c2bdd7df9 Update copyright year 3 years ago
namemap_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
ocspapitest.c e6623cfbff Fix safestack issues in x509.h 3 years ago
ossl_store_test.c 8020d79b40 Update copyright year 3 years ago
p_test.c 8020d79b40 Update copyright year 3 years ago
packettest.c 0d345f0e10 Make the PACKET/WPACKET code available to both libcrypto and libssl 4 years ago
param_build_test.c 3f883c7c83 Replace OSSL_PARAM_BLD_free_params() with OSSL_PARAM_free(). 3 years ago
params_api_test.c 884314cab7 Add OSSL_PARAM_dup() and OSSL_PARAM_merge(). 3 years ago
params_conversion_test.c 33388b44b6 Update copyright year 4 years ago
params_test.c 247a1786e2 OSSL_PARAM: Correct the assumptions on the UTF8 string length 3 years ago
pbelutest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
pem_read_depr_test.c cdbd27bab4 Test various deprecated PEM_read_bio_* APIs 3 years ago
pemtest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
pkcs12_format_test.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
pkcs7-1.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 25 years ago
pkcs7.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 25 years ago
pkey_meth_kdf_test.c eec0ad10b9 Update copyright year 3 years ago
pkey_meth_test.c 0f84cbc3e2 Update copyright year 3 years ago
pkits-test.pl 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
poly1305_internal_test.c 3d5a7578e0 Add ChaCha related ciphers to default provider 4 years ago
property_test.c 3c2bdd7df9 Update copyright year 3 years ago
provider_fallback_test.c b425001010 Rename OPENSSL_CTX prefix to OSSL_LIB_CTX 3 years ago
provider_internal_test.c 8020d79b40 Update copyright year 3 years ago
provider_internal_test.cnf.in 433deaffce Use .cnf for config files, not .conf 4 years ago
provider_status_test.c b425001010 Rename OPENSSL_CTX prefix to OSSL_LIB_CTX 3 years ago
provider_test.c 8020d79b40 Update copyright year 3 years ago
proxy.cnf 4e6e57cfcd Cleanup cert config files for tests 3 years ago
rand_status_test.c 4516bf7422 rand: instantiate the DRBGs upon first use. 3 years ago
rc2test.c 33388b44b6 Update copyright year 4 years ago
rc4test.c 33388b44b6 Update copyright year 4 years ago
rc5test.c 33388b44b6 Update copyright year 4 years ago
rdrand_sanitytest.c 24fd8541d4 Remove extern declarations of OPENSSL_ia32cap_P 4 years ago
recordlentest.c a28d06f3e9 Update copyright year 3 years ago
rsa_complex.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
rsa_mp_test.c 3a1ee3c199 Drop OPENSSL_NO_RSA everywhere 3 years ago
rsa_sp800_56b_test.c 3a1ee3c199 Drop OPENSSL_NO_RSA everywhere 3 years ago
rsa_test.c b0aae91324 Remove RSA SSLv23 padding mode 3 years ago
run_tests.pl a28d06f3e9 Update copyright year 3 years ago
sanitytest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
secmemtest.c 33388b44b6 Update copyright year 4 years ago
serverinfo.pem c655f40ed2 Require ServerInfo PEMs to be named "BEGIN SERVERINFO FOR"... 10 years ago
serverinfo2.pem b878afae4b Add a SERVERINFOV2 format test file 7 years ago
servername_test.c 66325793cc test: fix coverity 1451534: improper use of negative value 3 years ago
session.pem 6cf2dbd9fa Don't store the ticket nonce in the session 6 years ago
shibboleth.pfx 70bf33d182 Add PKCS#12 UTF-8 interoperability test. 7 years ago
shlibloadtest.c 3c2bdd7df9 Update copyright year 3 years ago
simpledynamic.c 9feb2fce65 Fix simpledynamic.c - a typo and missed a header 3 years ago
simpledynamic.h 4333b89f50 Update copyright year 3 years ago
siphash_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
sm2_internal_test.c 8020d79b40 Update copyright year 3 years ago
sm4_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
smcont.txt 382bb0b294 test/smcont.txt: trigger assertion in bio_enc.c. 7 years ago
smcont_zero.txt 947fb81345 Tests for processing zero-length content in SMIME format 3 years ago
sparse_array_test.c 25f2138b0a Reorganize private crypto header files 4 years ago
srptest.c a28d06f3e9 Update copyright year 3 years ago
ssl_cert_table_internal_test.c 3c2bdd7df9 Update copyright year 3 years ago
ssl_ctx_test.c 454afd9866 Update copyright year 4 years ago
ssl_old_test.c a763ca1177 Stop disabling TLSv1.3 if ec and dh are disabled 3 years ago
ssl_test.c a28d06f3e9 Update copyright year 3 years ago
ssl_test.tmpl f4941736a9 test/ssl_test.tmpl: make it work with elderly perl. 7 years ago
ssl_test_ctx_test.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
ssl_test_ctx_test.cnf 433deaffce Use .cnf for config files, not .conf 4 years ago
sslapitest.c feba11cf2e Handle set_alpn_protos inputs better. 3 years ago
sslbuffertest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
sslcorrupttest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
stack_test.c a28d06f3e9 Update copyright year 3 years ago
sysdefault.cnf 8a5ed9dce8 Apply system_default configuration on SSL_CTX_new(). 6 years ago
sysdefaulttest.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
test.cnf d462b5ff21 Add -section option to 'req' command 4 years ago
test_test.c e0249827b3 Fix --strict-warnings build 4 years ago
testcrl.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 25 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
tested25519.pem 81722fdf2e More testing for CLI usage of Ed25519 and Ed448 keys 4 years ago
tested25519pub.pem 81722fdf2e More testing for CLI usage of Ed25519 and Ed448 keys 4 years ago
tested448.pem 81722fdf2e More testing for CLI usage of Ed25519 and Ed448 keys 4 years ago
tested448pub.pem 81722fdf2e More testing for CLI usage of Ed25519 and Ed448 keys 4 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 25 years ago
testrsa.pem 10203a3472 Support writing RSA keys using the traditional format again 3 years ago
testrsa2048.pem 8d17cca5b8 Add fips checks for rsa encryption 3 years ago
testrsapss.pem a2a5506b93 rsa_kmgmt: Return OSSL_PKEY_PARAM_DEFAULT_DIGEST for unrestricted PSS keys 3 years ago
testrsapssmandatory.pem bbde856619 RSA: properly generate algorithm identifier for RSA-PSS signatures 3 years ago
testrsapub.pem 79a578b902 Add private/public key conversion tests 9 years ago
testsid.pem 45f55f6a5b Remove SSLv2 support 9 years ago
testutil.h f56c9c7c94 APPS and TEST: Make sure prog name is set for usage output 3 years ago
testx509.pem 1e41dadfa7 Extend X509 cert checks and error reporting in v3_{purp,crld}.c and x509_{set,vfy}.c 3 years ago
threadstest.c a135dea4e0 test: fix problem with threads test using default library context. 3 years ago
time_offset_test.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
tls-provider.c 57e7401fc5 Fix some TODO(3.0) occurrences in ssl/t1_lib.c 3 years ago
tls13ccstest.c 20f8bc7255 test cleanup: move helper .c and .h files to test/helpers/ 3 years ago
tls13encryptiontest.c ec27e619e8 Move MAC removal responsibility to the various protocol "enc" functions 3 years ago
tls13secretstest.c 4333b89f50 Update copyright year 3 years ago
uitest.c eec0ad10b9 Update copyright year 3 years ago
v3-cert1.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 25 years ago
v3-cert2.pem d02b48c63a Import of old SSLeay release: SSLeay 0.8.1b 25 years ago
v3_ca_exts.cnf 9495cfbc22 make various test CA certs RFC 5280 compliant w.r.t. X509 extensions 3 years ago
v3ext.c 33388b44b6 Update copyright year 4 years ago
v3nametest.c 7eea331eab v3nametest: Make the gennames structure static 3 years ago
verify_extra_test.c 1c0eede982 Improve ossl_cmp_build_cert_chain(); publish it as X509_build_chain() 3 years ago
versions.c 909f1a2e51 Following the license change, modify the boilerplates in test/ 5 years ago
wpackettest.c 12cbb8e049 WPACKET: don't write DER length when we don't want to 4 years ago
x509_check_cert_pkey_test.c f5afac4bda Update copyright year 3 years ago
x509_dup_cert_test.c 33388b44b6 Update copyright year 4 years ago
x509_internal_test.c 878dc8dd95 Join the x509 and x509v3 directories 5 years ago
x509_time_test.c 33388b44b6 Update copyright year 4 years ago
x509aux.c 4333b89f50 Update copyright year 3 years ago

README-dev.md

Guidelines for test developers

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/build.info. Please refer to the section "Changes to test/build.info" below.

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:
   60  X509 subsystem
   61  BIO subsystem
   65  CMP subsystem
   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 ../apps/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.

Note that the test infrastructure automatically sets up all required environment variables (such as OPENSSL_MODULES, OPENSSL_CONF, etc.) for the tests. Individual tests may choose to override the default settings as required.