From: Shuah Khan <skhan@linuxfoundation.org>
To: Laura Nao <laura.nao@collabora.com>
Cc: kernel@collabora.com, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, shuah@kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 1/2] selftests/watchdog: limit ping loop and allow configuring the number of pings
Date: Wed, 3 Jul 2024 17:10:59 -0600 [thread overview]
Message-ID: <6b2bca6d-61e8-40f6-b3b1-3a81dfb2b397@linuxfoundation.org> (raw)
In-Reply-To: <20240703144855.89747-1-laura.nao@collabora.com>
On 7/3/24 08:48, Laura Nao wrote:
> On 6/27/24 20:48, Shuah Khan wrote:
>> On 5/6/24 05:13, Laura Nao wrote:
>>> In order to run the watchdog selftest with the kselftest runner, the
>>> loop responsible for pinging the watchdog should be finite. This
>>> change limits the loop to 5 iterations by default and introduces a new
>>> '-c' option to adjust the number of pings as needed.
>>
>> This patch makes the test run finite in all cases changing the bevavior
>> to run it forever?
>
> Correct.
>
>>>
>>> Signed-off-by: Laura Nao <laura.nao@collabora.com>
>>> ---
>>> tools/testing/selftests/watchdog/watchdog-test.c | 16 ++++++++++++++--
>>> 1 file changed, 14 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/watchdog/watchdog-test.c
>>> b/tools/testing/selftests/watchdog/watchdog-test.c
>>> index bc71cbca0dde..786cc5a26206 100644
>>> --- a/tools/testing/selftests/watchdog/watchdog-test.c
>>> +++ b/tools/testing/selftests/watchdog/watchdog-test.c
>>> @@ -24,16 +24,18 @@
>>> #include <linux/watchdog.h>
>>> #define DEFAULT_PING_RATE 1
>>> +#define DEFAULT_PING_COUNT 5
>>> int fd;
>>> const char v = 'V';
>>> -static const char sopts[] = "bdehp:st:Tn:NLf:i";
>>> +static const char sopts[] = "bdehp:c:st:Tn:NLf:i";
>>> static const struct option lopts[] = {
>>> {"bootstatus", no_argument, NULL, 'b'},
>>> {"disable", no_argument, NULL, 'd'},
>>> {"enable", no_argument, NULL, 'e'},
>>> {"help", no_argument, NULL, 'h'},
>>> {"pingrate", required_argument, NULL, 'p'},
>>> + {"pingcount", required_argument, NULL, 'c'},
>>> {"status", no_argument, NULL, 's'},
>>> {"timeout", required_argument, NULL, 't'},
>>> {"gettimeout", no_argument, NULL, 'T'},
>>> @@ -90,6 +92,8 @@ static void usage(char *progname)
>>> printf(" -h, --help\t\tPrint the help message\n");
>>> printf(" -p, --pingrate=P\tSet ping rate to P seconds (default
>>> %d)\n",
>>> DEFAULT_PING_RATE);
>>> + printf(" -c, --pingcount=C\tSet number of pings to C (default
>>> %d)\n",
>>> + DEFAULT_PING_COUNT);
>>> printf(" -t, --timeout=T\tSet timeout to T seconds\n");
>>> printf(" -T, --gettimeout\tGet the timeout\n");
>>> printf(" -n, --pretimeout=T\tSet the pretimeout to T seconds\n");
>>> @@ -172,6 +176,7 @@ int main(int argc, char *argv[])
>>> {
>>> int flags;
>>> unsigned int ping_rate = DEFAULT_PING_RATE;
>>> + unsigned int ping_count = DEFAULT_PING_COUNT;
>>> int ret;
>>> int c;
>>> int oneshot = 0;
>>> @@ -248,6 +253,12 @@ int main(int argc, char *argv[])
>>> ping_rate = DEFAULT_PING_RATE;
>>> printf("Watchdog ping rate set to %u seconds.\n",
>>> ping_rate);
>>> break;
>>> + case 'c':
>>> + ping_count = strtoul(optarg, NULL, 0);
>>> + if (!ping_count)
>>> + ping_count = DEFAULT_PING_COUNT;
>>> + printf("Number of pings set to %u.\n", ping_count);
>>> + break;
>>> case 's':
>>> flags = 0;
>>> oneshot = 1;
>>> @@ -336,9 +347,10 @@ int main(int argc, char *argv[])
>>> signal(SIGINT, term);
>>> - while (1) {
>>> + while (ping_count > 0) {
>>> keep_alive();
>>> sleep(ping_rate);
>>> + ping_count--;
>>
>> So this test no longer runs forever?
>>
>
> That's correct, with this patch applied the test no longer runs forever.
> I understand you prefer the current behavior - how about keeping the
> keep_alive() loop infinite by default and only making it finite when the
> -c argument is passed? Would that be reasonable?
>
Yes. I am open to taking the patch if the default behavior doesn't change.
thanks,
-- Shuah
next prev parent reply other threads:[~2024-07-03 23:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-06 11:13 [PATCH 0/2] Modify the watchdog selftest for execution with kselftest runner Laura Nao
2024-05-06 11:13 ` [PATCH 1/2] selftests/watchdog: limit ping loop and allow configuring the number of pings Laura Nao
2024-06-27 18:48 ` Shuah Khan
2024-07-03 14:48 ` Laura Nao
2024-07-03 23:10 ` Shuah Khan [this message]
2024-05-06 11:13 ` [PATCH 2/2] selftests/watchdog: convert the test output to KTAP format Laura Nao
2024-06-27 18:41 ` Shuah Khan
2024-07-03 14:49 ` Laura Nao
2024-06-06 9:57 ` [PATCH 0/2] Modify the watchdog selftest for execution with Laura Nao
2024-06-06 23:03 ` Shuah Khan
2024-06-07 9:53 ` Laura Nao
2024-06-07 21:07 ` Shuah Khan
2024-06-18 13:40 ` Laura Nao
2024-06-21 21:08 ` Shuah Khan
2024-06-24 15:00 ` Laura Nao
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=6b2bca6d-61e8-40f6-b3b1-3a81dfb2b397@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=kernel@collabora.com \
--cc=laura.nao@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@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