X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=test%2FREADME;h=37722e79f3934b8d63a2ca1aaa38414bac9d59e3;hb=e363534cfe0ae01503dde6963e0631ec5f7fef3f;hp=cf7e4d4948d143834ccc38f19f01ab2f8675199b;hpb=2fae041d6c507315a619e2f29bff86e44cc1d0a1;p=oweals%2Fopenssl.git diff --git a/test/README b/test/README index cf7e4d4948..37722e79f3 100644 --- a/test/README +++ b/test/README @@ -39,9 +39,9 @@ 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. @@ -50,7 +50,7 @@ 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'. +`perldoc util/perl/OpenSSL/Test/Simple.pm'. A recipe that runs a more complex test @@ -58,33 +58,33 @@ 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'. +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 ========================== @@ -99,14 +99,13 @@ test): to modify the include paths and source files if you don't want to use the basic test framework: - SOURCE[{name}]={name}.c testutil.c test_main.c + SOURCE[{name}]={name}.c INCLUDE[{name}]=.. ../include - DEPEND[{name}]=../libcrypto + DEPEND[{name}]=../libcrypto libtestutil.a Generic form of C test executables ================================== - #include "test_main.h" #include "testutil.h" static int my_test(void) @@ -124,9 +123,10 @@ Generic form of C test executables return testresult; } - void register_tests(void) + 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 @@ -134,4 +134,16 @@ 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. +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. +