scanf: convert self-test to KUnit
Subsystems (3)
v6 cover scanf: convert self-test to KUnit
This is one of just 3 remaining "Test Module" kselftests (the others being bitmap and printf), the rest having been converted to KUnit. In addition to the enclosed patch, please consider this an RFC on the removal of the "Test Module" kselftest machinery.
I tested this using:
$ tools/testing/kunit/kunit.py run --arch arm64 --make_options LLVM=1 scanf
---
Changes in v6:
- s/at boot/at runtime/ for consistency with the printf series.
- Go back to kmalloc. (Geert Uytterhoeven)
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Remove extraneous trailing newlines from failure messages.
- Replace pr_debug with kunit_printk.
- Use static char arrays instead of kmalloc.
- Drop KUnit boilerplate from CONFIG_SCANF_KUNIT_TEST help text.
- Drop arch changes.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Bake test into various macros, greatly reducing diff noise.
- Revert control flow changes.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Reduce diff noise in lib/Makefile. (Petr Mladek)
- Split scanf_test into a few test cases. New output:
: =================== scanf (10 subtests) ====================
: [PASSED] numbers_simple
: ====================== numbers_list =======================
: [PASSED] delim=" "
: [PASSED] delim=":"
: [PASSED] delim=","
: [PASSED] delim="-"
: [PASSED] delim="/"
: ================== [PASSED] numbers_list ===================
: ============ numbers_list_field_width_typemax =============
: [PASSED] delim=" "
: [PASSED] delim=":"
: [PASSED] delim=","
: [PASSED] delim="-"
: [PASSED] delim="/"
: ======== [PASSED] numbers_list_field_width_typemax =========
: =========== numbers_list_field_width_val_width ============
: [PASSED] delim=" "
: [PASSED] delim=":"
: [PASSED] delim=","
: [PASSED] delim="-"
: [PASSED] delim="/"
: ======= [PASSED] numbers_list_field_width_val_width ========
: [PASSED] numbers_slice
: [PASSED] numbers_prefix_overflow
: [PASSED] test_simple_strtoull
: [PASSED] test_simple_strtoll
: [PASSED] test_simple_strtoul
: [PASSED] test_simple_strtol
: ====================== [PASSED] scanf ======================
: ============================================================
: Testing complete. Ran 22 tests: passed: 22
: Elapsed time: 5.517s total, 0.001s configuring, 5.440s building, 0.067s running
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Rename lib/{test_scanf.c => scanf_kunit.c}. (Andy Shevchenko)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Tamir Duberstein (2):
scanf: convert self-test to KUnit
scanf: break kunit into test cases
MAINTAINERS | 2 +-
lib/Kconfig.debug | 12 +-
lib/Makefile | 2 +-
lib/{test_scanf.c => scanf_kunit.c} | 274 +++++++++++++++++------------------
tools/testing/selftests/lib/Makefile | 2 +-
tools/testing/selftests/lib/config | 1 -
tools/testing/selftests/lib/scanf.sh | 4 -
7 files changed, 145 insertions(+), 152 deletions(-)---
base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250131-scanf-kunit-convert-f70dc33bb34c
Best regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
PATCH v6 1/2 scanf: convert self-test to KUnit
Convert the scanf() self-test to a KUnit test.
In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case.
---
MAINTAINERS | 2 +-
lib/Kconfig.debug | 12 +-
lib/Makefile | 2 +-
lib/{test_scanf.c => scanf_kunit.c} | 228 ++++++++++++++++-------------------
tools/testing/selftests/lib/Makefile | 2 +-
tools/testing/selftests/lib/config | 1 -
tools/testing/selftests/lib/scanf.sh | 4 -
7 files changed, 118 insertions(+), 133 deletions(-)MAINTAINERS +1 -1
@@ -25411,8 +25411,8 @@ R: Sergey Senozhatsky <[email protected]> S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git F: Documentation/core-api/printk-formats.rst +F: lib/scanf_kunit.c F: lib/test_printf.c -F: lib/test_scanf.c F: lib/vsprintf.c VT1211 HARDWARE MONITOR DRIVER
lib/Kconfig.debug +9 -3
@@ -2427,6 +2427,15 @@ config ASYNC_RAID6_TEST config TEST_HEXDUMP tristate "Test functions located in the hexdump module at runtime" +config SCANF_KUNIT_TEST + tristate "KUnit test scanf() family of functions at runtime" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enable this option to test the scanf functions at runtime. + + If unsure, say N. + config STRING_KUNIT_TEST tristate "KUnit test string functions at runtime" if !KUNIT_ALL_TESTS depends on KUNIT
@@ -2443,9 +2452,6 @@ config TEST_KSTRTOX config TEST_PRINTF tristate "Test printf() family of functions at runtime" -config TEST_SCANF - tristate "Test scanf() family of functions at runtime" - config TEST_BITMAP tristate "Test bitmap_*() family of functions at runtime" help
lib/Makefile +1 -1
@@ -85,7 +85,7 @@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o -obj-$(CONFIG_TEST_SCANF) += test_scanf.o +obj-$(CONFIG_SCANF_KUNIT_TEST) += scanf_kunit.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_KASAN),yy)
lib/scanf_kunit.c renamed from lib/test_scanf.c +106 -122
567 lines not on this page · raw message
tools/testing/selftests/lib/Makefile +1 -1
@@ -4,5 +4,5 @@ # No binaries, but make sure arg-less "make" doesn't trigger "run_tests" all: -TEST_PROGS := printf.sh bitmap.sh prime_numbers.sh scanf.sh +TEST_PROGS := printf.sh bitmap.sh prime_numbers.sh include ../lib.mk
tools/testing/selftests/lib/config +0 -1
@@ -1,5 +1,4 @@ CONFIG_TEST_PRINTF=m -CONFIG_TEST_SCANF=m CONFIG_TEST_BITMAP=m CONFIG_PRIME_NUMBERS=m CONFIG_TEST_BITOPS=m
tools/testing/selftests/lib/scanf.sh deleted +0 -4
@@ -1,4 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: GPL-2.0 -# Tests the scanf infrastructure using test_scanf kernel module. -$(dirname $0)/../kselftest/module.sh "scanf" test_scanf
Signature · 1 line
2.48.1
Quoted 7 lines · Tamir Duberstein
Convert the
scanf()self-test to a KUnit test.In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case.
Acked-by Petr Mladek <[email protected]>
Please, remove this. The patchset has changed a lot and it is not longer true.
Quoted 3 lines
lib/scanf_kunit.c renamed from lib/test_scanf.c +0
-0@@ -15,67 +13,49 @@
[...]
lib/scanf_kunit.c
Quoted 4 lines
#define
_check_numbers_template(arg_fmt, expect, str, fmt, n_args, ap)\
do { \lib/scanf_kunit.c renamed from lib/test_scanf.c +1
-1-pr_debug ("\"%s\", \"%s\" ->\n" , str, fmt); \ +kunit_printk (KERN_DEBUG , test,"\"%s\", \"%s\" ->" , str, fmt); \
The switch from pr_debug() to kunit_printk() causes printing huge amount of messages even when the test passes.
[ 5780.664377] KTAP version 1 [ 5780.664891] 1..1 [ 5780.665376] KTAP version 1 [ 5780.665765] # Subtest: scanf [ 5780.666104] # module: scanf_kunit [ 5780.666112] 1..10 [ 5780.667354] # numbers_simple: "0", "%llu" -> [ 5780.667371] # numbers_simple: 0 [ 5780.667923] # numbers_simple: "0", "%llu" -> [ 5780.668321] # numbers_simple: 0 [ 5780.668803] # numbers_simple: "1", "%llu" -> [ 5780.669175] # numbers_simple: 1 [ 5780.669624] # numbers_simple: "18446744073709551615", "%llu" ->
[... skipping 7500+ lines ...]
[ 5783.157777] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff
[ 5783.158229] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001
[ 5783.158683] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000
[ 5783.159131] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000
[ 5783.159586] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001
[ 5783.160048] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff
[ 5783.160506] # test_simple_strtol: simple_strtol("0xfffffffffffffffe", 0) -> 0xfffffffffffffffe
[ 5783.160957] # test_simple_strtol: simple_strtol("0x2", 0) -> 0x2
[ 5783.161467] # test_simple_strtol: simple_strtol("0xffffffffffffffff", 0) -> 0xffffffffffffffff
[ 5783.161806] # test_simple_strtol: simple_strtol("0x1", 0) -> 0x1
[ 5783.162564] ok 10 test_simple_strtol
[ 5783.163145] # scanf: pass:10 fail:0 skip:0 total:10
[ 5783.163537] # Totals: pass:22 fail:0 skip:0 total:22
[ 5783.164052] ok 1 scanfYes, it would help with debugging. But we should print these details only when the test fails!
Partial solution might be to use pr_debug(). The messages will be disabled by default and can be enabled via /sys/kernel/debug/dynamic_debug/control
Here is some POC:
From 7ea79fd67c4a7d8dff9d9fa986bb8dc037087c47 Mon Sep 17 00:00:00 2001
From: Petr Mladek <[email protected]>
Date: Tue, 11 Feb 2025 12:24:40 +0100
Subject: [POC] kunit/scanf_knunit: Add kunit_debug() to allow using the
dynamic debug facility
Do not fill the kernel logbuffer with debug messages by default. Allow to enable them via /sys/kernel/debug/dynamic_debug/control
The question is whether we want to print them into the kunit log.
FIXME: This use just a POC. The right solution should reduce
cut&paste.
--- include/kunit/test.h | 30 ++++++++++++++++++++++++++++++ lib/scanf_kunit.c | 6 +++--- 2 files changed, 33 insertions(+), 3 deletions(-)
include/kunit/test.h +30 -0
@@ -637,6 +637,36 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt,#define kunit_err (test, fmt, ...) \ kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__) +/* +* pr_debug and log to per-test or per-suite log buffer. Logging only done +* if CONFIG_KUNIT_DEBUGFS is 'y'; if it is 'n', no log is allocated/used. +* +* The special variant is needed to allow using the printk dynamic debug +* infrastructure, see CONFIG_DYNAMIC_DEBUG. +*/ +#define kunit_log_debug (test_or_suite, fmt, ...) \ + do { \ + pr_debug(fmt, ##__VA_ARGS__); \ + kunit_log_append((test_or_suite)->log, fmt, \ + ##__VA_ARGS__); \ + } while (0) + +#define kunit_printk_debug (test, fmt, ...) \ + kunit_log_debug(test, KUNIT_SUBTEST_INDENT "# %s: " fmt, \ + (test)->name, ##__VA_ARGS__) + +/** +* kunit_debug() - Prints an DEBUG level message associated with @test. +* +* @test: The test context object. +* @fmt: A printk() style format string. +* +* Prints an error level message. +*/ +#define kunit_debug (test, fmt, ...) \ + kunit_printk_debug(test, fmt, ##__VA_ARGS__) + +/* * Must be called at the beginning of each KUNIT_*_ASSERTION(). * Cf. KUNIT_CURRENT_LOC.
lib/scanf_kunit.c +3 -3
@@ -42,10 +42,10 @@ _test(struct kunit *test, check_fn fn, const void *check_data, const char *strin#define _check_numbers_template (arg_fmt, expect, str, fmt, n_args, ap) \ do { \ - kunit_printk(KERN_DEBUG, test, "\"%s\", \"%s\" ->", str, fmt); \ + kunit_debug(test, "\"%s\", \"%s\" ->", str, fmt); \ for (; n_args > 0; n_args--, expect++) { \ typeof(*expect) got = *va_arg(ap, typeof(expect)); \ - kunit_printk(KERN_DEBUG, test, "\t" arg_fmt, got); \ + kunit_debug(test, "\t" arg_fmt, got); \ KUNIT_EXPECT_EQ_MSG(test, got, *expect, \ "vsscanf(\"%s\", \"%s\", ...)", str, fmt); \ } \
@@ -677,7 +677,7 @@ do { \ \ len =snprintf (test_buffer,BUF_SIZE , gen_fmt, expect); \ got = (fn)(test_buffer, &endp, base); \ - kunit_printk(KERN_DEBUG, test, #fn "(\"%s\", %d) -> " gen_fmt, test_buffer, base, got); \ + kunit_debug(test, #fn "(\"%s\", %d) -> " gen_fmt, test_buffer, base, got); \ if (got != (expect)) { \ KUNIT_FAIL(test, #fn "(\"%s\", %d): got " gen_fmt " expected " gen_fmt, \ test_buffer, base, got, expect); \
Signature · 10 lines
2.48.1 But when thinking more about it. I think that even pr_debug() is not the right solution. IMHO, we really want to print these details only when the test fails. Best Regards, Petr
Quoted 4 lines · Petr Mladek
Quoted 2 lines · Tamir Duberstein
Convert the
scanf()self-test to a KUnit test.
Quoted 8 lines
Quoted 5 lines
In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case.
Acked-by Petr Mladek <[email protected]>Please, remove this. The patchset has changed a lot and it is not longer true.
Will do.
Quoted 5 lines
Quoted 4 lines
lib/scanf_kunit.c renamed from lib/test_scanf.c +0
-0@@ -15,67 +13,49 @@[...]
Quoted 7 lines
lib/scanf_kunit.c
Quoted 4 lines
#define
_check_numbers_template(arg_fmt, expect, str, fmt, n_args, ap)\
do { \lib/scanf_kunit.c renamed from lib/test_scanf.c +1
-1-pr_debug ("\"%s\", \"%s\" ->\n" , str, fmt); \ +kunit_printk (KERN_DEBUG , test,"\"%s\", \"%s\" ->" , str, fmt); \The switch from
pr_debug()tokunit_printk()causes printing huge amount of messages even when the test passes.
I'm not able to reproduce this. pr_debug expands to printk(KERN_DEBUG, ...) which is also what kunit_printk(KERN_DEBUG, ...) expands to. Can you help me understand how you're testing?
Quoted 129 lines
[ 5780.664377] KTAP version 1 [ 5780.664891] 1..1 [ 5780.665376] KTAP version 1 [ 5780.665765] # Subtest: scanf [ 5780.666104] # module: scanf_kunit [ 5780.666112] 1..10 [ 5780.667354] # numbers_simple: "0", "%llu" -> [ 5780.667371] # numbers_simple: 0 [ 5780.667923] # numbers_simple: "0", "%llu" -> [ 5780.668321] # numbers_simple: 0 [ 5780.668803] # numbers_simple: "1", "%llu" -> [ 5780.669175] # numbers_simple: 1 [ 5780.669624] # numbers_simple: "18446744073709551615", "%llu" ->[... skipping 7500+ lines ...]
[ 5783.157777] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff [ 5783.158229] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.158683] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159131] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159586] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.160048] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff [ 5783.160506] # test_simple_strtol: simple_strtol("0xfffffffffffffffe", 0) -> 0xfffffffffffffffe [ 5783.160957] # test_simple_strtol: simple_strtol("0x2", 0) -> 0x2 [ 5783.161467] # test_simple_strtol: simple_strtol("0xffffffffffffffff", 0) -> 0xffffffffffffffff [ 5783.161806] # test_simple_strtol: simple_strtol("0x1", 0) -> 0x1 [ 5783.162564] ok 10 test_simple_strtol [ 5783.163145] # scanf: pass:10 fail:0 skip:0 total:10 [ 5783.163537] # Totals: pass:22 fail:0 skip:0 total:22 [ 5783.164052] ok 1 scanfYes, it would help with debugging. But we should print these details only when the test fails!
Partial solution might be to use
pr_debug(). The messages will be disabled by default and can be enabled via/sys/kernel/debug/dynamic_debug/controlHere is some POC:
From
7ea79fd67c4a7d8dff9d9fa986bb8dc037087c47Mon Sep 17 00:00:00 2001
From: Petr Mladek <[email protected]>
Date: Tue, 11 Feb 2025 12:24:40 +0100
Subject: [POC] kunit/scanf_knunit: Addkunit_debug()to allow using the
dynamic debug facilityDo not fill the kernel logbuffer with debug messages by default. Allow to enable them via
/sys/kernel/debug/dynamic_debug/controlThe question is whether we want to print them into the kunit log.
FIXME: This use just a POC. The right solution should reduce
cut&paste.--- include/kunit/test.h | 30 ++++++++++++++++++++++++++++++ lib/scanf_kunit.c | 6 +++--- 2 files changed, 33 insertions(+), 3 deletions(-)include/kunit/test.h +30
-0@@ -637,6 +637,36 @@ void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt,#define kunit_err (test, fmt, ...) \ kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__) +/* +* pr_debug and log to per-test or per-suite log buffer. Logging only done +* if CONFIG_KUNIT_DEBUGFS is 'y'; if it is 'n', no log is allocated/used. +* +* The special variant is needed to allow using the printk dynamic debug +* infrastructure, see CONFIG_DYNAMIC_DEBUG. +*/ +#define kunit_log_debug (test_or_suite, fmt, ...) \ + do { \ + pr_debug(fmt, ##__VA_ARGS__); \ + kunit_log_append((test_or_suite)->log, fmt, \ + ##__VA_ARGS__); \ + } while (0) + +#define kunit_printk_debug (test, fmt, ...) \ + kunit_log_debug(test, KUNIT_SUBTEST_INDENT "# %s: " fmt, \ + (test)->name, ##__VA_ARGS__) + +/** +* kunit_debug() - Prints an DEBUG level message associated with @test. +* +* @test: The test context object. +* @fmt: A printk() style format string. +* +* Prints an error level message. +*/ +#define kunit_debug (test, fmt, ...) \ + kunit_printk_debug(test, fmt, ##__VA_ARGS__) + +/* * Must be called at the beginning of each KUNIT_*_ASSERTION(). * Cf. KUNIT_CURRENT_LOC. lib/scanf_kunit.c +3
-4@@ -42,10 +42,10 @@ _test(struct kunit *test, check_fn fn, const void *check_data, const char *strin#define _check_numbers_template (arg_fmt, expect, str, fmt, n_args, ap) \ do { \ - kunit_printk(KERN_DEBUG, test, "\"%s\", \"%s\" ->", str, fmt); \ + kunit_debug(test, "\"%s\", \"%s\" ->", str, fmt); \ for (; n_args > 0; n_args--, expect++) { \ typeof(*expect) got = *va_arg(ap, typeof(expect)); \ - kunit_printk(KERN_DEBUG, test, "\t" arg_fmt, got); \ + kunit_debug(test, "\t" arg_fmt, got); \ KUNIT_EXPECT_EQ_MSG(test, got, *expect, \ "vsscanf(\"%s\", \"%s\", ...)", str, fmt); \ } \@@ -677,7 +677,7 @@ do { \ \ len =snprintf (test_buffer,BUF_SIZE , gen_fmt, expect); \ got = (fn)(test_buffer, &endp, base); \ - kunit_printk(KERN_DEBUG, test, #fn "(\"%s\", %d) -> " gen_fmt, test_buffer, base, got); \ + kunit_debug(test, #fn "(\"%s\", %d) -> " gen_fmt, test_buffer, base, got); \ if (got != (expect)) { \ KUNIT_FAIL(test, #fn "(\"%s\", %d): got " gen_fmt " expected " gen_fmt, \ test_buffer, base, got, expect); \ --2.48.1
Quoted 7 lines
But when thinking more about it. I think that even
pr_debug()is not the right solution.IMHO, we really want to print these details only when the test fails.
Best Regards,
Petr
If you use one of the kunit userspace helpers, you will only see the output when the test fails. Having said that, in my local testing I don't see the KERN_DEBUG prints locally. I had to run with ignore_loglevel to see them at all.
Quoted 11 lines · Tamir Duberstein
Quoted 6 lines · Petr Mladek
Quoted 1 line · Tamir Duberstein
+
kunit_printk(KERN_DEBUG, test, "\"%s\", \"%s\" ->", str, fmt); \The switch from
pr_debug()tokunit_printk()causes printing huge amount of messages even when the test passes.I'm not able to reproduce this.
pr_debugexpands toprintk(KERN_DEBUG, ...)which is also whatkunit_printk(KERN_DEBUG, ...)expands to. Can you help me understand how you're testing?
You are missing something.
https://stackoverflow.com/a/57762255/2511795
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 14 lines · Andy Shevchenko
Quoted 11 lines · Tamir Duberstein
Quoted 6 lines · Petr Mladek
Quoted 1 line · Tamir Duberstein
+
kunit_printk(KERN_DEBUG, test, "\"%s\", \"%s\" ->", str, fmt); \The switch from
pr_debug()tokunit_printk()causes printing huge amount of messages even when the test passes.I'm not able to reproduce this.
pr_debugexpands toprintk(KERN_DEBUG, ...)which is also whatkunit_printk(KERN_DEBUG, ...)expands to. Can you help me understand how you're testing?
Quoted 7 lines
You are missing something.
https://stackoverflow.com/a/57762255/2511795--
With Best Regards,
Andy Shevchenko
I see. Given Petr's comment about pr_debug also not being the right thing, I took a closer look and realized that these debug logs are redundant as they don't provide any information beyond what the failure messages already do. So I'll just remove them.
Quoted 26 lines · Tamir Duberstein
Quoted 4 lines · Petr Mladek
Quoted 2 lines · Tamir Duberstein
Convert the
scanf()self-test to a KUnit test.Quoted 8 lines
Quoted 5 lines
In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case.
Acked-by Petr Mladek <[email protected]>Please, remove this. The patchset has changed a lot and it is not longer true.
Will do.
Quoted 10 lines
Quoted 4 lines
lib/scanf_kunit.c renamed from lib/test_scanf.c +0
-0@@ -15,67 +13,49 @@[...]
Quoted 4 lines
#define
_check_numbers_template(arg_fmt, expect, str, fmt, n_args, ap)\
do { \lib/scanf_kunit.c renamed from lib/test_scanf.c +1
-1-pr_debug ("\"%s\", \"%s\" ->\n" , str, fmt); \ +kunit_printk (KERN_DEBUG , test,"\"%s\", \"%s\" ->" , str, fmt); \
Quoted 4 lines
Quoted 2 lines
The switch from
pr_debug()tokunit_printk()causes printing huge amount of messages even when the test passes.I'm not able to reproduce this.
It is because the loglevel filtering, see below.
Quoted 3 lines
pr_debugexpands to printk(KERN_DEBUG,
...) which is also whatkunit_printk(KERN_DEBUG, ...)expands to. Can you help me understand how you're testing?
It is more complicated, see the following in include/linux/printk.h:
<paste>
/* If you are writing a driver, please use dev_dbg instead */
#if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
#include <linux/dynamic_debug.h>
/**
* pr_debug - Print a debug-level message conditionally
* @fmt: format string
* @...: arguments for the format string
*
* This macro expands to dynamic_pr_debug() if CONFIG_DYNAMIC_DEBUG is
* set. Otherwise, if DEBUG is defined, it's equivalent to a printk with
* KERN_DEBUG loglevel. If DEBUG is not defined it does nothing. *
* It uses pr_fmt() to generate the format string (dynamic_pr_debug() uses
* pr_fmt() internally).
*/
#define pr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) #elif defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
#endif
</paste>
It would be nice to define it the other way around. But it would require reworking the macro trickery which might be tricky ;-)
Quoted 16 lines
Quoted 16 lines
[ 5780.664377] KTAP version 1 [ 5780.664891] 1..1 [ 5780.665376] KTAP version 1 [ 5780.665765] # Subtest: scanf [ 5780.666104] # module: scanf_kunit [ 5780.666112] 1..10 [ 5780.667354] # numbers_simple: "0", "%llu" -> [ 5780.667371] # numbers_simple: 0 [ 5780.667923] # numbers_simple: "0", "%llu" -> [ 5780.668321] # numbers_simple: 0 [ 5780.668803] # numbers_simple: "1", "%llu" -> [ 5780.669175] # numbers_simple: 1 [ 5780.669624] # numbers_simple: "18446744073709551615", "%llu" ->[... skipping 7500+ lines ...]
Quoted 14 lines
Quoted 6 lines
[ 5783.157777] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff [ 5783.158229] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.158683] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159131] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159586] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.160048] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffffQuoted 8 lines
[ 5783.160506] # test_simple_strtol: simple_strtol("0xfffffffffffffffe", 0) -> 0xfffffffffffffffe [ 5783.160957] # test_simple_strtol: simple_strtol("0x2", 0) -> 0x2 [ 5783.161467] # test_simple_strtol: simple_strtol("0xffffffffffffffff", 0) -> 0xffffffffffffffff [ 5783.161806] # test_simple_strtol: simple_strtol("0x1", 0) -> 0x1 [ 5783.162564] ok 10 test_simple_strtol [ 5783.163145] # scanf: pass:10 fail:0 skip:0 total:10 [ 5783.163537] # Totals: pass:22 fail:0 skip:0 total:22 [ 5783.164052] ok 1 scanf
I saw the above messages using "dmesg".
They can also be seen in /sys/kernel/debug/kunit/scanf/results when CONFIG_KUNIT_DEBUGFS is enabled.
Quoted 4 lines
If you use one of the kunit userspace helpers, you will only see the output when the test fails. Having said that, in my local testing I don't see the
KERN_DEBUGprints locally. I had to run withignore_loglevelto see them at all.
Yeah, KERN_DEBUG are for the least important messages. Consoles usually do not print them to do not scare normal users and also historically because of slow serial consoles.
Anyway, they are always stored into the internal log buffer. So that they can be seen by "dmesg" even when they were filtered on the console.
BTW: The log buffer has a limited size. The oldest messages get lost
when are too many of them. Which is another reason to do not print the debug messages by default.
Best Regards,
Petr
PS: You are sending new revisions too fast. It is hard to follow.
I personally prefer to send one revision per week at maximum. It gives people chance to find time for the review and provide some feedback.
Quoted 130 lines · Petr Mladek
Quoted 26 lines · Tamir Duberstein
Quoted 4 lines · Petr Mladek
Quoted 2 lines · Tamir Duberstein
Convert the
scanf()self-test to a KUnit test.Quoted 8 lines
Quoted 5 lines
In the interest of keeping the patch reasonably-sized this doesn't refactor the tests into proper parameterized tests - it's all one big test case.
Acked-by Petr Mladek <[email protected]>Please, remove this. The patchset has changed a lot and it is not longer true.
Will do.
Quoted 10 lines
Quoted 4 lines
lib/scanf_kunit.c renamed from lib/test_scanf.c +0
-0@@ -15,67 +13,49 @@[...]
Quoted 4 lines
#define
_check_numbers_template(arg_fmt, expect, str, fmt, n_args, ap)\
do { \lib/scanf_kunit.c renamed from lib/test_scanf.c +1
-1-pr_debug ("\"%s\", \"%s\" ->\n" , str, fmt); \ +kunit_printk (KERN_DEBUG , test,"\"%s\", \"%s\" ->" , str, fmt); \Quoted 4 lines
Quoted 2 lines
The switch from
pr_debug()tokunit_printk()causes printing huge amount of messages even when the test passes.I'm not able to reproduce this.
It is because the loglevel filtering, see below.
Quoted 3 lines
pr_debugexpands to printk(KERN_DEBUG,
...) which is also whatkunit_printk(KERN_DEBUG, ...)expands to. Can you help me understand how you're testing?It is more complicated, see the following in
include/linux/printk.h:<paste>
/* If you are writing a driver, please usedev_dbginstead */#if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))#include <
linux/dynamic_debug.h>/**
*pr_debug- Print a debug-level message conditionally
* @fmt: format string
* @...: arguments for the format string
*
* This macro expands todynamic_pr_debug()ifCONFIG_DYNAMIC_DEBUGis
* set. Otherwise, if DEBUG is defined, it's equivalent to a printk with
*KERN_DEBUGloglevel. If DEBUG is not defined it does nothing. *
* It usespr_fmt()to generate the format string (dynamic_pr_debug()uses
*pr_fmt()internally).
*/#define pr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) #elif defined(DEBUG) #define pr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #define pr_debug(fmt, ...) \ no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)#endif
</paste>It would be nice to define it the other way around. But it would require reworking the macro trickery which might be tricky ;-)
Quoted 16 lines
Quoted 16 lines
[ 5780.664377] KTAP version 1 [ 5780.664891] 1..1 [ 5780.665376] KTAP version 1 [ 5780.665765] # Subtest: scanf [ 5780.666104] # module: scanf_kunit [ 5780.666112] 1..10 [ 5780.667354] # numbers_simple: "0", "%llu" -> [ 5780.667371] # numbers_simple: 0 [ 5780.667923] # numbers_simple: "0", "%llu" -> [ 5780.668321] # numbers_simple: 0 [ 5780.668803] # numbers_simple: "1", "%llu" -> [ 5780.669175] # numbers_simple: 1 [ 5780.669624] # numbers_simple: "18446744073709551615", "%llu" ->[... skipping 7500+ lines ...]
Quoted 14 lines
Quoted 6 lines
[ 5783.157777] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffff [ 5783.158229] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.158683] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159131] # test_simple_strtol: simple_strtol("0x8000000000000000", 0) -> 0x8000000000000000 [ 5783.159586] # test_simple_strtol: simple_strtol("0x8000000000000001", 0) -> 0x8000000000000001 [ 5783.160048] # test_simple_strtol: simple_strtol("0x7fffffffffffffff", 0) -> 0x7fffffffffffffffQuoted 8 lines
[ 5783.160506] # test_simple_strtol: simple_strtol("0xfffffffffffffffe", 0) -> 0xfffffffffffffffe [ 5783.160957] # test_simple_strtol: simple_strtol("0x2", 0) -> 0x2 [ 5783.161467] # test_simple_strtol: simple_strtol("0xffffffffffffffff", 0) -> 0xffffffffffffffff [ 5783.161806] # test_simple_strtol: simple_strtol("0x1", 0) -> 0x1 [ 5783.162564] ok 10 test_simple_strtol [ 5783.163145] # scanf: pass:10 fail:0 skip:0 total:10 [ 5783.163537] # Totals: pass:22 fail:0 skip:0 total:22 [ 5783.164052] ok 1 scanfI saw the above messages using "dmesg".
They can also be seen in
/sys/kernel/debug/kunit/scanf/resultswhenCONFIG_KUNIT_DEBUGFSis enabled.Quoted 4 lines
If you use one of the kunit userspace helpers, you will only see the output when the test fails. Having said that, in my local testing I don't see the
KERN_DEBUGprints locally. I had to run withignore_loglevelto see them at all.Yeah,
KERN_DEBUGare for the least important messages. Consoles usually do not print them to do not scare normal users and also historically because of slow serial consoles.Anyway, they are always stored into the internal log buffer. So that they can be seen by "dmesg" even when they were filtered on the console.
BTW: The log buffer has a limited size. The oldest messages get lost
when are too many of them. Which is another reason to do not print the debug messages by default.
Quoted 7 lines
Best Regards,
PetrPS: You are sending new revisions too fast. It is hard to follow.
I personally prefer to send one revision per week at maximum. It gives people chance to find time for the review and provide some feedback.
Thanks, I'll reduce the frequency. Apologies for the noise!
I think all this is addressed in v7.
PATCH v6 2/2 scanf: break kunit into test cases
In reply to Tamir DubersteinUse suite_init and move some tests into scanf_test_cases. This gives us nicer output in the event of a failure.
--- lib/scanf_kunit.c | 88 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 40 deletions(-)
lib/scanf_kunit.c +48 -40
@@ -4,14 +4,10 @@*/ #include <kunit/test.h> -#include <linux/bitops.h> -#include <linux/kernel.h> #include <linux/module.h> -#include <linux/overflow.h> -#include <linux/printk.h> #include <linux/prandom.h> #include <linux/slab.h> -#include <linux/string.h> +#include <linux/sprintf.h> #define BUF_SIZE 1024
@@ -428,8 +424,11 @@ static void numbers_list_hh(struct kunit *test, const char *delim) numbers_list_8(signed char, "0x%hhx", delim, "hhi", check_char); } -static void numbers_list (struct kunit *test,const char *delim) +static void numbers_list (struct kunit *test) { +const char *const *param = test->param_value; +const char *delim = *param; +numbers_list_ll (test, delim);numbers_list_l (test, delim);numbers_list_d (test, delim);
@@ -500,8 +499,11 @@ static void numbers_list_field_width_hh(struct kunit *test, const char *delim)* List of numbers separated by delim. Each field width specifier is the * maximum possible digits for the given type and base. */ -static void numbers_list_field_width_typemax (struct kunit *test,const char *delim) +static void numbers_list_field_width_typemax (struct kunit *test) { +const char *const *param = test->param_value; +const char *delim = *param; +numbers_list_field_width_ll (test, delim);numbers_list_field_width_l (test, delim);numbers_list_field_width_d (test, delim);
@@ -563,8 +565,11 @@ static void numbers_list_field_width_val_hh(struct kunit *test, const char *deli* List of numbers separated by delim. Each field width specifier is the * exact length of the corresponding value digits in the string being scanned. */ -static void numbers_list_field_width_val_width (struct kunit *test,const char *delim) +static void numbers_list_field_width_val_width (struct kunit *test) { +const char *const *param = test->param_value; +const char *delim = *param; +numbers_list_field_width_val_ll (test, delim);numbers_list_field_width_val_l (test, delim);numbers_list_field_width_val_d (test, delim);
@@ -580,7 +585,12 @@ static void numbers_list_field_width_val_width(struct kunit *test, const char *d*/ static void numbers_slice (struct kunit *test) { -numbers_list_field_width_val_width (test,"" ); +const char *delim ="" ; + +KUNIT_ASSERT_PTR_EQ (test, test->param_value,NULL ); + test->param_value = &delim; + +numbers_list_field_width_val_width (test); }#define test_number_prefix (T , str, scan_fmt, expect0, expect1, n_args, fn) \
@@ -732,62 +742,60 @@ static const char * const number_delimiters[] = { " ", ":", ",", "-", "/", }; -static void test_numbers (struct kunit *test) +static void number_delimiter_param_desc (const char *const *param, +char *desc) { -int i; +snprintf (desc,KUNIT_PARAM_DESC_SIZE ,"\"%s\"" , *param); +} -/* String containing only one number. */ -numbers_simple (test); +KUNIT_ARRAY_PARAM (number_delimiters, number_delimiters, number_delimiter_param_desc); +static struct kunit_case scanf_test_cases[] = { +KUNIT_CASE (numbers_simple),/* String with multiple numbers separated by delimiter. */ -for (i =0 ; i <ARRAY_SIZE (number_delimiters); i++) { -numbers_list (test, number_delimiters[i]); - -/* Field width may be longer than actual field digits. */ -numbers_list_field_width_typemax (test, number_delimiters[i]); - -/* Each field width exactly length of actual field digits. */ -numbers_list_field_width_val_width (test, number_delimiters[i]); - } - +KUNIT_CASE_PARAM (numbers_list, number_delimiters_gen_params), +/* Field width may be longer than actual field digits. */ +KUNIT_CASE_PARAM (numbers_list_field_width_typemax, number_delimiters_gen_params), +/* Each field width exactly length of actual field digits. */ +KUNIT_CASE_PARAM (numbers_list_field_width_val_width, number_delimiters_gen_params),/* Slice continuous sequence of digits using field widths. */ -numbers_slice (test); +KUNIT_CASE (numbers_slice), +KUNIT_CASE (numbers_prefix_overflow), -numbers_prefix_overflow (test); -} +KUNIT_CASE (test_simple_strtoull), +KUNIT_CASE (test_simple_strtoll), +KUNIT_CASE (test_simple_strtoul), +KUNIT_CASE (test_simple_strtol), + {} +}; -static void scanf_test (struct kunit *test) +static int scanf_suite_init (struct kunit_suite *suite) { test_buffer =kmalloc (BUF_SIZE ,GFP_KERNEL );if (!test_buffer) -return ; +return -ENOMEM ; fmt_buffer =kmalloc (BUF_SIZE ,GFP_KERNEL );if (!fmt_buffer) {kfree (test_buffer); -return ; +return -ENOMEM ; }prandom_seed_state (&rnd_state,3141592653589793238ULL ); -test_numbers (test); - -test_simple_strtoull (test); -test_simple_strtoll (test); -test_simple_strtoul (test); -test_simple_strtol (test); +return 0 ; +} +static void scanf_suite_exit (struct kunit_suite *suite) +{kfree (fmt_buffer);kfree (test_buffer); } -static struct kunit_case scanf_test_cases[] = { -KUNIT_CASE (scanf_test), - {} -}; -static struct kunit_suite scanf_test_suite = { .name ="scanf" , + .suite_init = scanf_suite_init, + .suite_exit = scanf_suite_exit, .test_cases = scanf_test_cases, };
Signature · 1 line
2.48.1
Re: [PATCH v6 2/2] scanf: break kunit into test cases
Quoted 2 lines · Tamir Duberstein
Use
suite_initand move some tests intoscanf_test_cases. This gives us nicer output in the event of a failure.
Hmm, simulate the following failure in the original test module:
lib/test_scanf.c +1 -1
@@ -564,7 +564,7 @@ static void __init numbers_list_field_width_val_h(const char *delim) numbers_list_val_width(unsigned short, "%hu", delim, "hu", check_ushort);numbers_list_val_width (short,"%hd" , delim,"hd" , check_short);numbers_list_val_width (short,"%hd" , delim,"hi" , check_short); - numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_ushort); + numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_uint); numbers_list_val_width(unsigned short, "0x%hx", delim, "hx", check_ushort);numbers_list_val_width (short,"0x%hx" , delim,"hi" , check_short); }
and I got:
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881
[ 383.102843] test_scanf: vsscanf("f12:2:d:2:c166:1:36b:1906", "%3hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) expected 131085 got 851970
[ 383.105376] test_scanf: vsscanf("4,b2fe,3,593,6,0,3bde,0", "%1hx,%4hx,%1hx,%3hx,%1hx,%1hx,%4hx,%1hx", ...) expected 93519875 got 242430
[ 383.105659] test_scanf: vsscanf("6-1-2-1-d9e6-f-93e-e567", "%1hx-%1hx-%1hx-%1hx-%4hx-%1hx-%3hx-%4hx", ...) expected 65538 got 131073
[ 383.106127] test_scanf: vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) expected 125069 got 3901554741
[ 383.106235] test_scanf: vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) expected 571539457 got 106936
[ 383.106398] test_scanf: failed 6 out of 2545 testsWhen I tried to do the same in the new module:
lib/scanf_kunit.c +1 -1
@@ -546,7 +546,7 @@ static void numbers_list_field_width_val_h(struct kunit *test, const char *delim numbers_list_val_width(unsigned short, "%hu", delim, "hu", check_ushort);numbers_list_val_width (short,"%hd" , delim,"hd" , check_short);numbers_list_val_width (short,"%hd" , delim,"hi" , check_short); - numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_ushort); + numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_uint); numbers_list_val_width(unsigned short, "0x%hx", delim, "hx", check_ushort);numbers_list_val_width (short,"0x%hx" , delim,"hi" , check_short); }
then I got:
[ 6625.895391] KTAP version 1
[ 6625.895928] 1..1
[ 6625.896494] KTAP version 1
[ 6625.896852] # Subtest: scanf
[ 6625.897191] # module: scanf_kunit
[ 6625.897198] 1..10
[ 6625.903479] ok 1 numbers_simple
[ 6625.903490] KTAP version 1
[ 6625.904352] # Subtest: numbers_list
[ 6625.905623] ok 1 " "
[ 6625.907654] ok 2 ":"
[ 6625.909654] ok 3 ","
[ 6625.911564] ok 4 "-"
[ 6625.913632] ok 5 "/"
[ 6625.914020] # numbers_list: pass:5 fail:0 skip:0 total:5
[ 6625.914370] ok 2 numbers_list
[ 6625.914964] KTAP version 1
[ 6625.915871] # Subtest: numbers_list_field_width_typemax
[ 6625.917527] ok 1 " "
[ 6625.919366] ok 2 ":"
[ 6625.921586] ok 3 ","
[ 6625.923240] ok 4 "-"
[ 6625.925226] ok 5 "/"
[ 6625.925622] # numbers_list_field_width_typemax: pass:5 fail:0 skip:0 total:5
[ 6625.925973] ok 3 numbers_list_field_width_typemax
[ 6625.926709] KTAP version 1
[ 6625.927613] # Subtest: numbers_list_field_width_val_width
[ 6625.928546] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1044578334 (0x3e43001e)
*pval == 837828163 (0x31f03e43)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.929225] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 837828163 (0x31f03e43)
*pval == 0 (0x0)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.932202] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 12784 (0x31f0)
*pval == 2624608151 (0x9c705797)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.934982] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 0 (0x0)
*pval == 1966080 (0x1e0000)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935004] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1469513728 (0x57970000)
*pval == 837828163 (0x31f03e43)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935025] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 2624608151 (0x9c705797)
*pval == 0 (0x0)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.935046] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 469802096 (0x1c009c70)
*pval == 2624608151 (0x9c705797)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
[ 6625.938161] not ok 1 " "
[ 6625.952074] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 131073 (0x20001)
*pval == 65538 (0x10002)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952098] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 65538 (0x10002)
*pval == 1038822 (0xfd9e6)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952121] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3655729153 (0xd9e60001)
*pval == 3848735038 (0xe567093e)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.952143] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1038822 (0xfd9e6)
*pval == 65542 (0x10006)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960548] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 155058191 (0x93e000f)
*pval == 65538 (0x10002)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960579] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3848735038 (0xe567093e)
*pval == 1038822 (0xfd9e6)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.960604] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 50390375 (0x300e567)
*pval == 3848735038 (0xe567093e)
vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...)
[ 6625.969351] not ok 2 ":"
[ 6625.969860] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3589275648 (0xd5f00000)
*pval == 3768047088 (0xe097d5f0)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.972121] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3768047088 (0xe097d5f0)
*pval == 878575619 (0x345e0003)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.972139] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 254103 (0x3e097)
*pval == 2832859455 (0xa8da013f)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976800] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 878575619 (0x345e0003)
*pval == 0 (0x0)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976819] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 20919390 (0x13f345e)
*pval == 3768047088 (0xe097d5f0)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976836] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 2832859455 (0xa8da013f)
*pval == 878575619 (0x345e0003)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.976853] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3691030746 (0xdc00a8da)
*pval == 2832859455 (0xa8da013f)
vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...)
[ 6625.979505] not ok 3 ","
[ 6625.989303] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1475084289 (0x57ec0001)
*pval == 3243268076 (0xc15057ec)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.989324] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3243268076 (0xc15057ec)
*pval == 21 (0x15)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.989343] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1425744 (0x15c150)
*pval == 786439 (0xc0007)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994177] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 21 (0x15)
*pval == 65537 (0x10001)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994196] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 458752 (0x70000)
*pval == 3243268076 (0xc15057ec)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994214] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 786439 (0xc0007)
*pval == 21 (0x15)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6625.994232] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3858759692 (0xe600000c)
*pval == 786439 (0xc0007)
vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...)
[ 6626.003487] not ok 4 "-"
[ 6626.004021] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 3901554741 (0xe88d0035)
*pval == 125069 (0x1e88d)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006206] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 125069 (0x1e88d)
*pval == 1821114368 (0x6c8c0000)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006226] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1 (0x1)
*pval == 65543 (0x10007)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006243] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1821114368 (0x6c8c0000)
*pval == 3502806 (0x3572d6)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.006261] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 486540 (0x76c8c)
*pval == 125069 (0x1e88d)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.015404] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 65543 (0x10007)
*pval == 1821114368 (0x6c8c0000)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.015423] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1828716545 (0x6d000001)
*pval == 65543 (0x10007)
vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...)
[ 6626.018041] not ok 5 "/"
[ 6626.022529] # numbers_list_field_width_val_width: pass:0 fail:5 skip:0 total:5
[ 6626.022535] not ok 4 numbers_list_field_width_val_width
[ 6626.023220] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 106936 (0x1a1b8)
*pval == 571539457 (0x22110001)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024017] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 571539457 (0x22110001)
*pval == 81562 (0x13e9a)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024035] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1050288657 (0x3e9a2211)
*pval == 91449567 (0x57368df)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024053] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 81562 (0x13e9a)
*pval == 2713242046 (0xa1b8c9be)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024073] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1759444993 (0x68df0001)
*pval == 571539457 (0x22110001)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024091] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 91449567 (0x57368df)
*pval == 81562 (0x13e9a)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.024108] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1107297651 (0x42000573)
*pval == 91449567 (0x57368df)
vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...)
[ 6626.026607] not ok 5 numbers_slice
[ 6626.039801] ok 6 numbers_prefix_overflow
[ 6626.040522] ok 7 test_simple_strtoull
[ 6626.041433] ok 8 test_simple_strtoll
[ 6626.042409] ok 9 test_simple_strtoul
[ 6626.043153] ok 10 test_simple_strtol
[ 6626.043161] # scanf: pass:8 fail:2 skip:0 total:10
[ 6626.043166] # Totals: pass:16 fail:6 skip:0 total:22
[ 6626.043170] not ok 1 scanfI like that the log better points to the test:
[ 6625.927613] # Subtest: numbers_list_field_width_val_width
But
[ 6625.928546] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91
Expected got == *pval, but
got == 1044578334 (0x3e43001e)
*pval == 837828163 (0x31f03e43)
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)is much harder to parse than the original
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881Also I wonder why the scanned string is different:
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^vs.
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^I would expect that the 1st error would be on the same string in both tests. I wonder why it differs.
Best Regards,
Petr
Re: [PATCH v6 2/2] scanf: break kunit into test cases
Quoted 313 lines · Petr Mladek
Quoted 2 lines · Tamir Duberstein
Use
suite_initand move some tests intoscanf_test_cases. This gives us nicer output in the event of a failure.Hmm, simulate the following failure in the original test module:
lib/test_scanf.c +1
-1@@ -564,7 +564,7 @@ static void __init numbers_list_field_width_val_h(const char *delim) numbers_list_val_width(unsigned short, "%hu", delim, "hu", check_ushort);numbers_list_val_width (short,"%hd" , delim,"hd" , check_short);numbers_list_val_width (short,"%hd" , delim,"hi" , check_short); - numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_ushort); + numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_uint); numbers_list_val_width(unsigned short, "0x%hx", delim, "hx", check_ushort);numbers_list_val_width (short,"0x%hx" , delim,"hi" , check_short); }and I got:
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881 [ 383.102843] test_scanf: vsscanf("f12:2:d:2:c166:1:36b:1906", "%3hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) expected 131085 got 851970 [ 383.105376] test_scanf: vsscanf("4,b2fe,3,593,6,0,3bde,0", "%1hx,%4hx,%1hx,%3hx,%1hx,%1hx,%4hx,%1hx", ...) expected 93519875 got 242430 [ 383.105659] test_scanf: vsscanf("6-1-2-1-d9e6-f-93e-e567", "%1hx-%1hx-%1hx-%1hx-%4hx-%1hx-%3hx-%4hx", ...) expected 65538 got 131073 [ 383.106127] test_scanf: vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) expected 125069 got 3901554741 [ 383.106235] test_scanf: vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) expected 571539457 got 106936 [ 383.106398] test_scanf: failed 6 out of 2545 testsWhen I tried to do the same in the new module:
lib/scanf_kunit.c +1
-1@@ -546,7 +546,7 @@ static void numbers_list_field_width_val_h(struct kunit *test, const char *delim numbers_list_val_width(unsigned short, "%hu", delim, "hu", check_ushort);numbers_list_val_width (short,"%hd" , delim,"hd" , check_short);numbers_list_val_width (short,"%hd" , delim,"hi" , check_short); - numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_ushort); + numbers_list_val_width(unsigned short, "%hx", delim, "hx", check_uint); numbers_list_val_width(unsigned short, "0x%hx", delim, "hx", check_ushort);numbers_list_val_width (short,"0x%hx" , delim,"hi" , check_short); }then I got:
[ 6625.895391] KTAP version 1 [ 6625.895928] 1..1 [ 6625.896494] KTAP version 1 [ 6625.896852] # Subtest: scanf [ 6625.897191] # module: scanf_kunit [ 6625.897198] 1..10 [ 6625.903479] ok 1 numbers_simple [ 6625.903490] KTAP version 1 [ 6625.904352] # Subtest: numbers_list [ 6625.905623] ok 1 " " [ 6625.907654] ok 2 ":" [ 6625.909654] ok 3 "," [ 6625.911564] ok 4 "-" [ 6625.913632] ok 5 "/" [ 6625.914020] # numbers_list: pass:5 fail:0 skip:0 total:5 [ 6625.914370] ok 2 numbers_list [ 6625.914964] KTAP version 1 [ 6625.915871] # Subtest: numbers_list_field_width_typemax [ 6625.917527] ok 1 " " [ 6625.919366] ok 2 ":" [ 6625.921586] ok 3 "," [ 6625.923240] ok 4 "-" [ 6625.925226] ok 5 "/" [ 6625.925622] # numbers_list_field_width_typemax: pass:5 fail:0 skip:0 total:5 [ 6625.925973] ok 3 numbers_list_field_width_typemax [ 6625.926709] KTAP version 1 [ 6625.927613] # Subtest: numbers_list_field_width_val_width [ 6625.928546] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1044578334 (0x3e43001e) *pval == 837828163 (0x31f03e43) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.929225] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 837828163 (0x31f03e43) *pval == 0 (0x0) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.932202] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 12784 (0x31f0) *pval == 2624608151 (0x9c705797) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.934982] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 0 (0x0) *pval == 1966080 (0x1e0000) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.935004] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1469513728 (0x57970000) *pval == 837828163 (0x31f03e43) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.935025] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 2624608151 (0x9c705797) *pval == 0 (0x0) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.935046] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 469802096 (0x1c009c70) *pval == 2624608151 (0x9c705797) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) [ 6625.938161] not ok 1 " " [ 6625.952074] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 131073 (0x20001) *pval == 65538 (0x10002) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.952098] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 65538 (0x10002) *pval == 1038822 (0xfd9e6) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.952121] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3655729153 (0xd9e60001) *pval == 3848735038 (0xe567093e) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.952143] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1038822 (0xfd9e6) *pval == 65542 (0x10006) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.960548] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 155058191 (0x93e000f) *pval == 65538 (0x10002) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.960579] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3848735038 (0xe567093e) *pval == 1038822 (0xfd9e6) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.960604] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 50390375 (0x300e567) *pval == 3848735038 (0xe567093e) vsscanf("6:1:2:1:d9e6:f:93e:e567", "%1hx:%1hx:%1hx:%1hx:%4hx:%1hx:%3hx:%4hx", ...) [ 6625.969351] not ok 2 ":" [ 6625.969860] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3589275648 (0xd5f00000) *pval == 3768047088 (0xe097d5f0) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.972121] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3768047088 (0xe097d5f0) *pval == 878575619 (0x345e0003) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.972139] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 254103 (0x3e097) *pval == 2832859455 (0xa8da013f) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.976800] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 878575619 (0x345e0003) *pval == 0 (0x0) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.976819] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 20919390 (0x13f345e) *pval == 3768047088 (0xe097d5f0) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.976836] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 2832859455 (0xa8da013f) *pval == 878575619 (0x345e0003) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.976853] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3691030746 (0xdc00a8da) *pval == 2832859455 (0xa8da013f) vsscanf("0,0,d5f0,e097,3,345e,13f,a8da", "%1hx,%1hx,%4hx,%4hx,%1hx,%4hx,%3hx,%4hx", ...) [ 6625.979505] not ok 3 "," [ 6625.989303] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1475084289 (0x57ec0001) *pval == 3243268076 (0xc15057ec) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.989324] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3243268076 (0xc15057ec) *pval == 21 (0x15) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.989343] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1425744 (0x15c150) *pval == 786439 (0xc0007) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.994177] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 21 (0x15) *pval == 65537 (0x10001) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.994196] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 458752 (0x70000) *pval == 3243268076 (0xc15057ec) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.994214] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 786439 (0xc0007) *pval == 21 (0x15) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6625.994232] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3858759692 (0xe600000c) *pval == 786439 (0xc0007) vsscanf("1-1-57ec-c150-15-0-7-c", "%1hx-%1hx-%4hx-%4hx-%2hx-%1hx-%1hx-%1hx", ...) [ 6626.003487] not ok 4 "-" [ 6626.004021] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 3901554741 (0xe88d0035) *pval == 125069 (0x1e88d) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.006206] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 125069 (0x1e88d) *pval == 1821114368 (0x6c8c0000) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.006226] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1 (0x1) *pval == 65543 (0x10007) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.006243] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1821114368 (0x6c8c0000) *pval == 3502806 (0x3572d6) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.006261] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 486540 (0x76c8c) *pval == 125069 (0x1e88d) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.015404] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 65543 (0x10007) *pval == 1821114368 (0x6c8c0000) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.015423] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1828716545 (0x6d000001) *pval == 65543 (0x10007) vsscanf("72d6/35/e88d/1/0/6c8c/7/1", "%4hx/%2hx/%4hx/%1hx/%1hx/%4hx/%1hx/%1hx", ...) [ 6626.018041] not ok 5 "/" [ 6626.022529] # numbers_list_field_width_val_width: pass:0 fail:5 skip:0 total:5 [ 6626.022535] not ok 4 numbers_list_field_width_val_width [ 6626.023220] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 106936 (0x1a1b8) *pval == 571539457 (0x22110001) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024017] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 571539457 (0x22110001) *pval == 81562 (0x13e9a) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024035] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1050288657 (0x3e9a2211) *pval == 91449567 (0x57368df) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024053] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 81562 (0x13e9a) *pval == 2713242046 (0xa1b8c9be) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024073] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1759444993 (0x68df0001) *pval == 571539457 (0x22110001) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024091] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 91449567 (0x57368df) *pval == 81562 (0x13e9a) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.024108] # numbers_slice: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1107297651 (0x42000573) *pval == 91449567 (0x57368df) vsscanf("c9bea1b8122113e9a168df573", "%4hx%4hx%1hx%4hx%4hx%1hx%4hx%3hx", ...) [ 6626.026607] not ok 5 numbers_slice [ 6626.039801] ok 6 numbers_prefix_overflow [ 6626.040522] ok 7 test_simple_strtoull [ 6626.041433] ok 8 test_simple_strtoll [ 6626.042409] ok 9 test_simple_strtoul [ 6626.043153] ok 10 test_simple_strtol [ 6626.043161] # scanf: pass:8 fail:2 skip:0 total:10 [ 6626.043166] # Totals: pass:16 fail:6 skip:0 total:22 [ 6626.043170] not ok 1 scanfI like that the log better points to the test:
[ 6625.927613] # Subtest: numbers_list_field_width_val_widthBut
Quoted 7 lines
[ 6625.928546] # numbers_list_field_width_val_width: EXPECTATION FAILED at lib/scanf_kunit.c:91 Expected got == *pval, but got == 1044578334 (0x3e43001e) *pval == 837828163 (0x31f03e43) vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...)is much harder to parse than the original
Yeah, I find that hard to look at as well. I'll revert this to the original format.
Quoted 7 lines
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881Also I wonder why the scanned string is different:
vsscanf("0 1e 3e43 31f0 0 0 5797 9c70", "%1hx %2hx %4hx %4hx %1hx %1hx %4hx %4hx", ...) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
vs.
[ 383.100048] test_scanf: vsscanf("1574 9 64ca 935b 7 142d ff58 0", "%4hx %1hx %4hx %4hx %1hx %4hx %4hx %1hx", ...) expected 2472240330 got 1690959881 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^I would expect that the 1st error would be on the same string in both tests. I wonder why it differs.
This is just because the order in which the tests run has changed. These strings come from a PRNG. Before the last patch the tests did (pseudocode):
for (delim : delims) {
for (test : tests) {
test(delim)
}
}
After the last patch the inner and outer loops have traded places.
Quoted 3 lines
Best Regards,
Petr