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

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

commit 6358b481fb693f0740be34163d6aed67ec1a4975
Author: yangguangcai <[email protected]>
AuthorDate: Wed Dec 13 15:17:42 2023 +0800

    test/watchdog:add test case for capture.
    
    Signed-off-by: yangguangcai <[email protected]>
---
 testing/drivertest/drivertest_watchdog.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/testing/drivertest/drivertest_watchdog.c 
b/testing/drivertest/drivertest_watchdog.c
index a5ba7a8b9..85e94a606 100644
--- a/testing/drivertest/drivertest_watchdog.c
+++ b/testing/drivertest/drivertest_watchdog.c
@@ -83,6 +83,8 @@ struct wdg_state_s
   bool test_getstatus;
 };
 
+static sem_t g_semaphore;
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -272,6 +274,16 @@ static void parse_commandline(FAR struct wdg_state_s 
*wdg_state, int argc,
     }
 }
 
+/****************************************************************************
+ * Name: capture_callback
+ ****************************************************************************/
+
+static int capture_callback(int irq, FAR void *context, FAR void *arg)
+{
+  sem_post(&g_semaphore);
+  return OK;
+}
+
 /****************************************************************************
  * Name: test_case_wdog_01
  *
@@ -425,6 +437,7 @@ static void test_case_wdog_04(FAR void **state)
   FAR struct wdg_state_s *wdg_state;
   struct watchdog_status_s status;
   struct boardioc_reset_cause_s reset_cause;
+  struct watchdog_capture_s watchdog_capture;
 
   wdg_state = (FAR struct wdg_state_s *)*state;
 
@@ -467,6 +480,22 @@ static void test_case_wdog_04(FAR void **state)
       assert_return_code(ret, OK);
     }
 
+  /* Test capture. */
+
+  ret = sem_init(&g_semaphore, 0, 0);
+  assert_return_code(ret, OK);
+
+  watchdog_capture.newhandler = capture_callback;
+  ret = ioctl(dev_fd, WDIOC_CAPTURE, &watchdog_capture);
+  assert_return_code(ret, OK);
+
+  sem_wait(&g_semaphore);
+  sem_destroy(&g_semaphore);
+
+  watchdog_capture.newhandler = watchdog_capture.oldhandler;
+  ret = ioctl(dev_fd, WDIOC_CAPTURE, &watchdog_capture);
+  assert_return_code(ret, OK);
+
   /* Then stop pinging */
 
   ret = ioctl(dev_fd, WDIOC_STOP, 0);

Reply via email to