Refactor the test framework testutil
[openssl.git] / test / README
index cf7e4d4948d143834ccc38f19f01ab2f8675199b..fc9f7d03b1c50b80f76381a618095aacfa3c224b 100644 (file)
@@ -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)
@@ -134,4 +133,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.
+