Skip to content
Snippets Groups Projects
Commit a3dafd3f authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Replace operators used as macro arguments with OP_XX macros

Part of fix for 13172
parent 2170171d
No related branches found
No related tags found
No related merge requests found
Showing
with 2017 additions and 2017 deletions
......@@ -717,7 +717,7 @@ tor_gettimeofday_cached_monotonic(struct timeval *tv)
struct timeval last_tv = { 0, 0 };
tor_gettimeofday_cached(tv);
if (timercmp(tv, &last_tv, <)) {
if (timercmp(tv, &last_tv, OP_LT)) {
memcpy(tv, &last_tv, sizeof(struct timeval));
} else {
memcpy(&last_tv, tv, sizeof(struct timeval));
......
......@@ -74,13 +74,13 @@ test_strcmp(void *data)
values of the failing things.
Fail unless strcmp("abc, "abc") == 0 */
tt_int_op(strcmp("abc", "abc"), ==, 0);
tt_int_op(strcmp("abc", "abc"), OP_EQ, 0);
/* Fail unless strcmp("abc, "abcd") is less than 0 */
tt_int_op(strcmp("abc", "abcd"), < , 0);
tt_int_op(strcmp("abc", "abcd"), OP_LT, 0);
/* Incidentally, there's a test_str_op that uses strcmp internally. */
tt_str_op("abc", <, "abcd");
tt_str_op("abc", OP_LT, "abcd");
/* Every test-case function needs to finish with an "end:"
......@@ -153,11 +153,11 @@ test_memcpy(void *ptr)
/* Let's make sure that memcpy does what we'd like. */
strcpy(db->buffer1, "String 0");
memcpy(db->buffer2, db->buffer1, sizeof(db->buffer1));
tt_str_op(db->buffer1, ==, db->buffer2);
tt_str_op(db->buffer1, OP_EQ, db->buffer2);
/* tt_mem_op() does a memcmp, as opposed to the strcmp in tt_str_op() */
db->buffer2[100] = 3; /* Make the buffers unequal */
tt_mem_op(db->buffer1, <, db->buffer2, sizeof(db->buffer1));
tt_mem_op(db->buffer1, OP_LT, db->buffer2, sizeof(db->buffer1));
/* Now we've allocated memory that's referenced by a local variable.
The end block of the function will clean it up. */
......@@ -165,7 +165,7 @@ test_memcpy(void *ptr)
tt_assert(mem);
/* Another rather trivial test. */
tt_str_op(db->buffer1, !=, mem);
tt_str_op(db->buffer1, OP_NE, mem);
end:
/* This time our end block has something to do. */
......@@ -186,9 +186,9 @@ test_timeout(void *ptr)
#endif
t2 = time(NULL);
tt_int_op(t2-t1, >=, 4);
tt_int_op(t2-t1, OP_GE, 4);
tt_int_op(t2-t1, <=, 6);
tt_int_op(t2-t1, OP_LE, 6);
end:
;
......
......@@ -200,7 +200,7 @@ circuit_is_better(const origin_circuit_t *oa, const origin_circuit_t *ob,
return 1;
} else {
if (a->timestamp_dirty ||
timercmp(&a->timestamp_began, &b->timestamp_began, >))
timercmp(&a->timestamp_began, &b->timestamp_began, OP_GT))
return 1;
if (ob->build_state->is_internal)
/* XXX023 what the heck is this internal thing doing here. I
......@@ -514,7 +514,7 @@ circuit_expire_building(void)
if (TO_ORIGIN_CIRCUIT(victim)->hs_circ_has_timed_out)
cutoff = hs_extremely_old_cutoff;
if (timercmp(&victim->timestamp_began, &cutoff, >))
if (timercmp(&victim->timestamp_began, &cutoff, OP_GT))
continue; /* it's still young, leave it alone */
/* We need to double-check the opened state here because
......@@ -524,7 +524,7 @@ circuit_expire_building(void)
* aren't either. */
if (!any_opened_circs && victim->state != CIRCUIT_STATE_OPEN) {
/* It's still young enough that we wouldn't close it, right? */
if (timercmp(&victim->timestamp_began, &close_cutoff, >)) {
if (timercmp(&victim->timestamp_began, &close_cutoff, OP_GT)) {
if (!TO_ORIGIN_CIRCUIT(victim)->relaxed_timeout) {
int first_hop_succeeded = TO_ORIGIN_CIRCUIT(victim)->cpath->state
== CPATH_STATE_OPEN;
......@@ -672,7 +672,7 @@ circuit_expire_building(void)
* it off at, we probably had a suspend event along this codepath,
* and we should discard the value.
*/
if (timercmp(&victim->timestamp_began, &extremely_old_cutoff, <)) {
if (timercmp(&victim->timestamp_began, &extremely_old_cutoff, OP_LT)) {
log_notice(LD_CIRC,
"Extremely large value for circuit build timeout: %lds. "
"Assuming clock jump. Purpose %d (%s)",
......@@ -1255,7 +1255,7 @@ circuit_expire_old_circuits_clientside(void)
if (circ->purpose != CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
} else if (!circ->timestamp_dirty && circ->state == CIRCUIT_STATE_OPEN) {
if (timercmp(&circ->timestamp_began, &cutoff, <)) {
if (timercmp(&circ->timestamp_began, &cutoff, OP_LT)) {
if (circ->purpose == CIRCUIT_PURPOSE_C_GENERAL ||
circ->purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT ||
circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
......
......@@ -277,9 +277,9 @@ test_onion_handshake(void *arg)
memset(c_keys, 0, 40);
tt_assert(! onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
tt_mem_op(c_keys,==, s_keys, 40);
tt_mem_op(c_keys,OP_EQ, s_keys, 40);
memset(s_buf, 0, 40);
tt_mem_op(c_keys,!=, s_buf, 40);
tt_mem_op(c_keys,OP_NE, s_buf, 40);
}
done:
crypto_dh_free(c_dh);
......@@ -311,7 +311,7 @@ test_bad_onion_handshake(void *arg)
memset(junk_buf, 0, sizeof(junk_buf));
crypto_pk_public_hybrid_encrypt(pk, junk_buf2, TAP_ONIONSKIN_CHALLENGE_LEN,
junk_buf, DH_KEY_LEN, PK_PKCS1_OAEP_PADDING, 1);
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_server_handshake(junk_buf2, pk, NULL,
s_buf, s_keys, 40));
......@@ -320,7 +320,7 @@ test_bad_onion_handshake(void *arg)
memset(junk_buf2, 0, sizeof(junk_buf2));
crypto_pk_public_encrypt(pk, junk_buf2, sizeof(junk_buf2),
junk_buf, 48, PK_PKCS1_OAEP_PADDING);
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_server_handshake(junk_buf2, pk, NULL,
s_buf, s_keys, 40));
......@@ -329,36 +329,36 @@ test_bad_onion_handshake(void *arg)
tt_assert(! onion_skin_TAP_create(pk, &c_dh, c_buf));
/* Server: Case 3: we just don't have the right key. */
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_server_handshake(c_buf, pk2, NULL,
s_buf, s_keys, 40));
/* Server: Case 4: The RSA-encrypted portion is corrupt. */
c_buf[64] ^= 33;
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_server_handshake(c_buf, pk, NULL,
s_buf, s_keys, 40));
c_buf[64] ^= 33;
/* (Let the server procede) */
tt_int_op(0, ==,
tt_int_op(0, OP_EQ,
onion_skin_TAP_server_handshake(c_buf, pk, NULL,
s_buf, s_keys, 40));
/* Client: Case 1: The server sent back junk. */
s_buf[64] ^= 33;
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
s_buf[64] ^= 33;
/* Let the client finish; make sure it can. */
tt_int_op(0, ==,
tt_int_op(0, OP_EQ,
onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
tt_mem_op(s_keys,==, c_keys, 40);
tt_mem_op(s_keys,OP_EQ, c_keys, 40);
/* Client: Case 2: The server sent back a degenerate DH. */
memset(s_buf, 0, sizeof(s_buf));
tt_int_op(-1, ==,
tt_int_op(-1, OP_EQ,
onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
done:
......@@ -395,24 +395,24 @@ test_ntor_handshake(void *arg)
/* client handshake 1. */
memset(c_buf, 0, NTOR_ONIONSKIN_LEN);
tt_int_op(0, ==, onion_skin_ntor_create(node_id, server_pubkey,
tt_int_op(0, OP_EQ, onion_skin_ntor_create(node_id, server_pubkey,
&c_state, c_buf));
/* server handshake */
memset(s_buf, 0, NTOR_REPLY_LEN);
memset(s_keys, 0, 40);
tt_int_op(0, ==, onion_skin_ntor_server_handshake(c_buf, s_keymap, NULL,
tt_int_op(0, OP_EQ, onion_skin_ntor_server_handshake(c_buf, s_keymap, NULL,
node_id,
s_buf, s_keys, 400));
/* client handshake 2 */
memset(c_keys, 0, 40);
tt_int_op(0, ==, onion_skin_ntor_client_handshake(c_state, s_buf,
tt_int_op(0, OP_EQ, onion_skin_ntor_client_handshake(c_state, s_buf,
c_keys, 400));
tt_mem_op(c_keys,==, s_keys, 400);
tt_mem_op(c_keys,OP_EQ, s_keys, 400);
memset(s_buf, 0, 40);
tt_mem_op(c_keys,!=, s_buf, 40);
tt_mem_op(c_keys,OP_NE, s_buf, 40);
done:
ntor_handshake_state_free(c_state);
......@@ -440,24 +440,24 @@ test_onion_queues(void *arg)
create_cell_init(create2, CELL_CREATE, ONION_HANDSHAKE_TYPE_NTOR,
NTOR_ONIONSKIN_LEN, buf2);
tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,==, onion_pending_add(circ1, create1));
tt_int_op(0,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,OP_EQ, onion_pending_add(circ1, create1));
create1 = NULL;
tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(1,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_int_op(0,==, onion_pending_add(circ2, create2));
tt_int_op(0,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_int_op(0,OP_EQ, onion_pending_add(circ2, create2));
create2 = NULL;
tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_int_op(1,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_ptr_op(circ2,==, onion_next_task(&onionskin));
tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_ptr_op(onionskin, ==, create2_ptr);
tt_ptr_op(circ2,OP_EQ, onion_next_task(&onionskin));
tt_int_op(1,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_ptr_op(onionskin, OP_EQ, create2_ptr);
clear_pending_onions();
tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_int_op(0,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
tt_int_op(0,OP_EQ, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
done:
circuit_free(TO_CIRCUIT(circ1));
......@@ -648,13 +648,13 @@ test_rend_fns(void *arg)
(void)arg;
tt_assert(BAD_HOSTNAME == parse_extended_hostname(address1));
tt_assert(ONION_HOSTNAME == parse_extended_hostname(address2));
tt_str_op(address2,==, "aaaaaaaaaaaaaaaa");
tt_str_op(address2,OP_EQ, "aaaaaaaaaaaaaaaa");
tt_assert(EXIT_HOSTNAME == parse_extended_hostname(address3));
tt_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4));
tt_assert(ONION_HOSTNAME == parse_extended_hostname(address5));
tt_str_op(address5,==, "abcdefghijklmnop");
tt_str_op(address5,OP_EQ, "abcdefghijklmnop");
tt_assert(ONION_HOSTNAME == parse_extended_hostname(address6));
tt_str_op(address6,==, "abcdefghijklmnop");
tt_str_op(address6,OP_EQ, "abcdefghijklmnop");
tt_assert(BAD_HOSTNAME == parse_extended_hostname(address7));
pk1 = pk_generate(0);
......@@ -693,7 +693,7 @@ test_rend_fns(void *arg)
tt_assert(rend_compute_v2_desc_id(computed_desc_id, service_id_base32,
NULL, now, 0) == 0);
tt_mem_op(((rend_encoded_v2_service_descriptor_t *)
smartlist_get(descs, 0))->desc_id, ==,
smartlist_get(descs, 0))->desc_id, OP_EQ,
computed_desc_id, DIGEST_LEN);
tt_assert(rend_parse_v2_service_descriptor(&parsed, parsed_desc_id,
&intro_points_encrypted,
......@@ -704,25 +704,25 @@ 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,==, 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),==, 3);
intro_points_size),OP_EQ, 3);
tt_assert(!crypto_pk_cmp_keys(generated->pk, parsed->pk));
tt_int_op(parsed->timestamp,==, now);
tt_int_op(parsed->version,==, 2);
tt_int_op(parsed->protocols,==, 42);
tt_int_op(smartlist_len(parsed->intro_nodes),==, 3);
tt_int_op(parsed->timestamp,OP_EQ, now);
tt_int_op(parsed->version,OP_EQ, 2);
tt_int_op(parsed->protocols,OP_EQ, 42);
tt_int_op(smartlist_len(parsed->intro_nodes),OP_EQ, 3);
for (i = 0; i < smartlist_len(parsed->intro_nodes); i++) {
rend_intro_point_t *par_intro = smartlist_get(parsed->intro_nodes, i),
*gen_intro = smartlist_get(generated->intro_nodes, i);
extend_info_t *par_info = par_intro->extend_info;
extend_info_t *gen_info = gen_intro->extend_info;
tt_assert(!crypto_pk_cmp_keys(gen_info->onion_key, par_info->onion_key));
tt_mem_op(gen_info->identity_digest,==, par_info->identity_digest,
tt_mem_op(gen_info->identity_digest,OP_EQ, par_info->identity_digest,
DIGEST_LEN);
tt_str_op(gen_info->nickname,==, par_info->nickname);
tt_str_op(gen_info->nickname,OP_EQ, par_info->nickname);
tt_assert(tor_addr_eq(&gen_info->addr, &par_info->addr));
tt_int_op(gen_info->port,==, par_info->port);
tt_int_op(gen_info->port,OP_EQ, par_info->port);
}
rend_service_descriptor_free(parsed);
......@@ -766,11 +766,11 @@ test_rend_fns(void *arg)
} while (0)
#define CHECK_COUNTRY(country, val) do { \
/* test ipv4 country lookup */ \
tt_str_op(country, ==, \
tt_str_op(country, OP_EQ, \
geoip_get_country_name(geoip_get_country_by_ipv4(val))); \
/* test ipv6 country lookup */ \
SET_TEST_IPV6(val); \
tt_str_op(country, ==, \
tt_str_op(country, OP_EQ, \
geoip_get_country_name(geoip_get_country_by_ipv6(&in6))); \
} while (0)
......@@ -831,23 +831,23 @@ test_geoip(void *arg)
* 'sort' step. These aren't very good IP addresses, but they're perfectly
* fine uint32_t values. */
(void)arg;
tt_int_op(0,==, geoip_parse_entry("10,50,AB", AF_INET));
tt_int_op(0,==, geoip_parse_entry("52,90,XY", AF_INET));
tt_int_op(0,==, geoip_parse_entry("95,100,AB", AF_INET));
tt_int_op(0,==, geoip_parse_entry("\"105\",\"140\",\"ZZ\"", AF_INET));
tt_int_op(0,==, geoip_parse_entry("\"150\",\"190\",\"XY\"", AF_INET));
tt_int_op(0,==, geoip_parse_entry("\"200\",\"250\",\"AB\"", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("10,50,AB", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("52,90,XY", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("95,100,AB", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("\"105\",\"140\",\"ZZ\"", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("\"150\",\"190\",\"XY\"", AF_INET));
tt_int_op(0,OP_EQ, geoip_parse_entry("\"200\",\"250\",\"AB\"", AF_INET));
/* Populate the IPv6 DB equivalently with fake IPs in the same range */
tt_int_op(0,==, geoip_parse_entry("::a,::32,AB", AF_INET6));
tt_int_op(0,==, geoip_parse_entry("::34,::5a,XY", AF_INET6));
tt_int_op(0,==, geoip_parse_entry("::5f,::64,AB", AF_INET6));
tt_int_op(0,==, geoip_parse_entry("::69,::8c,ZZ", AF_INET6));
tt_int_op(0,==, geoip_parse_entry("::96,::be,XY", AF_INET6));
tt_int_op(0,==, geoip_parse_entry("::c8,::fa,AB", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::a,::32,AB", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::34,::5a,XY", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::5f,::64,AB", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::69,::8c,ZZ", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::96,::be,XY", AF_INET6));
tt_int_op(0,OP_EQ, geoip_parse_entry("::c8,::fa,AB", AF_INET6));
/* We should have 4 countries: ??, ab, xy, zz. */
tt_int_op(4,==, geoip_get_n_countries());
tt_int_op(4,OP_EQ, geoip_get_n_countries());
memset(&in6, 0, sizeof(in6));
CHECK_COUNTRY("??", 3);
......@@ -858,9 +858,9 @@ test_geoip(void *arg)
CHECK_COUNTRY("xy", 190);
CHECK_COUNTRY("??", 2000);
tt_int_op(0,==, geoip_get_country_by_ipv4(3));
tt_int_op(0,OP_EQ, geoip_get_country_by_ipv4(3));
SET_TEST_IPV6(3);
tt_int_op(0,==, geoip_get_country_by_ipv6(&in6));
tt_int_op(0,OP_EQ, geoip_get_country_by_ipv6(&in6));
get_options_mutable()->BridgeRelay = 1;
get_options_mutable()->BridgeRecordUsageByCountry = 1;
......@@ -885,8 +885,8 @@ test_geoip(void *arg)
geoip_get_client_history(GEOIP_CLIENT_CONNECT, &s, &v);
tt_assert(s);
tt_assert(v);
tt_str_op("zz=24,ab=16,xy=8",==, s);
tt_str_op("v4=16,v6=16",==, v);
tt_str_op("zz=24,ab=16,xy=8",OP_EQ, s);
tt_str_op("v4=16,v6=16",OP_EQ, v);
tor_free(s);
tor_free(v);
......@@ -895,8 +895,8 @@ test_geoip(void *arg)
geoip_get_client_history(GEOIP_CLIENT_CONNECT, &s, &v);
tt_assert(s);
tt_assert(v);
tt_str_op("zz=24,xy=8",==, s);
tt_str_op("v4=16,v6=16",==, v);
tt_str_op("zz=24,xy=8",OP_EQ, s);
tt_str_op("v4=16,v6=16",OP_EQ, v);
tor_free(s);
tor_free(v);
......@@ -910,7 +910,7 @@ test_geoip(void *arg)
geoip_bridge_stats_init(now);
s = geoip_format_bridge_stats(now + 86400);
tt_assert(s);
tt_str_op(bridge_stats_1,==, s);
tt_str_op(bridge_stats_1,OP_EQ, s);
tor_free(s);
/* Stop collecting bridge stats and make sure we don't write a history
......@@ -939,7 +939,7 @@ test_geoip(void *arg)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
s = geoip_format_dirreq_stats(now + 86400);
tt_str_op(dirreq_stats_1,==, s);
tt_str_op(dirreq_stats_1,OP_EQ, s);
tor_free(s);
/* Stop collecting stats, add another connecting client, and ensure we
......@@ -957,20 +957,20 @@ test_geoip(void *arg)
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
geoip_reset_dirreq_stats(now);
s = geoip_format_dirreq_stats(now + 86400);
tt_str_op(dirreq_stats_2,==, s);
tt_str_op(dirreq_stats_2,OP_EQ, s);
tor_free(s);
/* Note a successful network status response and make sure that it
* appears in the history string. */
geoip_note_ns_response(GEOIP_SUCCESS);
s = geoip_format_dirreq_stats(now + 86400);
tt_str_op(dirreq_stats_3,==, s);
tt_str_op(dirreq_stats_3,OP_EQ, s);
tor_free(s);
/* Start a tunneled directory request. */
geoip_start_dirreq((uint64_t) 1, 1024, DIRREQ_TUNNELED);
s = geoip_format_dirreq_stats(now + 86400);
tt_str_op(dirreq_stats_4,==, s);
tt_str_op(dirreq_stats_4,OP_EQ, s);
tor_free(s);
/* Stop collecting directory request statistics and start gathering
......@@ -992,7 +992,7 @@ test_geoip(void *arg)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
s = geoip_format_entry_stats(now + 86400);
tt_str_op(entry_stats_1,==, s);
tt_str_op(entry_stats_1,OP_EQ, s);
tor_free(s);
/* Stop collecting stats, add another connecting client, and ensure we
......@@ -1010,7 +1010,7 @@ test_geoip(void *arg)
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
geoip_reset_entry_stats(now);
s = geoip_format_entry_stats(now + 86400);
tt_str_op(entry_stats_2,==, s);
tt_str_op(entry_stats_2,OP_EQ, s);
tor_free(s);
/* Stop collecting entry statistics. */
......@@ -1083,7 +1083,7 @@ test_geoip_with_pt(void *arg)
/* Test the transport history string. */
s = geoip_get_transport_history();
tor_assert(s);
tt_str_op(s,==, "<OR>=8,alpha=16,beta=8,charlie=16,ddr=136,"
tt_str_op(s,OP_EQ, "<OR>=8,alpha=16,beta=8,charlie=16,ddr=136,"
"entropy=8,fire=8,google=8");
/* Stop collecting entry statistics. */
......@@ -1126,7 +1126,7 @@ test_stats(void *arg)
tt_str_op("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"exit-kibibytes-written 80=1,443=1,other=0\n"
"exit-kibibytes-read 80=10,443=20,other=0\n"
"exit-streams-opened 80=4,443=4,other=0\n",==, s);
"exit-streams-opened 80=4,443=4,other=0\n",OP_EQ, s);
tor_free(s);
/* Add a few bytes on 10 more ports and ensure that only the top 10
......@@ -1142,7 +1142,7 @@ test_stats(void *arg)
"exit-kibibytes-read 52=1,53=1,54=1,55=1,56=1,57=1,58=1,"
"59=1,80=10,443=20,other=1\n"
"exit-streams-opened 52=4,53=4,54=4,55=4,56=4,57=4,58=4,"
"59=4,80=4,443=4,other=4\n",==, s);
"59=4,80=4,443=4,other=4\n",OP_EQ, s);
tor_free(s);
/* Stop collecting stats, add some bytes, and ensure we don't generate
......@@ -1162,7 +1162,7 @@ test_stats(void *arg)
tt_str_op("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"exit-kibibytes-written other=0\n"
"exit-kibibytes-read other=0\n"
"exit-streams-opened other=0\n",==, s);
"exit-streams-opened other=0\n",OP_EQ, s);
tor_free(s);
/* Continue with testing connection statistics; we shouldn't collect
......@@ -1178,7 +1178,7 @@ test_stats(void *arg)
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
s = rep_hist_format_conn_stats(now + 86400);
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n",==, s);
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n",OP_EQ, s);
tor_free(s);
/* Stop collecting stats, add some bytes, and ensure we don't generate
......@@ -1197,7 +1197,7 @@ test_stats(void *arg)
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
rep_hist_reset_conn_stats(now);
s = rep_hist_format_conn_stats(now + 86400);
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n",==, s);
tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n",OP_EQ, s);
tor_free(s);
/* Continue with testing buffer statistics; we shouldn't collect buffer
......@@ -1216,7 +1216,7 @@ test_stats(void *arg)
"cell-queued-cells 2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"
"0.00,0.00\n"
"cell-time-in-queue 2,0,0,0,0,0,0,0,0,0\n"
"cell-circuits-per-decile 1\n",==, s);
"cell-circuits-per-decile 1\n",OP_EQ, s);
tor_free(s);
/* Add nineteen more circuit statistics to the one that's already in the
......@@ -1231,7 +1231,7 @@ test_stats(void *arg)
"cell-queued-cells 2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,"
"2.75,2.75\n"
"cell-time-in-queue 3,3,3,3,3,3,3,3,3,3\n"
"cell-circuits-per-decile 2\n",==, s);
"cell-circuits-per-decile 2\n",OP_EQ, s);
tor_free(s);
/* Stop collecting stats, add statistics for one circuit, and ensure we
......@@ -1252,7 +1252,7 @@ test_stats(void *arg)
"cell-queued-cells 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"
"0.00,0.00\n"
"cell-time-in-queue 0,0,0,0,0,0,0,0,0,0\n"
"cell-circuits-per-decile 0\n",==, s);
"cell-circuits-per-decile 0\n",OP_EQ, s);
done:
tor_free(s);
......
......@@ -34,7 +34,7 @@
tt_mem_op(expr1, op, mem_op_hex_tmp, length/2); \
STMT_END
#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, ==, hex)
#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, OP_EQ, hex)
#define tt_double_op(a,op,b) \
tt_assert_test_type(a,b,#a" "#op" "#b,double,(val1_ op val2_),"%f", \
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -21,7 +21,7 @@ test_cq_manip(void *arg)
#endif /* ENABLE_MEMPOOLS */
cell_queue_init(&cq);
tt_int_op(cq.n, ==, 0);
tt_int_op(cq.n, OP_EQ, 0);
pc1 = packed_cell_new();
pc2 = packed_cell_new();
......@@ -29,26 +29,26 @@ test_cq_manip(void *arg)
pc4 = packed_cell_new();
tt_assert(pc1 && pc2 && pc3 && pc4);
tt_ptr_op(NULL, ==, cell_queue_pop(&cq));
tt_ptr_op(NULL, OP_EQ, cell_queue_pop(&cq));
/* Add and remove a singleton. */
cell_queue_append(&cq, pc1);
tt_int_op(cq.n, ==, 1);
tt_ptr_op(pc1, ==, cell_queue_pop(&cq));
tt_int_op(cq.n, ==, 0);
tt_int_op(cq.n, OP_EQ, 1);
tt_ptr_op(pc1, OP_EQ, cell_queue_pop(&cq));
tt_int_op(cq.n, OP_EQ, 0);
/* Add and remove four items */
cell_queue_append(&cq, pc4);
cell_queue_append(&cq, pc3);
cell_queue_append(&cq, pc2);
cell_queue_append(&cq, pc1);
tt_int_op(cq.n, ==, 4);
tt_ptr_op(pc4, ==, cell_queue_pop(&cq));
tt_ptr_op(pc3, ==, cell_queue_pop(&cq));
tt_ptr_op(pc2, ==, cell_queue_pop(&cq));
tt_ptr_op(pc1, ==, cell_queue_pop(&cq));
tt_int_op(cq.n, ==, 0);
tt_ptr_op(NULL, ==, cell_queue_pop(&cq));
tt_int_op(cq.n, OP_EQ, 4);
tt_ptr_op(pc4, OP_EQ, cell_queue_pop(&cq));
tt_ptr_op(pc3, OP_EQ, cell_queue_pop(&cq));
tt_ptr_op(pc2, OP_EQ, cell_queue_pop(&cq));
tt_ptr_op(pc1, OP_EQ, cell_queue_pop(&cq));
tt_int_op(cq.n, OP_EQ, 0);
tt_ptr_op(NULL, OP_EQ, cell_queue_pop(&cq));
/* Try a packed copy (wide, then narrow, which is a bit of a cheat, since a
* real cell queue has only one type.) */
......@@ -64,32 +64,32 @@ test_cq_manip(void *arg)
cell.circ_id = 0x2013;
cell_queue_append_packed_copy(NULL /*circ*/, &cq, 0 /*exitward*/, &cell,
0 /*wide*/, 0 /*stats*/);
tt_int_op(cq.n, ==, 2);
tt_int_op(cq.n, OP_EQ, 2);
pc_tmp = cell_queue_pop(&cq);
tt_int_op(cq.n, ==, 1);
tt_ptr_op(pc_tmp, !=, NULL);
tt_mem_op(pc_tmp->body, ==, "\x12\x34\x56\x78\x0a", 5);
tt_mem_op(pc_tmp->body+5, ==, cell.payload, sizeof(cell.payload));
tt_int_op(cq.n, OP_EQ, 1);
tt_ptr_op(pc_tmp, OP_NE, NULL);
tt_mem_op(pc_tmp->body, OP_EQ, "\x12\x34\x56\x78\x0a", 5);
tt_mem_op(pc_tmp->body+5, OP_EQ, cell.payload, sizeof(cell.payload));
packed_cell_free(pc_tmp);
pc_tmp = cell_queue_pop(&cq);
tt_int_op(cq.n, ==, 0);
tt_ptr_op(pc_tmp, !=, NULL);
tt_mem_op(pc_tmp->body, ==, "\x20\x13\x0a", 3);
tt_mem_op(pc_tmp->body+3, ==, cell.payload, sizeof(cell.payload));
tt_int_op(cq.n, OP_EQ, 0);
tt_ptr_op(pc_tmp, OP_NE, NULL);
tt_mem_op(pc_tmp->body, OP_EQ, "\x20\x13\x0a", 3);
tt_mem_op(pc_tmp->body+3, OP_EQ, cell.payload, sizeof(cell.payload));
packed_cell_free(pc_tmp);
pc_tmp = NULL;
tt_ptr_op(NULL, ==, cell_queue_pop(&cq));
tt_ptr_op(NULL, OP_EQ, cell_queue_pop(&cq));
/* Now make sure cell_queue_clear works. */
cell_queue_append(&cq, pc2);
cell_queue_append(&cq, pc1);
tt_int_op(cq.n, ==, 2);
tt_int_op(cq.n, OP_EQ, 2);
cell_queue_clear(&cq);
pc2 = pc1 = NULL; /* prevent double-free */
tt_int_op(cq.n, ==, 0);
tt_int_op(cq.n, OP_EQ, 0);
done:
packed_cell_free(pc1);
......@@ -129,17 +129,17 @@ test_circuit_n_cells(void *arg)
origin_c = origin_circuit_new();
origin_c->base_.purpose = CIRCUIT_PURPOSE_C_GENERAL;
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), ==, 0);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), OP_EQ, 0);
cell_queue_append(&or_c->p_chan_cells, pc1);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), ==, 1);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), OP_EQ, 1);
cell_queue_append(&or_c->base_.n_chan_cells, pc2);
cell_queue_append(&or_c->base_.n_chan_cells, pc3);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), ==, 3);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(or_c)), OP_EQ, 3);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(origin_c)), ==, 0);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(origin_c)), OP_EQ, 0);
cell_queue_append(&origin_c->base_.n_chan_cells, pc4);
cell_queue_append(&origin_c->base_.n_chan_cells, pc5);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(origin_c)), ==, 2);
tt_int_op(n_cells_in_circ_queues(TO_CIRCUIT(origin_c)), OP_EQ, 2);
done:
circuit_free(TO_CIRCUIT(or_c));
......
......@@ -31,41 +31,41 @@ test_checkdir_perms(void *testdata)
/* setup data directory before tests. */
tor_free(options->DataDirectory);
options->DataDirectory = tor_strdup(get_fname(subdir));
tt_int_op(mkdir(options->DataDirectory, 0750), ==, 0);
tt_int_op(mkdir(options->DataDirectory, 0750), OP_EQ, 0);
/* test: create new dir, no flags. */
testdir = get_datadir_fname("checkdir_new_none");
cpd_chkopts = CPD_CREATE;
unix_verify_optsmask = 0077;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: create new dir, CPD_GROUP_OK option set. */
testdir = get_datadir_fname("checkdir_new_groupok");
cpd_chkopts = CPD_CREATE|CPD_GROUP_OK;
unix_verify_optsmask = 0077;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: should get an error on existing dir with
wrong perms */
testdir = get_datadir_fname("checkdir_new_groupok_err");
tt_int_op(0, ==, mkdir(testdir, 027));
tt_int_op(0, OP_EQ, mkdir(testdir, 027));
cpd_chkopts = CPD_CHECK_MODE_ONLY|CPD_CREATE|CPD_GROUP_OK;
tt_int_op_nowin(-1, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op_nowin(-1, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tor_free(testdir);
/* test: create new dir, CPD_GROUP_READ option set. */
testdir = get_datadir_fname("checkdir_new_groupread");
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
......@@ -75,10 +75,10 @@ test_checkdir_perms(void *testdata)
unix_create_opts = 0700;
(void)unix_create_opts;
unix_verify_optsmask = 0077;
tt_int_op(0, ==, mkdir(testdir, unix_create_opts));
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, mkdir(testdir, unix_create_opts));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
......@@ -86,11 +86,11 @@ test_checkdir_perms(void *testdata)
testdir = get_datadir_fname("checkdir_exists_groupok");
cpd_chkopts = CPD_CREATE;
unix_verify_optsmask = 0077;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
cpd_chkopts = CPD_GROUP_OK;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with defaults,
......@@ -98,11 +98,11 @@ test_checkdir_perms(void *testdata)
testdir = get_datadir_fname("checkdir_exists_groupread");
cpd_chkopts = CPD_CREATE;
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
cpd_chkopts = CPD_GROUP_READ;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with CPD_GROUP_READ,
......@@ -110,11 +110,11 @@ test_checkdir_perms(void *testdata)
testdir = get_datadir_fname("checkdir_existsread_groupok");
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
cpd_chkopts = CPD_GROUP_OK;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
tor_free(testdir);
/* test: check existing dir created with CPD_GROUP_READ,
......@@ -122,9 +122,9 @@ test_checkdir_perms(void *testdata)
testdir = get_datadir_fname("checkdir_existsread_groupread");
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
unix_verify_optsmask = 0027;
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, ==, stat(testdir, &st));
tt_int_op_nowin(0, ==, (st.st_mode & unix_verify_optsmask));
tt_int_op(0, OP_EQ, check_private_dir(testdir, cpd_chkopts, NULL));
tt_int_op(0, OP_EQ, stat(testdir, &st));
tt_int_op_nowin(0, OP_EQ, (st.st_mode & unix_verify_optsmask));
done:
tor_free(testdir);
......
......@@ -50,17 +50,17 @@ circuitmux_detach_mock(circuitmux_t *cmux, circuit_t *circ)
}
#define GOT_CMUX_ATTACH(mux_, circ_, dir_) do { \
tt_int_op(cam.ncalls, ==, 1); \
tt_ptr_op(cam.cmux, ==, (mux_)); \
tt_ptr_op(cam.circ, ==, (circ_)); \
tt_int_op(cam.dir, ==, (dir_)); \
tt_int_op(cam.ncalls, OP_EQ, 1); \
tt_ptr_op(cam.cmux, OP_EQ, (mux_)); \
tt_ptr_op(cam.circ, OP_EQ, (circ_)); \
tt_int_op(cam.dir, OP_EQ, (dir_)); \
memset(&cam, 0, sizeof(cam)); \
} while (0)
#define GOT_CMUX_DETACH(mux_, circ_) do { \
tt_int_op(cdm.ncalls, ==, 1); \
tt_ptr_op(cdm.cmux, ==, (mux_)); \
tt_ptr_op(cdm.circ, ==, (circ_)); \
tt_int_op(cdm.ncalls, OP_EQ, 1); \
tt_ptr_op(cdm.cmux, OP_EQ, (mux_)); \
tt_ptr_op(cdm.circ, OP_EQ, (circ_)); \
memset(&cdm, 0, sizeof(cdm)); \
} while (0)
......@@ -90,14 +90,14 @@ test_clist_maps(void *arg)
or_c1 = or_circuit_new(100, ch2);
tt_assert(or_c1);
GOT_CMUX_ATTACH(ch2->cmux, or_c1, CELL_DIRECTION_IN);
tt_int_op(or_c1->p_circ_id, ==, 100);
tt_ptr_op(or_c1->p_chan, ==, ch2);
tt_int_op(or_c1->p_circ_id, OP_EQ, 100);
tt_ptr_op(or_c1->p_chan, OP_EQ, ch2);
or_c2 = or_circuit_new(100, ch1);
tt_assert(or_c2);
GOT_CMUX_ATTACH(ch1->cmux, or_c2, CELL_DIRECTION_IN);
tt_int_op(or_c2->p_circ_id, ==, 100);
tt_ptr_op(or_c2->p_chan, ==, ch1);
tt_int_op(or_c2->p_circ_id, OP_EQ, 100);
tt_ptr_op(or_c2->p_chan, OP_EQ, ch1);
circuit_set_n_circid_chan(TO_CIRCUIT(or_c1), 200, ch1);
GOT_CMUX_ATTACH(ch1->cmux, or_c1, CELL_DIRECTION_OUT);
......@@ -105,11 +105,11 @@ test_clist_maps(void *arg)
circuit_set_n_circid_chan(TO_CIRCUIT(or_c2), 200, ch2);
GOT_CMUX_ATTACH(ch2->cmux, or_c2, CELL_DIRECTION_OUT);
tt_ptr_op(circuit_get_by_circid_channel(200, ch1), ==, TO_CIRCUIT(or_c1));
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), ==, TO_CIRCUIT(or_c2));
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), ==, TO_CIRCUIT(or_c1));
tt_ptr_op(circuit_get_by_circid_channel(200, ch1), OP_EQ, TO_CIRCUIT(or_c1));
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), OP_EQ, TO_CIRCUIT(or_c2));
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), OP_EQ, TO_CIRCUIT(or_c1));
/* Try the same thing again, to test the "fast" path. */
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), ==, TO_CIRCUIT(or_c1));
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), OP_EQ, TO_CIRCUIT(or_c1));
tt_assert(circuit_id_in_use_on_channel(100, ch2));
tt_assert(! circuit_id_in_use_on_channel(101, ch2));
......@@ -117,9 +117,9 @@ test_clist_maps(void *arg)
circuit_set_p_circid_chan(or_c1, 500, ch3);
GOT_CMUX_DETACH(ch2->cmux, TO_CIRCUIT(or_c1));
GOT_CMUX_ATTACH(ch3->cmux, TO_CIRCUIT(or_c1), CELL_DIRECTION_IN);
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), ==, NULL);
tt_ptr_op(circuit_get_by_circid_channel(100, ch2), OP_EQ, NULL);
tt_assert(! circuit_id_in_use_on_channel(100, ch2));
tt_ptr_op(circuit_get_by_circid_channel(500, ch3), ==, TO_CIRCUIT(or_c1));
tt_ptr_op(circuit_get_by_circid_channel(500, ch3), OP_EQ, TO_CIRCUIT(or_c1));
/* Now let's see about destroy handling. */
tt_assert(! circuit_id_in_use_on_channel(205, ch2));
......@@ -132,26 +132,26 @@ test_clist_maps(void *arg)
tt_assert(circuit_id_in_use_on_channel(100, ch1));
tt_assert(TO_CIRCUIT(or_c2)->n_delete_pending != 0);
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), ==, TO_CIRCUIT(or_c2));
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), ==, TO_CIRCUIT(or_c2));
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), OP_EQ, TO_CIRCUIT(or_c2));
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), OP_EQ, TO_CIRCUIT(or_c2));
/* Okay, now free ch2 and make sure that the circuit ID is STILL not
* usable, because we haven't declared the destroy to be nonpending */
tt_int_op(cdm.ncalls, ==, 0);
tt_int_op(cdm.ncalls, OP_EQ, 0);
circuit_free(TO_CIRCUIT(or_c2));
or_c2 = NULL; /* prevent free */
tt_int_op(cdm.ncalls, ==, 2);
tt_int_op(cdm.ncalls, OP_EQ, 2);
memset(&cdm, 0, sizeof(cdm));
tt_assert(circuit_id_in_use_on_channel(200, ch2));
tt_assert(circuit_id_in_use_on_channel(100, ch1));
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), ==, NULL);
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), ==, NULL);
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), OP_EQ, NULL);
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), OP_EQ, NULL);
/* Now say that the destroy is nonpending */
channel_note_destroy_not_pending(ch2, 200);
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), ==, NULL);
tt_ptr_op(circuit_get_by_circid_channel(200, ch2), OP_EQ, NULL);
channel_note_destroy_not_pending(ch1, 100);
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), ==, NULL);
tt_ptr_op(circuit_get_by_circid_channel(100, ch1), OP_EQ, NULL);
tt_assert(! circuit_id_in_use_on_channel(200, ch2));
tt_assert(! circuit_id_in_use_on_channel(100, ch1));
......@@ -190,73 +190,73 @@ test_rend_token_maps(void *arg)
c4 = or_circuit_new(0, NULL);
/* Make sure we really filled up the tok* variables */
tt_int_op(tok1[REND_TOKEN_LEN-1], ==, 'y');
tt_int_op(tok2[REND_TOKEN_LEN-1], ==, ' ');
tt_int_op(tok3[REND_TOKEN_LEN-1], ==, '.');
tt_int_op(tok1[REND_TOKEN_LEN-1], OP_EQ, 'y');
tt_int_op(tok2[REND_TOKEN_LEN-1], OP_EQ, ' ');
tt_int_op(tok3[REND_TOKEN_LEN-1], OP_EQ, '.');
/* No maps; nothing there. */
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok1));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok1));
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok1));
circuit_set_rendezvous_cookie(c1, tok1);
circuit_set_intro_point_digest(c2, tok2);
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok3));
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok3));
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok2));
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok1));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok3));
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok3));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok2));
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok1));
/* Without purpose set, we don't get the circuits */
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok2));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok1));
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok2));
c1->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
c2->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
/* Okay, make sure they show up now. */
tt_ptr_op(c1, ==, circuit_get_rendezvous(tok1));
tt_ptr_op(c2, ==, circuit_get_intro_point(tok2));
tt_ptr_op(c1, OP_EQ, circuit_get_rendezvous(tok1));
tt_ptr_op(c2, OP_EQ, circuit_get_intro_point(tok2));
/* Two items at the same place with the same token. */
c3->base_.purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
circuit_set_rendezvous_cookie(c3, tok2);
tt_ptr_op(c2, ==, circuit_get_intro_point(tok2));
tt_ptr_op(c3, ==, circuit_get_rendezvous(tok2));
tt_ptr_op(c2, OP_EQ, circuit_get_intro_point(tok2));
tt_ptr_op(c3, OP_EQ, circuit_get_rendezvous(tok2));
/* Marking a circuit makes it not get returned any more */
circuit_mark_for_close(TO_CIRCUIT(c1), END_CIRC_REASON_FINISHED);
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok1));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok1));
circuit_free(TO_CIRCUIT(c1));
c1 = NULL;
/* Freeing a circuit makes it not get returned any more. */
circuit_free(TO_CIRCUIT(c2));
c2 = NULL;
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok2));
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok2));
/* c3 -- are you still there? */
tt_ptr_op(c3, ==, circuit_get_rendezvous(tok2));
tt_ptr_op(c3, OP_EQ, circuit_get_rendezvous(tok2));
/* Change its cookie. This never happens in Tor per se, but hey. */
c3->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
circuit_set_intro_point_digest(c3, tok3);
tt_ptr_op(NULL, ==, circuit_get_rendezvous(tok2));
tt_ptr_op(c3, ==, circuit_get_intro_point(tok3));
tt_ptr_op(NULL, OP_EQ, circuit_get_rendezvous(tok2));
tt_ptr_op(c3, OP_EQ, circuit_get_intro_point(tok3));
/* Now replace c3 with c4. */
c4->base_.purpose = CIRCUIT_PURPOSE_INTRO_POINT;
circuit_set_intro_point_digest(c4, tok3);
tt_ptr_op(c4, ==, circuit_get_intro_point(tok3));
tt_ptr_op(c4, OP_EQ, circuit_get_intro_point(tok3));
tt_ptr_op(c3->rendinfo, ==, NULL);
tt_ptr_op(c4->rendinfo, !=, NULL);
tt_mem_op(c4->rendinfo, ==, tok3, REND_TOKEN_LEN);
tt_ptr_op(c3->rendinfo, OP_EQ, NULL);
tt_ptr_op(c4->rendinfo, OP_NE, NULL);
tt_mem_op(c4->rendinfo, OP_EQ, tok3, REND_TOKEN_LEN);
/* Now clear c4's cookie. */
circuit_set_intro_point_digest(c4, NULL);
tt_ptr_op(c4->rendinfo, ==, NULL);
tt_ptr_op(NULL, ==, circuit_get_intro_point(tok3));
tt_ptr_op(c4->rendinfo, OP_EQ, NULL);
tt_ptr_op(NULL, OP_EQ, circuit_get_intro_point(tok3));
done:
if (c1)
......@@ -283,32 +283,32 @@ test_pick_circid(void *arg)
chan2->wide_circ_ids = 1;
chan1->circ_id_type = CIRC_ID_TYPE_NEITHER;
tt_int_op(0, ==, get_unique_circ_id_by_chan(chan1));
tt_int_op(0, OP_EQ, get_unique_circ_id_by_chan(chan1));
/* Basic tests, with no collisions */
chan1->circ_id_type = CIRC_ID_TYPE_LOWER;
for (i = 0; i < 50; ++i) {
circid = get_unique_circ_id_by_chan(chan1);
tt_uint_op(0, <, circid);
tt_uint_op(circid, <, (1<<15));
tt_uint_op(0, OP_LT, circid);
tt_uint_op(circid, OP_LT, (1<<15));
}
chan1->circ_id_type = CIRC_ID_TYPE_HIGHER;
for (i = 0; i < 50; ++i) {
circid = get_unique_circ_id_by_chan(chan1);
tt_uint_op((1<<15), <, circid);
tt_uint_op(circid, <, (1<<16));
tt_uint_op((1<<15), OP_LT, circid);
tt_uint_op(circid, OP_LT, (1<<16));
}
chan2->circ_id_type = CIRC_ID_TYPE_LOWER;
for (i = 0; i < 50; ++i) {
circid = get_unique_circ_id_by_chan(chan2);
tt_uint_op(0, <, circid);
tt_uint_op(circid, <, (1u<<31));
tt_uint_op(0, OP_LT, circid);
tt_uint_op(circid, OP_LT, (1u<<31));
}
chan2->circ_id_type = CIRC_ID_TYPE_HIGHER;
for (i = 0; i < 50; ++i) {
circid = get_unique_circ_id_by_chan(chan2);
tt_uint_op((1u<<31), <, circid);
tt_uint_op((1u<<31), OP_LT, circid);
}
/* Now make sure that we can behave well when we are full up on circuits */
......@@ -319,20 +319,20 @@ test_pick_circid(void *arg)
for (i = 0; i < (1<<15); ++i) {
circid = get_unique_circ_id_by_chan(chan1);
if (circid == 0) {
tt_int_op(i, >, (1<<14));
tt_int_op(i, OP_GT, (1<<14));
break;
}
tt_uint_op(circid, <, (1<<15));
tt_uint_op(circid, OP_LT, (1<<15));
tt_assert(! bitarray_is_set(ba, circid));
bitarray_set(ba, circid);
channel_mark_circid_unusable(chan1, circid);
}
tt_int_op(i, <, (1<<15));
tt_int_op(i, OP_LT, (1<<15));
/* Make sure that being full on chan1 does not interfere with chan2 */
for (i = 0; i < 100; ++i) {
circid = get_unique_circ_id_by_chan(chan2);
tt_uint_op(circid, >, 0);
tt_uint_op(circid, <, (1<<15));
tt_uint_op(circid, OP_GT, 0);
tt_uint_op(circid, OP_LT, (1<<15));
channel_mark_circid_unusable(chan2, circid);
}
......
......@@ -55,21 +55,21 @@ test_cmux_destroy_cell_queue(void *arg)
circuitmux_append_destroy_cell(ch, cmux, 190, 6);
circuitmux_append_destroy_cell(ch, cmux, 30, 1);
tt_int_op(circuitmux_num_cells(cmux), ==, 3);
tt_int_op(circuitmux_num_cells(cmux), OP_EQ, 3);
circ = circuitmux_get_first_active_circuit(cmux, &cq);
tt_assert(!circ);
tt_assert(cq);
tt_int_op(cq->n, ==, 3);
tt_int_op(cq->n, OP_EQ, 3);
pc = cell_queue_pop(cq);
tt_assert(pc);
tt_mem_op(pc->body, ==, "\x00\x00\x00\x64\x04\x0a\x00\x00\x00", 9);
tt_mem_op(pc->body, OP_EQ, "\x00\x00\x00\x64\x04\x0a\x00\x00\x00", 9);
packed_cell_free(pc);
pc = NULL;
tt_int_op(circuitmux_num_cells(cmux), ==, 2);
tt_int_op(circuitmux_num_cells(cmux), OP_EQ, 2);
done:
circuitmux_free(cmux);
......
......@@ -65,22 +65,22 @@ test_config_addressmap(void *arg)
/* MapAddress .google.com .torserver.exit */
strlcpy(address, "reader.google.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "reader.torserver.exit");
tt_str_op(address,OP_EQ, "reader.torserver.exit");
/* MapAddress *.yahoo.com *.google.com.torserver.exit */
strlcpy(address, "reader.yahoo.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "reader.google.com.torserver.exit");
tt_str_op(address,OP_EQ, "reader.google.com.torserver.exit");
/*MapAddress *.cnn.com www.cnn.com */
strlcpy(address, "cnn.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "www.cnn.com");
tt_str_op(address,OP_EQ, "www.cnn.com");
/* MapAddress .cn.com www.cnn.com */
strlcpy(address, "www.cn.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "www.cnn.com");
tt_str_op(address,OP_EQ, "www.cnn.com");
/* MapAddress ex.com www.cnn.com - no match */
strlcpy(address, "www.ex.com", sizeof(address));
......@@ -93,19 +93,19 @@ test_config_addressmap(void *arg)
/* Where mapping for FQDN match on FQDN */
strlcpy(address, "www.google.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "3.3.3.3");
tt_str_op(address,OP_EQ, "3.3.3.3");
strlcpy(address, "www.torproject.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "1.1.1.1");
tt_str_op(address,OP_EQ, "1.1.1.1");
strlcpy(address, "other.torproject.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "this.torproject.org.otherserver.exit");
tt_str_op(address,OP_EQ, "this.torproject.org.otherserver.exit");
strlcpy(address, "test.torproject.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "2.2.2.2");
tt_str_op(address,OP_EQ, "2.2.2.2");
/* Test a chain of address mappings and the order in which they were added:
"MapAddress www.example.org 4.4.4.4"
......@@ -114,12 +114,12 @@ test_config_addressmap(void *arg)
*/
strlcpy(address, "www.example.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "5.5.5.5");
tt_str_op(address,OP_EQ, "5.5.5.5");
/* Test infinite address mapping results in no change */
strlcpy(address, "www.infiniteloop.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "www.infiniteloop.org");
tt_str_op(address,OP_EQ, "www.infiniteloop.org");
/* Test we don't find false positives */
strlcpy(address, "www.example.com", sizeof(address));
......@@ -137,23 +137,23 @@ test_config_addressmap(void *arg)
strlcpy(address, "www.abc.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "www.abc.torserver.exit");
tt_str_op(address,OP_EQ, "www.abc.torserver.exit");
strlcpy(address, "www.def.com", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "www.def.torserver.exit");
tt_str_op(address,OP_EQ, "www.def.torserver.exit");
strlcpy(address, "www.torproject.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "1.1.1.1");
tt_str_op(address,OP_EQ, "1.1.1.1");
strlcpy(address, "test.torproject.org", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "1.1.1.1");
tt_str_op(address,OP_EQ, "1.1.1.1");
strlcpy(address, "torproject.net", sizeof(address));
tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
tt_str_op(address,==, "2.2.2.2");
tt_str_op(address,OP_EQ, "2.2.2.2");
/* We don't support '*' as a mapping directive */
config_free_lines(get_options_mutable()->AddressMap);
......@@ -213,9 +213,9 @@ test_config_check_or_create_data_subdir(void *arg)
subpath = get_datadir_fname(subdir);
#if defined (_WIN32)
tt_int_op(mkdir(options->DataDirectory), ==, 0);
tt_int_op(mkdir(options->DataDirectory), OP_EQ, 0);
#else
tt_int_op(mkdir(options->DataDirectory, 0700), ==, 0);
tt_int_op(mkdir(options->DataDirectory, 0700), OP_EQ, 0);
#endif
r = stat(subpath, &st);
......@@ -287,9 +287,9 @@ test_config_write_to_data_subdir(void *arg)
filepath = get_datadir_fname2(subdir, fname);
#if defined (_WIN32)
tt_int_op(mkdir(options->DataDirectory), ==, 0);
tt_int_op(mkdir(options->DataDirectory), OP_EQ, 0);
#else
tt_int_op(mkdir(options->DataDirectory, 0700), ==, 0);
tt_int_op(mkdir(options->DataDirectory, 0700), OP_EQ, 0);
#endif
// Write attempt shoudl fail, if subdirectory doesn't exist.
......@@ -300,13 +300,13 @@ test_config_write_to_data_subdir(void *arg)
// equal to the original string.
tt_assert(!write_to_data_subdir(subdir, fname, str, NULL));
cp = read_file_to_str(filepath, 0, NULL);
tt_str_op(cp,==, str);
tt_str_op(cp,OP_EQ, str);
tor_free(cp);
// A second write operation should overwrite the old content.
tt_assert(!write_to_data_subdir(subdir, fname, str, NULL));
cp = read_file_to_str(filepath, 0, NULL);
tt_str_op(cp,==, str);
tt_str_op(cp,OP_EQ, str);
tor_free(cp);
done:
......@@ -331,7 +331,7 @@ good_bridge_line_test(const char *string, const char *test_addrport,
/* test addrport */
tmp = tor_strdup(fmt_addrport(&bridge_line->addr, bridge_line->port));
tt_str_op(test_addrport,==, tmp);
tt_str_op(test_addrport,OP_EQ, tmp);
tor_free(tmp);
/* If we were asked to validate a digest, but we did not get a
......@@ -349,7 +349,7 @@ good_bridge_line_test(const char *string, const char *test_addrport,
if (test_digest) {
tmp = tor_strdup(hex_str(bridge_line->digest, DIGEST_LEN));
tor_strlower(tmp);
tt_str_op(test_digest,==, tmp);
tt_str_op(test_digest,OP_EQ, tmp);
tor_free(tmp);
}
......@@ -360,7 +360,7 @@ good_bridge_line_test(const char *string, const char *test_addrport,
if (!test_transport && bridge_line->transport_name)
tt_assert(0);
if (test_transport)
tt_str_op(test_transport,==, bridge_line->transport_name);
tt_str_op(test_transport,OP_EQ, bridge_line->transport_name);
/* Validate the SOCKS argument smartlist. */
if (test_socks_args && !bridge_line->socks_args)
......@@ -839,7 +839,7 @@ test_config_fix_my_family(void *arg)
TT_FAIL(("options_validate failed: %s", err));
}
tt_str_op(options->MyFamily,==, "$1111111111111111111111111111111111111111, "
tt_str_op(options->MyFamily,OP_EQ, "$1111111111111111111111111111111111111111, "
"$1111111111111111111111111111111111111112, "
"$1111111111111111111111111111111111111113");
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ help_test_bucket_note_empty(uint32_t expected_msec_since_midnight,
tvnow.tv_usec = (msec_since_epoch % 1000) * 1000;
connection_buckets_note_empty_ts(&timestamp_var, tokens_before,
tokens_removed, &tvnow);
tt_int_op(expected_msec_since_midnight, ==, timestamp_var);
tt_int_op(expected_msec_since_midnight, OP_EQ, timestamp_var);
done:
;
......@@ -57,20 +57,20 @@ test_cntev_bucket_millis_empty(void *arg)
tvnow.tv_usec = 200000;
/* Bucket has not been refilled. */
tt_int_op(0, ==, bucket_millis_empty(0, 42120, 0, 100, &tvnow));
tt_int_op(0, ==, bucket_millis_empty(-10, 42120, -10, 100, &tvnow));
tt_int_op(0, OP_EQ, bucket_millis_empty(0, 42120, 0, 100, &tvnow));
tt_int_op(0, OP_EQ, bucket_millis_empty(-10, 42120, -10, 100, &tvnow));
/* Bucket was not empty. */
tt_int_op(0, ==, bucket_millis_empty(10, 42120, 20, 100, &tvnow));
tt_int_op(0, OP_EQ, bucket_millis_empty(10, 42120, 20, 100, &tvnow));
/* Bucket has been emptied 80 msec ago and has just been refilled. */
tt_int_op(80, ==, bucket_millis_empty(-20, 42120, -10, 100, &tvnow));
tt_int_op(80, ==, bucket_millis_empty(-10, 42120, 0, 100, &tvnow));
tt_int_op(80, ==, bucket_millis_empty(0, 42120, 10, 100, &tvnow));
tt_int_op(80, OP_EQ, bucket_millis_empty(-20, 42120, -10, 100, &tvnow));
tt_int_op(80, OP_EQ, bucket_millis_empty(-10, 42120, 0, 100, &tvnow));
tt_int_op(80, OP_EQ, bucket_millis_empty(0, 42120, 10, 100, &tvnow));
/* Bucket has been emptied 180 msec ago, last refill was 100 msec ago
* which was insufficient to make it positive, so cap msec at 100. */
tt_int_op(100, ==, bucket_millis_empty(0, 42020, 1, 100, &tvnow));
tt_int_op(100, OP_EQ, bucket_millis_empty(0, 42020, 1, 100, &tvnow));
/* 1970-01-02 00:00:00:050000 */
tvnow.tv_sec = 86400;
......@@ -78,7 +78,7 @@ test_cntev_bucket_millis_empty(void *arg)
/* Last emptied 30 msec before midnight, tvnow is 50 msec after
* midnight, that's 80 msec in total. */
tt_int_op(80, ==, bucket_millis_empty(0, 86400000 - 30, 1, 100, &tvnow));
tt_int_op(80, OP_EQ, bucket_millis_empty(0, 86400000 - 30, 1, 100, &tvnow));
done:
;
......@@ -118,26 +118,26 @@ test_cntev_sum_up_cell_stats(void *arg)
cell_stats = tor_malloc_zero(sizeof(cell_stats_t));
add_testing_cell_stats_entry(circ, CELL_RELAY, 0, 0, 0);
sum_up_cell_stats_by_command(circ, cell_stats);
tt_u64_op(1, ==, cell_stats->added_cells_appward[CELL_RELAY]);
tt_u64_op(1, OP_EQ, cell_stats->added_cells_appward[CELL_RELAY]);
/* A single RELAY cell was added to the exitward queue. */
add_testing_cell_stats_entry(circ, CELL_RELAY, 0, 0, 1);
sum_up_cell_stats_by_command(circ, cell_stats);
tt_u64_op(1, ==, cell_stats->added_cells_exitward[CELL_RELAY]);
tt_u64_op(1, OP_EQ, cell_stats->added_cells_exitward[CELL_RELAY]);
/* A single RELAY cell was removed from the appward queue where it spent
* 20 msec. */
add_testing_cell_stats_entry(circ, CELL_RELAY, 2, 1, 0);
sum_up_cell_stats_by_command(circ, cell_stats);
tt_u64_op(20, ==, cell_stats->total_time_appward[CELL_RELAY]);
tt_u64_op(1, ==, cell_stats->removed_cells_appward[CELL_RELAY]);
tt_u64_op(20, OP_EQ, cell_stats->total_time_appward[CELL_RELAY]);
tt_u64_op(1, OP_EQ, cell_stats->removed_cells_appward[CELL_RELAY]);
/* A single RELAY cell was removed from the exitward queue where it
* spent 30 msec. */
add_testing_cell_stats_entry(circ, CELL_RELAY, 3, 1, 1);
sum_up_cell_stats_by_command(circ, cell_stats);
tt_u64_op(30, ==, cell_stats->total_time_exitward[CELL_RELAY]);
tt_u64_op(1, ==, cell_stats->removed_cells_exitward[CELL_RELAY]);
tt_u64_op(30, OP_EQ, cell_stats->total_time_exitward[CELL_RELAY]);
tt_u64_op(1, OP_EQ, cell_stats->removed_cells_exitward[CELL_RELAY]);
done:
tor_free(cell_stats);
......@@ -164,7 +164,7 @@ test_cntev_append_cell_stats(void *arg)
append_cell_stats_by_command(event_parts, key,
include_if_non_zero,
number_to_include);
tt_int_op(0, ==, smartlist_len(event_parts));
tt_int_op(0, OP_EQ, smartlist_len(event_parts));
/* There's a RELAY cell to include, but the corresponding field in
* include_if_non_zero is still zero. */
......@@ -172,7 +172,7 @@ test_cntev_append_cell_stats(void *arg)
append_cell_stats_by_command(event_parts, key,
include_if_non_zero,
number_to_include);
tt_int_op(0, ==, smartlist_len(event_parts));
tt_int_op(0, OP_EQ, smartlist_len(event_parts));
/* Now include single RELAY cell. */
include_if_non_zero[CELL_RELAY] = 2;
......@@ -180,7 +180,7 @@ test_cntev_append_cell_stats(void *arg)
include_if_non_zero,
number_to_include);
cp = smartlist_pop_last(event_parts);
tt_str_op("Z=relay:1", ==, cp);
tt_str_op("Z=relay:1", OP_EQ, cp);
tor_free(cp);
/* Add four CREATE cells. */
......@@ -190,7 +190,7 @@ test_cntev_append_cell_stats(void *arg)
include_if_non_zero,
number_to_include);
cp = smartlist_pop_last(event_parts);
tt_str_op("Z=create:4,relay:1", ==, cp);
tt_str_op("Z=create:4,relay:1", OP_EQ, cp);
done:
tor_free(cp);
......@@ -220,14 +220,14 @@ test_cntev_format_cell_stats(void *arg)
/* Origin circuit was completely idle. */
cell_stats = tor_malloc_zero(sizeof(cell_stats_t));
format_cell_stats(&event_string, TO_CIRCUIT(ocirc), cell_stats);
tt_str_op("ID=2 OutboundQueue=3 OutboundConn=1", ==, event_string);
tt_str_op("ID=2 OutboundQueue=3 OutboundConn=1", OP_EQ, event_string);
tor_free(event_string);
/* Origin circuit had 4 RELAY cells added to its exitward queue. */
cell_stats->added_cells_exitward[CELL_RELAY] = 4;
format_cell_stats(&event_string, TO_CIRCUIT(ocirc), cell_stats);
tt_str_op("ID=2 OutboundQueue=3 OutboundConn=1 OutboundAdded=relay:4",
==, event_string);
OP_EQ, event_string);
tor_free(event_string);
/* Origin circuit also had 5 CREATE2 cells added to its exitward
......@@ -235,7 +235,7 @@ test_cntev_format_cell_stats(void *arg)
cell_stats->added_cells_exitward[CELL_CREATE2] = 5;
format_cell_stats(&event_string, TO_CIRCUIT(ocirc), cell_stats);
tt_str_op("ID=2 OutboundQueue=3 OutboundConn=1 OutboundAdded=relay:4,"
"create2:5", ==, event_string);
"create2:5", OP_EQ, event_string);
tor_free(event_string);
/* Origin circuit also had 7 RELAY cells removed from its exitward queue
......@@ -245,7 +245,7 @@ test_cntev_format_cell_stats(void *arg)
format_cell_stats(&event_string, TO_CIRCUIT(ocirc), cell_stats);
tt_str_op("ID=2 OutboundQueue=3 OutboundConn=1 OutboundAdded=relay:4,"
"create2:5 OutboundRemoved=relay:7 OutboundTime=relay:6",
==, event_string);
OP_EQ, event_string);
tor_free(event_string);
p_chan = tor_malloc_zero(sizeof(channel_tls_t));
......@@ -265,14 +265,14 @@ test_cntev_format_cell_stats(void *arg)
cell_stats = tor_malloc_zero(sizeof(cell_stats_t));
format_cell_stats(&event_string, TO_CIRCUIT(or_circ), cell_stats);
tt_str_op("InboundQueue=8 InboundConn=2 OutboundQueue=9 OutboundConn=1",
==, event_string);
OP_EQ, event_string);
tor_free(event_string);
/* OR circuit had 3 RELAY cells added to its appward queue. */
cell_stats->added_cells_appward[CELL_RELAY] = 3;
format_cell_stats(&event_string, TO_CIRCUIT(or_circ), cell_stats);
tt_str_op("InboundQueue=8 InboundConn=2 InboundAdded=relay:3 "
"OutboundQueue=9 OutboundConn=1", ==, event_string);
"OutboundQueue=9 OutboundConn=1", OP_EQ, event_string);
tor_free(event_string);
/* OR circuit had 7 RELAY cells removed from its appward queue which
......@@ -282,7 +282,7 @@ test_cntev_format_cell_stats(void *arg)
format_cell_stats(&event_string, TO_CIRCUIT(or_circ), cell_stats);
tt_str_op("InboundQueue=8 InboundConn=2 InboundAdded=relay:3 "
"InboundRemoved=relay:7 InboundTime=relay:6 "
"OutboundQueue=9 OutboundConn=1", ==, event_string);
"OutboundQueue=9 OutboundConn=1", OP_EQ, event_string);
done:
tor_free(cell_stats);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -85,7 +85,7 @@ test_hs_desc_event(void *arg)
expected_msg = "650 HS_DESC REQUESTED "STR_HS_ADDR" NO_AUTH "\
STR_HSDIR_EXIST_LONGNAME" "STR_HS_ID"\r\n";
tt_assert(received_msg);
tt_str_op(received_msg,==, expected_msg);
tt_str_op(received_msg,OP_EQ, expected_msg);
tor_free(received_msg);
/* test received event */
......@@ -94,7 +94,7 @@ test_hs_desc_event(void *arg)
expected_msg = "650 HS_DESC RECEIVED "STR_HS_ADDR" BASIC_AUTH "\
STR_HSDIR_EXIST_LONGNAME"\r\n";
tt_assert(received_msg);
tt_str_op(received_msg,==, expected_msg);
tt_str_op(received_msg,OP_EQ, expected_msg);
tor_free(received_msg);
/* test failed event */
......@@ -103,7 +103,7 @@ test_hs_desc_event(void *arg)
expected_msg = "650 HS_DESC FAILED "STR_HS_ADDR" STEALTH_AUTH "\
STR_HSDIR_NONE_EXIST_LONGNAME"\r\n";
tt_assert(received_msg);
tt_str_op(received_msg,==, expected_msg);
tt_str_op(received_msg,OP_EQ, expected_msg);
tor_free(received_msg);
/* test invalid auth type */
......@@ -112,7 +112,7 @@ test_hs_desc_event(void *arg)
expected_msg = "650 HS_DESC FAILED "STR_HS_ADDR" UNKNOWN "\
STR_HSDIR_EXIST_LONGNAME"\r\n";
tt_assert(received_msg);
tt_str_op(received_msg,==, expected_msg);
tt_str_op(received_msg,OP_EQ, expected_msg);
tor_free(received_msg);
done:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment