Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: brendanhiggins@google.com
Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Subject: [bug report] kunit: test: add support for test abort
Date: Sat, 18 Apr 2020 20:25:54 +0300	[thread overview]
Message-ID: <20200418172554.GA802865@mwanda> (raw)

Hello Brendan Higgins,

The patch 5f3e06208920: "kunit: test: add support for test abort"
from Sep 23, 2019, leads to the following static checker warning:

	lib/kunit/try-catch.c:93 kunit_try_catch_run()
	misplaced newline? '    # %s: Unknown error: %d

lib/kunit/try-catch.c
    58  void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context)
    59  {
    60          DECLARE_COMPLETION_ONSTACK(try_completion);
    61          struct kunit *test = try_catch->test;
    62          struct task_struct *task_struct;
    63          int exit_code, time_remaining;
    64  
    65          try_catch->context = context;
    66          try_catch->try_completion = &try_completion;
    67          try_catch->try_result = 0;
    68          task_struct = kthread_run(kunit_generic_run_threadfn_adapter,
    69                                    try_catch,
    70                                    "kunit_try_catch_thread");
    71          if (IS_ERR(task_struct)) {
    72                  try_catch->catch(try_catch->context);
    73                  return;
    74          }
    75  
    76          time_remaining = wait_for_completion_timeout(&try_completion,
    77                                                       kunit_test_timeout());
    78          if (time_remaining == 0) {
    79                  kunit_err(test, "try timed out\n");
                                                      ^^
The kunit_log() macro adds its own newline.  Most of the callers add
a newline.  It should be the callers add a newline because that's how
everything else works in the kernel.

The dev_printk() stuff will sometimes add a newline, but never a
duplicate newline.  In other words, it's slightly complicated.  But
basically the caller should add a newline.

    80                  try_catch->try_result = -ETIMEDOUT;
    81          }
    82  
    83          exit_code = try_catch->try_result;
    84  
    85          if (!exit_code)
    86                  return;
    87  
    88          if (exit_code == -EFAULT)
    89                  try_catch->try_result = 0;
    90          else if (exit_code == -EINTR)
    91                  kunit_err(test, "wake_up_process() was never called\n");
                                                                           ^^

    92          else if (exit_code)
    93                  kunit_err(test, "Unknown error: %d\n", exit_code);
                                                          ^^

    94  
    95          try_catch->catch(try_catch->context);
    96  }

regards,
dan carpenter

             reply	other threads:[~2020-04-18 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 17:25 Dan Carpenter [this message]
2020-04-20 16:11 ` [bug report] kunit: test: add support for test abort Brendan Higgins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200418172554.GA802865@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=brendanhiggins@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox