This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 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 1985c6667 testing/drivers/taskwdt: test a channel that is changed
after it expired.
1985c6667 is described below
commit 1985c6667bb8d578fb5540e898919a146b0a36e9
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Wed Oct 28 17:06:34 2026 -0300
testing/drivers/taskwdt: test a channel that is changed after it expired.
A task that is late by less than the keepalive interval must not escape
the supervision by changing its channel before the monitor notices it:
add the cases latestop (WDIOC_STOP), latev ('V' write) and latestart
(WDIOC_START), which must end in a reset like the late case does.
Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Daniel P. Carvalho <[email protected]>
---
testing/drivers/taskwdt/taskwdt_test.c | 54 ++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/testing/drivers/taskwdt/taskwdt_test.c
b/testing/drivers/taskwdt/taskwdt_test.c
index 54fefad74..954251d0e 100644
--- a/testing/drivers/taskwdt/taskwdt_test.c
+++ b/testing/drivers/taskwdt/taskwdt_test.c
@@ -79,6 +79,9 @@ 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_latestop(unsigned int timeout_ms);
+static int case_latev(unsigned int timeout_ms);
+static int case_latestart(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);
@@ -103,6 +106,9 @@ 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" },
+ { "latestop", case_latestop, 500, true, "ms: WDIOC_STOP after expiry" },
+ { "latev", case_latev, 500, true, "ms: 'V' after expiry" },
+ { "latestart", case_latestart, 500, true, "ms: WDIOC_START 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" }
@@ -530,6 +536,54 @@ static int case_late(unsigned int timeout_ms)
return EXIT_FAILURE;
}
+/* A task that is late must not escape by changing its channel, before the
+ * monitor notices that it is late. Wait a little more than the timeout,
+ * less than the keepalive interval, and try.
+ */
+
+static int late_op(unsigned int timeout_ms, int cmd)
+{
+ int fd = chan_open(timeout_ms);
+
+ if (fd < 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ usleep((timeout_ms + timeout_ms / 5) * 1000);
+
+ if (cmd == 0)
+ {
+ write(fd, "V", 1);
+ printf("channel of %u ms late, then a 'V'\n", timeout_ms);
+ }
+ else
+ {
+ ioctl(fd, cmd, 0);
+ printf("channel of %u ms late, then %s\n", timeout_ms,
+ cmd == WDIOC_STOP ? "WDIOC_STOP" : "WDIOC_START");
+ }
+
+ feed_for(fd, 60, true);
+ printf("FAIL: no reset after the timeout, changing the channel\n");
+ return EXIT_FAILURE;
+}
+
+static int case_latestop(unsigned int timeout_ms)
+{
+ return late_op(timeout_ms, WDIOC_STOP);
+}
+
+static int case_latev(unsigned int timeout_ms)
+{
+ return late_op(timeout_ms, 0);
+}
+
+static int case_latestart(unsigned int timeout_ms)
+{
+ return late_op(timeout_ms, WDIOC_START);
+}
+
static FAR void *thread_handoff(FAR void *arg)
{
feed_for((int)(uintptr_t)arg, 12, false);