Ticket #758: pjlib-test.diff

File pjlib-test.diff, 4.6 KB (added by bennylp, 15 years ago)

Cleaning up to run pjlib-test on Symbian

  • pjlib/src/pj/ioqueue_symbian.cpp

     
    213213    } else { 
    214214        aAddress_.SetAddress(0); 
    215215        aAddress_.SetPort(0); 
    216         sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 
     216 
     217        //sock_->Socket().Recv(aBufferPtr_, flags, iStatus); 
     218        static TSockXfrLength len; 
     219        sock_->Socket().RecvOneOrMore(aBufferPtr_, flags, iStatus, len); 
    217220    } 
    218221 
    219222    SetActive(); 
  • pjlib/src/pjlib-test/main_symbian.cpp

     
    4444LOCAL_D CConsoleBase* console;  // write all messages to this 
    4545 
    4646 
    47 //  Local Functions 
    48  
    49 LOCAL_C void MainL() 
    50 { 
    51     // 
    52     // add your program code here, example code below 
    53     // 
    54     test_main(); 
    55  
    56     console->Printf(_L(" [press any key]\n")); 
    57     console->Getch(); 
    58  
    59     CActiveScheduler::Stop(); 
    60 } 
    61  
    6247class MyScheduler : public CActiveScheduler 
    6348{ 
    6449public: 
     
    7358    PJ_UNUSED_ARG(aError); 
    7459} 
    7560 
    76 class ProgramStarter : public CActive 
    77 { 
    78 public: 
    79     static ProgramStarter *NewL(); 
    80     void Start(); 
    81  
    82 protected: 
    83     ProgramStarter(); 
    84     void ConstructL(); 
    85     virtual void RunL(); 
    86     virtual void DoCancel(); 
    87     TInt RunError(TInt aError); 
    88  
    89 private: 
    90     RTimer timer_; 
    91 }; 
    92  
    93 ProgramStarter::ProgramStarter() 
    94 : CActive(EPriorityNormal) 
    95 { 
    96 } 
    97  
    98 void ProgramStarter::ConstructL() 
    99 { 
    100     timer_.CreateLocal(); 
    101     CActiveScheduler::Add(this); 
    102 } 
    103  
    104 ProgramStarter *ProgramStarter::NewL() 
    105 { 
    106     ProgramStarter *self = new (ELeave) ProgramStarter; 
    107     CleanupStack::PushL(self); 
    108  
    109     self->ConstructL(); 
    110  
    111     CleanupStack::Pop(self); 
    112     return self; 
    113 } 
    114  
    115 void ProgramStarter::Start() 
    116 { 
    117     timer_.After(iStatus, 0); 
    118     SetActive(); 
    119 } 
    120  
    121 void ProgramStarter::RunL() 
    122 { 
    123     MainL(); 
    124 } 
    125  
    126 void ProgramStarter::DoCancel() 
    127 { 
    128 } 
    129  
    130 TInt ProgramStarter::RunError(TInt aError) 
    131 { 
    132     PJ_UNUSED_ARG(aError); 
    133     return KErrNone; 
    134 } 
    135  
    136  
    13761LOCAL_C void DoStartL() 
    13862    { 
    13963    // Create active scheduler (to run active objects) 
     
    14165    CleanupStack::PushL(scheduler); 
    14266    CActiveScheduler::Install(scheduler); 
    14367 
    144     ProgramStarter *starter = ProgramStarter::NewL(); 
    145     starter->Start(); 
     68    test_main(); 
    14669 
    147     CActiveScheduler::Start(); 
     70    CActiveScheduler::Install(NULL); 
     71    CleanupStack::Pop(scheduler); 
     72    delete scheduler; 
    14873    } 
    14974 
    15075 
     
    180105    TRAPD(mainError, DoStartL()); 
    181106    if (mainError) 
    182107        console->Printf(_L(" failed, leave code = %d"), mainError); 
     108     
    183109    console->Printf(_L(" [press any key]\n")); 
    184110    console->Getch(); 
    185111     
    186112    delete console; 
    187113    delete cleanup; 
     114     
     115    CloseSTDLIB();  
     116     
    188117    __UHEAP_MARKEND; 
     118     
    189119    return KErrNone; 
    190120    } 
    191121 
  • pjlib/src/pjlib-test/activesock.c

     
    212212 
    213213        for (i=0; i<10 && last_rx1 == srv1->rx_cnt && last_rx2 == srv2->rx_cnt; ++i) { 
    214214            pj_time_val delay = {0, 10}; 
     215#ifdef PJ_SYMBIAN 
     216            pj_symbianos_poll(-1, 100); 
     217#else 
    215218            pj_ioqueue_poll(ioqueue, &delay); 
     219#endif 
    216220        } 
    217221 
    218222        if (srv1->rx_err_cnt+srv1->tx_err_cnt != 0 || 
     
    403407        status = pj_activesock_send(asock2, &op_key->op_key, pkt, &len, 0); 
    404408        if (status == PJ_EPENDING) { 
    405409            do { 
     410#ifdef PJ_SYMBIAN 
     411                pj_symbianos_poll(-1, -1); 
     412#else 
    406413                pj_ioqueue_poll(ioqueue, NULL); 
     414#endif 
    407415            } while (!state2->sent); 
    408416        } else if (status != PJ_SUCCESS) { 
    409417                PJ_LOG(1,("", "   err: send status=%d", status)); 
     
    420428 
    421429    /* Wait until everything has been sent/received */ 
    422430    if (state1->next_recv_seq < COUNT) { 
     431#ifdef PJ_SYMBIAN 
     432        while (pj_symbianos_poll(-1, 1000) == PJ_TRUE) 
     433            ; 
     434#else 
    423435        pj_time_val delay = {0, 100}; 
    424436        while (pj_ioqueue_poll(ioqueue, &delay) > 0) 
    425437            ; 
     438#endif 
    426439    } 
    427440 
    428441    if (status == PJ_EPENDING) 
  • pjlib/src/pjlib-test/test.c

     
    197197        PJ_LOG(3,("test", "Looks like everything is okay!..")); 
    198198    else 
    199199        PJ_LOG(3,("test", "Test completed with error(s)")); 
     200     
     201    pj_shutdown(); 
     202     
    200203    return 0; 
    201204}