~ubuntu-branches/ubuntu/jaunty/transmission/jaunty-security

« back to all changes in this revision

Viewing changes to libtransmission/blocklist-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2008-11-28 15:33:48 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20081128153348-it70trfnxiroblmc
Tags: 1.40-0ubuntu1
* New upstream release (LP: #302672)
  - Tracker communication uses fewer resources
  - More accurate bandwidth limits
  - Reduce disk fragmentation by preallocating files (LP: #287726)
  - Stability, security and performance improvements to the RPC /
    Web UI server (closes LP: #290423)
  - Support compression when serving Web UI and RPC responses
  - Simplify the RPC whitelist
  - Fix bug that prevented handshakes with encrypted BitComet peers
  - Fix 1.3x bug that could re-download some data unnecessarily
    (LP: #295040)
  - Option to automatically update the blocklist weekly
  - Added off-hour bandwidth scheduling
  - Simplify file/priority selection in the details dialog
  - Fix a couple of crashes
  - New / updated translations
  - Don't inhibit hibernation by default (LP: #292929)
  - Use "close" animation when sending to notification area (LP: #130811)
  - Fix resize problems (LP: #269872)
  - Support "--version" option when launching from command line
    (LP: #292011)
  - Correctly parse announce URLs that have leading or trailing
    spaces (LP: #262411)
  - Display an error when "Open Torrent" fails (LP: #281463)
* Dropped 10_fix_crasher_from_upstream.dpatch: Fix is in this
  upstream release.
* debian/control: Don't just build-depend on libcurl-dev, which is
  a virtual package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#define VERBOSE 0
10
10
 
11
 
#define check(A) { \
12
 
    ++test; \
13
 
    if (A) { \
14
 
        if( VERBOSE ) \
15
 
            fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
16
 
    } else { \
17
 
        if( VERBOSE ) \
18
 
            fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
19
 
        return test; \
20
 
    } \
21
 
}
 
11
#define check( A ) \
 
12
    { \
 
13
        ++test; \
 
14
        if( A ){ \
 
15
            if( VERBOSE ) \
 
16
                fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
 
17
                         __LINE__ );\
 
18
        } else { \
 
19
            if( VERBOSE ) \
 
20
                fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
 
21
                         __LINE__ );\
 
22
            return test; \
 
23
        } \
 
24
    }
22
25
 
23
26
static void
24
27
createTestBlocklist( const char * tmpfile )
27
30
                             "Sargent Controls and Aerospace:216.19.18.0-216.19.18.255",
28
31
                             "Corel Corporation:216.21.157.192-216.21.157.223",
29
32
                             "Fox Speed Channel:216.79.131.192-216.79.131.223" };
30
 
    FILE * out;
31
 
    int i;
32
 
    const int lineCount = sizeof(lines) / sizeof(lines[0]);
 
33
    FILE *       out;
 
34
    int          i;
 
35
    const int    lineCount = sizeof( lines ) / sizeof( lines[0] );
33
36
 
34
37
    /* create the ascii file to feed to libtransmission */
35
38
    out = fopen( tmpfile, "w+" );
36
 
    for( i=0; i<lineCount; ++i )
 
39
    for( i = 0; i < lineCount; ++i )
37
40
        fprintf( out, "%s\n", lines[i] );
38
41
    fclose( out );
39
42
}
41
44
int
42
45
main( void )
43
46
{
44
 
    char * tmpfile_txt = "/tmp/transmission-blocklist-test.txt";
45
 
    char * tmpfile_bin = "/tmp/transmission-blocklist-test.bin";
 
47
#ifndef WIN32
 
48
    char *         tmpfile_txt = "/tmp/transmission-blocklist-test.txt";
 
49
    char *         tmpfile_bin = "/tmp/transmission-blocklist-test.bin";
 
50
#else
 
51
    char *         tmpfile_txt = "transmission-blocklist-test.txt";
 
52
    char *         tmpfile_bin = "transmission-blocklist-test.bin";
 
53
#endif
46
54
    struct in_addr addr;
47
 
    int test = 0;
 
55
    int            test = 0;
48
56
    tr_blocklist * b;
49
57
 
50
58
    remove( tmpfile_txt );
58
66
    check( !tr_netResolve( "216.16.1.143", &addr ) );
59
67
    check( !_tr_blocklistHasAddress( b, &addr ) );
60
68
    check( !tr_netResolve( "216.16.1.144", &addr ) );
61
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
69
    check( _tr_blocklistHasAddress( b, &addr ) );
62
70
    check( !tr_netResolve( "216.16.1.145", &addr ) );
63
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
71
    check( _tr_blocklistHasAddress( b, &addr ) );
64
72
    check( !tr_netResolve( "216.16.1.146", &addr ) );
65
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
73
    check( _tr_blocklistHasAddress( b, &addr ) );
66
74
    check( !tr_netResolve( "216.16.1.147", &addr ) );
67
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
75
    check( _tr_blocklistHasAddress( b, &addr ) );
68
76
    check( !tr_netResolve( "216.16.1.148", &addr ) );
69
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
77
    check( _tr_blocklistHasAddress( b, &addr ) );
70
78
    check( !tr_netResolve( "216.16.1.149", &addr ) );
71
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
79
    check( _tr_blocklistHasAddress( b, &addr ) );
72
80
    check( !tr_netResolve( "216.16.1.150", &addr ) );
73
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
81
    check( _tr_blocklistHasAddress( b, &addr ) );
74
82
    check( !tr_netResolve( "216.16.1.151", &addr ) );
75
 
    check(  _tr_blocklistHasAddress( b, &addr ) );
 
83
    check( _tr_blocklistHasAddress( b, &addr ) );
76
84
    check( !tr_netResolve( "216.16.1.152", &addr ) );
77
85
    check( !_tr_blocklistHasAddress( b, &addr ) );
78
86
    check( !tr_netResolve( "216.16.1.153", &addr ) );
87
95
    remove( tmpfile_bin );
88
96
    return 0;
89
97
}
 
98