* + lib-test_stringc-add-strspn-and-strcspn-tests.patch added to -mm tree
@ 2022-03-28 22:46 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-03-28 22:46 UTC (permalink / raw)
To: mm-commits, andy, linux, akpm
The patch titled
Subject: lib/test_string.c: add strspn and strcspn tests
has been added to the -mm tree. Its filename is
lib-test_stringc-add-strspn-and-strcspn-tests.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/lib-test_stringc-add-strspn-and-strcspn-tests.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/lib-test_stringc-add-strspn-and-strcspn-tests.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: lib/test_string.c: add strspn and strcspn tests
Before refactoring strspn() and strcspn(), add some simple test cases.
Link: https://lkml.kernel.org/r/20220328224119.3003834-1-linux@rasmusvillemoes.dk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/test_string.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
--- a/lib/test_string.c~lib-test_stringc-add-strspn-and-strcspn-tests
+++ a/lib/test_string.c
@@ -179,6 +179,34 @@ static __init int strnchr_selftest(void)
return 0;
}
+static __init int strspn_selftest(void)
+{
+ static const struct strspn_test {
+ const char str[16];
+ const char accept[16];
+ const char reject[16];
+ unsigned a;
+ unsigned r;
+ } tests[] __initconst = {
+ { "foobar", "", "", 0, 6 },
+ { "abba", "abc", "ABBA", 4, 4 },
+ { "abba", "a", "b", 1, 1 },
+ { "", "abc", "abc", 0, 0},
+ };
+ const struct strspn_test *s = tests;
+ size_t i, res;
+
+ for (i = 0; i < ARRAY_SIZE(tests); ++i, ++s) {
+ res = strspn(s->str, s->accept);
+ if (res != s->a)
+ return 0x100 + 2*i;
+ res = strcspn(s->str, s->reject);
+ if (res != s->r)
+ return 0x100 + 2*i + 1;
+ }
+ return 0;
+}
+
static __exit void string_selftest_remove(void)
{
}
@@ -212,6 +240,11 @@ static __init int string_selftest_init(v
if (subtest)
goto fail;
+ test = 6;
+ subtest = strspn_selftest();
+ if (subtest)
+ goto fail;
+
pr_info("String selftests succeeded\n");
return 0;
fail:
_
Patches currently in -mm which might be from linux@rasmusvillemoes.dk are
lib-kconfigdebug-remove-more-config__value-indirections.patch
lib-test_stringc-add-strspn-and-strcspn-tests.patch
lib-stringc-simplify-strspn.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-28 22:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-28 22:46 + lib-test_stringc-add-strspn-and-strcspn-tests.patch added to -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.