예제 #1
0
//--------------------------------------------------------------------------------------------------
static void TestMdc_Handler ( void )
{
    le_result_t res;

    /* Create the thread to subcribe and call the handlers */
    ThreadSemaphore = le_sem_Create("HandlerSem",0);
    le_thread_Ref_t thread = le_thread_Create("Threadhandler", ThreadTestHandler, NULL);
    le_thread_Start(thread);
    int i;
    le_clk_Time_t   timeToWait;
    timeToWait.sec = 0;
    timeToWait.usec = 1000000;

    /* Wait the thread to be ready */
    le_sem_Wait(ThreadSemaphore);

    for (i = 0; i < NB_PROFILE; i++)
    {
        /* Start a session for the current profile: the handler should be called */
        res = le_mdc_StartSession(ProfileRef[i]);
        LE_ASSERT(res == LE_OK);
        /* Wait for the call of the handler (error if timeout) */
        LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, timeToWait) == LE_OK);
        /* Check the the handler parameters */
        LE_ASSERT(ProfileRefReceivedByHandler == ProfileRef[i]);
        LE_ASSERT(ConnectionStateReceivedByHandler == true);
        ConnectionStateReceivedByHandler = false;
    }

    for (i = 0; i < NB_PROFILE; i++)
    {
        /* Stop a session for the current profile: the handler should be called */
        res = le_mdc_StopSession(ProfileRef[i]);
        LE_ASSERT(res == LE_OK);
        /* Wait for the call of the handler (error if timeout) */
        LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, timeToWait) == LE_OK);
        /* Check the the handler parameters */
        LE_ASSERT(ProfileRefReceivedByHandler == ProfileRef[i]);
        LE_ASSERT(ConnectionStateReceivedByHandler == false);
        ConnectionStateReceivedByHandler = true;
    }

    /* Remove the handler of the profile 1: ther handler can be removed only by the thread which
     * subscribed to the handler, so put the RemoveHandler() function in queue of this thread */
    le_event_QueueFunctionToThread(         thread,
                                            RemoveHandler,
                                            SessionStateHandler[1],
                                            NULL);
    le_sem_Wait(ThreadSemaphore);
    /* Start a session for the current profile: no handler should be called */
    res = le_mdc_StartSession(ProfileRef[1]);
    /* No semaphore post is waiting, we are expecting a timeout */
    LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, timeToWait) == LE_TIMEOUT);
    res = le_mdc_StopSession(ProfileRef[1]);
    /* No semaphore post is waiting, we are expecting a timeout */
    LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, timeToWait) == LE_TIMEOUT);

}
예제 #2
0
//--------------------------------------------------------------------------------------------------
void simTest_SimPowerUpDown
(
    void
)
{
    le_sim_States_t  state;
    le_sim_Id_t simId;
    le_result_t res;
    le_clk_Time_t timeOut;

    //set timeout seconds for waiting for asynchronous power down event.
    timeOut.sec = 5;
    timeOut.usec = 0;

    SimPowerCycleSemaphore = le_sem_Create("HandlerSimPowerCycle", 0);

    SimPowerCycleThreadRef= le_thread_Create("ThreadSimPowerCycle", SimPowerCycleIndThread, NULL);

    le_thread_Start(SimPowerCycleThreadRef);

    // get blocked here until our event handler is registered and powerCycle thread is running
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);

    // Power down cases
    simId = le_sim_GetSelectedCard();
    state = le_sim_GetState(simId);
    LE_INFO("test: SIM state %d", state);
    LE_ASSERT(LE_SIM_READY == state);
    LE_ASSERT_OK(le_sim_SetPower(simId, LE_OFF));

    // Wait for complete asynchronous event of powered down (LE_SIM_POWER_DOWN)
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);
    LE_INFO("Powers Down current SIM: success");

    // Power up cases
    LE_ASSERT_OK(le_sim_SetPower(simId, LE_ON));
    // Wait for complete asynchronous event of powered up  (LE_SIM_READY)
    res = le_sem_WaitWithTimeOut(SimPowerCycleSemaphore, timeOut);
    LE_ASSERT_OK(res);
    LE_INFO("Powers On current SIM: success");

    // Remove the handler
    le_sim_RemoveNewStateHandler(SimPowerCycleHdlrRef);

    // cancel the power cycle test thread
    le_thread_Cancel(SimPowerCycleThreadRef);
}
예제 #3
0
파일: main.c 프로젝트: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
void Testle_ecall_RemoveHandlers
(
    void
)
{
    int i;

    // Remove handlers: add le_ecall_RemoveStateChangeHandler to the eventLoop of tasks
    for (i=0; i<NB_CLIENT; i++)
    {
        le_event_QueueFunctionToThread(AppCtx[i].appThreadRef,
                                       RemoveHandler,
                                       &AppCtx[i],
                                       NULL);
    }

    // Wait for the tasks
    SynchTest();

    // Provoke event which should call the handlers
    pa_ecallSimu_ReportEcallState(LE_ECALL_STATE_STARTED);

    // Wait for the semaphore timeout to check that handlers are not called
    LE_ASSERT( le_sem_WaitWithTimeOut(ThreadSemaphore, TimeToWait) == LE_TIMEOUT );
}
예제 #4
0
파일: main.c 프로젝트: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
void TestSim_RemoveHandlers
(
    void
)
{
    int i;

    // Remove handlers: add le_sim_RemoveNewStateHandler and le_sim_RemoveSimToolkitEventHandler
    // to the eventLoop of tasks
    for (i=0; i<NB_CLIENT; i++)
    {
        le_event_QueueFunctionToThread( AppCtx[i].appThreadRef,
                                        RemoveHandler,
                                        &AppCtx[i],
                                        NULL );
    }

    // Wait for the tasks
    SynchTest();

    // Provoke events which called the handlers (sim state event, and stk event)

    // Go into ABSENT state
    CurrentSimState = LE_SIM_ABSENT;
    pa_simSimu_ReportSimState(CurrentSimState);

    // Invoke Stk event, and check that no handler is called
    pa_simSimu_ReportStkEvent(StkEvent);

    // Wait for the semaphore timeout to check that handlers are not called
    LE_ASSERT( le_sem_WaitWithTimeOut(ThreadSemaphore, TimeToWait) == LE_TIMEOUT );
}
예제 #5
0
//--------------------------------------------------------------------------------------------------
static void TestMdc_StartStopAsync
(
    void
)
{
    le_clk_Time_t   timeToWait;
    timeToWait.sec = 0;
    timeToWait.usec = 1000000;

    const StartStopAsyncFunc_t testFunc[] = { le_mdc_StartSessionAsync,
                                              le_mdc_StopSessionAsync,
                                              NULL
                                            };
    int i=0;

    while (testFunc[i])
    {
        le_thread_Ref_t testThread = le_thread_Create("AsyncStartStopSessionThread",
                                                      AsyncStartStopSessionThread,
                                                      testFunc[i]);

        // Start the thread
        le_thread_Start(testThread);

        LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, timeToWait) != LE_TIMEOUT);

        le_thread_Cancel(testThread);

        i++;
    }
}
예제 #6
0
파일: main.c 프로젝트: H-H-bin/legato-af
//--------------------------------------------------------------------------------------------------
static void Testle_Temp_RemoveHandlers
(
    void
)
{
    int i;

    // Remove handlers: add le_temp_RemoveThresholdEventHandler to the eventLoop of tasks
    for (i=0; i<NB_CLIENT; i++)
    {
        le_event_QueueFunctionToThread( AppCtx[i].appThreadRef,
                                        RemoveHandler,
                                        &AppCtx[i],
                                        NULL );
    }

    // Wait for the tasks
    SynchTest();

    // trigger an event report
    ExpectedStatus = 0;
    pa_tempSimu_TriggerEventReport(ExpectedStatus);

    // Wait for the semaphore timeout to check that handlers are not called
    LE_ASSERT( le_sem_WaitWithTimeOut(ThreadSemaphore, TimeToWait) == LE_TIMEOUT );
}
예제 #7
0
파일: main.c 프로젝트: tegoo/legato-af
//--------------------------------------------------------------------------------------------------
static void SynchTest( void )
{
    int i=0;

    for (;i<NB_CLIENT;i++)
    {
        LE_ASSERT(le_sem_WaitWithTimeOut(ThreadSemaphore, TimeToWait) == LE_OK);
    }
}