From ce2cdac2787da32bcde210c7d6acdcbe41b1cd40 Mon Sep 17 00:00:00 2001 From: Emilia Kasper Date: Mon, 4 Jul 2016 20:16:14 +0200 Subject: SSL test framework: port NPN and ALPN tests Reviewed-by: Rich Salz --- test/testutil.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/testutil.c') diff --git a/test/testutil.c b/test/testutil.c index 9a67630fd3..a16ef0fa07 100644 --- a/test/testutil.c +++ b/test/testutil.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "e_os.h" /* @@ -89,3 +90,20 @@ int run_tests(const char *test_prog_name) printf(" All tests passed.\n"); return EXIT_SUCCESS; } + +static const char *print_string_maybe_null(const char *s) +{ + return s == NULL ? "(NULL)" : s; +} + +int strings_equal(const char *desc, const char *s1, const char *s2) +{ + if (s1 == NULL && s2 == NULL) + return 1; + if (s1 == NULL || s2 == NULL || strcmp(s1, s2) != 0) { + fprintf(stderr, "%s mismatch: %s vs %s\n", desc, print_string_maybe_null(s1), + print_string_maybe_null(s2)); + return 0; + } + return 1; +} -- cgit v1.2.3