Changeset eefaf068 in rtems


Ignore:
Timestamp:
07/01/22 06:36:30 (6 weeks ago)
Author:
Gabriel Moyano <gabriel.moyano@…>
Branches:
master
Children:
22015c0
Parents:
03e4d1e9
git-author:
Gabriel Moyano <gabriel.moyano@…> (07/01/22 06:36:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/05/22 13:17:15)
Message:

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

Update #2349.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/sppps01/init.c

    r03e4d1e9 reefaf068  
    4747  struct pps_state pps;
    4848  rtems_id task_waiting;
     49  int wokenup;
    4950};
    5051
     
    6061  struct pps_fetch_args fetch;
    6162
     63  memset( &pps_dev, 0, sizeof( pps_dev ) );
    6264  pps_dev.task_waiting = RTEMS_INVALID_ID;
    6365
    64   memset( &pps_dev.pps, 0, sizeof( pps_dev.pps ) );
    6566  pps_dev.pps.ppscap = PPS_CAPTUREBOTH;
    6667  pps_init_abi( &pps_dev.pps );
     
    7778}
    7879
     80static void fake_wakeup(struct pps_state *pps)
     81{
     82  struct test_pps_device *pps_dev;
     83
     84  pps_dev = RTEMS_CONTAINER_OF( pps, struct test_pps_device, pps );
     85  pps_dev->wokenup++;
     86}
     87
     88T_TEST_CASE( PPSEventEarlyReturns )
     89{
     90  struct test_pps_device pps_dev;
     91
     92  memset( &pps_dev, 0, sizeof( pps_dev ) );
     93  pps_dev.task_waiting = RTEMS_INVALID_ID;
     94
     95  pps_dev.pps.ppscap = PPS_CAPTUREBOTH;
     96  pps_init_abi( &pps_dev.pps );
     97  pps_dev.pps.wakeup = fake_wakeup;
     98  pps_dev.pps.ppsparam.mode = PPS_CAPTUREASSERT;
     99
     100  pps_capture( &pps_dev.pps );
     101  /* Trigger event with a different event than the one previously selected */
     102  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
     103  T_eq_int( pps_dev.wokenup, 0 );
     104
     105  pps_dev.pps.ppsparam.mode = PPS_CAPTURECLEAR;
     106
     107  /* Wait th_generation to be updated */
     108  rtems_task_wake_after(1);
     109  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
     110  T_eq_int( pps_dev.wokenup, 0 );
     111
     112  /* Save current timecounter in pps_state object */
     113  pps_capture( &pps_dev.pps );
     114  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
     115  T_eq_int( pps_dev.wokenup, 0 );
     116
     117  pps_capture( &pps_dev.pps );
     118  pps_event( &pps_dev.pps, PPS_CAPTURECLEAR );
     119  T_eq_int( pps_dev.wokenup, 1 );
     120}
     121
    79122static void wakeup(struct pps_state *pps)
    80123{
     
    121164  T_rsc_success( sc );
    122165
    123   rtems_task_delete(rtems_task_self());
     166  rtems_task_exit();
    124167}
    125168
     
    135178  rtems_event_set out;
    136179
     180  memset( &pps_dev, 0, sizeof( pps_dev ) );
    137181  pps_dev.task_waiting = RTEMS_INVALID_ID;
    138182  ctx.pps_dev = &pps_dev;
    139183  ctx.main_task = rtems_task_self();
    140184
    141   memset( &pps_dev.pps, 0, sizeof( pps_dev.pps ) );
    142185  pps_dev.pps.ppscap = PPS_CAPTUREBOTH;
    143186  pps_init_abi( &pps_dev.pps );
Note: See TracChangeset for help on using the changeset viewer.