Create test/testutil.h for unit test helper macros

Defines SETUP_TEST_FIXTURE and EXECUTE_TEST, and updates ssl/heartbeat_test.c
using these macros. SETUP_TEST_FIXTURE makes use of the new TEST_CASE_NAME
macro, defined to use __func__ or __FUNCTION__ on platforms that support those
symbols, or to use the file name and line number otherwise. This should fix
several reported build problems related to lack of C99 support.
This commit is contained in:
Mike Bland
2014-06-07 13:05:50 -04:00
committed by Matt Caswell
parent 7a9d59c148
commit 3ead9f3798
2 changed files with 120 additions and 6 deletions

View File

@@ -38,6 +38,7 @@
* http://mike-bland.com/tags/heartbleed.html
*/
#include "../test/testutil.h"
#include "../ssl/ssl_locl.h"
#include <ctype.h>
#include <stdio.h>
@@ -190,7 +191,7 @@ static void print_payload(const char* const prefix,
else printf("\\x%02x", c);
}
printf("\"\n");
}
}
static int execute_heartbeat(HEARTBEAT_TEST_FIXTURE fixture)
{
@@ -263,13 +264,10 @@ static int honest_payload_size(unsigned char payload_buf[])
}
#define SETUP_HEARTBEAT_TEST_FIXTURE(type)\
HEARTBEAT_TEST_FIXTURE fixture = set_up_##type(__func__);\
int result = 0
SETUP_TEST_FIXTURE(HEARTBEAT_TEST_FIXTURE, set_up_##type)
#define EXECUTE_HEARTBEAT_TEST()\
if (execute_heartbeat(fixture) != 0) result = 1;\
tear_down(fixture);\
return result
EXECUTE_TEST(execute_heartbeat, tear_down)
static int test_dtls1_not_bleeding()
{