From patchwork Fri Oct 21 22:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 617394 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 E78C2C3A59D for ; Fri, 21 Oct 2022 22:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbiJUWS0 (ORCPT ); Fri, 21 Oct 2022 18:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiJUWSY (ORCPT ); Fri, 21 Oct 2022 18:18:24 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA9F2AB119 for ; Fri, 21 Oct 2022 15:18:23 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id n73so3452755iod.13 for ; Fri, 21 Oct 2022 15:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BZvHy7jdg7bn/NJGr1GFQwTrExyfPTldTZ+sxF4fBFk=; b=DPPzQn6bpnBujPZ4Po2qLVhYnKyqqB56z+hRzedBT+NeViwX3jGWzdOS1lofPngvYL 0qf2JZIGX5bKY6sUyjWrRR90ki955StSmKMtrfGaqk79n8luJpEQ527LqW78kcgn0wyx cnvmOnTqlf4WGWa5dQKEeCEZLXZdrLNoea3t4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BZvHy7jdg7bn/NJGr1GFQwTrExyfPTldTZ+sxF4fBFk=; b=wuEmwRFUuHc/q27Uj5gw7RZYgRF7P9w/kNJ5a3BGKqPNc58Toaq6wfSuDafMZrT2O5 jPfNuDupaEbwLHu/gWWdStP3clwnwSM7aYnLhQi1Ifhu3nqMcq6PnPoZtPZsjEZKgEPf DGeZjB6Oqacc096/Jo2A8bCgKcVdXdBPR4LEDxTNTGpprNVKPYmwLdZ3P84K6kaNNb28 Ddb22cGycEHmsV0BK7hkc8kuQr1uhu881WnoqumOWHZqY/puvr0ttUVfu6Tz5xNtumZI 08Lwfm/5fTPM5HakDOl/R/LDdVlm+E6UwXx7le1xBCikNe/rh5eiOdz9vfhQHqlf59k0 nrXg== X-Gm-Message-State: ACrzQf1ejaHeF4tEUkaO/2PQ9qH1EdXahbYQpBitpw7mWgTmXVpDEQAL 19bBGSk8td7H9vCgSmalJDsyaTY+KIVuwQ== X-Google-Smtp-Source: AMsMyM7qFgbQoonCDjTvSpxKOA3uQILHkyAzMUOM9/7JV5qxcrt8wyutiuuLa6ftTC3mxrNHR1LDUQ== X-Received: by 2002:a02:390c:0:b0:363:79f0:ad37 with SMTP id l12-20020a02390c000000b0036379f0ad37mr16856345jaa.95.1666390702490; Fri, 21 Oct 2022 15:18:22 -0700 (PDT) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id cp6-20020a056638480600b0036cc14af7adsm430740jab.149.2022.10.21.15.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 15:18:21 -0700 (PDT) From: Shuah Khan To: skhan@linuxfoundation.org, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] selftests/watchdog: change to print reset reason info. Date: Fri, 21 Oct 2022 16:18:16 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The test prints reset reason when WDIOC_GETBOOTSTATUS returns a 0 flag value and all other cases simply say watchdog. Parse the flag values returned by WDIOC_GETBOOTSTATUS and print corresponding reset reason for each WDIOF_* boot status. Signed-off-by: Shuah Khan --- .../selftests/watchdog/watchdog-test.c | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index f45e510500c0..5db9ad8b543c 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -1,6 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Watchdog Driver Test Program +* Watchdog Driver Test Program +* - Tests all ioctls except WDIOC_GETTEMP +* - Tests Magic Close - CONFIG_WATCHDOG_NOWAYOUT +* - Could be tested against softdog driver on systems that +* don't have watchdog hadrware. +* - TODO: +* - WDIOC_GETSTATUS is called when WDIOC_GETBOOTSTATUS is called. +* - Enhance the logic to call WDIOC_GETSTATUS and test return values. +* - Enhance coverage of ioctl return values - flags and status. +* - Enhance test to add coverage for WDIOC_GETTEMP. +* +* Reference: Documentation/watchdog/watchdog-api.rst */ #include @@ -91,6 +102,44 @@ static void usage(char *progname) printf("Example: %s -t 12 -T -n 7 -N\n", progname); } +struct wdiof_status { + int flag; + const char *status_str; +}; + +#define WDIOF_NUM_BOOTSTATUS 7 + +static const struct wdiof_status wdiof_bootstatus[WDIOF_NUM_BOOTSTATUS] = { + {WDIOF_OVERHEAT, "Reset due to CPU overheat"}, + {WDIOF_FANFAULT, "Fan failed"}, + {WDIOF_EXTERN1, "External relay 1"}, + {WDIOF_EXTERN2, "External relay 2"}, + {WDIOF_POWERUNDER, "Power bad/power fault"}, + {WDIOF_CARDRESET, "Card previously reset the CPU"}, + {WDIOF_POWEROVER, "Power over voltage"}, +}; + +static void print_boot_status(int flags) +{ + int wdiof = 0; + + if (flags == WDIOF_UNKNOWN) { + printf("Unknown flag error from WDIOC_GETBOOTSTATUS\n"); + return; + } + + if (flags == 0) { + printf("Last boot is caused by: Power-On-Reset\n"); + return; + } + + for (wdiof = 0; wdiof < WDIOF_NUM_BOOTSTATUS; wdiof++) { + if (flags & wdiof_bootstatus[wdiof].flag) + printf("Last boot is caused by: %s\n", + wdiof_bootstatus[wdiof].status_str); + } +} + int main(int argc, char *argv[]) { int flags; @@ -140,8 +189,7 @@ int main(int argc, char *argv[]) oneshot = 1; ret = ioctl(fd, WDIOC_GETBOOTSTATUS, &flags); if (!ret) - printf("Last boot is caused by: %s.\n", (flags != 0) ? - "Watchdog" : "Power-On-Reset"); + print_boot_status(flags); else printf("WDIOC_GETBOOTSTATUS error '%s'\n", strerror(errno)); break; @@ -249,6 +297,10 @@ int main(int argc, char *argv[]) sleep(ping_rate); } end: + /* + * Send specific magic character 'V' just in case Magic Close is + * enabled to ensure watchdog gets disabled on close. + */ ret = write(fd, &v, 1); if (ret < 0) printf("Stopping watchdog ticks failed (%d)...\n", errno); From patchwork Fri Oct 21 22:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 618541 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 774AEC3A59D for ; Fri, 21 Oct 2022 22:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiJUWS3 (ORCPT ); Fri, 21 Oct 2022 18:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiJUWS0 (ORCPT ); Fri, 21 Oct 2022 18:18:26 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7150F2AA176 for ; Fri, 21 Oct 2022 15:18:24 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id q18so2377061ils.12 for ; Fri, 21 Oct 2022 15:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mlh6byGTM8abd+hoZXnHkK8wpHen7Kg7enAq8H4CPPg=; b=fx3eYTlJhUHw9ssE2UFhZioTH5qkq8bbUlKoP3gCYFuyZ5CTJ6I30rvFDFt0xTwsls 4FeyxKdYL6SCSn9DwNscDbkvWF5Cg3ZDfomKYrLavJn5sZk98NMu24LI2sAw/kdoHDHA Y5+TArRJuMGxlCjU1GzHehRi13O8t3D21O2iU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mlh6byGTM8abd+hoZXnHkK8wpHen7Kg7enAq8H4CPPg=; b=sJ6M9EcfeV9VQDHgY4EHNp6Eel+H4n8LzIMXnjrHLmG5/kf13tKYtIIJ7+M+fLP3gF vCsJEVrfBe0L3RTPBa3VJSGTPRkH0DjntEzRqcJgsFkRcZe/YngtWdWWeYMS7kzVWkr4 7m1wMpdt3HFQwtx+raATtmiCi+PTXZqGgaYMxNsoc90H3MaM9X643pp+JbzRaLs3c5I1 2lDnwJlJN3lRjF+meincDZ7jK7ryTCBZCganSBEzJelEGUeeZsbe0VGNdq9+Bqs/looF 2kDPNk1I90QvcyF8XyCXUS6sq1TZvkmlVXzxrQf3iP7i6FBdQC3/Ikox0A3IIg+999Ft 8Ahg== X-Gm-Message-State: ACrzQf3lrgrF6bNKb3cwgHjl04fR58vduy9L7OZsipr6i2CK3JXm7rn6 YAgLOmU3JoBKfo7/nNE9gJwzgA== X-Google-Smtp-Source: AMsMyM43+LSyXTj6Uagl4g1vhPUIUEEKVecmTeM5qHOJz02aFGaZpbaeQjHz7HkuHgxm+AAFG65WyA== X-Received: by 2002:a05:6e02:1c0c:b0:2fa:bd75:55a5 with SMTP id l12-20020a056e021c0c00b002fabd7555a5mr15240001ilh.234.1666390703410; Fri, 21 Oct 2022 15:18:23 -0700 (PDT) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id cp6-20020a056638480600b0036cc14af7adsm430740jab.149.2022.10.21.15.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 15:18:22 -0700 (PDT) From: Shuah Khan To: skhan@linuxfoundation.org, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] selftests/watchdog: add support for WDIOC_GETSTATUS Date: Fri, 21 Oct 2022 16:18:17 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add support for calling WDIOC_GETSTATUS and printing supported features and status. Signed-off-by: Shuah Khan --- .../selftests/watchdog/watchdog-test.c | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 5db9ad8b543c..e6af6e327eb3 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -6,8 +6,6 @@ * - Could be tested against softdog driver on systems that * don't have watchdog hadrware. * - TODO: -* - WDIOC_GETSTATUS is called when WDIOC_GETBOOTSTATUS is called. -* - Enhance the logic to call WDIOC_GETSTATUS and test return values. * - Enhance coverage of ioctl return values - flags and status. * - Enhance test to add coverage for WDIOC_GETTEMP. * @@ -30,13 +28,14 @@ int fd; const char v = 'V'; -static const char sopts[] = "bdehp:t:Tn:NLf:i"; +static const char sopts[] = "bdehp: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'}, + {"status", no_argument, NULL, 's'}, {"timeout", required_argument, NULL, 't'}, {"gettimeout", no_argument, NULL, 'T'}, {"pretimeout", required_argument, NULL, 'n'}, @@ -85,6 +84,7 @@ static void usage(char *progname) printf(" -f, --file\t\tOpen watchdog device file\n"); printf("\t\t\tDefault is /dev/watchdog\n"); printf(" -i, --info\t\tShow watchdog_info\n"); + printf(" -s, --status\t\tGet status & supported features\n"); printf(" -b, --bootstatus\tGet last boot status (Watchdog/POR)\n"); printf(" -d, --disable\t\tTurn off the watchdog timer\n"); printf(" -e, --enable\t\tTurn on the watchdog timer\n"); @@ -107,6 +107,35 @@ struct wdiof_status { const char *status_str; }; +#define WDIOF_NUM_STATUS 8 + +static const struct wdiof_status wdiof_status[WDIOF_NUM_STATUS] = { + {WDIOF_SETTIMEOUT, "Set timeout (in seconds)"}, + {WDIOF_MAGICCLOSE, "Supports magic close char"}, + {WDIOF_PRETIMEOUT, "Pretimeout (in seconds), get/set"}, + {WDIOF_ALARMONLY, "Watchdog triggers a management or other external alarm not a reboot"}, + {WDIOF_KEEPALIVEPING, "Keep alive ping reply"}, + {WDIOS_DISABLECARD, "Turn off the watchdog timer"}, + {WDIOS_ENABLECARD, "Turn on the watchdog timer"}, + {WDIOS_TEMPPANIC, "Kernel panic on temperature trip"}, +}; + +static void print_status(int flags) +{ + int wdiof = 0; + + if (flags == WDIOS_UNKNOWN) { + printf("Unknown status error from WDIOC_GETSTATUS\n"); + return; + } + + for (wdiof = 0; wdiof < WDIOF_NUM_STATUS; wdiof++) { + if (flags & wdiof_status[wdiof].flag) + printf("Support/Status: %s\n", + wdiof_status[wdiof].status_str); + } +} + #define WDIOF_NUM_BOOTSTATUS 7 static const struct wdiof_status wdiof_bootstatus[WDIOF_NUM_BOOTSTATUS] = { @@ -219,6 +248,15 @@ int main(int argc, char *argv[]) ping_rate = DEFAULT_PING_RATE; printf("Watchdog ping rate set to %u seconds.\n", ping_rate); break; + case 's': + flags = 0; + oneshot = 1; + ret = ioctl(fd, WDIOC_GETSTATUS, &flags); + if (!ret) + print_status(flags); + else + printf("WDIOC_GETSTATUS error '%s'\n", strerror(errno)); + break; case 't': flags = strtoul(optarg, NULL, 0); ret = ioctl(fd, WDIOC_SETTIMEOUT, &flags); From patchwork Fri Oct 21 22:18:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 617393 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 21D05C433FE for ; Fri, 21 Oct 2022 22:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbiJUWSa (ORCPT ); Fri, 21 Oct 2022 18:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbiJUWS0 (ORCPT ); Fri, 21 Oct 2022 18:18:26 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554542AB114 for ; Fri, 21 Oct 2022 15:18:25 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id l127so3461656iof.12 for ; Fri, 21 Oct 2022 15:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FkcAxJz5UaV/gOoKQ5YqYMglqfBBTV2T6cx36FG5wQc=; b=Sz88s7fjekFj/AV26xOLEymhM3uxOHkIsuexheI2cWmJmITgqMJnr6heCXWUiUcafn Ye40LPs16A7SZaXogZy8xm3jQrBbJ7luV2Gwgkb+sU69uFDtQ9J+RRd24pBz5vUFkRM8 G+NDC+UTbDtvoKMqcdLyT9Y8VfzY9cVRIaWYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FkcAxJz5UaV/gOoKQ5YqYMglqfBBTV2T6cx36FG5wQc=; b=2ASOx7j8u8UKfJzZy1P01Fx0uINzvBSa5IzPvF/T6ABq+yNUXRFlxpK+e1KRSA4M7H 7nsrDeR+ICNeD9uY6orY3NfjJBTpuWiKm3z8nogywt+4Q3Lk9KOqiUciYgaYGrOImysg pL/1rZXXHhk4Dy6LYvERo13A53EDLOJ6+IMi88IYIAODOTGNaewIaQIRGH7bQMfaCuQ4 /a14hcZJWnPOXM4YhX9F6A00ioJ5amMHWYlsPaX+Dnk+a1Xx0mEC9MefVCz2bNaw/soJ yvd21B4BhG26Pu5mZXB+r0ALgJ/CC9ZDnkQBiKclsbvxJhbujqZR2Ne488fariq0YTlC 4CfA== X-Gm-Message-State: ACrzQf3T5DLFbt48SfD4q9kTburn4TSOUDTL3x1WSlIZ5KkVzDu3APh2 y2Y6ycHMc7Ib41KKQRiICZPiWw== X-Google-Smtp-Source: AMsMyM6eMy/U/vUFn+jdgCTz9ehgGzteVfkAgj4cBxe9txPKSPslSBTaqNbPVq3i/pS9NEnlFqxmDw== X-Received: by 2002:a6b:671e:0:b0:6bb:f05a:fb11 with SMTP id b30-20020a6b671e000000b006bbf05afb11mr14278642ioc.74.1666390704312; Fri, 21 Oct 2022 15:18:24 -0700 (PDT) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id cp6-20020a056638480600b0036cc14af7adsm430740jab.149.2022.10.21.15.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 15:18:23 -0700 (PDT) From: Shuah Khan To: skhan@linuxfoundation.org, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] selftests/watchdog: print watchdog_info option strings Date: Fri, 21 Oct 2022 16:18:18 -0600 Message-Id: <2fb04f40e3d3a35fd2b30896202931cf5b9a1311.1666390362.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Change show watchdog_info output to print option strings instead of hex values to make it user friendly and human readable. Signed-off-by: Shuah Khan --- tools/testing/selftests/watchdog/watchdog-test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index e6af6e327eb3..03103eaa946c 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -6,7 +6,6 @@ * - Could be tested against softdog driver on systems that * don't have watchdog hadrware. * - TODO: -* - Enhance coverage of ioctl return values - flags and status. * - Enhance test to add coverage for WDIOC_GETTEMP. * * Reference: Documentation/watchdog/watchdog-api.rst @@ -314,7 +313,7 @@ int main(int argc, char *argv[]) printf(" identity:\t\t%s\n", info.identity); printf(" firmware_version:\t%u\n", info.firmware_version); - printf(" options:\t\t%08x\n", info.options); + print_status(info.options); break; default: From patchwork Fri Oct 21 22:18:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 618540 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 8D00EC433FE for ; Fri, 21 Oct 2022 22:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbiJUWSj (ORCPT ); Fri, 21 Oct 2022 18:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbiJUWS2 (ORCPT ); Fri, 21 Oct 2022 18:18:28 -0400 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF0BB2AB11A for ; Fri, 21 Oct 2022 15:18:26 -0700 (PDT) Received: by mail-il1-x12b.google.com with SMTP id q11so2368200ilj.10 for ; Fri, 21 Oct 2022 15:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xEShaJ32qONw6Ik3PO9e5EbC1hloeWQUD82bcXUGSI8=; b=fEx4OTp+x4ZE3H0fyqrFYVgdQxHMwlNZn9v+cFhrbYHz7TvbhSRwcHFDCONm6rROR8 KZGHntnFCQuRr909vmwZQjb1lJgqJpCwL/jigAYpuLI7eCLxKzlne6Wm2rIiNKrhBxYi CLeJjlNpmomCTYwKuAhN9vxHI8n2g7ByAVVV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xEShaJ32qONw6Ik3PO9e5EbC1hloeWQUD82bcXUGSI8=; b=Ld/XZrCQ6RRueSWKdKjgAbCrLTqhJC6Nkj4H5PuvZgTj1pUiXqmcfC6x3YCGWzSzSv seaLtj9Q78cW48x4CFW6zYbKfRUS8bSSB6PGF5IZDQpc4y1DGp6PXVUuIgBIDlW8JH9p gfFyXGSmAy2+vydb4pq7jPIP8VSBnxaAPXNw+LR9R7SzLozk+Q34wMsvHrsl3NyWbvt0 TrDx5GyLyJNjwoDGFoEkiJrn1RX9QoQmkdpNP5jQD0Tr3EYUxY+gb20VVqPbsllMhnAu bvbS5gXIbwu5XZkbaN+KH9CQ2OxxlPATs90v1ZIRUuxXm4MdqIAArKhzb9OW7mD9WkVL iqpg== X-Gm-Message-State: ACrzQf0YpPSMtZSqvBcpf1WoO3FXxU/ZtLTY+dwfyHENvjiDcfAWTh1O ddlDzZ7uYVxAwPJYA0PQh5CKmQ== X-Google-Smtp-Source: AMsMyM6lM/rYjfxg+jLPtpZy6aJxXUzDKCO0FalDgdayZH+Xuieo7F5XlhyjFLFaCIc2/6eX9SdmgQ== X-Received: by 2002:a05:6e02:184d:b0:2fc:2d17:4fbf with SMTP id b13-20020a056e02184d00b002fc2d174fbfmr14693702ilv.150.1666390705483; Fri, 21 Oct 2022 15:18:25 -0700 (PDT) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id cp6-20020a056638480600b0036cc14af7adsm430740jab.149.2022.10.21.15.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 15:18:24 -0700 (PDT) From: Shuah Khan To: skhan@linuxfoundation.org, shuah@kernel.org Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] selftests/watchdog: add test for WDIOC_GETTEMP Date: Fri, 21 Oct 2022 16:18:19 -0600 Message-Id: <2b559a7d0d2be46729f3a03dc639dd4a69e465bb.1666390362.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add test for WDIOC_GETTEMP and this ioctl might not be supported by some devices and if it is this test will print the following message: Inappropriate ioctl for device Signed-off-by: Shuah Khan --- tools/testing/selftests/watchdog/watchdog-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c index 03103eaa946c..5ec0384b7f02 100644 --- a/tools/testing/selftests/watchdog/watchdog-test.c +++ b/tools/testing/selftests/watchdog/watchdog-test.c @@ -1,12 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* * Watchdog Driver Test Program -* - Tests all ioctls except WDIOC_GETTEMP +* - Tests all ioctls * - Tests Magic Close - CONFIG_WATCHDOG_NOWAYOUT * - Could be tested against softdog driver on systems that * don't have watchdog hadrware. -* - TODO: -* - Enhance test to add coverage for WDIOC_GETTEMP. * * Reference: Documentation/watchdog/watchdog-api.rst */ @@ -177,6 +175,7 @@ int main(int argc, char *argv[]) int oneshot = 0; char *file = "/dev/watchdog"; struct watchdog_info info; + int temperature; setbuf(stdout, NULL); @@ -255,6 +254,12 @@ int main(int argc, char *argv[]) print_status(flags); else printf("WDIOC_GETSTATUS error '%s'\n", strerror(errno)); + ret = ioctl(fd, WDIOC_GETTEMP, &temperature); + if (ret) + printf("WDIOC_GETTEMP: '%s'\n", strerror(errno)); + else + printf("Temeprature: %d\n", temperature); + break; case 't': flags = strtoul(optarg, NULL, 0);