Re: [PATCH v2 2/2] selftests: watchdog: get boot reason via WDIOC_GETBOOTSTATUS

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

 



On 05/28/2017 01:58 PM, Eugeniu Rosca wrote:
> Some watchdog drivers implement WDIOF_CARDRESET feature. As example,
> see commit b6ef36d2c1e3 ("watchdog: qcom: Report reboot reason").
> This option allows reporting to userspace the cause of the last boot
> (POR/watchdog reset), being helpful in e.g. automated test-cases.
> 
> Add support for WDIOC_GETBOOTSTATUS in the test code, to be able to
> check whether watchdog drivers properly implement WDIOF_CARDRESET.
> 
> Tested on Rcar-H3 Salvator-X board:
> ********************** Cold boot finished
> salvator-x:/home/root#
> salvator-x:/home/root# ./wdt_test -s -t 1 -p 10 -e
> Last boot is caused by: Power-On-Reset.
> Watchdog timeout set to 1 seconds.
> Watchdog ping rate set to 10 seconds.
> Watchdog card enabled.
> Watchdog Ticking Away!
> ********************** Reboot due to watchdog trigger finished
> salvator-x:/home/root#
> salvator-x:/home/root# ./wdt_test -s
> Last boot is caused by: Watchdog.
> Watchdog Ticking Away!
> .....^C
> Stopping watchdog ticks...
> salvator-x:/home/root# reboot
> ********************** Reboot due to user action finished
> salvator-x:/home/root#
> salvator-x:/home/root# ./wdt_test -s
> Last boot is caused by: Power-On-Reset.
> Watchdog Ticking Away!
> ...^C
> Stopping watchdog ticks...
> salvator-x:/home/root# ./wdt_test --help
> -s to print the status (POR/watchdog) of the last boot,
> -d to disable, -e to enable, -t <n> to set the timeout,
> -p <n> to set the ping rate, and run by itself to tick the card.
> Parameters are parsed left-to-right in real-time.
> Example: ./wdt_test -d -t 10 -p 5 -e
> salvator-x:/home/root#
> 
> Signed-off-by: Eugeniu Rosca <erosca@xxxxxxxxxxxxxx>
> ---
>  tools/testing/selftests/watchdog/watchdog-test.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
> index 11d3e8cfb20c..28826eda69af 100644
> --- a/tools/testing/selftests/watchdog/watchdog-test.c
> +++ b/tools/testing/selftests/watchdog/watchdog-test.c
> @@ -54,6 +54,7 @@ int main(int argc, char *argv[])
>      unsigned int ping_rate = 1;
>      int ret;
>      int i;
> +    int bootstatus;
>  
>      setbuf(stdout, NULL);
>  
> @@ -85,7 +86,15 @@ int main(int argc, char *argv[])
>              ping_rate = strtoul(argv[i + 1], NULL, 0);
>              printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
>              i++;
> +        } else if (!strncasecmp(argv[i], "-s", 2)) {
> +            ret = ioctl(fd, WDIOC_GETBOOTSTATUS, &bootstatus);
> +            if (!ret)
> +                printf("Last boot is caused by: %s.\n", (bootstatus != 0) ?
> +                       "Watchdog" : "Power-On-Reset");
> +            else
> +                printf("Error: WDIOC_GETBOOTSTATUS failed.\n");
>          } else {
> +            printf("-s to print the status (POR/watchdog) of the last boot,\n");
>              printf("-d to disable, -e to enable, -t <n> to set "
>                  "the timeout,\n-p <n> to set the ping rate, and ");
>              printf("run by itself to tick the card.\n");
> 

Please see my responses to cover-letter.

Please add this new argument on top of the patch that converts to
getopt.

thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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