[PATCH] sppps01: Add test case for early returns of pps_event()

Gabriel Moyano gabriel.moyano at dlr.de
Wed Jun 15 13:08:30 UTC 2022


---
 testsuites/sptests/sppps01/init.c | 42 +++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/testsuites/sptests/sppps01/init.c b/testsuites/sptests/sppps01/init.c
index 996a3a1e16..ee3fe1645b 100644
--- a/testsuites/sptests/sppps01/init.c
+++ b/testsuites/sptests/sppps01/init.c
@@ -76,6 +76,48 @@ T_TEST_CASE( WaitPPSEventDefaultHandler )
   T_eq_int( status, ETIMEDOUT );
 }
 
+static int wokenup = 0;
+
+static void fake_wakeup(struct pps_state *pps)
+{
+    wokenup++;
+}
+
+T_TEST_CASE( PPSEventEarlyReturns )
+{
+  struct test_pps_device pps_dev;
+
+  wokenup = 0;
+  pps_dev.task_waiting = RTEMS_INVALID_ID;
+
+  memset( &pps_dev.pps, 0, sizeof( pps_dev.pps ) );
+  pps_dev.pps.ppscap = PPS_CAPTUREBOTH;
+  pps_init_abi( &pps_dev.pps );
+  pps_dev.pps.wakeup = fake_wakeup;
+  pps_dev.pps.ppsparam.mode = PPS_CAPTUREASSERT;
+
+  pps_capture( &pps_dev.pps );
+  /* Trigger event with a different event than the one previously selected */
+  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
+  T_eq_int( wokenup, 0 );
+
+  pps_dev.pps.ppsparam.mode = PPS_CAPTURECLEAR;
+
+  /* Wait th_generation to be updated */
+  rtems_task_wake_after(1);
+  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
+  T_eq_int( wokenup, 0 );
+
+  /* Save current timecounter in pps_state object */
+  pps_capture( &pps_dev.pps );
+  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
+  T_eq_int( wokenup, 0 );
+
+  pps_capture( &pps_dev.pps );
+  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
+  T_eq_int( wokenup, 1 );
+}
+
 static void wakeup(struct pps_state *pps)
 {
   struct test_pps_device *pps_dev;
-- 
2.25.1



More information about the devel mailing list