This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new b89cb4160 testing/drivers/taskwdt: test the watchdog task monitor.
b89cb4160 is described below

commit b89cb4160afecd8fbff863a7afe923cf7ef21b95
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Sat Oct 24 09:47:16 2026 -0300

    testing/drivers/taskwdt: test the watchdog task monitor.
    
    The task watchdog supervisor is now the task monitor of the watchdog upper
    half, CONFIG_WATCHDOG_TASKMONITOR, and its channels are opened on
    CONFIG_WATCHDOG_DEVPATH instead of CONFIG_TASKWDT_DEVPATH.
    
    Depend on the new option and include nuttx/timers/watchdog.h. The ioctl that
    must fail with ENOTTY is an unused request, as the task monitor does not
    forward the other commands to the lower half. Add the handoff case: a thread
    opens a channel and another one feeds it, which a channel per open file
    description must allow.
    
    Assisted-by: Claude Code:claude-sonnet-5-5
    Signed-off-by: Daniel P. Carvalho <[email protected]>
---
 testing/drivers/taskwdt/Kconfig        |  4 ++--
 testing/drivers/taskwdt/taskwdt_test.c | 33 +++++++++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/testing/drivers/taskwdt/Kconfig b/testing/drivers/taskwdt/Kconfig
index 8979bbfe7..b95525d69 100644
--- a/testing/drivers/taskwdt/Kconfig
+++ b/testing/drivers/taskwdt/Kconfig
@@ -6,9 +6,9 @@
 config TESTING_TASKWDT
        bool "Task watchdog supervisor test (taskwdt_test)"
        default n
-       depends on TASKWDT
+       depends on WATCHDOG_TASKMONITOR
        ---help---
-               Test the task watchdog supervisor (CONFIG_TASKWDT). Run
+               Test the task watchdog supervisor 
(CONFIG_WATCHDOG_TASKMONITOR). Run
                "taskwdt_test" without arguments for the list of test cases. The
                cases that must not reset the system print PASS or FAIL, the
                others stop feeding on purpose and expect the system to reset.
diff --git a/testing/drivers/taskwdt/taskwdt_test.c 
b/testing/drivers/taskwdt/taskwdt_test.c
index 7fa7f230c..54fefad74 100644
--- a/testing/drivers/taskwdt/taskwdt_test.c
+++ b/testing/drivers/taskwdt/taskwdt_test.c
@@ -40,7 +40,7 @@
 #include <unistd.h>
 
 #include <nuttx/irq.h>
-#include <nuttx/timers/taskwdt.h>
+#include <nuttx/timers/watchdog.h>
 
 /****************************************************************************
  * Pre-processor Definitions
@@ -79,6 +79,7 @@ static int case_exit(unsigned int timeout_ms);
 static int case_kill(unsigned int timeout_ms);
 static int case_two(unsigned int timeout_ms);
 static int case_late(unsigned int timeout_ms);
+static int case_handoff(unsigned int sec);
 static int case_hog(unsigned int sec);
 static int case_hang(unsigned int sec);
 
@@ -102,6 +103,7 @@ static const struct testcase_s g_cases[] =
   { "kill", case_kill, 2000, true, "ms: task deleted, channel armed" },
   { "two", case_two, 2000, true, "ms: only one of two threads feeds" },
   { "late", case_late, 1000, true, "ms: feeding resumes after expiry" },
+  { "handoff", case_handoff, 12, false, "sec: one opens, another feeds" },
   { "hog", case_hog, 0, true, "scheduler locked, work queue starves" },
   { "hang", case_hang, 0, true, "interrupts disabled" }
 };
@@ -112,11 +114,11 @@ static const struct testcase_s g_cases[] =
 
 static int chan_open(unsigned int timeout_ms)
 {
-  int fd = open(CONFIG_TASKWDT_DEVPATH, O_WRONLY);
+  int fd = open(CONFIG_WATCHDOG_DEVPATH, O_WRONLY);
 
   if (fd < 0)
     {
-      printf("open %s failed: %d\n", CONFIG_TASKWDT_DEVPATH, errno);
+      printf("open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno);
       return -1;
     }
 
@@ -381,7 +383,7 @@ static int case_errors(unsigned int arg)
       return fail("errors", "GETSTATUS NULL must fail with EINVAL");
     }
 
-  if (ioctl(fd, WDIOC_CAPTURE, 0) >= 0 || errno != ENOTTY)
+  if (ioctl(fd, _WDIOC(0x7f), 0) >= 0 || errno != ENOTTY)
     {
       return fail("errors", "unknown ioctl must fail with ENOTTY");
     }
@@ -528,6 +530,29 @@ static int case_late(unsigned int timeout_ms)
   return EXIT_FAILURE;
 }
 
+static FAR void *thread_handoff(FAR void *arg)
+{
+  feed_for((int)(uintptr_t)arg, 12, false);
+  return NULL;
+}
+
+static int case_handoff(unsigned int sec)
+{
+  pthread_t thread;
+  int fd = chan_open(2000);
+
+  if (fd < 0)
+    {
+      return EXIT_FAILURE;
+    }
+
+  pthread_create(&thread, NULL, thread_handoff, (FAR void *)(uintptr_t)fd);
+  pthread_join(thread, NULL);
+  write(fd, "V", 1);
+  close(fd);
+  return pass("handoff");
+}
+
 static int case_hog(unsigned int sec)
 {
   /* Nothing else runs, in particular not the low priority work queue

Reply via email to