Commit b79ec4cb22 for openssl.org

commit b79ec4cb221dbc5b5fdee2db0dc8fd2aa8d2306f
Author: Pauli <paul.dale@oracle.com>
Date:   Wed Jan 14 08:13:52 2026 +1100

    test: get rid of the TEST_strn2_ functions

    Their semantics are poorly defined and they are rarely used.  The _ne
    version being completely unused & tricky to define properly.

    Reviewed-by: Norbert Pocs <norbertp@openssl.org>
    Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
    Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
    (Merged from https://github.com/openssl/openssl/pull/29627)

diff --git a/test/testutil.h b/test/testutil.h
index b79ebd6914..de4023f761 100644
--- a/test/testutil.h
+++ b/test/testutil.h
@@ -355,9 +355,9 @@ DECLARE_COMPARISON(char *, str, ne)
  * Same as above, but for strncmp.
  */
 int test_strn_eq(const char *file, int line, const char *, const char *,
-    const char *a, size_t an, const char *b, size_t bn);
+    const char *a, const char *b, size_t n);
 int test_strn_ne(const char *file, int line, const char *, const char *,
-    const char *a, size_t an, const char *b, size_t bn);
+    const char *a, const char *b, size_t n);

 /*
  * Equality test for memory blocks where NULL is a legitimate value.
@@ -511,10 +511,8 @@ void test_perror(const char *s);

 #define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
 #define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
-#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, n, b, n)
-#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, n, b, n)
-#define TEST_strn2_eq(a, m, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
-#define TEST_strn2_ne(a, m, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
+#define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, b, n)
+#define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, b, n)

 #define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
 #define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
diff --git a/test/testutil/tests.c b/test/testutil/tests.c
index f67b5ce4bf..ee83f8a4a9 100644
--- a/test/testutil/tests.c
+++ b/test/testutil/tests.c
@@ -302,28 +302,28 @@ int test_str_ne(const char *file, int line, const char *st1, const char *st2,
 }

 int test_strn_eq(const char *file, int line, const char *st1, const char *st2,
-    const char *s1, size_t n1, const char *s2, size_t n2)
+    const char *s1, const char *s2, size_t n)
 {
     if (s1 == NULL && s2 == NULL)
         return 1;
-    if (n1 != n2 || s1 == NULL || s2 == NULL || strncmp(s1, s2, n1) != 0) {
+    if (s1 == NULL || s2 == NULL || strncmp(s1, s2, n) != 0) {
         test_fail_string_message(NULL, file, line, "string", st1, st2, "==",
-            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
-            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
+            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
         return 0;
     }
     return 1;
 }

 int test_strn_ne(const char *file, int line, const char *st1, const char *st2,
-    const char *s1, size_t n1, const char *s2, size_t n2)
+    const char *s1, const char *s2, size_t n)
 {
     if ((s1 == NULL) ^ (s2 == NULL))
         return 1;
-    if (n1 != n2 || s1 == NULL || strncmp(s1, s2, n1) == 0) {
+    if (s1 == NULL || strncmp(s1, s2, n) == 0) {
         test_fail_string_message(NULL, file, line, "string", st1, st2, "!=",
-            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n1),
-            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n2));
+            s1, s1 == NULL ? 0 : OPENSSL_strnlen(s1, n),
+            s2, s2 == NULL ? 0 : OPENSSL_strnlen(s2, n));
         return 0;
     }
     return 1;