Beispiel #1
0
/******************************************************************************
**  Function:  CFE_PSP_DeleteOSResources()
**
**  Purpose:
**    Clean up any OS resources when exiting from the cFE
**
**  Arguments:
**    (none)
**
**  Return:
**    (none)
*/
void CFE_PSP_DeleteOSResources (void)
{
   uint32          i;
   int32           ReturnCode;

   for ( i = 0; i < OS_MAX_TASKS; i++)
      ReturnCode = OS_TaskDelete(i);
   printf("CFE_PSP: Deleted all Tasks in system\n");
   
   for ( i = 0; i < OS_MAX_BIN_SEMAPHORES; i++ )
      ReturnCode = OS_BinSemDelete(i);
   printf("CFE_PSP: Deleted all Binary Semaphores in system\n");
      
   for ( i = 0; i < OS_MAX_COUNT_SEMAPHORES; i++ )
      ReturnCode = OS_CountSemDelete(i);
   printf("CFE_PSP: Deleted all Counting Semaphores in system\n");
   
   for ( i = 0; i < OS_MAX_MUTEXES; i++ )
      ReturnCode = OS_MutSemDelete(i);
   printf("CFE_PSP: Deleted all Mutexes in system\n");

   for ( i = 0; i < OS_MAX_QUEUES; i++ )
      ReturnCode = OS_QueueDelete(i);
   printf("CFE_PSP: Deleted all Queues in system\n");
  
   for ( i = 0; i < OS_MAX_TIMERS; i++ )
      ReturnCode = OS_TimerDelete(i);
   printf("CFE_PSP: Deleted all Timers in system\n");
 
   printf("CFE_PSP: NOTE: After quitting the cFE with a Control-C signal, it MUST be started next time\n");
   printf("     with a Poweron Reset ( --reset PO ). \n");
   
}
static void test_004_001_execute(void) {

  /* [4.1.1] OS_BinSemCreate() is invoked with sem_id set to NULL, an
     error is expected.*/
  test_set_step(1);
  {
    int32 err;

    err = OS_BinSemCreate(NULL,                     /* Error.*/
                         "failing semaphore",
                         0,
                         0);
    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
  }

  /* [4.1.2] OS_BinSemCreate() is invoked with sem_name set to NULL, an
     error is expected.*/
  test_set_step(2);
  {
    int32 err;

    err = OS_BinSemCreate(&bsid,
                         NULL,                      /* Error.*/
                         0,
                         0);
    test_assert(err == OS_INVALID_POINTER, "NULL not detected");
  }

  /* [4.1.3] OS_BinSemCreate() is invoked with an invalid
     sem_initial_value, an error is expected.*/
  test_set_step(3);
  {
    int32 err;

    err = OS_BinSemCreate(&bsid,
                         "failing semaphore",
                         2,                         /* Error.*/
                         0);
    test_assert(err == OS_INVALID_INT_NUM, "counter error not detected");
  }

  /* [4.1.4] OS_BinSemCreate() is invoked with a very long timer name,
     an error is expected.*/
  test_set_step(4);
  {
#if 0 /* Semaphore name currently not implemented.*/
    int32 err;

    err = OS_BinSemCreate(&bsid,
                         "very very long semaphore name",   /* Error.*/
                         0,
                         0);
    test_assert(err == OS_ERR_NAME_TOO_LONG, "name limit not detected");
#endif
  }

  /* [4.1.5] OS_BinSemDelete() is invoked with timer_id set to -1, an
     error is expected.*/
  test_set_step(5);
  {
    int32 err;

    err = OS_BinSemDelete((uint32)-1);
    test_assert(err == OS_ERR_INVALID_ID, "wrong semaphore id not detected");
  }

  /* [4.1.6] OS_BinSemCreate() is invoked twice with duplicated name,
     an error is expected, then the queue is deleted using
     OS_BinSemDelete().*/
  test_set_step(6);
  {
    int32 err;
    uint32 bsid1; /*, bsid2;*/

    err = OS_BinSemCreate(&bsid1, "my semaphore", 0, 0);
    test_assert(err == OS_SUCCESS, "semaphore creation failed");

#if 0 /* Semaphore name currently not implemented.*/
    err = OS_BinSemCreate(&bsid2, "my semaphore", 0, 0);
    test_assert(err == OS_ERR_NAME_TAKEN, "name conflict not detected");
#endif

    err = OS_BinSemDelete(bsid1);
    test_assert(err == OS_SUCCESS, "semaphore deletion failed");
  }
}
static void test_004_007_teardown(void) {
  if (bsid > 0) {
    (void) OS_BinSemDelete(bsid);
  }
}