Ignore:
Timestamp:
Mar 28, 2011, 4:31:05 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) break the mac build and introduce new crashes.

This is partially to address #4145 "Downloads stuck at 100%" by refactoring the bitset, bitfield, and tr_completion; however, the ripple effect is larger than usual so things may get worse in the short term before getting better.

livings124: to fix the mac build, remove bitset.[ch] from xcode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils-test.c

    r12204 r12248  
    5656    int count2;
    5757    const int bitCount = 100 + tr_cryptoWeakRandInt( 1000 );
    58     tr_bitfield * bf;
     58    tr_bitfield bf;
    5959
    6060    /* generate a random bitfield */
    61     bf = tr_bitfieldNew( bitCount );
     61    tr_bitfieldConstruct( &bf, bitCount );
    6262    for( i=0, n=tr_cryptoWeakRandInt(bitCount); i<n; ++i )
    63         tr_bitfieldAdd( bf, tr_cryptoWeakRandInt(bitCount) );
     63        tr_bitfieldAdd( &bf, tr_cryptoWeakRandInt(bitCount) );
    6464
    6565    begin = tr_cryptoWeakRandInt( bitCount );
     
    7575    count1 = 0;
    7676    for( i=begin; i<end; ++i )
    77         if( tr_bitfieldHas( bf, i ) )
     77        if( tr_bitfieldHas( &bf, i ) )
    7878            ++count1;
    79     count2 = tr_bitfieldCountRange( bf, begin, end );
     79    count2 = tr_bitfieldCountRange( &bf, begin, end );
    8080    check( count1 == count2 );
    8181
    82     tr_bitfieldFree( bf );
     82    tr_bitfieldDestruct( &bf );
    8383    return 0;
    8484}
     
    8888{
    8989    unsigned int  i;
    90     unsigned int  bitcount = 5000000;
    91     tr_bitfield * field = tr_bitfieldNew( bitcount );
     90    unsigned int  bitcount = 500;
     91    tr_bitfield field;
     92
     93    tr_bitfieldConstruct( &field, bitcount );
    9294
    9395    /* test tr_bitfieldAdd */
    9496    for( i = 0; i < bitcount; ++i )
    9597        if( !( i % 7 ) )
    96             tr_bitfieldAdd( field, i );
     98            tr_bitfieldAdd( &field, i );
    9799    for( i = 0; i < bitcount; ++i )
    98         check( tr_bitfieldHas( field, i ) == ( !( i % 7 ) ) );
     100        check( tr_bitfieldHas( &field, i ) == ( !( i % 7 ) ) );
    99101
    100102    /* test tr_bitfieldAddRange */
    101     tr_bitfieldAddRange( field, 0, bitcount );
     103    tr_bitfieldAddRange( &field, 0, bitcount );
    102104    for( i = 0; i < bitcount; ++i )
    103         check( tr_bitfieldHas( field, i ) );
     105        check( tr_bitfieldHas( &field, i ) );
    104106
    105107    /* test tr_bitfieldRemRange in the middle of a boundary */
    106     tr_bitfieldRemRange( field, 4, 21 );
     108    tr_bitfieldRemRange( &field, 4, 21 );
    107109    for( i = 0; i < 64; ++i )
    108         check( tr_bitfieldHas( field, i ) == ( ( i < 4 ) || ( i >= 21 ) ) );
     110        check( tr_bitfieldHas( &field, i ) == ( ( i < 4 ) || ( i >= 21 ) ) );
    109111
    110112    /* test tr_bitfieldRemRange on the boundaries */
    111     tr_bitfieldAddRange( field, 0, 64 );
    112     tr_bitfieldRemRange( field, 8, 24 );
     113    tr_bitfieldAddRange( &field, 0, 64 );
     114    tr_bitfieldRemRange( &field, 8, 24 );
    113115    for( i = 0; i < 64; ++i )
    114         check( tr_bitfieldHas( field, i ) == ( ( i < 8 ) || ( i >= 24 ) ) );
     116        check( tr_bitfieldHas( &field, i ) == ( ( i < 8 ) || ( i >= 24 ) ) );
    115117
    116118    /* test tr_bitfieldRemRange when begin & end is on the same word */
    117     tr_bitfieldAddRange( field, 0, 64 );
    118     tr_bitfieldRemRange( field, 4, 5 );
     119    tr_bitfieldAddRange( &field, 0, 64 );
     120    tr_bitfieldRemRange( &field, 4, 5 );
    119121    for( i = 0; i < 64; ++i )
    120         check( tr_bitfieldHas( field, i ) == ( ( i < 4 ) || ( i >= 5 ) ) );
     122        check( tr_bitfieldHas( &field, i ) == ( ( i < 4 ) || ( i >= 5 ) ) );
    121123
    122124    /* test tr_bitfieldAddRange */
    123     tr_bitfieldRemRange( field, 0, 64 );
    124     tr_bitfieldAddRange( field, 4, 21 );
     125    tr_bitfieldRemRange( &field, 0, 64 );
     126    tr_bitfieldAddRange( &field, 4, 21 );
    125127    for( i = 0; i < 64; ++i )
    126         check( tr_bitfieldHas( field, i ) == ( ( 4 <= i ) && ( i < 21 ) ) );
     128        check( tr_bitfieldHas( &field, i ) == ( ( 4 <= i ) && ( i < 21 ) ) );
    127129
    128130    /* test tr_bitfieldAddRange on the boundaries */
    129     tr_bitfieldRemRange( field, 0, 64 );
    130     tr_bitfieldAddRange( field, 8, 24 );
     131    tr_bitfieldRemRange( &field, 0, 64 );
     132    tr_bitfieldAddRange( &field, 8, 24 );
    131133    for( i = 0; i < 64; ++i )
    132         check( tr_bitfieldHas( field, i ) == ( ( 8 <= i ) && ( i < 24 ) ) );
     134        check( tr_bitfieldHas( &field, i ) == ( ( 8 <= i ) && ( i < 24 ) ) );
    133135
    134136    /* test tr_bitfieldAddRange when begin & end is on the same word */
    135     tr_bitfieldRemRange( field, 0, 64 );
    136     tr_bitfieldAddRange( field, 4, 5 );
     137    tr_bitfieldRemRange( &field, 0, 64 );
     138    tr_bitfieldAddRange( &field, 4, 5 );
    137139    for( i = 0; i < 64; ++i )
    138         check( tr_bitfieldHas( field, i ) == ( ( 4 <= i ) && ( i < 5 ) ) );
    139 
    140     tr_bitfieldFree( field );
     140        check( tr_bitfieldHas( &field, i ) == ( ( 4 <= i ) && ( i < 5 ) ) );
     141
     142    tr_bitfieldDestruct( &field );
    141143    return 0;
    142144}
     
    514516
    515517    /* bitfield count range */
    516     for( l=0; l<1000000; ++l )
     518    for( l=0; l<10000; ++l )
    517519        if(( i = test_bitfield_count_range( )))
    518520            return i;
Note: See TracChangeset for help on using the changeset viewer.