torture:charset: use < and > assertions for strcasecmp_m
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 5 Apr 2024 00:14:38 +0000 (13:14 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Apr 2024 22:56:33 +0000 (22:56 +0000)
strcasecmp_m is supposed to return a negative, zero, or positive
number, depending on whether the first argument is less than, equal to,
or greater than the second argument (respectively).

We have been asserting that it returns exactly the difference between
the codepoints in the first character that differs.

This fixes a knownfail on 32 bit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15625

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/tests/charset.c
selftest/knownfail-32bit

index 547dc51e59d5c6571c020a8908be22678bfab2bd..94bf76c010d9b05568dd93d146d49727a788c84e 100644 (file)
@@ -72,16 +72,16 @@ static bool test_strcasecmp_m(struct torture_context *tctx)
        const char file_iso8859_1[7] = { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xe9, 0 };
        /* file.{accented e} in utf8 */
        const char file_utf8[8] =      { 0x66, 0x69, 0x6c, 0x65, 0x2d, 0xc3, 0xa9, 0 };
-       torture_assert_int_equal(tctx, strcasecmp_m("foo", "bar"), 4, "different strings both lower");
-       torture_assert_int_equal(tctx, strcasecmp_m("foo", "Bar"), 4, "different strings lower/upper");
-       torture_assert_int_equal(tctx, strcasecmp_m("Foo", "bar"), 4, "different strings upper/lower");
-       torture_assert_int_equal(tctx, strcasecmp_m("AFoo", "_bar"), 2, "different strings upper/lower");
+       torture_assert_int_greater(tctx, strcasecmp_m("foo", "bar"), 0, "different strings both lower");
+       torture_assert_int_greater(tctx, strcasecmp_m("foo", "Bar"), 0, "different strings lower/upper");
+       torture_assert_int_greater(tctx, strcasecmp_m("Foo", "bar"), 0, "different strings upper/lower");
+       torture_assert_int_greater(tctx, strcasecmp_m("AFoo", "_bar"), 0, "different strings upper/lower");
        torture_assert_int_equal(tctx, strcasecmp_m("foo", "foo"), 0, "same case strings");
        torture_assert_int_equal(tctx, strcasecmp_m("foo", "Foo"), 0, "different case strings");
-       torture_assert_int_equal(tctx, strcasecmp_m(NULL, "Foo"),  -1, "one NULL");
-       torture_assert_int_equal(tctx, strcasecmp_m("foo", NULL),  1, "other NULL");
+       torture_assert_int_less(tctx, strcasecmp_m(NULL, "Foo"),  0, "one NULL");
+       torture_assert_int_greater(tctx, strcasecmp_m("foo", NULL),  0, "other NULL");
        torture_assert_int_equal(tctx, strcasecmp_m(NULL, NULL),   0, "both NULL");
-       torture_assert_int_equal(tctx, strcasecmp_m(file_iso8859_1, file_utf8), 38,
+       torture_assert_int_greater(tctx, strcasecmp_m(file_iso8859_1, file_utf8), 0,
                "file.{accented e} should differ");
        return true;
 }
index 2946f3e9936d3e194038c1f1ab7b462404f1c489..5cb896f14fea21f9a1bb78ccfa9db1cd6620c615 100644 (file)
@@ -65,9 +65,6 @@
 # [171(1386)/261 at 6m24s, 4 errors] samba4.local.charset
 # UNEXPECTED(failure): samba4.local.charset.strcasecmp(none)
 # REASON: Exception: Exception: ../../lib/util/charset/tests/charset.c:56: strcasecmp("foo", "bar") was 1 (0x1), expected 4 (0x4): different strings both lower
-# UNEXPECTED(failure): samba4.local.charset.strcasecmp_m(none)
-# REASON: Exception: Exception: ../../lib/util/charset/tests/charset.c:85: strcasecmp_m(file_iso8859_1, file_utf8) was 1 (0x1), expected 38 (0x26): file.{accented e}
-#  should differ
 # UNEXPECTED(failure): samba4.local.charset.strncasecmp(none)
 # REASON: Exception: Exception: ../../lib/util/charset/tests/charset.c:132: strncasecmp("foo", "bar", 3) was 1 (0x1), expected 4 (0x4): different strings both lower
 # UNEXPECTED(failure): samba4.local.charset.strncasecmp_m(none)
@@ -82,7 +79,6 @@
 # ERROR: Testsuite[samba4.local.charset]
 # REASON: Exit code was 1
 ^samba4.local.charset.strcasecmp.none
-^samba4.local.charset.strcasecmp_m.none
 ^samba4.local.charset.strncasecmp.none
 ^samba4.local.charset.strncasecmp_m.none
 #