From 2a3d4fe0c9eacf9d0b2261ef116a1f6b741e20ee Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 6 Sep 2017 10:39:00 +0200 Subject: [PATCH] charset/tests: add more str[n]casecmp_m() tests to demonstrate the bug BUG: https://bugzilla.samba.org/show_bug.cgi?id=13018 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- lib/util/charset/tests/charset.c | 8 +++++++- selftest/knownfail.d/strcasecmp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 selftest/knownfail.d/strcasecmp diff --git a/lib/util/charset/tests/charset.c b/lib/util/charset/tests/charset.c index e2d4155a4b8..918bf57fb99 100644 --- a/lib/util/charset/tests/charset.c +++ b/lib/util/charset/tests/charset.c @@ -55,6 +55,9 @@ static bool test_strcasecmp_m(struct torture_context *tctx) /* 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_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"); @@ -112,7 +115,10 @@ static bool test_strncasecmp_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, strncasecmp_m("foo", "bar", 3), 4, "different strings"); + torture_assert_int_equal(tctx, strncasecmp_m("foo", "bar", 3), 4, "different strings both lower"); + torture_assert_int_equal(tctx, strncasecmp_m("foo", "Bar", 3), 4, "different strings lower/upper"); + torture_assert_int_equal(tctx, strncasecmp_m("Foo", "bar", 3), 4, "different strings upper/lower"); + torture_assert_int_equal(tctx, strncasecmp_m("AFoo", "_bar", 4), 2, "different strings upper/lower"); torture_assert_int_equal(tctx, strncasecmp_m("foo", "foo", 3), 0, "same case strings"); torture_assert_int_equal(tctx, strncasecmp_m("foo", "Foo", 3), 0, "different case strings"); torture_assert_int_equal(tctx, strncasecmp_m("fool", "Foo", 3),0, "different case strings"); diff --git a/selftest/knownfail.d/strcasecmp b/selftest/knownfail.d/strcasecmp new file mode 100644 index 00000000000..23d755a5ad1 --- /dev/null +++ b/selftest/knownfail.d/strcasecmp @@ -0,0 +1,2 @@ +^samba4.local.charset.strcasecmp_m +^samba4.local.charset.strncasecmp_m -- 2.11.4.GIT