From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F6B6426693 for ; Fri, 22 May 2026 14:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779460503; cv=none; b=XqfqRPScYUoEg2gwm6BXyX5OVDlpW5i21O4lvDWAyzZMVRvJZwxRg5BAH5m/hc0N0PPAF/RlJYdrS9n/0vaedvPfjc8vNsNWgjqlvgm3iODqYkXmvIl6I4nK8nwJ9oHdjudhh/TkcnkqBZ+6LAE0jwc1bJM5PZjtYJfQWLb2coA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779460503; c=relaxed/simple; bh=bYj4noasIVcXaU0ZQZFXSCzSO/8QarCBfrVyenbJBcE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ivG/voED+uA655M3p4k4tTfR7YSo2CAPqjfizXW+a+wa6W5+TdZLoIB/eWgq1mVl4ZyNXGLbla8O1heP6emsblMbRmOwuXy1eODELMP5BlYk9JQ4O5Sr4DlHf/o/rTRR08evjWbjyDO8wmVUKP9W+QePE1nqOMIj4slES0PIUGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nb8XKzmN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nb8XKzmN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB1A1F00A3E; Fri, 22 May 2026 14:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779460501; bh=eKsVfrH0Dr0g4kgHtR9f4PLod3KiwkMqUeKMY44x6/g=; h=Date:From:To:Cc:Subject:References; b=Nb8XKzmNun9V7yrV7RcjZhDU/FdFreXa0MZb5UbUv3AbeMnQQsbAykmZfrNZ2ZvxO i9f544fgDdLWO+had/5EVaV1+FMtirExvV6zGFbmxf0hd7ryBppwn3tqZ/dRbG3dRy gFwtyZveJHonZScQ04qpcz8NnKY+agVKXFF44wSd24mUnlNb8RfoNmeuSJ4/rfRDmj SZnKaadpFePua5+98t6t9p5Zb4SyWwlyP2u0Ljsbjnc0zWkyMcLTfepzr100WxkbR3 CZnQupBXygn9jEuHDm6Lsccu/k0QO7H94nmNaPpYAz1Llujo20vL1r0KfLVm4UZmvr s0To+zbygFKJA== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQQyD-0000000666f-1UMV; Fri, 22 May 2026 10:35:25 -0400 Message-ID: <20260522143525.200081787@kernel.org> User-Agent: quilt/0.69 Date: Fri, 22 May 2026 10:35:10 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , David Gow , Shuvam Pandey Subject: [for-next][PATCH 02/15] seq_buf: Export seq_buf_putmem_hex() and add KUnit tests References: <20260522143508.298439732@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Shuvam Pandey The seq_buf KUnit suite does not exercise seq_buf_putmem_hex(). Add one test for the len > 8 chunking path and one overflow test where a later chunk no longer fits in the buffer. Export seq_buf_putmem_hex() as well so SEQ_BUF_KUNIT_TEST=m links cleanly. Without the export, modpost reports seq_buf_putmem_hex as undefined when seq_buf_kunit is built as a module. Cc: Andrew Morton Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: David Gow Link: https://patch.msgid.link/20260408202351.21829-1-shuvampandey1@gmail.com Acked-by: Steven Rostedt (Google) Signed-off-by: Shuvam Pandey Signed-off-by: Steven Rostedt --- lib/seq_buf.c | 1 + lib/tests/seq_buf_kunit.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/seq_buf.c b/lib/seq_buf.c index f3f3436d60a9..b59488fa8135 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -298,6 +298,7 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem, } return 0; } +EXPORT_SYMBOL_GPL(seq_buf_putmem_hex); /** * seq_buf_path - copy a path into the sequence buffer diff --git a/lib/tests/seq_buf_kunit.c b/lib/tests/seq_buf_kunit.c index 8a01579a978e..eb466386bbef 100644 --- a/lib/tests/seq_buf_kunit.c +++ b/lib/tests/seq_buf_kunit.c @@ -184,6 +184,38 @@ static void seq_buf_get_buf_commit_test(struct kunit *test) KUNIT_EXPECT_TRUE(test, seq_buf_has_overflowed(&s)); } +static void seq_buf_putmem_hex_test(struct kunit *test) +{ + DECLARE_SEQ_BUF(s, 24); + const u8 data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; +#ifdef __BIG_ENDIAN + const char *expected = "0001020304050607 0809 "; +#else + const char *expected = "0706050403020100 0908 "; +#endif + + KUNIT_EXPECT_EQ(test, seq_buf_putmem_hex(&s, data, sizeof(data)), 0); + KUNIT_EXPECT_FALSE(test, seq_buf_has_overflowed(&s)); + KUNIT_EXPECT_EQ(test, seq_buf_used(&s), strlen(expected)); + KUNIT_EXPECT_STREQ(test, seq_buf_str(&s), expected); +} + +static void seq_buf_putmem_hex_overflow_test(struct kunit *test) +{ + DECLARE_SEQ_BUF(s, 20); + const u8 data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; +#ifdef __BIG_ENDIAN + const char *expected = "0001020304050607 "; +#else + const char *expected = "0706050403020100 "; +#endif + + KUNIT_EXPECT_EQ(test, seq_buf_putmem_hex(&s, data, sizeof(data)), -1); + KUNIT_EXPECT_TRUE(test, seq_buf_has_overflowed(&s)); + KUNIT_EXPECT_EQ(test, seq_buf_used(&s), 20); + KUNIT_EXPECT_STREQ(test, seq_buf_str(&s), expected); +} + static struct kunit_case seq_buf_test_cases[] = { KUNIT_CASE(seq_buf_init_test), KUNIT_CASE(seq_buf_declare_test), @@ -194,6 +226,8 @@ static struct kunit_case seq_buf_test_cases[] = { KUNIT_CASE(seq_buf_printf_test), KUNIT_CASE(seq_buf_printf_overflow_test), KUNIT_CASE(seq_buf_get_buf_commit_test), + KUNIT_CASE(seq_buf_putmem_hex_test), + KUNIT_CASE(seq_buf_putmem_hex_overflow_test), {} }; -- 2.53.0