Merge patch series "some string cleanup, and a tweak of the "config" command"

Rasmus Villemoes <rv@rasmusvillemoes.dk> says:

This started by me wanting something like what patch 8 does. That
wasn't too hard, except we had no strcasestr(), and also our regex
engine (which I didn't really want to pull into the mix anyway)
doesn't have a flag that requests case-insensitive matching. So I
wanted to add strcasestr(), but then I stumbled on a bunch of stuff
that should be cleaned up in str-land.

Link: https://lore.kernel.org/r/20260708203711.849489-1-rv@rasmusvillemoes.dk
This commit is contained in:
Tom Rini
2026-07-21 13:52:00 -06:00
8 changed files with 146 additions and 107 deletions
+1
View File
@@ -17,6 +17,7 @@ ifdef CONFIG_CONSOLE_RECORD
obj-$(CONFIG_CMD_ACPI) += acpi.o
endif
obj-$(CONFIG_CMD_BDI) += bdinfo.o
obj-$(CONFIG_CMD_CONFIG) += config.o
obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
obj-$(CONFIG_CMD_FDT) += fdt.o
obj-$(CONFIG_CMD_HASH) += hash.o
+28
View File
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Tests for config command
*/
#include <console.h>
#include <test/cmd.h>
#include <test/ut.h>
static int cmd_test_config(struct unit_test_state *uts)
{
ut_assertok(run_command("config", 0));
ut_assert_skip_to_line("# Automatically generated file; DO NOT EDIT.");
ut_assert_skip_to_linen("# Compiler:");
ut_assert_skip_to_line("CONFIG_CMD_CONFIG=y");
console_record_reset_enable();
ut_assertok(run_command("config cmd_config=y", 0));
ut_assert_nextline("CONFIG_CMD_CONFIG=y");
ut_assert_console_end();
ut_assertok(run_command("config 'this string never appears in .config'", 0));
ut_assert_console_end();
return 0;
}
CMD_TEST(cmd_test_config, UTF_CONSOLE);
+21 -3
View File
@@ -284,18 +284,36 @@ static int lib_strstr(struct unit_test_state *uts)
{
const char *s1 = "Itsy Bitsy Teenie Weenie";
const char *s2 = "eenie";
const char *s3 = "easy";
const char *s3 = "bits";
ut_asserteq_ptr(&s1[12], strstr(s1, s2));
ut_asserteq_ptr(&s1[13], strstr(&s1[3], &s2[1]));
ut_assertnull(strstr(s1, s3));
ut_asserteq_ptr(&s1[2], strstr(s1, &s3[2]));
ut_asserteq_ptr(&s1[8], strstr(&s1[5], &s3[2]));
ut_asserteq_ptr(&s1[1], strstr(s1, &s3[2]));
ut_asserteq_ptr(&s1[7], strstr(&s1[5], &s3[2]));
return 0;
}
LIB_TEST(lib_strstr, 0);
/** lib_strcasestr() - unit test for strcasestr() */
static int lib_strcasestr(struct unit_test_state *uts)
{
const char *s1 = "Itsy Bitsy Teenie Weenie";
const char *s2 = "eenie";
const char *s3 = "bits";
ut_asserteq_ptr(&s1[12], strcasestr(s1, s2));
ut_asserteq_ptr(&s1[13], strcasestr(&s1[3], &s2[1]));
ut_asserteq_ptr(&s1[5], strcasestr(s1, s3));
ut_asserteq_ptr(&s1[1], strcasestr(s1, &s3[2]));
ut_asserteq_ptr(&s1[7], strcasestr(&s1[5], &s3[2]));
ut_assertnull(strcasestr(&s1[6], s3));
return 0;
}
LIB_TEST(lib_strcasestr, 0);
static int lib_strim(struct unit_test_state *uts)
{
char buf[BUFLEN], *p;