Ignore:
Timestamp:
Mar 7, 2014, 7:39:42 PM (10 years ago)
Author:
hock@…
Message:

TEST_F(SystemQueueTimingTest, MultipleCalls)

which fails, every time.. (but should not)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12753 r12754  
    112112    void OrderedCall(int num)
    113113    {
     114        // XXX
     115        cout << "### OrderedCall num: " << num << endl;
     116       
    114117        // check ordering
    115118        EXPECT_EQ( num, last_ordered_call + 1);
     
    273276 *  but should not lengthen the test excessivly
    274277 */
    275 #define DELAY_TIME 10  // ms
    276 #define DELAY_MARGIN 1000  // microseconds (1/1000 ms)
     278#define DELAY_TIME 20  // ms
     279#define DELAY_MARGIN 2000  // microseconds (1/1000 ms)
    277280
    278281
     
    308311    // scheduleCall
    309312    sysq.scheduleCall(
    310         boost::bind(&SystemQueueTest::Check, this), DELAY_TIME
     313        boost::bind(&SystemQueueTimingTest::Check, this), DELAY_TIME
    311314    );
    312315
    313316    // noting to do until the delay is up..
    314     usleep(DELAY_TIME + DELAY_MARGIN);
     317    usleep(DELAY_TIME + DELAY_MARGIN*10);  // XXX margin too high (TODO lower when SysQ is reimplemented)
    315318   
    316319    // wait for the event to happen
    317320    wait_for_checkmark(MAX_WAIT);
    318321   
    319     EXPECT_TRUE( checkmark ) << "Deleyed function was not called within delaytime ("
     322    EXPECT_TRUE( checkmark ) << "Delayed function was not called within delaytime ("
    320323        << DELAY_TIME << " ms) + " << (MAX_WAIT + DELAY_MARGIN) << " microseconds.";
    321324}
    322325
     326
     327/**
     328 *  schedules a delayed call and tests whether it is called (more or less timely..)
     329 */
     330TEST_F(SystemQueueTimingTest, MultipleCalls)
     331{
     332    // schedule 4th call
     333    sysq.scheduleCall(
     334        boost::bind(&SystemQueueTest::OrderedCall, this, 4),
     335                    DELAY_TIME*3
     336    );
     337   
     338    // schedule 2nd call
     339    sysq.scheduleCall(
     340        boost::bind(&SystemQueueTest::OrderedCall, this, 2),
     341                    DELAY_TIME*1
     342    );
     343   
     344    // schedule 3rd call
     345    sysq.scheduleCall(
     346        boost::bind(&SystemQueueTest::OrderedCall, this, 3),
     347                    DELAY_TIME*2
     348    );
     349
     350    // schedule 1st call (without delay)
     351    sysq.scheduleCall(
     352        boost::bind(&SystemQueueTest::OrderedCall, this, 1)
     353    );
     354   
     355   
     356    // XXX the usual bug..
     357    sysq.scheduleCall(
     358        boost::bind(&SystemQueueTest::Check, this),
     359                    DELAY_TIME*4
     360    );
     361
     362    // noting to do until the delay is up..
     363    usleep(DELAY_TIME*4 + DELAY_MARGIN*100);  // XXX margin too high
     364   
     365    // wait for the event to happen
     366    wait_for_checkmark(MAX_WAIT);
     367   
     368    // evaluation
     369    EXPECT_EQ( 4, last_ordered_call);
     370}
Note: See TracChangeset for help on using the changeset viewer.