X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Ftestutil.h;h=f779fd53053e505311d4cbfe556ed7d2478d894b;hp=399f521a4e9e9ec3c740fe61334f40292333f830;hb=99801878c09404e45d8176739d3a555c41b77d0b;hpb=fa9ad41476d40185b6fe06fa6564ea01cd527dad diff --git a/test/testutil.h b/test/testutil.h index 399f521a4e..f779fd5305 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -65,12 +65,13 @@ * SETUP_TEST_FIXTURE will call set_up() to create a new TEST_FIXTURE_TYPE * object called "fixture". It will also allocate the "result" variable used * by EXECUTE_TEST. set_up() should take a const char* specifying the test - * case name and return a TEST_FIXTURE_TYPE by value. + * case name and return a TEST_FIXTURE_TYPE by reference. * - * EXECUTE_TEST will pass fixture to execute_func() by value, call + * EXECUTE_TEST will pass fixture to execute_func() by reference, call * tear_down(), and return the result of execute_func(). execute_func() should - * take a TEST_FIXTURE_TYPE by value and return 1 on success and 0 on - * failure. + * take a TEST_FIXTURE_TYPE by reference and return 1 on success and 0 on + * failure. The tear_down function is responsible for deallocation of the + * result variable, if required. * * Unit tests can define their own SETUP_TEST_FIXTURE and EXECUTE_TEST * variations like so: @@ -91,13 +92,14 @@ * } */ # define SETUP_TEST_FIXTURE(TEST_FIXTURE_TYPE, set_up)\ - TEST_FIXTURE_TYPE fixture = set_up(TEST_CASE_NAME); \ + TEST_FIXTURE_TYPE *fixture = set_up(TEST_CASE_NAME); \ int result = 0 # define EXECUTE_TEST(execute_func, tear_down)\ + if (fixture != NULL) {\ result = execute_func(fixture);\ tear_down(fixture);\ - return result + } /* * TEST_CASE_NAME is defined as the name of the test case function where