diff options
author | Rich Salz <rsalz@openssl.org> | 2017-04-18 16:33:15 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-04-18 16:33:15 -0400 |
commit | adcd8e37db682a5818415b1e0e1d8847dd9ab1e6 (patch) | |
tree | 87d3c0d4da92ff291ab78be08b778876b0586453 /test/testutil.c | |
parent | f3ab6c16c424054c8d6d2c152744dcbaf41c3232 (diff) | |
download | openssl-adcd8e37db682a5818415b1e0e1d8847dd9ab1e6.tar.gz |
Convert more tests
ct_test,evp_extra_test,wpackettest,packettest
Add strncmp TEST wrappers
And make some style/consistency fixes to ct_test
Silence travis; gcc bug?
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3234)
Diffstat (limited to 'test/testutil.c')
-rw-r--r-- | test/testutil.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/testutil.c b/test/testutil.c index 3d2824c1f9..ae98e1096d 100644 --- a/test/testutil.c +++ b/test/testutil.c @@ -363,6 +363,38 @@ int test_str_ne(const char *file, int line, const char *st1, const char *st2, return 1; } +int test_strn_eq(const char *file, int line, const char *st1, const char *st2, + const char *s1, const char *s2, size_t len) +{ + int prec = (int)len; + + if (s1 == NULL && s2 == NULL) + return 1; + if (s1 == NULL || s2 == NULL || strncmp(s1, s2, len) != 0) { + test_fail_message(NULL, file, line, "string", "%.s [%.*s] == %s [%.*s]", + st1, prec, print_string_maybe_null(s1), + st2, prec, print_string_maybe_null(s2)); + return 0; + } + return 1; +} + +int test_strn_ne(const char *file, int line, const char *st1, const char *st2, + const char *s1, const char *s2, size_t len) +{ + int prec = (int)len; + + if ((s1 == NULL) ^ (s2 == NULL)) + return 1; + if (s1 == NULL || strncmp(s1, s2, len) == 0) { + test_fail_message(NULL, file, line, "string", "%s [%.*s] != %s [%.*s]", + st1, prec, print_string_maybe_null(s1), + st2, prec, print_string_maybe_null(s2)); + return 0; + } + return 1; +} + /* * We could use OPENSSL_buf2hexstr() to do this but trying to allocate memory * in a failure state isn't generally a great idea. |