mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
Fix wide lines (from 13172)
This commit is contained in:
parent
a3dafd3f58
commit
4ac5175109
@ -704,7 +704,7 @@ test_rend_fns(void *arg)
|
||||
smartlist_get(descs, 0))->desc_str) == 0);
|
||||
tt_assert(parsed);
|
||||
tt_mem_op(((rend_encoded_v2_service_descriptor_t *)
|
||||
smartlist_get(descs, 0))->desc_id,OP_EQ, parsed_desc_id, DIGEST_LEN);
|
||||
smartlist_get(descs, 0))->desc_id,OP_EQ, parsed_desc_id, DIGEST_LEN);
|
||||
tt_int_op(rend_parse_introduction_points(parsed, intro_points_encrypted,
|
||||
intro_points_size),OP_EQ, 3);
|
||||
tt_assert(!crypto_pk_cmp_keys(generated->pk, parsed->pk));
|
||||
|
@ -62,12 +62,13 @@ test_addr_basic(void *arg)
|
||||
struct in_addr in;
|
||||
|
||||
/* good round trip */
|
||||
tt_int_op(tor_inet_pton(AF_INET, ip, &in),OP_EQ, 1);
|
||||
tt_ptr_op(tor_inet_ntop(AF_INET, &in, tmpbuf, sizeof(tmpbuf)),OP_EQ, &tmpbuf);
|
||||
tt_int_op(tor_inet_pton(AF_INET, ip, &in), OP_EQ, 1);
|
||||
tt_ptr_op(tor_inet_ntop(AF_INET, &in, tmpbuf, sizeof(tmpbuf)),
|
||||
OP_EQ, &tmpbuf);
|
||||
tt_str_op(tmpbuf,OP_EQ, ip);
|
||||
|
||||
/* just enough buffer length */
|
||||
tt_str_op(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip) + 1),OP_EQ, ip);
|
||||
tt_str_op(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip) + 1), OP_EQ, ip);
|
||||
|
||||
/* too short buffer */
|
||||
tt_ptr_op(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip)),OP_EQ, NULL);
|
||||
@ -414,7 +415,8 @@ test_addr_ip6_helpers(void *arg)
|
||||
test_addr_compare("0::3:2:1", OP_LT, "0::ffff:0.3.2.1");
|
||||
test_addr_compare("0::2:2:1", OP_LT, "0::ffff:0.3.2.1");
|
||||
test_addr_compare("0::ffff:0.3.2.1", OP_GT, "0::0:0:0");
|
||||
test_addr_compare("0::ffff:5.2.2.1", OP_LT, "::ffff:6.0.0.0"); /* XXXX wrong. */
|
||||
test_addr_compare("0::ffff:5.2.2.1", OP_LT,
|
||||
"::ffff:6.0.0.0"); /* XXXX wrong. */
|
||||
tor_addr_parse_mask_ports("[::ffff:2.3.4.5]", 0, &t1, NULL, NULL, NULL);
|
||||
tor_addr_parse_mask_ports("2.3.4.5", 0, &t2, NULL, NULL, NULL);
|
||||
tt_assert(tor_addr_compare(&t1, &t2, CMP_SEMANTIC) == 0);
|
||||
@ -461,7 +463,8 @@ test_addr_ip6_helpers(void *arg)
|
||||
tt_ptr_op(tor_addr_to_str(buf, &t1, 7, 0),OP_EQ, NULL); /* too short buf */
|
||||
tt_str_op(tor_addr_to_str(buf, &t1, 8, 0),OP_EQ, "1.2.3.4");
|
||||
|
||||
tt_int_op(AF_INET,OP_EQ, tor_addr_parse(&t1, "255.255.255.255")); /* 15 + \0 */
|
||||
tt_int_op(AF_INET, OP_EQ,
|
||||
tor_addr_parse(&t1, "255.255.255.255")); /* 15 + \0 */
|
||||
tt_ptr_op(tor_addr_to_str(buf, &t1, 15, 0),OP_EQ, NULL); /* too short buf */
|
||||
tt_str_op(tor_addr_to_str(buf, &t1, 16, 0),OP_EQ, "255.255.255.255");
|
||||
tt_ptr_op(tor_addr_to_str(buf, &t1, 15, 1),OP_EQ, NULL); /* too short buf */
|
||||
@ -1014,7 +1017,8 @@ test_addr_is_loopback(void *data)
|
||||
|
||||
for (i=0; loopback_items[i].name; ++i) {
|
||||
tt_int_op(tor_addr_parse(&addr, loopback_items[i].name), OP_GE, 0);
|
||||
tt_int_op(tor_addr_is_loopback(&addr), OP_EQ, loopback_items[i].is_loopback);
|
||||
tt_int_op(tor_addr_is_loopback(&addr), OP_EQ,
|
||||
loopback_items[i].is_loopback);
|
||||
}
|
||||
|
||||
tor_addr_make_unspec(&addr);
|
||||
|
@ -499,7 +499,8 @@ test_buffer_allocation_tracking(void *arg)
|
||||
tt_int_op(buf_get_total_allocation(), OP_EQ, 16384);
|
||||
write_to_buf(junk, 4000, buf2);
|
||||
tt_int_op(buf_allocation(buf2), OP_EQ, 8192); /* another 4k chunk. */
|
||||
tt_int_op(buf_get_total_allocation(), OP_EQ, 5*4096); /* that chunk was new. */
|
||||
tt_int_op(buf_get_total_allocation(),
|
||||
OP_EQ, 5*4096); /* that chunk was new. */
|
||||
|
||||
/* Make a really huge buffer */
|
||||
for (i = 0; i < 1000; ++i) {
|
||||
@ -554,7 +555,8 @@ test_buffer_time_tracking(void *arg)
|
||||
|
||||
buf2 = buf_copy(buf);
|
||||
tt_assert(buf2);
|
||||
tt_int_op(1234, OP_EQ, buf_get_oldest_chunk_timestamp(buf2, START_MSEC+1234));
|
||||
tt_int_op(1234, OP_EQ,
|
||||
buf_get_oldest_chunk_timestamp(buf2, START_MSEC+1234));
|
||||
|
||||
/* Now add more bytes; enough to overflow the first chunk. */
|
||||
tv0.tv_usec += 123 * 1000;
|
||||
|
@ -841,7 +841,8 @@ test_cfmt_extended_cells(void *arg)
|
||||
crypto_rand((char*)b, 42);
|
||||
memcpy(p,"\x00\x2a",2);
|
||||
memcpy(p+2,b,42);
|
||||
tt_int_op(0, OP_EQ, extended_cell_parse(&ec, RELAY_COMMAND_EXTENDED2, p, 2+42));
|
||||
tt_int_op(0, OP_EQ,
|
||||
extended_cell_parse(&ec, RELAY_COMMAND_EXTENDED2, p, 2+42));
|
||||
tt_int_op(RELAY_COMMAND_EXTENDED2, OP_EQ, ec.cell_type);
|
||||
tt_int_op(cc->cell_type, OP_EQ, CELL_CREATED2);
|
||||
tt_int_op(cc->handshake_len, OP_EQ, 42);
|
||||
|
@ -839,7 +839,8 @@ test_config_fix_my_family(void *arg)
|
||||
TT_FAIL(("options_validate failed: %s", err));
|
||||
}
|
||||
|
||||
tt_str_op(options->MyFamily,OP_EQ, "$1111111111111111111111111111111111111111, "
|
||||
tt_str_op(options->MyFamily,OP_EQ,
|
||||
"$1111111111111111111111111111111111111111, "
|
||||
"$1111111111111111111111111111111111111112, "
|
||||
"$1111111111111111111111111111111111111113");
|
||||
|
||||
|
@ -241,11 +241,14 @@ test_container_smartlist_strings(void *arg)
|
||||
tt_int_op(f,OP_EQ, 1);
|
||||
tt_int_op(1,OP_EQ, smartlist_bsearch_idx(sl," arm",cmp_without_first_,&f));
|
||||
tt_int_op(f,OP_EQ, 0);
|
||||
tt_int_op(1,OP_EQ, smartlist_bsearch_idx(sl," arma",cmp_without_first_,&f));
|
||||
tt_int_op(1,OP_EQ,
|
||||
smartlist_bsearch_idx(sl," arma",cmp_without_first_,&f));
|
||||
tt_int_op(f,OP_EQ, 1);
|
||||
tt_int_op(2,OP_EQ, smartlist_bsearch_idx(sl," armb",cmp_without_first_,&f));
|
||||
tt_int_op(2,OP_EQ,
|
||||
smartlist_bsearch_idx(sl," armb",cmp_without_first_,&f));
|
||||
tt_int_op(f,OP_EQ, 0);
|
||||
tt_int_op(7,OP_EQ, smartlist_bsearch_idx(sl," zzzz",cmp_without_first_,&f));
|
||||
tt_int_op(7,OP_EQ,
|
||||
smartlist_bsearch_idx(sl," zzzz",cmp_without_first_,&f));
|
||||
tt_int_op(f,OP_EQ, 0);
|
||||
|
||||
/* Test trivial cases for list of length 0 or 1 */
|
||||
@ -477,7 +480,8 @@ test_container_smartlist_join(void *arg)
|
||||
tt_str_op(joined,OP_EQ, "Anemias,Anemias,Crossbowmen,Work");
|
||||
tor_free(joined);
|
||||
joined = smartlist_join_strings(sl4, ",", 0, NULL);
|
||||
tt_str_op(joined,OP_EQ, "Ambush,Anchorman,Anchorman,Bacon,Inhumane,Insurance,"
|
||||
tt_str_op(joined,OP_EQ,
|
||||
"Ambush,Anchorman,Anchorman,Bacon,Inhumane,Insurance,"
|
||||
"Knish,Know,Manners,Manners,Maraschinos,Wombats,Wombats");
|
||||
tor_free(joined);
|
||||
|
||||
@ -887,7 +891,8 @@ test_container_order_functions(void *arg)
|
||||
tt_int_op(7,OP_EQ, third_quartile()); /* 1, 2, 3, 4, 5, 6, ~7~, 8, 9 */
|
||||
lst2[n++] = 10;
|
||||
lst2[n++] = 11;
|
||||
tt_int_op(9,OP_EQ, third_quartile()); /* 1, 2, 3, 4, 5, 6, 7, 8, ~9~, 10, 11 */
|
||||
/* 1, 2, 3, 4, 5, 6, 7, 8, ~9~, 10, 11 */
|
||||
tt_int_op(9,OP_EQ, third_quartile());
|
||||
|
||||
#undef third_quartile
|
||||
|
||||
|
@ -700,7 +700,8 @@ test_crypto_formats(void *arg)
|
||||
tt_int_op(strlen(data1),OP_EQ, 40);
|
||||
data2 = tor_malloc(FINGERPRINT_LEN+1);
|
||||
crypto_add_spaces_to_fp(data2, FINGERPRINT_LEN+1, data1);
|
||||
tt_str_op(data2,OP_EQ, "ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 0000");
|
||||
tt_str_op(data2, OP_EQ,
|
||||
"ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 0000");
|
||||
tor_free(data1);
|
||||
tor_free(data2);
|
||||
}
|
||||
@ -1474,7 +1475,8 @@ test_crypto_curve25519_persist(void *arg)
|
||||
|
||||
tt_int_op(0,OP_EQ,curve25519_keypair_generate(&keypair, 0));
|
||||
|
||||
tt_int_op(0,OP_EQ,curve25519_keypair_write_to_file(&keypair, fname, "testing"));
|
||||
tt_int_op(0,OP_EQ,
|
||||
curve25519_keypair_write_to_file(&keypair, fname, "testing"));
|
||||
tt_int_op(0,OP_EQ,curve25519_keypair_read_from_file(&keypair2, &tag, fname));
|
||||
tt_str_op(tag,OP_EQ,"testing");
|
||||
tor_free(tag);
|
||||
@ -1505,12 +1507,15 @@ test_crypto_curve25519_persist(void *arg)
|
||||
tor_free(fname);
|
||||
fname = tor_strdup(get_fname("bogus_keypair"));
|
||||
|
||||
tt_int_op(-1, OP_EQ, curve25519_keypair_read_from_file(&keypair2, &tag, fname));
|
||||
tt_int_op(-1, OP_EQ,
|
||||
curve25519_keypair_read_from_file(&keypair2, &tag, fname));
|
||||
tor_free(tag);
|
||||
|
||||
content[69] ^= 0xff;
|
||||
tt_int_op(0, OP_EQ, write_bytes_to_file(fname, content, (size_t)st.st_size, 1));
|
||||
tt_int_op(-1, OP_EQ, curve25519_keypair_read_from_file(&keypair2, &tag, fname));
|
||||
tt_int_op(0, OP_EQ,
|
||||
write_bytes_to_file(fname, content, (size_t)st.st_size, 1));
|
||||
tt_int_op(-1, OP_EQ,
|
||||
curve25519_keypair_read_from_file(&keypair2, &tag, fname));
|
||||
|
||||
done:
|
||||
tor_free(fname);
|
||||
|
@ -879,7 +879,8 @@ test_dir_versions(void *arg)
|
||||
/* Now try svn revisions. */
|
||||
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
|
||||
"Tor 0.2.1.0-dev (r99)"));
|
||||
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r100) on Banana Jr",
|
||||
tt_int_op(1,OP_EQ, tor_version_as_new_as(
|
||||
"Tor 0.2.1.0-dev (r100) on Banana Jr",
|
||||
"Tor 0.2.1.0-dev (r99) on Hal 9000"));
|
||||
tt_int_op(1,OP_EQ, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
|
||||
"Tor 0.2.1.0-dev on Colossus"));
|
||||
@ -929,7 +930,8 @@ test_dir_fp_pairs(void *arg)
|
||||
tt_mem_op(pair->first,OP_EQ, "Hexadecimal isn't so", DIGEST_LEN);
|
||||
tt_mem_op(pair->second,OP_EQ, "good for hiding your", DIGEST_LEN);
|
||||
pair = smartlist_get(sl, 1);
|
||||
tt_mem_op(pair->first,OP_EQ, "secret data.\0\0\0\0\0\xff\xff\xff", DIGEST_LEN);
|
||||
tt_mem_op(pair->first,OP_EQ, "secret data.\0\0\0\0\0\xff\xff\xff",
|
||||
DIGEST_LEN);
|
||||
tt_mem_op(pair->second,OP_EQ, "Use AES-256 instead.", DIGEST_LEN);
|
||||
|
||||
done:
|
||||
@ -2067,8 +2069,8 @@ test_a_networkstatus(
|
||||
{
|
||||
digests_t *dsig_digests = strmap_get(dsig1->digests, "ns");
|
||||
tt_assert(dsig_digests);
|
||||
tt_mem_op(dsig_digests->d[DIGEST_SHA1],OP_EQ, con3->digests.d[DIGEST_SHA1],
|
||||
DIGEST_LEN);
|
||||
tt_mem_op(dsig_digests->d[DIGEST_SHA1], OP_EQ,
|
||||
con3->digests.d[DIGEST_SHA1], DIGEST_LEN);
|
||||
dsig_digests = strmap_get(dsig1->digests, "microdesc");
|
||||
tt_assert(dsig_digests);
|
||||
tt_mem_op(dsig_digests->d[DIGEST_SHA256],OP_EQ,
|
||||
@ -2095,8 +2097,8 @@ test_a_networkstatus(
|
||||
|
||||
/* Try adding it to con2. */
|
||||
detached_text2 = get_detached_sigs(con2,con_md2);
|
||||
tt_int_op(1,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1, "test",
|
||||
LOG_INFO, &msg));
|
||||
tt_int_op(1,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1,
|
||||
"test", LOG_INFO, &msg));
|
||||
tor_free(detached_text2);
|
||||
tt_int_op(1,OP_EQ,
|
||||
networkstatus_add_detached_signatures(con_md2, dsig1, "test",
|
||||
@ -2121,12 +2123,12 @@ test_a_networkstatus(
|
||||
"microdesc")));
|
||||
|
||||
/* Try adding to con2 twice; verify that nothing changes. */
|
||||
tt_int_op(0,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1, "test",
|
||||
LOG_INFO, &msg));
|
||||
tt_int_op(0,OP_EQ, networkstatus_add_detached_signatures(con2, dsig1,
|
||||
"test", LOG_INFO, &msg));
|
||||
|
||||
/* Add to con. */
|
||||
tt_int_op(2,OP_EQ, networkstatus_add_detached_signatures(con, dsig2, "test",
|
||||
LOG_INFO, &msg));
|
||||
tt_int_op(2,OP_EQ, networkstatus_add_detached_signatures(con, dsig2,
|
||||
"test", LOG_INFO, &msg));
|
||||
/* Check signatures */
|
||||
voter = smartlist_get(con->voters, 1);
|
||||
sig = smartlist_get(voter->sigs, 0);
|
||||
@ -2832,7 +2834,8 @@ test_dir_http_handling(void *args)
|
||||
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
||||
tor_free(url);
|
||||
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.600\r\n", &url),OP_EQ, 0);
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.600\r\n", &url),
|
||||
OP_EQ, 0);
|
||||
tt_str_op(url,OP_EQ, "/tor/a/b/c.txt");
|
||||
tor_free(url);
|
||||
|
||||
@ -2867,7 +2870,8 @@ test_dir_http_handling(void *args)
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1", &url),OP_EQ, -1);
|
||||
tt_assert(!url);
|
||||
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1x\r\n", &url),OP_EQ, -1);
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1x\r\n", &url),
|
||||
OP_EQ, -1);
|
||||
tt_assert(!url);
|
||||
|
||||
tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.", &url),OP_EQ, -1);
|
||||
|
@ -75,7 +75,8 @@ setup_fake_routerlist(void)
|
||||
|
||||
/* Sanity checking of routerlist and nodelist. */
|
||||
our_routerlist = router_get_routerlist();
|
||||
tt_int_op(smartlist_len(our_routerlist->routers), OP_EQ, NUMBER_OF_DESCRIPTORS);
|
||||
tt_int_op(smartlist_len(our_routerlist->routers), OP_EQ,
|
||||
NUMBER_OF_DESCRIPTORS);
|
||||
routerlist_assert_ok(our_routerlist);
|
||||
|
||||
our_nodelist = nodelist_get_list();
|
||||
@ -408,7 +409,7 @@ test_entry_guards_parse_state_simple(void *arg)
|
||||
|
||||
tt_assert(e->is_dir_cache); /* Verify dirness */
|
||||
|
||||
tt_str_op(e->chosen_by_version, OP_EQ, tor_version); /* Verify tor version */
|
||||
tt_str_op(e->chosen_by_version, OP_EQ, tor_version); /* Verify version */
|
||||
|
||||
tt_assert(e->made_contact); /* All saved guards have been contacted */
|
||||
|
||||
@ -507,7 +508,8 @@ test_entry_guards_parse_state_pathbias(void *arg)
|
||||
/* XXX tt_double_op doesn't support equality. Cast to int for now. */
|
||||
tt_int_op((int)e->circ_attempts, OP_EQ, (int)circ_attempts);
|
||||
tt_int_op((int)e->circ_successes, OP_EQ, (int)circ_successes);
|
||||
tt_int_op((int)e->successful_circuits_closed, OP_EQ, (int)successful_closed);
|
||||
tt_int_op((int)e->successful_circuits_closed, OP_EQ,
|
||||
(int)successful_closed);
|
||||
tt_int_op((int)e->timeouts, OP_EQ, (int)timeouts);
|
||||
tt_int_op((int)e->collapsed_circuits, OP_EQ, (int)collapsed);
|
||||
tt_int_op((int)e->unusable_circuits, OP_EQ, (int)unusable);
|
||||
|
@ -24,7 +24,8 @@ test_ext_or_id_map(void *arg)
|
||||
(void)arg;
|
||||
|
||||
/* pre-initialization */
|
||||
tt_ptr_op(NULL, OP_EQ, connection_or_get_by_ext_or_id("xxxxxxxxxxxxxxxxxxxx"));
|
||||
tt_ptr_op(NULL, OP_EQ,
|
||||
connection_or_get_by_ext_or_id("xxxxxxxxxxxxxxxxxxxx"));
|
||||
|
||||
c1 = or_connection_new(CONN_TYPE_EXT_OR, AF_INET);
|
||||
c2 = or_connection_new(CONN_TYPE_EXT_OR, AF_INET);
|
||||
@ -36,7 +37,8 @@ test_ext_or_id_map(void *arg)
|
||||
|
||||
tt_ptr_op(c1, OP_EQ, connection_or_get_by_ext_or_id(c1->ext_or_conn_id));
|
||||
tt_ptr_op(c2, OP_EQ, connection_or_get_by_ext_or_id(c2->ext_or_conn_id));
|
||||
tt_ptr_op(NULL, OP_EQ, connection_or_get_by_ext_or_id("xxxxxxxxxxxxxxxxxxxx"));
|
||||
tt_ptr_op(NULL, OP_EQ,
|
||||
connection_or_get_by_ext_or_id("xxxxxxxxxxxxxxxxxxxx"));
|
||||
|
||||
idp = tor_memdup(c2->ext_or_conn_id, EXT_OR_CONN_ID_LEN);
|
||||
|
||||
@ -423,7 +425,8 @@ do_ext_or_handshake(or_connection_t *conn)
|
||||
MOCK(crypto_rand, crypto_rand_return_tse_str);
|
||||
tt_int_op(0, OP_EQ, connection_ext_or_process_inbuf(conn));
|
||||
UNMOCK(crypto_rand);
|
||||
tt_int_op(TO_CONN(conn)->state, OP_EQ, EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH);
|
||||
tt_int_op(TO_CONN(conn)->state, OP_EQ,
|
||||
EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH);
|
||||
CONTAINS("\xec\x80\xed\x6e\x54\x6d\x3b\x36\xfd\xfc\x22\xfe\x13\x15\x41\x6b"
|
||||
"\x02\x9f\x1a\xde\x76\x10\xd9\x10\x87\x8b\x62\xee\xb7\x40\x38\x21"
|
||||
"te road There is always another ", 64);
|
||||
|
@ -432,8 +432,8 @@ test_socks_5_malformed_commands(void *ptr)
|
||||
*/
|
||||
ADD_DATA(buf, "\x05\x01\x00");
|
||||
ADD_DATA(buf, "\x05\x01\x00\x01\x02\x02\x02\x02\x11\x11");
|
||||
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),OP_EQ,
|
||||
-1);
|
||||
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),
|
||||
OP_EQ, -1);
|
||||
|
||||
tt_int_op(5,OP_EQ,socks->socks_version);
|
||||
tt_int_op(10,OP_EQ,socks->replylen);
|
||||
|
@ -435,8 +435,8 @@ NS(logv)(int severity, log_domain_mask_t domain,
|
||||
case 2:
|
||||
tt_int_op(severity, OP_EQ, LOG_NOTICE);
|
||||
tt_int_op(domain, OP_EQ, LD_HEARTBEAT);
|
||||
tt_ptr_op(
|
||||
strstr(funcname, "rep_hist_log_circuit_handshake_stats"), OP_NE, NULL);
|
||||
tt_ptr_op(strstr(funcname, "rep_hist_log_circuit_handshake_stats"),
|
||||
OP_NE, NULL);
|
||||
tt_ptr_op(suffix, OP_EQ, NULL);
|
||||
tt_str_op(format, OP_EQ,
|
||||
"Circuit handshake stats since last time: %d/%d TAP, %d/%d NTor.");
|
||||
@ -737,7 +737,8 @@ NS(logv)(int severity, log_domain_mask_t domain,
|
||||
tt_str_op(va_arg(ap, char *), OP_EQ, "0 kB"); /* acc_rcvd */
|
||||
tt_str_op(va_arg(ap, char *), OP_EQ, "0 kB"); /* acc_max */
|
||||
/* format_local_iso_time uses local tz, just check mins and secs. */
|
||||
tt_ptr_op(strstr(va_arg(ap, char *), ":01:00"), OP_NE, NULL); /* end_buf */
|
||||
tt_ptr_op(strstr(va_arg(ap, char *), ":01:00"),
|
||||
OP_NE, NULL); /* end_buf */
|
||||
tt_str_op(va_arg(ap, char *), OP_EQ, "0:01 hours"); /* remaining */
|
||||
break;
|
||||
default:
|
||||
|
@ -544,7 +544,8 @@ test_util_time(void *arg)
|
||||
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
||||
/* The timezone doesn't matter */
|
||||
t_res = 0;
|
||||
tt_int_op(0,OP_EQ, parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res));
|
||||
tt_int_op(0,OP_EQ,
|
||||
parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res));
|
||||
tt_int_op(t_res,OP_EQ, (time_t)1091580502UL);
|
||||
tt_int_op(-1,OP_EQ,
|
||||
parse_rfc1123_time("Wed, zz Aug 2004 99-99x99 GMT", &t_res));
|
||||
@ -680,10 +681,12 @@ test_util_parse_http_time(void *arg)
|
||||
parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time));
|
||||
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("1994-08-04 00:48:22");
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||
tt_int_op(0,OP_EQ,
|
||||
parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("1994-08-04 00:48:22");
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||
tt_int_op(0,OP_EQ,
|
||||
parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
|
||||
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("1994-08-04 00:48:22");
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time));
|
||||
@ -695,10 +698,10 @@ test_util_parse_http_time(void *arg)
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time));
|
||||
tt_int_op((time_t)775961302UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("1994-08-04 00:48:22");
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
|
||||
tt_int_op(0,OP_EQ,parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
|
||||
tt_int_op((time_t)1325376000UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("2012-01-01 00:00:00");
|
||||
tt_int_op(0,OP_EQ, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
|
||||
tt_int_op(0,OP_EQ,parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
|
||||
tt_int_op((time_t)1356912000UL,OP_EQ, tor_timegm(&a_time));
|
||||
T("2012-12-31 00:00:00");
|
||||
tt_int_op(-1,OP_EQ, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time));
|
||||
@ -1373,7 +1376,8 @@ test_util_strmisc(void *arg)
|
||||
/* Test tor_parse_* where we overflow/underflow the underlying type. */
|
||||
/* This string should overflow 64-bit ints. */
|
||||
#define TOOBIG "100000000000000000000000000"
|
||||
tt_int_op(0L,OP_EQ, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
|
||||
tt_int_op(0L, OP_EQ,
|
||||
tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
|
||||
tt_int_op(i,OP_EQ, 0);
|
||||
tt_int_op(0L,OP_EQ,
|
||||
tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
|
||||
@ -1551,10 +1555,10 @@ test_util_strmisc(void *arg)
|
||||
|
||||
/* Test strcmp_len */
|
||||
tt_int_op(strcmp_len("foo", "bar", 3), OP_GT, 0);
|
||||
tt_int_op(strcmp_len("foo", "bar", 2), OP_LT, 0); /* First len, then lexical */
|
||||
tt_int_op(strcmp_len("foo", "bar", 2), OP_LT, 0);
|
||||
tt_int_op(strcmp_len("foo2", "foo1", 4), OP_GT, 0);
|
||||
tt_int_op(strcmp_len("foo2", "foo1", 3), OP_LT, 0); /* Really stop at len */
|
||||
tt_int_op(strcmp_len("foo2", "foo", 3), OP_EQ, 0); /* Really stop at len */
|
||||
tt_int_op(strcmp_len("foo2", "foo", 3), OP_EQ, 0); /* Really stop at len */
|
||||
tt_int_op(strcmp_len("blah", "", 4), OP_GT, 0);
|
||||
tt_int_op(strcmp_len("blah", "", 0), OP_EQ, 0);
|
||||
|
||||
@ -1570,7 +1574,8 @@ test_util_pow2(void *arg)
|
||||
tt_int_op(tor_log2(64),OP_EQ, 6);
|
||||
tt_int_op(tor_log2(65),OP_EQ, 6);
|
||||
tt_int_op(tor_log2(63),OP_EQ, 5);
|
||||
tt_int_op(tor_log2(0),OP_EQ, 0);/* incorrect mathematically, but as specified */
|
||||
/* incorrect mathematically, but as specified: */
|
||||
tt_int_op(tor_log2(0),OP_EQ, 0);
|
||||
tt_int_op(tor_log2(1),OP_EQ, 0);
|
||||
tt_int_op(tor_log2(2),OP_EQ, 1);
|
||||
tt_int_op(tor_log2(3),OP_EQ, 1);
|
||||
@ -1835,7 +1840,8 @@ test_util_gzip(void *arg)
|
||||
|
||||
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf1, 1024-len1,
|
||||
ZLIB_METHOD, 1, LOG_WARN));
|
||||
tt_str_op(buf3,OP_EQ,"ABCDEFGHIJABCDEFGHIJ"); /*Make sure it compressed right.*/
|
||||
/* Make sure it compressed right. */
|
||||
tt_str_op(buf3, OP_EQ, "ABCDEFGHIJABCDEFGHIJ");
|
||||
tt_int_op(21,OP_EQ, len2);
|
||||
|
||||
done:
|
||||
@ -2043,7 +2049,8 @@ test_util_sscanf(void *arg)
|
||||
tt_int_op(99u,OP_EQ, u3);
|
||||
|
||||
/* Hex (ie. %x) */
|
||||
tt_int_op(3,OP_EQ, tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3));
|
||||
tt_int_op(3,OP_EQ,
|
||||
tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3));
|
||||
tt_int_op(0x1234,OP_EQ, u1);
|
||||
tt_int_op(0x2ABCDEF,OP_EQ, u2);
|
||||
tt_int_op(0xFF,OP_EQ, u3);
|
||||
@ -3067,12 +3074,14 @@ test_util_find_str_at_start_of_line(void *ptr)
|
||||
tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "he"));
|
||||
tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hell"));
|
||||
tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hello k"));
|
||||
tt_ptr_op(line2,OP_EQ, find_str_at_start_of_line(long_string, "hello kitty\n"));
|
||||
tt_ptr_op(line2,OP_EQ,
|
||||
find_str_at_start_of_line(long_string, "hello kitty\n"));
|
||||
tt_ptr_op(line2,OP_EQ,
|
||||
find_str_at_start_of_line(long_string, "hello kitty\nt"));
|
||||
tt_ptr_op(line3,OP_EQ, find_str_at_start_of_line(long_string, "third"));
|
||||
tt_ptr_op(line3,OP_EQ, find_str_at_start_of_line(long_string, "third line"));
|
||||
tt_ptr_op(NULL,OP_EQ, find_str_at_start_of_line(long_string, "third line\n"));
|
||||
tt_ptr_op(NULL, OP_EQ,
|
||||
find_str_at_start_of_line(long_string, "third line\n"));
|
||||
tt_ptr_op(short_line2,OP_EQ, find_str_at_start_of_line(short_string,
|
||||
"second line\n"));
|
||||
done:
|
||||
@ -3283,7 +3292,7 @@ test_util_ftruncate(void *ptr)
|
||||
tt_int_op(fd, OP_GE, 0);
|
||||
|
||||
/* Make the file be there. */
|
||||
tt_int_op(strlen(message), OP_EQ, write_all(fd, message, strlen(message), 0));
|
||||
tt_int_op(strlen(message), OP_EQ, write_all(fd, message, strlen(message),0));
|
||||
tt_int_op((int)tor_fd_getpos(fd), OP_EQ, strlen(message));
|
||||
tt_int_op(0, OP_EQ, fstat(fd, &st));
|
||||
tt_int_op((int)st.st_size, OP_EQ, strlen(message));
|
||||
@ -4145,8 +4154,10 @@ test_util_di_ops(void *arg)
|
||||
ii = (uint8_t)i;
|
||||
zz = (uint8_t)z;
|
||||
tt_int_op(tor_memeq(&zz, &ii, 1),OP_EQ, zz == ii);
|
||||
tt_int_op(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ,OP_EQ, zz > ii ? GT : EQ);
|
||||
tt_int_op(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ,OP_EQ, ii < zz ? LT : EQ);
|
||||
tt_int_op(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ,OP_EQ,
|
||||
zz > ii ? GT : EQ);
|
||||
tt_int_op(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ,OP_EQ,
|
||||
ii < zz ? LT : EQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4219,7 +4230,8 @@ test_util_eat_whitespace(void *ptr)
|
||||
/* Only ws */
|
||||
strlcpy(str, " \t\r\n", sizeof(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ,
|
||||
eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + strlen(str) - 1,OP_EQ,
|
||||
eat_whitespace_no_nl(str));
|
||||
tt_ptr_op(str + strlen(str) - 1,OP_EQ,
|
||||
@ -4238,7 +4250,8 @@ test_util_eat_whitespace(void *ptr)
|
||||
for (i = 0; i < sizeof(ws); ++i)
|
||||
str[i] = ws[i];
|
||||
tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace(str));
|
||||
tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + sizeof(ws),OP_EQ,
|
||||
eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + sizeof(ws),OP_EQ, eat_whitespace_no_nl(str));
|
||||
tt_ptr_op(str + sizeof(ws),OP_EQ,
|
||||
eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
||||
@ -4260,14 +4273,16 @@ test_util_eat_whitespace(void *ptr)
|
||||
/* Eat entire comment */
|
||||
strlcpy(str, "#Comment", sizeof(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ,
|
||||
eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str,OP_EQ, eat_whitespace_no_nl(str));
|
||||
tt_ptr_op(str,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
||||
|
||||
/* Blank line, then comment */
|
||||
strlcpy(str, " \t\n # Comment", sizeof(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace(str));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ, eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + strlen(str),OP_EQ,
|
||||
eat_whitespace_eos(str, str + strlen(str)));
|
||||
tt_ptr_op(str + 2,OP_EQ, eat_whitespace_no_nl(str));
|
||||
tt_ptr_op(str + 2,OP_EQ, eat_whitespace_eos_no_nl(str, str + strlen(str)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user