2 Commits
Author SHA1 Message Date
Shuvam Pandey ae3197ee07 seq_buf: Export seq_buf_putmem_hex() and add KUnit tests
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 <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: David Gow <[email protected]>
Link: https://patch.msgid.link/[email protected]
Acked-by: Steven Rostedt (Google) <[email protected]>
Signed-off-by: Shuvam Pandey <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
2026-05-21 18:03:06 -04:00
Kees Cook fc07839203 seq_buf: Introduce KUnit tests
Add KUnit tests for the seq_buf API to ensure its correctness and
prevent future regressions, covering the following functions:
- seq_buf_init()
- DECLARE_SEQ_BUF()
- seq_buf_clear()
- seq_buf_puts()
- seq_buf_putc()
- seq_buf_printf()
- seq_buf_get_buf()
- seq_buf_commit()

$ tools/testing/kunit/kunit.py run seq_buf
=================== seq_buf (9 subtests) ===================
[PASSED] seq_buf_init_test
[PASSED] seq_buf_declare_test
[PASSED] seq_buf_clear_test
[PASSED] seq_buf_puts_test
[PASSED] seq_buf_puts_overflow_test
[PASSED] seq_buf_putc_test
[PASSED] seq_buf_printf_test
[PASSED] seq_buf_printf_overflow_test
[PASSED] seq_buf_get_buf_commit_test
===================== [PASSED] seq_buf =====================

Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: David Gow <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
2025-07-19 23:03:24 -07:00