Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D76D7C64EC4 for ; Wed, 8 Mar 2023 05:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbjCHFFG (ORCPT ); Wed, 8 Mar 2023 00:05:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjCHFFC (ORCPT ); Wed, 8 Mar 2023 00:05:02 -0500 Received: from mail-ua1-x935.google.com (mail-ua1-x935.google.com [IPv6:2607:f8b0:4864:20::935]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CA656520 for ; Tue, 7 Mar 2023 21:05:00 -0800 (PST) Received: by mail-ua1-x935.google.com with SMTP id s23so10484050uae.5 for ; Tue, 07 Mar 2023 21:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678251900; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TUgAiKGNBQP/RT6jDIpMkTdO4LKmep+w3zslDTHUJSw=; b=hjr6/ClcBHmby++uzpvGtT/exSzwgGikBiwnk7PVB46zEK0NwWZW0E9GN02Q+TKLWG JJvnlxknz2ymOol370mgMiMbsOjZD2K75x3+RXUtmoeoTG7TADYvyw3d40zmt0ka9TQL 2cR61sw0JsOspmprax3QGNDftn4qvj2KOKDeZQSoLthzaYRBjCSernrccI3T2O8YBUdm sE0XKVu2FKWL4AZ3k/Sslqaiw7Mi9a0YJ/0mSe9Cd+WdFEbuz3c3MsFcgpRu2ASK/JGe ResCnTImb/9YmaZn5af+0nKzmHl6JExjmdNeCdxexDJZIi9BoICuvHb7s0A7XWzUEKcO 95ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678251900; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TUgAiKGNBQP/RT6jDIpMkTdO4LKmep+w3zslDTHUJSw=; b=iMkJXBr/RXVxPernp/jmCCXrt8YYmoBqx/YbDwsmcyxS/acB2sArIg43cZnRf2tR+W XMRc50To40+9w50EDeB1pxnxx/ibIg1+dOFHwdyWlVbeuCdECUKR+X79hbI5UuIqodV5 CFcnj+3pApKtfXszIuJaadT9UJLrC0DelZj+fqBUOc5x7UfOS/Wj41eeu67Ji2eURTrD i2lycC7bCTzkluToqW7M+MfcNHa65gtf4Twi6fOGSH19ICj08ObHJbbeYetLpEzu0NW6 XsiXCEabKs1m4L0+y/Qyp8F90ZaOXK+lj7M0t2Ri3tZ02zUAdWEOvSvvSXtzQB0b3dDy 8tVg== X-Gm-Message-State: AO0yUKWUUcE962p7Lmun21WAd0UK3KnLYPLvQY76ADfIhWiMqYYV8GnR l+9IN+a0s9taNPwiCUHiD4rUDJF9qlUbwQdg9QwXdA== X-Google-Smtp-Source: AK7set+4BUMsZ732fMW7noscfMsWblY0Bhmaj33UYRsgJCLObqhOnsFjfnZedoRcCJTf3jS5REOFPoRa49M6ces089Y= X-Received: by 2002:ab0:4714:0:b0:68e:2ed3:92eb with SMTP id h20-20020ab04714000000b0068e2ed392ebmr5275409uac.1.1678251899774; Tue, 07 Mar 2023 21:04:59 -0800 (PST) MIME-Version: 1.0 References: <20230307223937.2892762-1-rmoar@google.com> In-Reply-To: <20230307223937.2892762-1-rmoar@google.com> From: David Gow Date: Wed, 8 Mar 2023 13:04:47 +0800 Message-ID: Subject: Re: [PATCH v3 1/3] kunit: fix bug in debugfs logs of parameterized tests To: Rae Moar Cc: brendanhiggins@google.com, dlatypov@google.com, skhan@linuxfoundation.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000005aa91a05f65c78ec" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000005aa91a05f65c78ec Content-Type: text/plain; charset="UTF-8" On Wed, 8 Mar 2023 at 06:39, Rae Moar wrote: > > Fix bug in debugfs logs that causes individual parameterized results to not > appear because the log is reinitialized (cleared) when each parameter is > run. > > Ensure these results appear in the debugfs logs, increase log size to > allow for the size of parameterized results. As a result, append lines to > the log directly rather than using an intermediate variable that can cause > stack size warnings due to the increased log size. > > Here is the debugfs log of ext4_inode_test which uses parameterized tests > before the fix: > > KTAP version 1 > > # Subtest: ext4_inode_test > 1..1 > # Totals: pass:16 fail:0 skip:0 total:16 > ok 1 ext4_inode_test > > As you can see, this log does not include any of the individual > parametrized results. > > After (in combination with the next two fixes to remove extra empty line > and ensure KTAP valid format): > > KTAP version 1 > 1..1 > KTAP version 1 > # Subtest: ext4_inode_test > 1..1 > KTAP version 1 > # Subtest: inode_test_xtimestamp_decoding > ok 1 1901-12-13 Lower bound of 32bit < 0 timestamp, no extra bits > ... (the rest of the individual parameterized tests) > ok 16 2446-05-10 Upper bound of 32bit >=0 timestamp. All extra > # inode_test_xtimestamp_decoding: pass:16 fail:0 skip:0 total:16 > ok 1 inode_test_xtimestamp_decoding > # Totals: pass:16 fail:0 skip:0 total:16 > ok 1 ext4_inode_test > > Signed-off-by: Rae Moar > Reviewed-by: David Gow > --- Thanks, this is working fine here! Reviewed-by: David Gow Cheers, -- David > > Changes from v2 -> v3: > - Fix a off-by-one bug in the kunit_log_append method. > > Changes from v1 -> v2: > - Remove the use of the line variable in kunit_log_append that was causing > stack size warnings. > - Add before and after to the commit message. > > include/kunit/test.h | 2 +- > lib/kunit/test.c | 18 ++++++++++++------ > 2 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/include/kunit/test.h b/include/kunit/test.h > index 08d3559dd703..0668d29f3453 100644 > --- a/include/kunit/test.h > +++ b/include/kunit/test.h > @@ -34,7 +34,7 @@ DECLARE_STATIC_KEY_FALSE(kunit_running); > struct kunit; > > /* Size of log associated with test. */ > -#define KUNIT_LOG_SIZE 512 > +#define KUNIT_LOG_SIZE 1500 > > /* Maximum size of parameter description string. */ > #define KUNIT_PARAM_DESC_SIZE 128 > diff --git a/lib/kunit/test.c b/lib/kunit/test.c > index c9e15bb60058..c4d6304edd61 100644 > --- a/lib/kunit/test.c > +++ b/lib/kunit/test.c > @@ -114,22 +114,27 @@ static void kunit_print_test_stats(struct kunit *test, > */ > void kunit_log_append(char *log, const char *fmt, ...) > { > - char line[KUNIT_LOG_SIZE]; > va_list args; > - int len_left; > + int len, log_len, len_left; > > if (!log) > return; > > - len_left = KUNIT_LOG_SIZE - strlen(log) - 1; > + log_len = strlen(log); > + len_left = KUNIT_LOG_SIZE - log_len - 1; > if (len_left <= 0) > return; > > + /* Evaluate length of line to add to log */ > va_start(args, fmt); > - vsnprintf(line, sizeof(line), fmt, args); > + len = vsnprintf(NULL, 0, fmt, args) + 1; > + va_end(args); > + > + /* Print formatted line to the log */ > + va_start(args, fmt); > + vsnprintf(log + log_len, min(len, len_left), fmt, args); > va_end(args); > > - strncat(log, line, len_left); > } > EXPORT_SYMBOL_GPL(kunit_log_append); > > @@ -437,7 +442,6 @@ static void kunit_run_case_catch_errors(struct kunit_suite *suite, > struct kunit_try_catch_context context; > struct kunit_try_catch *try_catch; > > - kunit_init_test(test, test_case->name, test_case->log); > try_catch = &test->try_catch; > > kunit_try_catch_init(try_catch, > @@ -533,6 +537,8 @@ int kunit_run_tests(struct kunit_suite *suite) > struct kunit_result_stats param_stats = { 0 }; > test_case->status = KUNIT_SKIPPED; > > + kunit_init_test(&test, test_case->name, test_case->log); > + > if (!test_case->generate_params) { > /* Non-parameterised test. */ > kunit_run_case_catch_errors(suite, test_case, &test); > > base-commit: 60684c2bd35064043360e6f716d1b7c20e967b7d > -- > 2.40.0.rc0.216.gc4246ad0f0-goog > --0000000000005aa91a05f65c78ec Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIPnwYJKoZIhvcNAQcCoIIPkDCCD4wCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg ggz5MIIEtjCCA56gAwIBAgIQeAMYYHb81ngUVR0WyMTzqzANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA3MjgwMDAwMDBaFw0yOTAzMTgwMDAwMDBaMFQxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSowKAYDVQQDEyFHbG9iYWxTaWduIEF0bGFz IFIzIFNNSU1FIENBIDIwMjAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvLe9xPU9W dpiHLAvX7kFnaFZPuJLey7LYaMO8P/xSngB9IN73mVc7YiLov12Fekdtn5kL8PjmDBEvTYmWsuQS 6VBo3vdlqqXZ0M9eMkjcKqijrmDRleudEoPDzTumwQ18VB/3I+vbN039HIaRQ5x+NHGiPHVfk6Rx c6KAbYceyeqqfuJEcq23vhTdium/Bf5hHqYUhuJwnBQ+dAUcFndUKMJrth6lHeoifkbw2bv81zxJ I9cvIy516+oUekqiSFGfzAqByv41OrgLV4fLGCDH3yRh1tj7EtV3l2TngqtrDLUs5R+sWIItPa/4 AJXB1Q3nGNl2tNjVpcSn0uJ7aFPbAgMBAAGjggGKMIIBhjAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0l BBYwFAYIKwYBBQUHAwIGCCsGAQUFBwMEMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFHzM CmjXouseLHIb0c1dlW+N+/JjMB8GA1UdIwQYMBaAF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