Re: [PATCH 1/4] kunit: Drop redundant text from suite init failure message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 26 Sept 2023 at 01:58, Michal Wajdeczko
<michal.wajdeczko@xxxxxxxxx> wrote:
>
> If a suite initialization fails, then our diagnostic message
> will include redundant indent and hash sign as all this was
> already added by the kunit_printk() used by kunit_err() macro.
>
> This could be easily seen if we force some error in our example
> test by modyfing example_test_init_suite() and running:
>
> $ ./tools/testing/kunit/kunit.py run --raw_output \
>         --kunitconfig ./lib/kunit/.kunitconfig "example.*"
>
>     KTAP version 1
>     1..1
>         # example: initializing suite
>         # example:     # failed to initialize (-19)
>     not ok 1 example
>
> Fix that and while around improve error code reporting by using
> error pointer format %pe that gives more user friendly output:
>
>     KTAP version 1
>     1..1
>         # example: initializing suite
>         # example: failed to initialize (-ENODEV)
>     not ok 1 example
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx>
> Cc: David Gow <davidgow@xxxxxxxxxx>
> Cc: Rae Moar <rmoar@xxxxxxxxxx>
> ---

Nice catch!

Reviewed-by: David Gow <davidgow@xxxxxxxxxx>

Cheers,
-- David


>  lib/kunit/test.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index f2eb71f1a66c..fb5981ce578d 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -568,8 +568,8 @@ int kunit_run_tests(struct kunit_suite *suite)
>         if (suite->suite_init) {
>                 suite->suite_init_err = suite->suite_init(suite);
>                 if (suite->suite_init_err) {
> -                       kunit_err(suite, KUNIT_SUBTEST_INDENT
> -                                 "# failed to initialize (%d)", suite->suite_init_err);
> +                       kunit_err(suite, "failed to initialize (%pe)",
> +                                 ERR_PTR(suite->suite_init_err));
>                         goto suite_end;
>                 }
>         }
> --
> 2.25.1
>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux