Merge branch 'ahf_bug22497_redux'

This commit is contained in:
Nick Mathewson 2017-08-24 16:11:43 -04:00
commit da75dfc0e5
66 changed files with 2561 additions and 2434 deletions

4
changes/bug22497 Normal file
View File

@ -0,0 +1,4 @@
o Code simplification and refactoring:
- Use our test macros more consistently, to produce more useful
error messages when our unit tests fail. Add coccinelle patches
to allow us to re-check for test macro uses. Closes ticket 22497.

View File

@ -0,0 +1,6 @@
@@
expression n, d;
@@
- (((n) + (d) - 1) / (d))
+ CEIL_DIV(n, d)

View File

@ -0,0 +1,11 @@
#!/usr/bin/perl -w -p -i
next if m#^ */\*# or m#^ *\* #;
s/<([,)])/OP_LT$1/;
s/(?<=[\s,])>([,)])/OP_GT$1/;
#s/>([,)])/OP_GT$1/;
s/==([,)])/OP_EQ$1/;
s/>=([,)])/OP_GE$1/;
s/<=([,)])/OP_LE$1/;
s/!=([,)])/OP_NE$1/;

View File

@ -0,0 +1,49 @@
@@
int e;
constant c;
@@
(
- tt_assert(e == c)
+ tt_int_op(e, OP_EQ, c)
|
- tt_assert(e != c)
+ tt_int_op(e, OP_NE, c)
|
- tt_assert(e < c)
+ tt_int_op(e, OP_LT, c)
|
- tt_assert(e <= c)
+ tt_int_op(e, OP_LE, c)
|
- tt_assert(e > c)
+ tt_int_op(e, OP_GT, c)
|
- tt_assert(e >= c)
+ tt_int_op(e, OP_GE, c)
)
@@
unsigned int e;
constant c;
@@
(
- tt_assert(e == c)
+ tt_uint_op(e, OP_EQ, c)
|
- tt_assert(e != c)
+ tt_uint_op(e, OP_NE, c)
|
- tt_assert(e < c)
+ tt_uint_op(e, OP_LT, c)
|
- tt_assert(e <= c)
+ tt_uint_op(e, OP_LE, c)
|
- tt_assert(e > c)
+ tt_uint_op(e, OP_GT, c)
|
- tt_assert(e >= c)
+ tt_uint_op(e, OP_GE, c)
)

View File

@ -0,0 +1,11 @@
@@
expression * e;
@@
(
- tt_assert(e != NULL)
+ tt_ptr_op(e, OP_NE, NULL)
|
- tt_assert(e == NULL)
+ tt_ptr_op(e, OP_EQ, NULL)
)

View File

@ -0,0 +1,5 @@
@@
@@
- tt_assert(0)
+ tt_abort()

View File

@ -66,7 +66,7 @@ ENABLE_GCC_WARNING(redundant-decls)
#elif OPENSSL_VERSION_NUMBER >= OPENSSL_V_NOPATCH(1,0,1) && \
(defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || \
defined(_M_AMD64) || defined(_M_X64) || defined(__INTEL__)) \
defined(_M_AMD64) || defined(_M_X64) || defined(__INTEL__))
#define USE_EVP_AES_CTR

View File

@ -251,7 +251,7 @@ ratchet_timeval(const struct timeval *timeval_raw, struct timeval *out)
{
/* must hold lock */
timeradd(timeval_raw, &timeofday_offset, out);
if (PREDICT_UNLIKELY(timercmp(out, &last_timeofday, <))) {
if (PREDICT_UNLIKELY(timercmp(out, &last_timeofday, OP_LT))) {
/* time ran backwards. Instead, declare that no time occurred. */
timersub(&last_timeofday, timeval_raw, &timeofday_offset);
memcpy(out, &last_timeofday, sizeof(struct timeval));

View File

@ -2552,7 +2552,7 @@ rep_hist_format_buffer_stats(time_t now)
processed_cells_string,
queued_cells_string,
time_in_queue_string,
(number_of_circuits + SHARES - 1) / SHARES);
CEIL_DIV(number_of_circuits, SHARES));
tor_free(processed_cells_string);
tor_free(queued_cells_string);
tor_free(time_in_queue_string);

View File

@ -409,11 +409,11 @@ test_circuit_timeout(void *arg)
} while (fabs(circuit_build_times_cdf(&initial, timeout0) -
circuit_build_times_cdf(&initial, timeout1)) > 0.02);
tt_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE);
tt_int_op(estimate.total_build_times, OP_LE, CBT_NCIRCUITS_TO_OBSERVE);
circuit_build_times_update_state(&estimate, state);
circuit_build_times_free_timeouts(&final);
tt_assert(circuit_build_times_parse_state(&final, state) == 0);
tt_int_op(circuit_build_times_parse_state(&final, state), OP_EQ, 0);
circuit_build_times_update_alpha(&final);
timeout2 = circuit_build_times_calculate_timeout(&final,
@ -491,7 +491,7 @@ test_circuit_timeout(void *arg)
}
}
tt_assert(estimate.liveness.after_firsthop_idx == 0);
tt_int_op(estimate.liveness.after_firsthop_idx, OP_EQ, 0);
tt_assert(final.liveness.after_firsthop_idx ==
CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT-1);
@ -571,20 +571,21 @@ test_rend_fns(void *arg)
intro->intro_key = crypto_pk_dup_key(pk2);
smartlist_add(generated->intro_nodes, intro);
}
tt_assert(rend_encode_v2_descriptors(descs, generated, now, 0,
REND_NO_AUTH, NULL, NULL) > 0);
tt_assert(rend_compute_v2_desc_id(computed_desc_id, service_id_base32,
NULL, now, 0) == 0);
int rv = rend_encode_v2_descriptors(descs, generated, now, 0,
REND_NO_AUTH, NULL, NULL);
tt_int_op(rv, OP_GT, 0);
rv = rend_compute_v2_desc_id(computed_desc_id, service_id_base32, NULL,
now, 0);
tt_int_op(rv, OP_EQ, 0);
tt_mem_op(((rend_encoded_v2_service_descriptor_t *)
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,
&intro_points_size,
&encoded_size,
&next_desc,
((rend_encoded_v2_service_descriptor_t *)
smartlist_get(descs, 0))->desc_str, 1) == 0);
rv = rend_parse_v2_service_descriptor(&parsed, parsed_desc_id,
&intro_points_encrypted, &intro_points_size, &encoded_size,
&next_desc,
((rend_encoded_v2_service_descriptor_t *)smartlist_get(descs, 0))
->desc_str, 1);
tt_int_op(rv, OP_EQ, 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);
@ -786,7 +787,7 @@ test_geoip(void *arg)
/* Start testing bridge statistics by making sure that we don't output
* bridge stats without initializing them. */
s = geoip_format_bridge_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats and generate the bridge-stats history string out of
* the connecting clients added above. */
@ -800,7 +801,7 @@ test_geoip(void *arg)
* string anymore. */
geoip_bridge_stats_term();
s = geoip_format_bridge_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Stop being a bridge and start being a directory mirror that gathers
* directory request statistics. */
@ -814,7 +815,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_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats, note one connecting client, and generate the
* dirreq-stats history string. */
@ -831,7 +832,7 @@ test_geoip(void *arg)
SET_TEST_ADDRESS(101);
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
s = geoip_format_dirreq_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Re-start stats, add a connecting client, reset stats, and make sure
* that we get an all empty history string. */
@ -867,7 +868,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_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats, note one connecting client, and generate the
* entry-stats history string. */
@ -884,7 +885,7 @@ test_geoip(void *arg)
SET_TEST_ADDRESS(101);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
s = geoip_format_entry_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Re-start stats, add a connecting client, reset stats, and make sure
* that we get an all empty history string. */
@ -995,7 +996,7 @@ test_stats(void *arg)
rep_hist_note_exit_stream_opened(80);
rep_hist_note_exit_bytes(80, 100, 10000);
s = rep_hist_format_exit_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats, note some streams and bytes, and generate history
* string. */
@ -1033,7 +1034,7 @@ test_stats(void *arg)
rep_hist_exit_stats_term();
rep_hist_note_exit_bytes(80, 100, 10000);
s = rep_hist_format_exit_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Re-start stats, add some bytes, reset stats, and see what history we
* get when observing no streams or bytes at all. */
@ -1052,7 +1053,7 @@ test_stats(void *arg)
* conn stats without initializing them. */
rep_hist_note_or_conn_bytes(1, 20, 400, now);
s = rep_hist_format_conn_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats, note bytes, and generate history string. */
rep_hist_conn_stats_init(now);
@ -1069,7 +1070,7 @@ test_stats(void *arg)
rep_hist_conn_stats_term();
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
s = rep_hist_format_conn_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Re-start stats, add some bytes, reset stats, and see what history we
* get when observing no bytes at all. */
@ -1087,7 +1088,7 @@ test_stats(void *arg)
* stats without initializing them. */
rep_hist_add_buffer_stats(2.0, 2.0, 20);
s = rep_hist_format_buffer_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Initialize stats, add statistics for a single circuit, and generate
* the history string. */
@ -1122,7 +1123,7 @@ test_stats(void *arg)
rep_hist_buffer_stats_term();
rep_hist_add_buffer_stats(2.0, 2.0, 20);
s = rep_hist_format_buffer_stats(now + 86400);
tt_assert(!s);
tt_ptr_op(s, OP_EQ, NULL);
/* Re-start stats, add statistics for one circuit, reset stats, and make
* sure that the history has all zeros. */

View File

@ -45,8 +45,8 @@
* you're doing. */
#define tt_double_eq(a,b) \
STMT_BEGIN \
tt_double_op((a), >=, (b)); \
tt_double_op((a), <=, (b)); \
tt_double_op((a), OP_GE, (b)); \
tt_double_op((a), OP_LE, (b)); \
STMT_END
#ifdef _MSC_VER

View File

@ -451,10 +451,10 @@ test_addr_ip6_helpers(void *arg)
"::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);
tt_int_op(tor_addr_compare(&t1, &t2, CMP_SEMANTIC), OP_EQ, 0);
tor_addr_parse_mask_ports("[::ffff:2.3.4.4]", 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);
tt_int_op(tor_addr_compare(&t1, &t2, CMP_SEMANTIC), OP_LT, 0);
/* test compare_masked */
test_addr_compare_masked("ffff::", OP_EQ, "ffff::0", 128);
@ -637,7 +637,7 @@ test_addr_ip6_helpers(void *arg)
/* Try some long addresses. */
r=tor_addr_parse_mask_ports("[ffff:1111:1111:1111:1111:1111:1111:1111]",
0, &t1, NULL, NULL, NULL);
tt_assert(r == AF_INET6);
tt_int_op(r, OP_EQ, AF_INET6);
r=tor_addr_parse_mask_ports("[ffff:1111:1111:1111:1111:1111:1111:11111]",
0, &t1, NULL, NULL, NULL);
tt_int_op(r, OP_EQ, -1);
@ -686,38 +686,38 @@ test_addr_ip6_helpers(void *arg)
tt_int_op(r, OP_EQ, -1);
r=tor_addr_parse_mask_ports("*6",0,&t1, &mask, NULL, NULL);
tt_int_op(r, OP_EQ, -1);
tt_assert(r == -1);
tt_int_op(r, OP_EQ, -1);
/* Try a mask with a wildcard. */
r=tor_addr_parse_mask_ports("*/16",0,&t1, &mask, NULL, NULL);
tt_assert(r == -1);
tt_int_op(r, OP_EQ, -1);
r=tor_addr_parse_mask_ports("*4/16",TAPMP_EXTENDED_STAR,
&t1, &mask, NULL, NULL);
tt_assert(r == -1);
tt_int_op(r, OP_EQ, -1);
r=tor_addr_parse_mask_ports("*6/30",TAPMP_EXTENDED_STAR,
&t1, &mask, NULL, NULL);
tt_assert(r == -1);
tt_int_op(r, OP_EQ, -1);
/* Basic mask tests*/
r=tor_addr_parse_mask_ports("1.1.2.2/31",0,&t1, &mask, NULL, NULL);
tt_assert(r == AF_INET);
tt_int_op(r, OP_EQ, AF_INET);
tt_int_op(mask,OP_EQ,31);
tt_int_op(tor_addr_family(&t1),OP_EQ,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),OP_EQ,0x01010202);
r=tor_addr_parse_mask_ports("3.4.16.032:1-2",0,&t1, &mask, &port1, &port2);
tt_assert(r == AF_INET);
tt_int_op(r, OP_EQ, AF_INET);
tt_int_op(mask,OP_EQ,32);
tt_int_op(tor_addr_family(&t1),OP_EQ,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),OP_EQ,0x03041020);
tt_assert(port1 == 1);
tt_assert(port2 == 2);
tt_uint_op(port1, OP_EQ, 1);
tt_uint_op(port2, OP_EQ, 2);
r=tor_addr_parse_mask_ports("1.1.2.3/255.255.128.0",0,&t1, &mask,NULL,NULL);
tt_assert(r == AF_INET);
tt_int_op(r, OP_EQ, AF_INET);
tt_int_op(mask,OP_EQ,17);
tt_int_op(tor_addr_family(&t1),OP_EQ,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),OP_EQ,0x01010203);
r=tor_addr_parse_mask_ports("[efef::]/112",0,&t1, &mask, &port1, &port2);
tt_assert(r == AF_INET6);
tt_assert(port1 == 1);
tt_assert(port2 == 65535);
tt_int_op(r, OP_EQ, AF_INET6);
tt_uint_op(port1, OP_EQ, 1);
tt_uint_op(port2, OP_EQ, 65535);
/* Try regular wildcard behavior without TAPMP_EXTENDED_STAR */
r=tor_addr_parse_mask_ports("*:80-443",0,&t1,&mask,&port1,&port2);
tt_int_op(r,OP_EQ,AF_INET); /* Old users of this always get inet */
@ -752,9 +752,9 @@ test_addr_ip6_helpers(void *arg)
tt_int_op(port2,OP_EQ,65535);
/* make sure inet address lengths >= max */
tt_assert(INET_NTOA_BUF_LEN >= sizeof("255.255.255.255"));
tt_assert(TOR_ADDR_BUF_LEN >=
sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"));
tt_int_op(INET_NTOA_BUF_LEN, OP_GE, sizeof("255.255.255.255"));
tt_int_op(TOR_ADDR_BUF_LEN, OP_GE,
sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"));
tt_assert(sizeof(tor_addr_t) >= sizeof(struct in6_addr));

View File

@ -224,7 +224,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
smartlist = ifaddrs_to_smartlist(ifa, AF_UNSPEC);
tt_assert(smartlist);
tt_assert(smartlist_len(smartlist) == 3);
tt_int_op(smartlist_len(smartlist), OP_EQ, 3);
sockaddr_to_check = tor_malloc(sizeof(struct sockaddr_in6));
@ -233,7 +233,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
sizeof(struct sockaddr_in));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in));
tt_assert(sockaddr_in_are_equal((struct sockaddr_in *)sockaddr_to_check,
ipv4_sockaddr_local));
@ -242,7 +242,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
sizeof(struct sockaddr_in));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in));
tt_assert(sockaddr_in_are_equal((struct sockaddr_in *)sockaddr_to_check,
ipv4_sockaddr_remote));
@ -251,7 +251,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
sizeof(struct sockaddr_in6));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in6));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in6));
tt_assert(sockaddr_in6_are_equal((struct sockaddr_in6*)sockaddr_to_check,
ipv6_sockaddr));
@ -319,7 +319,7 @@ test_address_get_if_addrs_win32(void *arg)
results = get_interface_addresses_win32(LOG_ERR, AF_UNSPEC);
tt_int_op(smartlist_len(results),>=,1);
tt_int_op(smartlist_len(results),OP_GE,1);
tt_assert(smartlist_contains_localhost_tor_addr(results));
tt_assert(!smartlist_contains_null_tor_addr(results));
@ -384,7 +384,7 @@ test_address_ip_adapter_addresses_to_smartlist(void *arg)
result = ip_adapter_addresses_to_smartlist(addrs1);
tt_assert(result);
tt_assert(smartlist_len(result) == 3);
tt_int_op(smartlist_len(result), OP_EQ, 3);
tor_addr = smartlist_get(result,0);
@ -456,14 +456,14 @@ test_address_ifreq_to_smartlist(void *arg)
ifc->ifc_ifcu.ifcu_req = ifr;
results = ifreq_to_smartlist(ifc->ifc_buf,ifc->ifc_len);
tt_int_op(smartlist_len(results),==,1);
tt_int_op(smartlist_len(results),OP_EQ,1);
tor_addr = smartlist_get(results, 0);
addr_len =
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
sizeof(struct sockaddr_in));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in));
tt_assert(sockaddr_in_are_equal(sockaddr,sockaddr_to_check));
ifr = tor_realloc(ifr,2*sizeof(struct ifreq));
@ -479,14 +479,14 @@ test_address_ifreq_to_smartlist(void *arg)
smartlist_free(results);
results = ifreq_to_smartlist(ifc->ifc_buf,ifc->ifc_len);
tt_int_op(smartlist_len(results),==,2);
tt_int_op(smartlist_len(results),OP_EQ,2);
tor_addr = smartlist_get(results, 0);
addr_len =
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
sizeof(struct sockaddr_in));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in));
tt_assert(sockaddr_in_are_equal(sockaddr,sockaddr_to_check));
tor_addr = smartlist_get(results, 1);
@ -494,7 +494,7 @@ test_address_ifreq_to_smartlist(void *arg)
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
sizeof(struct sockaddr_in));
tt_int_op(addr_len,==,sizeof(struct sockaddr_in));
tt_int_op(addr_len,OP_EQ,sizeof(struct sockaddr_in));
tt_assert(sockaddr_in_are_equal(sockaddr_eth1,sockaddr_to_check));
done:
@ -633,7 +633,7 @@ test_address_udp_socket_trick_whitebox(void *arg)
get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
AF_INET, addr_from_hack);
tt_int_op(hack_retval,==,0);
tt_int_op(hack_retval,OP_EQ,0);
tt_assert(tor_addr_eq_ipv4h(addr_from_hack, 0x1720f676));
/* Now, lets do an IPv6 case. */
@ -648,7 +648,7 @@ test_address_udp_socket_trick_whitebox(void *arg)
get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
AF_INET6, addr_from_hack);
tt_int_op(hack_retval,==,0);
tt_int_op(hack_retval,OP_EQ,0);
tor_addr_to_sockaddr(addr_from_hack,0,(struct sockaddr *)ipv6_to_check,
sizeof(struct sockaddr_in6));
@ -693,7 +693,7 @@ test_address_udp_socket_trick_blackbox(void *arg)
AF_INET,
&addr4_to_check);
tt_int_op(retval,==,retval_reference);
tt_int_op(retval,OP_EQ,retval_reference);
tt_assert( (retval == -1 && retval_reference == -1) ||
(tor_addr_compare(&addr4,&addr4_to_check,CMP_EXACT) == 0) );
@ -702,7 +702,7 @@ test_address_udp_socket_trick_blackbox(void *arg)
AF_INET6,
&addr6_to_check);
tt_int_op(retval,==,retval_reference);
tt_int_op(retval,OP_EQ,retval_reference);
tt_assert( (retval == -1 && retval_reference == -1) ||
(tor_addr_compare(&addr6,&addr6_to_check,CMP_EXACT) == 0) );
@ -730,7 +730,7 @@ test_address_udp_socket_trick_blackbox(void *arg)
retval = get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
AF_INET+AF_INET6,&addr4);
tt_assert(retval == -1);
tt_int_op(retval, OP_EQ, -1);
done:
return;
@ -745,11 +745,11 @@ test_address_get_if_addrs_list_internal(void *arg)
results = get_interface_address_list(LOG_ERR, 1);
tt_assert(results != NULL);
tt_ptr_op(results, OP_NE, NULL);
/* When the network is down, a system might not have any non-local
* non-multicast addresseses, not even internal ones.
* Unit tests shouldn't fail because of this. */
tt_int_op(smartlist_len(results),>=,0);
tt_int_op(smartlist_len(results),OP_GE,0);
tt_assert(!smartlist_contains_localhost_tor_addr(results));
tt_assert(!smartlist_contains_multicast_tor_addr(results));
@ -776,9 +776,9 @@ test_address_get_if_addrs_list_no_internal(void *arg)
results = get_interface_address_list(LOG_ERR, 0);
tt_assert(results != NULL);
tt_ptr_op(results, OP_NE, NULL);
/* Work even on systems with only internal IPv4 addresses */
tt_int_op(smartlist_len(results),>=,0);
tt_int_op(smartlist_len(results),OP_GE,0);
tt_assert(!smartlist_contains_localhost_tor_addr(results));
tt_assert(!smartlist_contains_multicast_tor_addr(results));
@ -818,9 +818,9 @@ test_address_get_if_addrs6_list_internal(void *arg)
}
teardown_capture_of_logs();
tt_assert(results != NULL);
tt_ptr_op(results, OP_NE, NULL);
/* Work even on systems without IPv6 interfaces */
tt_int_op(smartlist_len(results),>=,0);
tt_int_op(smartlist_len(results),OP_GE,0);
tt_assert(!smartlist_contains_localhost_tor_addr(results));
tt_assert(!smartlist_contains_multicast_tor_addr(results));
@ -861,9 +861,9 @@ test_address_get_if_addrs6_list_no_internal(void *arg)
}
teardown_capture_of_logs();
tt_assert(results != NULL);
tt_ptr_op(results, OP_NE, NULL);
/* Work even on systems without IPv6 interfaces */
tt_int_op(smartlist_len(results),>=,0);
tt_int_op(smartlist_len(results),OP_GE,0);
tt_assert(!smartlist_contains_localhost_tor_addr(results));
tt_assert(!smartlist_contains_multicast_tor_addr(results));
@ -927,18 +927,18 @@ test_address_get_if_addrs_internal_fail(void *arg)
mock_get_interface_address6_via_udp_socket_hack_fail);
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 1);
tt_assert(results1 != NULL);
tt_int_op(smartlist_len(results1),==,0);
tt_ptr_op(results1, OP_NE, NULL);
tt_int_op(smartlist_len(results1),OP_EQ,0);
results2 = get_interface_address_list(LOG_ERR, 1);
tt_assert(results2 != NULL);
tt_int_op(smartlist_len(results2),==,0);
tt_ptr_op(results2, OP_NE, NULL);
tt_int_op(smartlist_len(results2),OP_EQ,0);
rv = get_interface_address6(LOG_ERR, AF_INET6, &ipv6_addr);
tt_assert(rv == -1);
tt_int_op(rv, OP_EQ, -1);
rv = get_interface_address(LOG_ERR, &ipv4h_addr);
tt_assert(rv == -1);
tt_int_op(rv, OP_EQ, -1);
done:
UNMOCK(get_interface_addresses_raw);
@ -961,12 +961,12 @@ test_address_get_if_addrs_no_internal_fail(void *arg)
mock_get_interface_address6_via_udp_socket_hack_fail);
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 0);
tt_assert(results1 != NULL);
tt_int_op(smartlist_len(results1),==,0);
tt_ptr_op(results1, OP_NE, NULL);
tt_int_op(smartlist_len(results1),OP_EQ,0);
results2 = get_interface_address_list(LOG_ERR, 0);
tt_assert(results2 != NULL);
tt_int_op(smartlist_len(results2),==,0);
tt_ptr_op(results2, OP_NE, NULL);
tt_int_op(smartlist_len(results2),OP_EQ,0);
done:
UNMOCK(get_interface_addresses_raw);

View File

@ -762,11 +762,11 @@ test_buffers_tls_read_mocked(void *arg)
buf = buf_new();
next_reply_val[0] = 1024;
tt_int_op(128, ==, read_to_buf_tls(NULL, 128, buf));
tt_int_op(128, OP_EQ, read_to_buf_tls(NULL, 128, buf));
next_reply_val[0] = 5000;
next_reply_val[1] = 5000;
tt_int_op(6000, ==, read_to_buf_tls(NULL, 6000, buf));
tt_int_op(6000, OP_EQ, read_to_buf_tls(NULL, 6000, buf));
done:
UNMOCK(tor_tls_read);
@ -831,8 +831,8 @@ test_buffers_find_contentlen(void *arg)
r = buf_http_find_content_length(tmp, headerlen, &sz);
tor_free(tmp);
log_debug(LD_DIR, "%d: %s", i, escaped(results[i].headers));
tt_int_op(r, ==, results[i].r);
tt_int_op(sz, ==, results[i].contentlen);
tt_int_op(r, OP_EQ, results[i].r);
tt_int_op(sz, OP_EQ, results[i].contentlen);
}
done:
;

View File

@ -86,7 +86,7 @@ channel_note_destroy_not_pending_mock(channel_t *ch,
static const char *
chan_test_describe_transport(channel_t *ch)
{
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
done:
return "Fake channel for unit tests";
@ -100,7 +100,7 @@ chan_test_describe_transport(channel_t *ch)
static void
chan_test_channel_dump_statistics_mock(channel_t *chan, int severity)
{
tt_assert(chan != NULL);
tt_ptr_op(chan, OP_NE, NULL);
(void)severity;
@ -125,7 +125,7 @@ chan_test_channel_flush_from_first_active_circuit_mock(channel_t *chan,
int result = 0, c = 0;
packed_cell_t *cell = NULL;
tt_assert(chan != NULL);
tt_ptr_op(chan, OP_NE, NULL);
if (test_target_cmux != NULL &&
test_target_cmux == chan->cmux) {
while (c <= max && test_cmux_cells > 0) {
@ -154,7 +154,7 @@ chan_test_circuitmux_num_cells_mock(circuitmux_t *cmux)
{
unsigned int result = 0;
tt_assert(cmux != NULL);
tt_ptr_op(cmux, OP_NE, NULL);
if (cmux != NULL) {
if (cmux == test_target_cmux) {
result = test_cmux_cells;
@ -193,7 +193,7 @@ chan_test_cell_handler(channel_t *ch,
static void
chan_test_dumpstats(channel_t *ch, int severity)
{
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
(void)severity;
@ -268,7 +268,7 @@ static const char *
chan_test_get_remote_descr(channel_t *ch, int flags)
{
tt_assert(ch);
tt_int_op(flags & ~(GRD_FLAG_ORIGINAL | GRD_FLAG_ADDR_ONLY), ==, 0);
tt_int_op(flags & ~(GRD_FLAG_ORIGINAL | GRD_FLAG_ADDR_ONLY), OP_EQ, 0);
done:
return "Fake channel for unit tests; no real endpoint";
@ -286,7 +286,7 @@ chan_test_get_overhead_estimate(channel_t *ch)
static int
chan_test_is_canonical(channel_t *ch, int req)
{
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
tt_assert(req == 0 || req == 1);
done:
@ -380,7 +380,7 @@ chan_test_write_var_cell(channel_t *ch, var_cell_t *var_cell)
void
make_fake_cell(cell_t *c)
{
tt_assert(c != NULL);
tt_ptr_op(c, OP_NE, NULL);
c->circ_id = 1;
c->command = CELL_RELAY;
@ -397,7 +397,7 @@ make_fake_cell(cell_t *c)
void
make_fake_var_cell(var_cell_t *c)
{
tt_assert(c != NULL);
tt_ptr_op(c, OP_NE, NULL);
c->circ_id = 1;
c->command = CELL_VERSIONS;
@ -552,24 +552,24 @@ test_channel_dumpstats(void *arg)
channel_dumpstats(LOG_DEBUG);
/* Assert that we hit the mock */
tt_int_op(dump_statistics_mock_matches, ==, 1);
tt_int_op(dump_statistics_mock_matches, OP_EQ, 1);
/* Close the channel */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
/* Try again and hit the finished channel */
channel_dumpstats(LOG_DEBUG);
tt_int_op(dump_statistics_mock_matches, ==, 2);
tt_int_op(dump_statistics_mock_matches, OP_EQ, 2);
channel_run_cleanup();
ch = NULL;
/* Now we should hit nothing */
channel_dumpstats(LOG_DEBUG);
tt_int_op(dump_statistics_mock_matches, ==, 2);
tt_int_op(dump_statistics_mock_matches, OP_EQ, 2);
/* Unmock */
UNMOCK(channel_dump_statistics);
@ -594,7 +594,7 @@ test_channel_dumpstats(void *arg)
old_count = test_cells_written;
channel_write_cell(ch, cell);
cell = NULL;
tt_int_op(test_cells_written, ==, old_count + 1);
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
tt_assert(ch->n_bytes_xmitted > 0);
tt_assert(ch->n_cells_xmitted > 0);
@ -602,14 +602,15 @@ test_channel_dumpstats(void *arg)
channel_set_cell_handlers(ch,
chan_test_cell_handler,
chan_test_var_cell_handler);
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), ==, chan_test_var_cell_handler);
tt_ptr_op(channel_get_cell_handler(ch), OP_EQ, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ,
chan_test_var_cell_handler);
cell = tor_malloc_zero(sizeof(cell_t));
make_fake_cell(cell);
old_count = test_chan_fixed_cells_recved;
channel_queue_cell(ch, cell);
tor_free(cell);
tt_int_op(test_chan_fixed_cells_recved, ==, old_count + 1);
tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_count + 1);
tt_assert(ch->n_bytes_recved > 0);
tt_assert(ch->n_cells_recved > 0);
@ -619,13 +620,13 @@ test_channel_dumpstats(void *arg)
ch->is_canonical = chan_test_is_canonical;
old_count = test_dumpstats_calls;
channel_dump_statistics(ch, LOG_DEBUG);
tt_int_op(test_dumpstats_calls, ==, old_count + 1);
tt_int_op(test_dumpstats_calls, OP_EQ, old_count + 1);
/* Close the channel */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -664,21 +665,21 @@ test_channel_flush(void *arg)
make_fake_cell(cell);
channel_write_cell(ch, cell);
/* It should be queued, so assert that we didn't write it */
tt_int_op(test_cells_written, ==, init_count);
tt_int_op(test_cells_written, OP_EQ, init_count);
/* Queue a var cell */
v_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
make_fake_var_cell(v_cell);
channel_write_var_cell(ch, v_cell);
/* It should be queued, so assert that we didn't write it */
tt_int_op(test_cells_written, ==, init_count);
tt_int_op(test_cells_written, OP_EQ, init_count);
/* Try a packed cell now */
p_cell = packed_cell_new();
tt_assert(p_cell);
channel_write_packed_cell(ch, p_cell);
/* It should be queued, so assert that we didn't write it */
tt_int_op(test_cells_written, ==, init_count);
tt_int_op(test_cells_written, OP_EQ, init_count);
/* Now allow writes through again */
test_chan_accept_cells = 1;
@ -687,7 +688,7 @@ test_channel_flush(void *arg)
channel_flush_cells(ch);
/* All three should have gone through */
tt_int_op(test_cells_written, ==, init_count + 3);
tt_int_op(test_cells_written, OP_EQ, init_count + 3);
done:
tor_free(ch);
@ -728,9 +729,9 @@ test_channel_flushmux(void *arg)
result = channel_flush_some_cells(ch, 1);
tt_int_op(result, ==, 1);
tt_int_op(test_cells_written, ==, old_count + 1);
tt_int_op(test_cmux_cells, ==, 0);
tt_int_op(result, OP_EQ, 1);
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
tt_int_op(test_cmux_cells, OP_EQ, 0);
/* Now try it without accepting to force them into the queue */
test_chan_accept_cells = 0;
@ -740,19 +741,19 @@ test_channel_flushmux(void *arg)
result = channel_flush_some_cells(ch, 1);
/* We should not have actually flushed any */
tt_int_op(result, ==, 0);
tt_int_op(test_cells_written, ==, old_count + 1);
tt_int_op(result, OP_EQ, 0);
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
/* But we should have gotten to the fake cellgen loop */
tt_int_op(test_cmux_cells, ==, 0);
tt_int_op(test_cmux_cells, OP_EQ, 0);
/* ...and we should have a queued cell */
q_len_after = chan_cell_queue_len(&(ch->outgoing_queue));
tt_int_op(q_len_after, ==, q_len_before + 1);
tt_int_op(q_len_after, OP_EQ, q_len_before + 1);
/* Now accept cells again and drain the queue */
test_chan_accept_cells = 1;
channel_flush_cells(ch);
tt_int_op(test_cells_written, ==, old_count + 2);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(test_cells_written, OP_EQ, old_count + 2);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
test_target_cmux = NULL;
test_cmux_cells = 0;
@ -803,8 +804,9 @@ test_channel_incoming(void *arg)
chan_test_cell_handler,
chan_test_var_cell_handler);
/* Test cell handler getters */
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), ==, chan_test_var_cell_handler);
tt_ptr_op(channel_get_cell_handler(ch), OP_EQ, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ,
chan_test_var_cell_handler);
/* Try to register it */
channel_register(ch);
@ -812,7 +814,7 @@ test_channel_incoming(void *arg)
/* Open it */
channel_change_state_open(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_OPEN);
/* Receive a fixed cell */
cell = tor_malloc_zero(sizeof(cell_t));
@ -820,7 +822,7 @@ test_channel_incoming(void *arg)
old_count = test_chan_fixed_cells_recved;
channel_queue_cell(ch, cell);
tor_free(cell);
tt_int_op(test_chan_fixed_cells_recved, ==, old_count + 1);
tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_count + 1);
/* Receive a variable-size cell */
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
@ -828,13 +830,13 @@ test_channel_incoming(void *arg)
old_count = test_chan_var_cells_recved;
channel_queue_var_cell(ch, var_cell);
tor_free(cell);
tt_int_op(test_chan_var_cells_recved, ==, old_count + 1);
tt_int_op(test_chan_var_cells_recved, OP_EQ, old_count + 1);
/* Close it */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -896,13 +898,13 @@ test_channel_lifecycle(void *arg)
make_fake_cell(cell);
old_count = test_cells_written;
channel_write_cell(ch1, cell);
tt_int_op(old_count, ==, test_cells_written);
tt_int_op(old_count, OP_EQ, test_cells_written);
/* Move it to OPEN and flush */
channel_change_state_open(ch1);
/* Queue should drain */
tt_int_op(old_count + 1, ==, test_cells_written);
tt_int_op(old_count + 1, OP_EQ, test_cells_written);
/* Get another one */
ch2 = new_fake_channel();
@ -915,41 +917,42 @@ test_channel_lifecycle(void *arg)
tt_assert(ch2->registered);
/* Check counters */
tt_int_op(test_doesnt_want_writes_count, ==, init_doesnt_want_writes_count);
tt_int_op(test_releases_count, ==, init_releases_count);
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count);
tt_int_op(test_releases_count, OP_EQ, init_releases_count);
/* Move ch1 to MAINT */
channel_change_state(ch1, CHANNEL_STATE_MAINT);
tt_int_op(test_doesnt_want_writes_count, ==,
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count + 1);
tt_int_op(test_releases_count, ==, init_releases_count);
tt_int_op(test_releases_count, OP_EQ, init_releases_count);
/* Move ch2 to OPEN */
channel_change_state_open(ch2);
tt_int_op(test_doesnt_want_writes_count, ==,
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count + 1);
tt_int_op(test_releases_count, ==, init_releases_count);
tt_int_op(test_releases_count, OP_EQ, init_releases_count);
/* Move ch1 back to OPEN */
channel_change_state_open(ch1);
tt_int_op(test_doesnt_want_writes_count, ==,
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count + 1);
tt_int_op(test_releases_count, ==, init_releases_count);
tt_int_op(test_releases_count, OP_EQ, init_releases_count);
/* Mark ch2 for close */
channel_mark_for_close(ch2);
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(test_doesnt_want_writes_count, ==,
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSING);
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count + 1);
tt_int_op(test_releases_count, ==, init_releases_count + 1);
tt_int_op(test_releases_count, OP_EQ, init_releases_count + 1);
/* Shut down channels */
channel_free_all();
ch1 = ch2 = NULL;
tt_int_op(test_doesnt_want_writes_count, ==,
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
init_doesnt_want_writes_count + 1);
/* channel_free() calls scheduler_release_channel() */
tt_int_op(test_releases_count, ==, init_releases_count + 4);
tt_int_op(test_releases_count, OP_EQ, init_releases_count + 4);
done:
free_fake_channel(ch1);
@ -1001,11 +1004,11 @@ test_channel_lifecycle_2(void *arg)
/* Try to close it */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
/* Finish closing it */
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -1022,9 +1025,9 @@ test_channel_lifecycle_2(void *arg)
/* Error exit from lower layer */
chan_test_error(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_ERROR);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_ERROR);
channel_run_cleanup();
ch = NULL;
@ -1038,19 +1041,19 @@ test_channel_lifecycle_2(void *arg)
/* Finish opening it */
channel_change_state_open(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_OPEN);
/* Go to maintenance state */
channel_change_state(ch, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, ==, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_MAINT);
/* Lower layer close */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
/* Finish */
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -1067,19 +1070,19 @@ test_channel_lifecycle_2(void *arg)
/* Finish opening it */
channel_change_state_open(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_OPEN);
/* Go to maintenance state */
channel_change_state(ch, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, ==, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_MAINT);
/* Lower layer close */
channel_close_from_lower_layer(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
/* Finish */
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -1093,19 +1096,19 @@ test_channel_lifecycle_2(void *arg)
/* Finish opening it */
channel_change_state_open(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_OPEN);
/* Go to maintenance state */
channel_change_state(ch, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, ==, CHANNEL_STATE_MAINT);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_MAINT);
/* Lower layer close */
chan_test_error(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
/* Finish */
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_ERROR);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_ERROR);
channel_run_cleanup();
ch = NULL;
@ -1142,11 +1145,11 @@ test_channel_multi(void *arg)
/* Initial queue size update */
channel_update_xmit_queue_size(ch1);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 0);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Queue some cells, check queue estimates */
cell = tor_malloc_zero(sizeof(cell_t));
@ -1159,10 +1162,10 @@ test_channel_multi(void *arg)
channel_update_xmit_queue_size(ch1);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 0);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Stop accepting cells at lower layer */
test_chan_accept_cells = 0;
@ -1173,18 +1176,18 @@ test_channel_multi(void *arg)
channel_write_cell(ch1, cell);
channel_update_xmit_queue_size(ch1);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 512);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 512);
tt_u64_op(global_queue_estimate, OP_EQ, 512);
cell = tor_malloc_zero(sizeof(cell_t));
make_fake_cell(cell);
channel_write_cell(ch2, cell);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 512);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 1024);
tt_u64_op(global_queue_estimate, OP_EQ, 1024);
/* Allow cells through again */
test_chan_accept_cells = 1;
@ -1195,10 +1198,10 @@ test_channel_multi(void *arg)
/* Update and check queue sizes */
channel_update_xmit_queue_size(ch1);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 512);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 512);
tt_u64_op(global_queue_estimate, OP_EQ, 512);
/* Flush chan 1 */
channel_flush_cells(ch1);
@ -1206,10 +1209,10 @@ test_channel_multi(void *arg)
/* Update and check queue sizes */
channel_update_xmit_queue_size(ch1);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 0);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Now block again */
test_chan_accept_cells = 0;
@ -1227,10 +1230,10 @@ test_channel_multi(void *arg)
/* Check the estimates */
channel_update_xmit_queue_size(ch1);
channel_update_xmit_queue_size(ch2);
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch2->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 512);
tt_u64_op(ch2->bytes_queued_for_xmit, OP_EQ, 512);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 1024);
tt_u64_op(global_queue_estimate, OP_EQ, 1024);
/* Now close channel 2; it should be subtracted from the global queue */
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
@ -1238,7 +1241,7 @@ test_channel_multi(void *arg)
UNMOCK(scheduler_release_channel);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 512);
tt_u64_op(global_queue_estimate, OP_EQ, 512);
/*
* Since the fake channels aren't registered, channel_free_all() can't
@ -1249,7 +1252,7 @@ test_channel_multi(void *arg)
UNMOCK(scheduler_release_channel);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Now free everything */
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
@ -1297,7 +1300,7 @@ test_channel_queue_impossible(void *arg)
old_count = test_cells_written;
/* Assert that the queue is initially empty */
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
/* Get a fresh cell and write it to the channel*/
cell = tor_malloc_zero(sizeof(cell_t));
@ -1306,11 +1309,11 @@ test_channel_queue_impossible(void *arg)
channel_write_cell(ch, cell);
/* Now it should be queued */
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 1);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 1);
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
tt_assert(q);
if (q) {
tt_int_op(q->type, ==, CELL_QUEUE_FIXED);
tt_int_op(q->type, OP_EQ, CELL_QUEUE_FIXED);
tt_assert((uintptr_t)q->u.fixed.cell == cellintptr);
}
/* Do perverse things to it */
@ -1324,7 +1327,7 @@ test_channel_queue_impossible(void *arg)
test_chan_accept_cells = 1;
channel_change_state_open(ch);
tt_assert(test_cells_written == old_count);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
/* Same thing but for a var_cell */
@ -1336,11 +1339,11 @@ test_channel_queue_impossible(void *arg)
channel_write_var_cell(ch, var_cell);
/* Check that it's queued */
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 1);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 1);
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
tt_assert(q);
if (q) {
tt_int_op(q->type, ==, CELL_QUEUE_VAR);
tt_int_op(q->type, OP_EQ, CELL_QUEUE_VAR);
tt_assert((uintptr_t)q->u.var.var_cell == cellintptr);
}
@ -1352,7 +1355,7 @@ test_channel_queue_impossible(void *arg)
test_chan_accept_cells = 1;
channel_change_state_open(ch);
tt_assert(test_cells_written == old_count);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
/* Same thing with a packed_cell */
@ -1364,11 +1367,11 @@ test_channel_queue_impossible(void *arg)
channel_write_packed_cell(ch, packed_cell);
/* Check that it's queued */
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 1);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 1);
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
tt_assert(q);
if (q) {
tt_int_op(q->type, ==, CELL_QUEUE_PACKED);
tt_int_op(q->type, OP_EQ, CELL_QUEUE_PACKED);
tt_assert((uintptr_t)q->u.packed.packed_cell == cellintptr);
}
@ -1380,7 +1383,7 @@ test_channel_queue_impossible(void *arg)
test_chan_accept_cells = 1;
channel_change_state_open(ch);
tt_assert(test_cells_written == old_count);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
/* Unknown cell type case */
test_chan_accept_cells = 0;
@ -1391,11 +1394,11 @@ test_channel_queue_impossible(void *arg)
channel_write_cell(ch, cell);
/* Check that it's queued */
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 1);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 1);
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
tt_assert(q);
if (q) {
tt_int_op(q->type, ==, CELL_QUEUE_FIXED);
tt_int_op(q->type, OP_EQ, CELL_QUEUE_FIXED);
tt_assert((uintptr_t)q->u.fixed.cell == cellintptr);
}
/* Clobber it, including the queue entry type */
@ -1408,9 +1411,9 @@ test_channel_queue_impossible(void *arg)
tor_capture_bugs_(1);
channel_change_state_open(ch);
tt_assert(test_cells_written == old_count);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), ==, 1);
tt_int_op(smartlist_len(tor_get_captured_bug_log_()), OP_EQ, 1);
tor_end_capture_bugs_();
done:
@ -1455,8 +1458,8 @@ test_channel_queue_incoming(void *arg)
ch->cmux = circuitmux_alloc();
/* Test cell handler getters */
tt_ptr_op(channel_get_cell_handler(ch), ==, NULL);
tt_ptr_op(channel_get_var_cell_handler(ch), ==, NULL);
tt_ptr_op(channel_get_cell_handler(ch), OP_EQ, NULL);
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ, NULL);
/* Try to register it */
channel_register(ch);
@ -1464,7 +1467,7 @@ test_channel_queue_incoming(void *arg)
/* Open it */
channel_change_state_open(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_OPEN);
/* Assert that the incoming queue is empty */
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
@ -1475,7 +1478,7 @@ test_channel_queue_incoming(void *arg)
channel_queue_cell(ch, cell);
/* Assert that the incoming queue has one entry */
tt_int_op(chan_cell_queue_len(&(ch->incoming_queue)), ==, 1);
tt_int_op(chan_cell_queue_len(&(ch->incoming_queue)), OP_EQ, 1);
/* Queue an incoming var cell */
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
@ -1483,7 +1486,7 @@ test_channel_queue_incoming(void *arg)
channel_queue_var_cell(ch, var_cell);
/* Assert that the incoming queue has two entries */
tt_int_op(chan_cell_queue_len(&(ch->incoming_queue)), ==, 2);
tt_int_op(chan_cell_queue_len(&(ch->incoming_queue)), OP_EQ, 2);
/*
* Install cell handlers; this will drain the queue, so save the old
@ -1494,12 +1497,13 @@ test_channel_queue_incoming(void *arg)
channel_set_cell_handlers(ch,
chan_test_cell_handler,
chan_test_var_cell_handler);
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), ==, chan_test_var_cell_handler);
tt_ptr_op(channel_get_cell_handler(ch), OP_EQ, chan_test_cell_handler);
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ,
chan_test_var_cell_handler);
/* Assert cells were received */
tt_int_op(test_chan_fixed_cells_recved, ==, old_fixed_count + 1);
tt_int_op(test_chan_var_cells_recved, ==, old_var_count + 1);
tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_fixed_count + 1);
tt_int_op(test_chan_var_cells_recved, OP_EQ, old_var_count + 1);
/*
* Assert that the pointers are different from the cells we allocated;
@ -1508,17 +1512,17 @@ test_channel_queue_incoming(void *arg)
* delivery. These pointers will have already been freed by the time
* we get here, so don't dereference them.
*/
tt_ptr_op(test_chan_last_seen_fixed_cell_ptr, !=, cell);
tt_ptr_op(test_chan_last_seen_var_cell_ptr, !=, var_cell);
tt_ptr_op(test_chan_last_seen_fixed_cell_ptr, OP_NE, cell);
tt_ptr_op(test_chan_last_seen_var_cell_ptr, OP_NE, var_cell);
/* Assert queue is now empty */
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
/* Close it; this contains an assertion that the incoming queue is empty */
channel_mark_for_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
chan_test_finish_close(ch);
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSED);
channel_run_cleanup();
ch = NULL;
@ -1548,14 +1552,14 @@ test_channel_queue_size(void *arg)
/* Initial queue size update */
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Test the call-through to our fake lower layer */
n = channel_num_cells_writeable(ch);
/* chan_test_num_cells_writeable() always returns 32 */
tt_int_op(n, ==, 32);
tt_int_op(n, OP_EQ, 32);
/*
* Now we queue some cells and check that channel_num_cells_writeable()
@ -1574,32 +1578,33 @@ test_channel_queue_size(void *arg)
old_count = test_cells_written;
channel_write_cell(ch, cell);
/* Assert that it got queued, not written through, correctly */
tt_int_op(test_cells_written, ==, old_count);
tt_int_op(test_cells_written, OP_EQ, old_count);
/* Now check chan_test_num_cells_writeable() again */
n = channel_num_cells_writeable(ch);
tt_int_op(n, ==, 0); /* Should return 0 since we're in CHANNEL_STATE_MAINT */
/* Should return 0 since we're in CHANNEL_STATE_MAINT */
tt_int_op(n, OP_EQ, 0);
/* Update queue size estimates */
channel_update_xmit_queue_size(ch);
/* One cell, times an overhead factor of 1.0 */
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 512);
/* Try a different overhead factor */
test_overhead_estimate = 0.5;
/* This one should be ignored since it's below 1.0 */
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 512);
/* Now try a larger one */
test_overhead_estimate = 2.0;
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 1024);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 1024);
/* Go back to 1.0 */
test_overhead_estimate = 1.0;
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 512);
/* Check the global estimate too */
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 512);
tt_u64_op(global_queue_estimate, OP_EQ, 512);
/* Go to open */
old_count = test_cells_written;
@ -1609,37 +1614,37 @@ test_channel_queue_size(void *arg)
* It should try to write, but we aren't accepting cells right now, so
* it'll requeue
*/
tt_int_op(test_cells_written, ==, old_count);
tt_int_op(test_cells_written, OP_EQ, old_count);
/* Check the queue size again */
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 512);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 512);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 512);
tt_u64_op(global_queue_estimate, OP_EQ, 512);
/*
* Now the cell is in the queue, and we're open, so we should get 31
* writeable cells.
*/
n = channel_num_cells_writeable(ch);
tt_int_op(n, ==, 31);
tt_int_op(n, OP_EQ, 31);
/* Accept cells again */
test_chan_accept_cells = 1;
/* ...and re-process the queue */
old_count = test_cells_written;
channel_flush_cells(ch);
tt_int_op(test_cells_written, ==, old_count + 1);
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
/* Should have 32 writeable now */
n = channel_num_cells_writeable(ch);
tt_int_op(n, ==, 32);
tt_int_op(n, OP_EQ, 32);
/* Should have queue size estimate of zero */
channel_update_xmit_queue_size(ch);
tt_u64_op(ch->bytes_queued_for_xmit, ==, 0);
tt_u64_op(ch->bytes_queued_for_xmit, OP_EQ, 0);
global_queue_estimate = channel_get_global_queue_estimate();
tt_u64_op(global_queue_estimate, ==, 0);
tt_u64_op(global_queue_estimate, OP_EQ, 0);
/* Okay, now we're done with this one */
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
@ -1780,7 +1785,7 @@ test_channel_id_map(void *arg)
ed25519_public_key_t ed_zero;
memset(&ed_zero, 0, sizeof(ed_zero));
tt_assert(sizeof(rsa_id[0]) == DIGEST_LEN); // Do I remember C?
tt_int_op(DIGEST_LEN, OP_EQ, sizeof(rsa_id[0])); // Do I remember C?
for (i = 0; i < N_CHAN; ++i) {
crypto_rand(rsa_id[i], DIGEST_LEN);
@ -1822,7 +1827,7 @@ test_channel_id_map(void *arg)
ch = channel_next_with_rsa_identity(ch);
tt_assert(ch == chan[2] || ch == chan[4] || ch == chan[5]);
ch = channel_next_with_rsa_identity(ch);
tt_assert(ch == NULL);
tt_ptr_op(ch, OP_EQ, NULL);
/* As above, but with zero Ed25519 ID (meaning "any ID") */
tt_ptr_op(chan[0], OP_EQ,
@ -1838,7 +1843,7 @@ test_channel_id_map(void *arg)
ch = channel_next_with_rsa_identity(ch);
tt_assert(ch == chan[2] || ch == chan[4] || ch == chan[5]);
ch = channel_next_with_rsa_identity(ch);
tt_assert(ch == NULL);
tt_ptr_op(ch, OP_EQ, NULL);
/* Lookup nonexistent RSA identity */
tt_ptr_op(NULL, OP_EQ,

View File

@ -72,7 +72,7 @@ test_channeltls_create(void *arg)
/* Try connecting */
ch = channel_tls_connect(&test_addr, 567, test_digest, NULL);
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
done:
if (ch) {
@ -121,7 +121,7 @@ test_channeltls_num_bytes_queued(void *arg)
/* Try connecting */
ch = channel_tls_connect(&test_addr, 567, test_digest, NULL);
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
/*
* Next, we have to test ch->num_bytes_queued, which is
@ -132,7 +132,7 @@ test_channeltls_num_bytes_queued(void *arg)
tt_assert(ch->num_bytes_queued != NULL);
tlschan = BASE_CHAN_TO_TLS(ch);
tt_assert(tlschan != NULL);
tt_ptr_op(tlschan, OP_NE, NULL);
if (TO_CONN(tlschan->conn)->outbuf == NULL) {
/* We need an outbuf to make sure buf_datalen() gets called */
fake_outbuf = 1;
@ -142,7 +142,7 @@ test_channeltls_num_bytes_queued(void *arg)
tlschan_buf_datalen_mock_size = 1024;
MOCK(buf_datalen, tlschan_buf_datalen_mock);
len = ch->num_bytes_queued(ch);
tt_int_op(len, ==, tlschan_buf_datalen_mock_size);
tt_int_op(len, OP_EQ, tlschan_buf_datalen_mock_size);
/*
* We also cover num_cells_writeable here; since wide_circ_ids = 0 on
* the fake tlschans, cell_network_size returns 512, and so with
@ -151,7 +151,7 @@ test_channeltls_num_bytes_queued(void *arg)
* - 2 cells.
*/
n = ch->num_cells_writeable(ch);
tt_int_op(n, ==, CEIL_DIV(OR_CONN_HIGHWATER, 512) - 2);
tt_int_op(n, OP_EQ, CEIL_DIV(OR_CONN_HIGHWATER, 512) - 2);
UNMOCK(buf_datalen);
tlschan_buf_datalen_mock_target = NULL;
tlschan_buf_datalen_mock_size = 0;
@ -206,11 +206,11 @@ test_channeltls_overhead_estimate(void *arg)
/* Try connecting */
ch = channel_tls_connect(&test_addr, 567, test_digest, NULL);
tt_assert(ch != NULL);
tt_ptr_op(ch, OP_NE, NULL);
/* First case: silly low ratios should get clamped to 1.0 */
tlschan = BASE_CHAN_TO_TLS(ch);
tt_assert(tlschan != NULL);
tt_ptr_op(tlschan, OP_NE, NULL);
tlschan->conn->bytes_xmitted = 128;
tlschan->conn->bytes_xmitted_by_tls = 64;
r = ch->get_overhead_estimate(ch);
@ -273,10 +273,10 @@ tlschan_connection_or_connect_mock(const tor_addr_t *addr,
or_connection_t *result = NULL;
(void) ed_id; // XXXX Not yet used.
tt_assert(addr != NULL);
tt_assert(port != 0);
tt_assert(digest != NULL);
tt_assert(tlschan != NULL);
tt_ptr_op(addr, OP_NE, NULL);
tt_uint_op(port, OP_NE, 0);
tt_ptr_op(digest, OP_NE, NULL);
tt_ptr_op(tlschan, OP_NE, NULL);
/* Make a fake orconn */
result = tor_malloc_zero(sizeof(*result));
@ -301,11 +301,11 @@ tlschan_fake_close_method(channel_t *chan)
{
channel_tls_t *tlschan = NULL;
tt_assert(chan != NULL);
tt_int_op(chan->magic, ==, TLS_CHAN_MAGIC);
tt_ptr_op(chan, OP_NE, NULL);
tt_int_op(chan->magic, OP_EQ, TLS_CHAN_MAGIC);
tlschan = BASE_CHAN_TO_TLS(chan);
tt_assert(tlschan != NULL);
tt_ptr_op(tlschan, OP_NE, NULL);
/* Just free the fake orconn */
tor_free(tlschan->conn->base_.address);
@ -320,7 +320,7 @@ tlschan_fake_close_method(channel_t *chan)
static int
tlschan_is_local_addr_mock(const tor_addr_t *addr)
{
tt_assert(addr != NULL);
tt_ptr_op(addr, OP_NE, NULL);
done:
return tlschan_local;

View File

@ -48,8 +48,8 @@ test_cmux_destroy_cell_queue(void *arg)
ch->wide_circ_ids = 1;
circ = circuitmux_get_first_active_circuit(cmux, &cq);
tt_assert(!circ);
tt_assert(!cq);
tt_ptr_op(circ, OP_EQ, NULL);
tt_ptr_op(cq, OP_EQ, NULL);
circuitmux_append_destroy_cell(ch, cmux, 100, 10);
circuitmux_append_destroy_cell(ch, cmux, 190, 6);
@ -58,7 +58,7 @@ test_cmux_destroy_cell_queue(void *arg)
tt_int_op(circuitmux_num_cells(cmux), OP_EQ, 3);
circ = circuitmux_get_first_active_circuit(cmux, &cq);
tt_assert(!circ);
tt_ptr_op(circ, OP_EQ, NULL);
tt_assert(cq);
tt_int_op(cq->n, OP_EQ, 3);

View File

@ -22,7 +22,7 @@ test_circuit_is_available_for_use_ret_false_when_marked_for_close(void *arg)
circuit_t *circ = tor_malloc(sizeof(circuit_t));
circ->marked_for_close = 1;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
tor_free(circ);
@ -36,7 +36,7 @@ test_circuit_is_available_for_use_ret_false_when_timestamp_dirty(void *arg)
circuit_t *circ = tor_malloc(sizeof(circuit_t));
circ->timestamp_dirty = 1;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
tor_free(circ);
@ -50,7 +50,7 @@ test_circuit_is_available_for_use_ret_false_for_non_general_purpose(void *arg)
circuit_t *circ = tor_malloc(sizeof(circuit_t));
circ->purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
tor_free(circ);
@ -64,7 +64,7 @@ test_circuit_is_available_for_use_ret_false_for_non_general_origin(void *arg)
circuit_t *circ = tor_malloc(sizeof(circuit_t));
circ->purpose = CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
tor_free(circ);
@ -78,7 +78,7 @@ test_circuit_is_available_for_use_ret_false_for_non_origin_purpose(void *arg)
circuit_t *circ = tor_malloc(sizeof(circuit_t));
circ->purpose = CIRCUIT_PURPOSE_OR;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
tor_free(circ);
@ -92,7 +92,7 @@ test_circuit_is_available_for_use_ret_false_unusable_for_new_conns(void *arg)
circuit_t *circ = dummy_origin_circuit_new(30);
mark_circuit_unusable_for_new_conns(TO_ORIGIN_CIRCUIT(circ));
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
circuit_free(circ);
@ -108,7 +108,7 @@ test_circuit_is_available_for_use_returns_false_for_onehop_tunnel(void *arg)
oc->build_state = tor_malloc_zero(sizeof(cpath_build_state_t));
oc->build_state->onehop_tunnel = 1;
tt_int_op(0, ==, circuit_is_available_for_use(circ));
tt_int_op(0, OP_EQ, circuit_is_available_for_use(circ));
done:
circuit_free(circ);
@ -124,7 +124,7 @@ test_circuit_is_available_for_use_returns_true_for_clean_circuit(void *arg)
oc->build_state = tor_malloc_zero(sizeof(cpath_build_state_t));
oc->build_state->onehop_tunnel = 0;
tt_int_op(1, ==, circuit_is_available_for_use(circ));
tt_int_op(1, OP_EQ, circuit_is_available_for_use(circ));
done:
circuit_free(circ);
@ -165,7 +165,8 @@ test_needs_exit_circuits_ret_false_for_predicted_ports_and_path(void *arg)
int needs_capacity = 0;
time_t now = time(NULL);
tt_int_op(0, ==, needs_exit_circuits(now, &needs_uptime, &needs_capacity));
tt_int_op(0, OP_EQ,
needs_exit_circuits(now, &needs_uptime, &needs_capacity));
done:
UNMOCK(circuit_all_predicted_ports_handled);
@ -183,7 +184,8 @@ test_needs_exit_circuits_ret_false_for_non_exit_consensus_path(void *arg)
MOCK(router_have_consensus_path, mock_router_have_unknown_consensus_path);
time_t now = time(NULL);
tt_int_op(0, ==, needs_exit_circuits(now, &needs_uptime, &needs_capacity));
tt_int_op(0, OP_EQ,
needs_exit_circuits(now, &needs_uptime, &needs_capacity));
done:
UNMOCK(circuit_all_predicted_ports_handled);
@ -202,7 +204,8 @@ test_needs_exit_circuits_ret_true_for_predicted_ports_and_path(void *arg)
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
time_t now = time(NULL);
tt_int_op(1, ==, needs_exit_circuits(now, &needs_uptime, &needs_capacity));
tt_int_op(1, OP_EQ,
needs_exit_circuits(now, &needs_uptime, &needs_capacity));
done:
UNMOCK(circuit_all_predicted_ports_handled);
@ -214,7 +217,7 @@ test_needs_circuits_for_build_ret_false_consensus_path_unknown(void *arg)
{
(void)arg;
MOCK(router_have_consensus_path, mock_router_have_unknown_consensus_path);
tt_int_op(0, ==, needs_circuits_for_build(0));
tt_int_op(0, OP_EQ, needs_circuits_for_build(0));
done: ;
}
@ -223,7 +226,7 @@ test_needs_circuits_for_build_ret_false_if_num_less_than_max(void *arg)
{
(void)arg;
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
tt_int_op(0, ==, needs_circuits_for_build(13));
tt_int_op(0, OP_EQ, needs_circuits_for_build(13));
done:
UNMOCK(router_have_consensus_path);
}
@ -233,7 +236,7 @@ test_needs_circuits_for_build_returns_true_when_more_are_needed(void *arg)
{
(void)arg;
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
tt_int_op(1, ==, needs_circuits_for_build(0));
tt_int_op(1, OP_EQ, needs_circuits_for_build(0));
done:
UNMOCK(router_have_consensus_path);
}

File diff suppressed because it is too large Load Diff

View File

@ -70,7 +70,7 @@ test_conn_lookup_addr_helper(const char *address, int family, tor_addr_t *addr)
rv = tor_addr_lookup(address, family, addr);
/* XXXX - should we retry on transient failure? */
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
tt_assert(tor_addr_is_loopback(addr));
tt_assert(tor_addr_is_v4(addr));
@ -292,7 +292,7 @@ test_conn_download_status_teardown(const struct testcase_t *tc, void *arg)
/* connection_free_() cleans up requested_resource */
rv = test_conn_get_rsrc_teardown(tc, conn);
tt_assert(rv == 1);
tt_int_op(rv, OP_EQ, 1);
}
} SMARTLIST_FOREACH_END(conn);
@ -366,12 +366,13 @@ test_conn_get_basic(void *arg)
* its attributes, but get NULL when we supply a different value. */
tt_assert(connection_get_by_global_id(conn->global_identifier) == conn);
tt_assert(connection_get_by_global_id(!conn->global_identifier) == NULL);
tt_ptr_op(connection_get_by_global_id(!conn->global_identifier), OP_EQ,
NULL);
tt_assert(connection_get_by_type(conn->type) == conn);
tt_assert(connection_get_by_type(TEST_CONN_TYPE) == conn);
tt_assert(connection_get_by_type(!conn->type) == NULL);
tt_assert(connection_get_by_type(!TEST_CONN_TYPE) == NULL);
tt_ptr_op(connection_get_by_type(!conn->type), OP_EQ, NULL);
tt_ptr_op(connection_get_by_type(!TEST_CONN_TYPE), OP_EQ, NULL);
tt_assert(connection_get_by_type_state(conn->type, conn->state)
== conn);
@ -485,7 +486,7 @@ test_conn_get_rend(void *arg)
#define sl_is_conn_assert(sl_input, conn) \
do { \
the_sl = (sl_input); \
tt_assert(smartlist_len((the_sl)) == 1); \
tt_int_op(smartlist_len((the_sl)), OP_EQ, 1); \
tt_assert(smartlist_get((the_sl), 0) == (conn)); \
smartlist_free(the_sl); the_sl = NULL; \
} while (0)
@ -493,7 +494,7 @@ test_conn_get_rend(void *arg)
#define sl_no_conn_assert(sl_input) \
do { \
the_sl = (sl_input); \
tt_assert(smartlist_len((the_sl)) == 0); \
tt_int_op(smartlist_len((the_sl)), OP_EQ, 0); \
smartlist_free(the_sl); the_sl = NULL; \
} while (0)
@ -539,43 +540,32 @@ test_conn_get_rsrc(void *arg)
TEST_CONN_RSRC_2,
!TEST_CONN_STATE));
tt_assert(connection_dir_count_by_purpose_and_resource(
conn->base_.purpose,
conn->requested_resource)
== 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
TEST_CONN_RSRC)
== 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
!conn->base_.purpose,
"")
== 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
!TEST_CONN_RSRC_PURPOSE,
TEST_CONN_RSRC_2)
== 0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
conn->base_.purpose, conn->requested_resource),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, TEST_CONN_RSRC),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
!conn->base_.purpose, ""),
OP_EQ, 0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
!TEST_CONN_RSRC_PURPOSE, TEST_CONN_RSRC_2),
OP_EQ, 0);
tt_assert(connection_dir_count_by_purpose_resource_and_state(
conn->base_.purpose,
conn->requested_resource,
conn->base_.state)
== 1);
tt_assert(connection_dir_count_by_purpose_resource_and_state(
TEST_CONN_RSRC_PURPOSE,
TEST_CONN_RSRC,
TEST_CONN_STATE)
== 1);
tt_assert(connection_dir_count_by_purpose_resource_and_state(
!conn->base_.purpose,
"",
!conn->base_.state)
== 0);
tt_assert(connection_dir_count_by_purpose_resource_and_state(
!TEST_CONN_RSRC_PURPOSE,
TEST_CONN_RSRC_2,
!TEST_CONN_STATE)
== 0);
tt_int_op(connection_dir_count_by_purpose_resource_and_state(
conn->base_.purpose, conn->requested_resource,
conn->base_.state),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_resource_and_state(
TEST_CONN_RSRC_PURPOSE, TEST_CONN_RSRC, TEST_CONN_STATE),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_resource_and_state(
!conn->base_.purpose, "", !conn->base_.state),
OP_EQ, 0);
tt_int_op(connection_dir_count_by_purpose_resource_and_state(
!TEST_CONN_RSRC_PURPOSE, TEST_CONN_RSRC_2, !TEST_CONN_STATE),
OP_EQ, 0);
done:
smartlist_free(the_sl);
@ -601,117 +591,127 @@ test_conn_download_status(void *arg)
const char *other_res = networkstatus_get_flavor_name(other_flavor);
/* no connections */
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* one connection, not downloading */
conn = test_conn_download_status_add_a_connection(res);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* one connection, downloading but not linked (not possible on a client,
* but possible on a relay) */
conn->base_.state = TEST_CONN_DL_STATE;
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* one connection, downloading and linked, but not yet attached */
ap_conn = test_conn_get_linked_connection(TO_CONN(conn),
TEST_CONN_UNATTACHED_STATE);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* one connection, downloading and linked and attached */
ap_conn->state = TEST_CONN_ATTACHED_STATE;
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* one connection, linked and attached but not downloading */
conn->base_.state = TEST_CONN_STATE;
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* two connections, both not downloading */
conn2 = test_conn_download_status_add_a_connection(res);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 2);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 2);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* two connections, one downloading */
conn->base_.state = TEST_CONN_DL_STATE;
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 2);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 2);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
conn->base_.state = TEST_CONN_STATE;
/* more connections, all not downloading */
/* ignore the return value, it's free'd using the connection list */
(void)test_conn_download_status_add_a_connection(res);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 0);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 0);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* more connections, one downloading */
conn->base_.state = TEST_CONN_DL_STATE;
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* more connections, two downloading (should never happen, but needs
* to be tested for completeness) */
@ -719,38 +719,41 @@ test_conn_download_status(void *arg)
/* ignore the return value, it's free'd using the connection list */
(void)test_conn_get_linked_connection(TO_CONN(conn2),
TEST_CONN_ATTACHED_STATE);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
conn->base_.state = TEST_CONN_STATE;
/* more connections, a different one downloading */
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 0);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 0);
/* a connection for the other flavor (could happen if a client is set to
* cache directory documents), one preferred flavor downloading
*/
conn4 = test_conn_download_status_add_a_connection(other_res);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 0);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 1);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
0);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 1);
/* a connection for the other flavor (could happen if a client is set to
* cache directory documents), both flavors downloading
@ -759,14 +762,15 @@ test_conn_download_status(void *arg)
/* ignore the return value, it's free'd using the connection list */
(void)test_conn_get_linked_connection(TO_CONN(conn4),
TEST_CONN_ATTACHED_STATE);
tt_assert(networkstatus_consensus_is_already_downloading(res) == 1);
tt_assert(networkstatus_consensus_is_already_downloading(other_res) == 1);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
res) == 3);
tt_assert(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE,
other_res) == 1);
tt_int_op(networkstatus_consensus_is_already_downloading(res), OP_EQ, 1);
tt_int_op(networkstatus_consensus_is_already_downloading(other_res), OP_EQ,
1);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, res),
OP_EQ, 3);
tt_int_op(connection_dir_count_by_purpose_and_resource(
TEST_CONN_RSRC_PURPOSE, other_res),
OP_EQ, 1);
done:
/* the teardown function removes all the connections in the global list*/;

View File

@ -200,7 +200,7 @@ test_conscache_cleanup(void *arg)
tt_assert(e_tmp);
tt_assert(consensus_cache_entry_is_mapped(e_tmp));
e_tmp = consensus_cache_find_first(cache, "index", "7");
tt_assert(e_tmp == NULL); // not found because pending deletion.
tt_ptr_op(e_tmp, OP_EQ, NULL); // not found because pending deletion.
/* Delete the pending-deletion items. */
consensus_cache_delete_pending(cache, 0);
@ -212,9 +212,9 @@ test_conscache_cleanup(void *arg)
tt_int_op(n, OP_EQ, 20 - 2); /* 1 entry was deleted; 1 is not-found. */
}
e_tmp = consensus_cache_find_first(cache, "index", "7"); // refcnt == 1...
tt_assert(e_tmp == NULL); // so deleted.
tt_ptr_op(e_tmp, OP_EQ, NULL); // so deleted.
e_tmp = consensus_cache_find_first(cache, "index", "14"); // refcnt == 2
tt_assert(e_tmp == NULL); // not deleted; but not found.
tt_ptr_op(e_tmp, OP_EQ, NULL); // not deleted; but not found.
/* Now do lazy unmapping. */
// should do nothing.

View File

@ -325,8 +325,8 @@ test_consdiffmgr_add(void *arg)
tt_mem_op(body, OP_EQ, "quux", 4);
/* Try looking up another entry, but fail */
tt_assert(NULL == cdm_cache_lookup_consensus(FLAV_MICRODESC, now-60));
tt_assert(NULL == cdm_cache_lookup_consensus(FLAV_NS, now-61));
tt_ptr_op(cdm_cache_lookup_consensus(FLAV_MICRODESC, now - 60), OP_EQ, NULL);
tt_ptr_op(cdm_cache_lookup_consensus(FLAV_NS, now - 61), OP_EQ, NULL);
done:
networkstatus_vote_free(ns_tmp);

View File

@ -510,22 +510,22 @@ test_container_smartlist_pos(void *arg)
smartlist_add_strdup(sl, "function");
/* Test string_pos */
tt_int_op(smartlist_string_pos(NULL, "Fred"), ==, -1);
tt_int_op(smartlist_string_pos(sl, "Fred"), ==, -1);
tt_int_op(smartlist_string_pos(sl, "This"), ==, 0);
tt_int_op(smartlist_string_pos(sl, "a"), ==, 2);
tt_int_op(smartlist_string_pos(sl, "function"), ==, 6);
tt_int_op(smartlist_string_pos(NULL, "Fred"), OP_EQ, -1);
tt_int_op(smartlist_string_pos(sl, "Fred"), OP_EQ, -1);
tt_int_op(smartlist_string_pos(sl, "This"), OP_EQ, 0);
tt_int_op(smartlist_string_pos(sl, "a"), OP_EQ, 2);
tt_int_op(smartlist_string_pos(sl, "function"), OP_EQ, 6);
/* Test pos */
tt_int_op(smartlist_pos(NULL, "Fred"), ==, -1);
tt_int_op(smartlist_pos(sl, "Fred"), ==, -1);
tt_int_op(smartlist_pos(sl, "This"), ==, -1);
tt_int_op(smartlist_pos(sl, "a"), ==, -1);
tt_int_op(smartlist_pos(sl, "function"), ==, -1);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,0)), ==, 0);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,2)), ==, 2);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,5)), ==, 5);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), ==, 6);
tt_int_op(smartlist_pos(NULL, "Fred"), OP_EQ, -1);
tt_int_op(smartlist_pos(sl, "Fred"), OP_EQ, -1);
tt_int_op(smartlist_pos(sl, "This"), OP_EQ, -1);
tt_int_op(smartlist_pos(sl, "a"), OP_EQ, -1);
tt_int_op(smartlist_pos(sl, "function"), OP_EQ, -1);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,0)), OP_EQ, 0);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,2)), OP_EQ, 2);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,5)), OP_EQ, 5);
tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), OP_EQ, 6);
done:
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
@ -990,13 +990,13 @@ test_container_order_functions(void *arg)
tt_assert(15 == median_time(times, 5));
int32_t int32s[] = { -5, -10, -50, 100 };
tt_int_op(-5, ==, median_int32(int32s, 1));
tt_int_op(-10, ==, median_int32(int32s, 2));
tt_int_op(-10, ==, median_int32(int32s, 3));
tt_int_op(-10, ==, median_int32(int32s, 4));
tt_int_op(-5, OP_EQ, median_int32(int32s, 1));
tt_int_op(-10, OP_EQ, median_int32(int32s, 2));
tt_int_op(-10, OP_EQ, median_int32(int32s, 3));
tt_int_op(-10, OP_EQ, median_int32(int32s, 4));
long longs[] = { -30, 30, 100, -100, 7 };
tt_int_op(7, ==, find_nth_long(longs, 5, 2));
tt_int_op(7, OP_EQ, find_nth_long(longs, 5, 2));
done:
;
@ -1153,31 +1153,31 @@ test_container_smartlist_most_frequent(void *arg)
const char *cp;
cp = smartlist_get_most_frequent_string_(sl, &count);
tt_int_op(count, ==, 0);
tt_ptr_op(cp, ==, NULL);
tt_int_op(count, OP_EQ, 0);
tt_ptr_op(cp, OP_EQ, NULL);
/* String must be sorted before we call get_most_frequent */
smartlist_split_string(sl, "abc:def:ghi", ":", 0, 0);
cp = smartlist_get_most_frequent_string_(sl, &count);
tt_int_op(count, ==, 1);
tt_str_op(cp, ==, "ghi"); /* Ties broken in favor of later element */
tt_int_op(count, OP_EQ, 1);
tt_str_op(cp, OP_EQ, "ghi"); /* Ties broken in favor of later element */
smartlist_split_string(sl, "def:ghi", ":", 0, 0);
smartlist_sort_strings(sl);
cp = smartlist_get_most_frequent_string_(sl, &count);
tt_int_op(count, ==, 2);
tt_ptr_op(cp, !=, NULL);
tt_str_op(cp, ==, "ghi"); /* Ties broken in favor of later element */
tt_int_op(count, OP_EQ, 2);
tt_ptr_op(cp, OP_NE, NULL);
tt_str_op(cp, OP_EQ, "ghi"); /* Ties broken in favor of later element */
smartlist_split_string(sl, "def:abc:qwop", ":", 0, 0);
smartlist_sort_strings(sl);
cp = smartlist_get_most_frequent_string_(sl, &count);
tt_int_op(count, ==, 3);
tt_ptr_op(cp, !=, NULL);
tt_str_op(cp, ==, "def"); /* No tie */
tt_int_op(count, OP_EQ, 3);
tt_ptr_op(cp, OP_NE, NULL);
tt_str_op(cp, OP_EQ, "def"); /* No tie */
done:
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
@ -1206,7 +1206,7 @@ test_container_smartlist_sort_ptrs(void *arg)
smartlist_shuffle(sl);
smartlist_sort_pointers(sl);
for (j = 0; j < ARRAY_LENGTH(arrayptrs); ++j) {
tt_ptr_op(smartlist_get(sl, j), ==, arrayptrs[j]);
tt_ptr_op(smartlist_get(sl, j), OP_EQ, arrayptrs[j]);
}
}
@ -1232,11 +1232,11 @@ test_container_smartlist_strings_eq(void *arg)
} while (0)
/* Both NULL, so equal */
tt_int_op(1, ==, smartlist_strings_eq(NULL, NULL));
tt_int_op(1, OP_EQ, smartlist_strings_eq(NULL, NULL));
/* One NULL, not equal. */
tt_int_op(0, ==, smartlist_strings_eq(NULL, sl1));
tt_int_op(0, ==, smartlist_strings_eq(sl1, NULL));
tt_int_op(0, OP_EQ, smartlist_strings_eq(NULL, sl1));
tt_int_op(0, OP_EQ, smartlist_strings_eq(sl1, NULL));
/* Both empty, both equal. */
EQ_SHOULD_SAY("", "", 1);

View File

@ -31,7 +31,7 @@ test_add_onion_helper_keyarg(void *arg)
tt_assert(pk);
tt_str_op(key_new_alg, OP_EQ, "RSA1024");
tt_assert(key_new_blob);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test "BEST" key generation (Assumes BEST = RSA1024). */
crypto_pk_free(pk);
@ -41,7 +41,7 @@ test_add_onion_helper_keyarg(void *arg)
tt_assert(pk);
tt_str_op(key_new_alg, OP_EQ, "RSA1024");
tt_assert(key_new_blob);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test discarding the private key. */
crypto_pk_free(pk);
@ -49,17 +49,17 @@ test_add_onion_helper_keyarg(void *arg)
pk = add_onion_helper_keyarg("NEW:BEST", 1, &key_new_alg, &key_new_blob,
&err_msg);
tt_assert(pk);
tt_assert(!key_new_alg);
tt_assert(!key_new_blob);
tt_assert(!err_msg);
tt_ptr_op(key_new_alg, OP_EQ, NULL);
tt_ptr_op(key_new_blob, OP_EQ, NULL);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test generating a invalid key type. */
crypto_pk_free(pk);
pk = add_onion_helper_keyarg("NEW:RSA512", 0, &key_new_alg, &key_new_blob,
&err_msg);
tt_assert(!pk);
tt_assert(!key_new_alg);
tt_assert(!key_new_blob);
tt_ptr_op(pk, OP_EQ, NULL);
tt_ptr_op(key_new_alg, OP_EQ, NULL);
tt_ptr_op(key_new_blob, OP_EQ, NULL);
tt_assert(err_msg);
/* Test loading a RSA1024 key. */
@ -70,10 +70,10 @@ test_add_onion_helper_keyarg(void *arg)
pk2 = add_onion_helper_keyarg(arg_str, 0, &key_new_alg, &key_new_blob,
&err_msg);
tt_assert(pk2);
tt_assert(!key_new_alg);
tt_assert(!key_new_blob);
tt_assert(!err_msg);
tt_assert(crypto_pk_cmp_keys(pk, pk2) == 0);
tt_ptr_op(key_new_alg, OP_EQ, NULL);
tt_ptr_op(key_new_blob, OP_EQ, NULL);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_int_op(crypto_pk_cmp_keys(pk, pk2), OP_EQ, 0);
/* Test loading a invalid key type. */
tor_free(arg_str);
@ -81,9 +81,9 @@ test_add_onion_helper_keyarg(void *arg)
tor_asprintf(&arg_str, "RSA512:%s", encoded);
pk = add_onion_helper_keyarg(arg_str, 0, &key_new_alg, &key_new_blob,
&err_msg);
tt_assert(!pk);
tt_assert(!key_new_alg);
tt_assert(!key_new_blob);
tt_ptr_op(pk, OP_EQ, NULL);
tt_ptr_op(key_new_alg, OP_EQ, NULL);
tt_ptr_op(key_new_blob, OP_EQ, NULL);
tt_assert(err_msg);
/* Test loading a invalid key. */
@ -94,9 +94,9 @@ test_add_onion_helper_keyarg(void *arg)
tor_asprintf(&arg_str, "RSA1024:%s", encoded);
pk = add_onion_helper_keyarg(arg_str, 0, &key_new_alg, &key_new_blob,
&err_msg);
tt_assert(!pk);
tt_assert(!key_new_alg);
tt_assert(!key_new_blob);
tt_ptr_op(pk, OP_EQ, NULL);
tt_ptr_op(key_new_alg, OP_EQ, NULL);
tt_ptr_op(key_new_blob, OP_EQ, NULL);
tt_assert(err_msg);
done:
@ -123,13 +123,13 @@ test_getinfo_helper_onion(void *arg)
/* successfully get an empty answer */
rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg);
tt_assert(rt == 0);
tt_int_op(rt, OP_EQ, 0);
tt_str_op(answer, OP_EQ, "");
tor_free(answer);
/* successfully get an empty answer */
rt = getinfo_helper_onions(&dummy, "onions/detached", &answer, &errmsg);
tt_assert(rt == 0);
tt_int_op(rt, OP_EQ, 0);
tt_str_op(answer, OP_EQ, "");
tor_free(answer);
@ -138,7 +138,7 @@ test_getinfo_helper_onion(void *arg)
dummy.ephemeral_onion_services = smartlist_new();
smartlist_add(dummy.ephemeral_onion_services, service_id);
rt = getinfo_helper_onions(&dummy, "onions/current", &answer, &errmsg);
tt_assert(rt == 0);
tt_int_op(rt, OP_EQ, 0);
tt_str_op(answer, OP_EQ, "dummy_onion_id");
done:
@ -159,25 +159,25 @@ test_rend_service_parse_port_config(void *arg)
/* Test "VIRTPORT" only. */
cfg = rend_service_parse_port_config("80", sep, &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test "VIRTPORT,TARGET" (Target is port). */
rend_service_port_config_free(cfg);
cfg = rend_service_parse_port_config("80,8080", sep, &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test "VIRTPORT,TARGET" (Target is IPv4:port). */
rend_service_port_config_free(cfg);
cfg = rend_service_parse_port_config("80,192.0.2.1:8080", sep, &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
/* Test "VIRTPORT,TARGET" (Target is IPv6:port). */
rend_service_port_config_free(cfg);
cfg = rend_service_parse_port_config("80,[2001:db8::1]:8080", sep, &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
rend_service_port_config_free(cfg);
cfg = NULL;
@ -186,13 +186,13 @@ test_rend_service_parse_port_config(void *arg)
/* Test empty config. */
rend_service_port_config_free(cfg);
cfg = rend_service_parse_port_config("", sep, &err_msg);
tt_assert(!cfg);
tt_ptr_op(cfg, OP_EQ, NULL);
tt_assert(err_msg);
/* Test invalid port. */
tor_free(err_msg);
cfg = rend_service_parse_port_config("90001", sep, &err_msg);
tt_assert(!cfg);
tt_ptr_op(cfg, OP_EQ, NULL);
tt_assert(err_msg);
tor_free(err_msg);
@ -204,7 +204,7 @@ test_rend_service_parse_port_config(void *arg)
cfg = rend_service_parse_port_config("100 unix:\"/tmp/foo bar\"",
" ", &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
rend_service_port_config_free(cfg);
cfg = NULL;
@ -213,14 +213,14 @@ test_rend_service_parse_port_config(void *arg)
cfg = rend_service_parse_port_config("100 unix:\"/tmp/foo bar\"",
" ", &err_msg);
tt_assert(cfg);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
rend_service_port_config_free(cfg);
cfg = NULL;
/* quoted unix port, missing end quote */
cfg = rend_service_parse_port_config("100 unix:\"/tmp/foo bar",
" ", &err_msg);
tt_assert(!cfg);
tt_ptr_op(cfg, OP_EQ, NULL);
tt_str_op(err_msg, OP_EQ, "Couldn't process address <unix:\"/tmp/foo bar> "
"from hidden service configuration");
tor_free(err_msg);
@ -230,7 +230,7 @@ test_rend_service_parse_port_config(void *arg)
cfg = rend_service_parse_port_config("100 foo!!.example.com:9000",
" ", &err_msg);
UNMOCK(tor_addr_lookup);
tt_assert(!cfg);
tt_ptr_op(cfg, OP_EQ, NULL);
tt_str_op(err_msg, OP_EQ, "Unparseable address in hidden service port "
"configuration.");
tor_free(err_msg);
@ -238,7 +238,7 @@ test_rend_service_parse_port_config(void *arg)
/* bogus port port */
cfg = rend_service_parse_port_config("100 99999",
" ", &err_msg);
tt_assert(!cfg);
tt_ptr_op(cfg, OP_EQ, NULL);
tt_str_op(err_msg, OP_EQ, "Unparseable or out-of-range port \"99999\" "
"in hidden service port configuration.");
tor_free(err_msg);
@ -261,7 +261,7 @@ test_add_onion_helper_clientauth(void *arg)
client = add_onion_helper_clientauth("alice", &created, &err_msg);
tt_assert(client);
tt_assert(created);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
rend_authorized_client_free(client);
/* Test "ClientName:Blob" */
@ -269,26 +269,26 @@ test_add_onion_helper_clientauth(void *arg)
&created, &err_msg);
tt_assert(client);
tt_assert(!created);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
rend_authorized_client_free(client);
/* Test invalid client names */
client = add_onion_helper_clientauth("no*asterisks*allowed", &created,
&err_msg);
tt_assert(!client);
tt_ptr_op(client, OP_EQ, NULL);
tt_assert(err_msg);
tor_free(err_msg);
/* Test invalid auth cookie */
client = add_onion_helper_clientauth("alice:12345", &created, &err_msg);
tt_assert(!client);
tt_ptr_op(client, OP_EQ, NULL);
tt_assert(err_msg);
tor_free(err_msg);
/* Test invalid syntax */
client = add_onion_helper_clientauth(":475hGBHPlq7Mc0cRZitK/B", &created,
&err_msg);
tt_assert(!client);
tt_ptr_op(client, OP_EQ, NULL);
tt_assert(err_msg);
tor_free(err_msg);
@ -544,7 +544,7 @@ cert_dl_status_def_for_auth_mock(const char *digest)
download_status_t *dl = NULL;
char digest_str[HEX_DIGEST_LEN+1];
tt_assert(digest != NULL);
tt_ptr_op(digest, OP_NE, NULL);
base16_encode(digest_str, HEX_DIGEST_LEN + 1,
digest, DIGEST_LEN);
digest_str[HEX_DIGEST_LEN] = '\0';
@ -568,7 +568,7 @@ cert_dl_status_sks_for_auth_id_mock(const char *digest)
char *tmp;
int len;
tt_assert(digest != NULL);
tt_ptr_op(digest, OP_NE, NULL);
base16_encode(digest_str, HEX_DIGEST_LEN + 1,
digest, DIGEST_LEN);
digest_str[HEX_DIGEST_LEN] = '\0';
@ -622,11 +622,11 @@ cert_dl_status_fp_sk_mock(const char *fp_digest, const char *sk_digest)
* dl status we want.
*/
tt_assert(fp_digest != NULL);
tt_ptr_op(fp_digest, OP_NE, NULL);
base16_encode(fp_digest_str, HEX_DIGEST_LEN + 1,
fp_digest, DIGEST_LEN);
fp_digest_str[HEX_DIGEST_LEN] = '\0';
tt_assert(sk_digest != NULL);
tt_ptr_op(sk_digest, OP_NE, NULL);
base16_encode(sk_digest_str, HEX_DIGEST_LEN + 1,
sk_digest, DIGEST_LEN);
sk_digest_str[HEX_DIGEST_LEN] = '\0';
@ -706,7 +706,7 @@ descbr_get_dl_by_digest_mock(const char *digest)
char digest_str[HEX_DIGEST_LEN+1];
if (!disable_descbr) {
tt_assert(digest != NULL);
tt_ptr_op(digest, OP_NE, NULL);
base16_encode(digest_str, HEX_DIGEST_LEN + 1,
digest, DIGEST_LEN);
digest_str[HEX_DIGEST_LEN] = '\0';
@ -773,7 +773,7 @@ test_download_status_consensus(void *arg)
/* Check that the unknown prefix case works; no mocks needed yet */
getinfo_helper_downloads(&dummy, "downloads/foo", &answer, &errmsg);
tt_assert(answer == NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_str_op(errmsg, OP_EQ, "Unknown download status query");
setup_ns_mocks();
@ -788,8 +788,8 @@ test_download_status_consensus(void *arg)
sizeof(download_status_t));
getinfo_helper_downloads(&dummy, "downloads/networkstatus/ns",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_1_str);
tor_free(answer);
errmsg = NULL;
@ -799,8 +799,8 @@ test_download_status_consensus(void *arg)
sizeof(download_status_t));
getinfo_helper_downloads(&dummy, "downloads/networkstatus/microdesc",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_2_str);
tor_free(answer);
errmsg = NULL;
@ -810,8 +810,8 @@ test_download_status_consensus(void *arg)
sizeof(download_status_t));
getinfo_helper_downloads(&dummy, "downloads/networkstatus/ns/bootstrap",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_3_str);
tor_free(answer);
errmsg = NULL;
@ -822,8 +822,8 @@ test_download_status_consensus(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/networkstatus/microdesc/bootstrap",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_4_str);
tor_free(answer);
errmsg = NULL;
@ -834,8 +834,8 @@ test_download_status_consensus(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/networkstatus/ns/running",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_5_str);
tor_free(answer);
errmsg = NULL;
@ -846,8 +846,8 @@ test_download_status_consensus(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/networkstatus/microdesc/running",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_6_str);
tor_free(answer);
errmsg = NULL;
@ -855,8 +855,8 @@ test_download_status_consensus(void *arg)
/* Now check the error case */
getinfo_helper_downloads(&dummy, "downloads/networkstatus/foo",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "Unknown flavor");
errmsg = NULL;
@ -890,8 +890,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fps",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, auth_id_digest_expected_list);
tor_free(answer);
errmsg = NULL;
@ -900,10 +900,10 @@ test_download_status_cert(void *arg)
memcpy(&auth_def_cert_download_status_1, &dls_sample_1,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s", auth_id_digest_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_1_str);
tor_free(question);
tor_free(answer);
@ -913,10 +913,10 @@ test_download_status_cert(void *arg)
memcpy(&auth_def_cert_download_status_2, &dls_sample_2,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s", auth_id_digest_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_2_str);
tor_free(question);
tor_free(answer);
@ -924,10 +924,10 @@ test_download_status_cert(void *arg)
/* Case 4 - list of signing key digests for 1st auth id */
tor_asprintf(&question, "downloads/cert/fp/%s/sks", auth_id_digest_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, auth_1_sk_digest_expected_list);
tor_free(question);
tor_free(answer);
@ -935,10 +935,10 @@ test_download_status_cert(void *arg)
/* Case 5 - list of signing key digests for 2nd auth id */
tor_asprintf(&question, "downloads/cert/fp/%s/sks", auth_id_digest_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, auth_2_sk_digest_expected_list);
tor_free(question);
tor_free(answer);
@ -949,10 +949,10 @@ test_download_status_cert(void *arg)
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s/%s",
auth_id_digest_1_str, auth_1_sk_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_3_str);
tor_free(question);
tor_free(answer);
@ -963,10 +963,10 @@ test_download_status_cert(void *arg)
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s/%s",
auth_id_digest_1_str, auth_1_sk_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_4_str);
tor_free(question);
tor_free(answer);
@ -977,10 +977,10 @@ test_download_status_cert(void *arg)
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s/%s",
auth_id_digest_2_str, auth_2_sk_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_5_str);
tor_free(question);
tor_free(answer);
@ -991,10 +991,10 @@ test_download_status_cert(void *arg)
sizeof(download_status_t));
tor_asprintf(&question, "downloads/cert/fp/%s/%s",
auth_id_digest_2_str, auth_2_sk_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_6_str);
tor_free(question);
tor_free(answer);
@ -1005,8 +1005,8 @@ test_download_status_cert(void *arg)
/* Case 1 - query is garbage after downloads/cert/ part */
getinfo_helper_downloads(&dummy, "downloads/cert/blahdeblah",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "Unknown certificate download status query");
errmsg = NULL;
@ -1016,8 +1016,8 @@ test_download_status_cert(void *arg)
*/
getinfo_helper_downloads(&dummy, "downloads/cert/fp/2B1D36D32B2942406",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a digest");
errmsg = NULL;
@ -1028,8 +1028,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fp/82F52AF55D250115FE44D3GC81D49643241D56A1",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a digest");
errmsg = NULL;
@ -1040,8 +1040,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fp/AC4F23B5745BDD2A77997B85B1FD85D05C2E0F61",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"Failed to get download status for this authority identity digest");
errmsg = NULL;
@ -1053,8 +1053,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fp/82F52AF55D250115FE44D3GC81D49643241D56A1/blah",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like an identity digest");
errmsg = NULL;
@ -1065,8 +1065,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fp/82F52AF55D25/blah",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like an identity digest");
errmsg = NULL;
@ -1077,8 +1077,8 @@ test_download_status_cert(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/cert/fp/AC4F23B5745BDD2A77997B85B1FD85D05C2E0F61/sks",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"Failed to get list of signing key digests for this authority "
"identity digest");
@ -1092,8 +1092,8 @@ test_download_status_cert(void *arg)
"downloads/cert/fp/AC4F23B5745BDD2A77997B85B1FD85D05C2E0F61/"
"82F52AF55D250115FE44D3GC81D49643241D56A1",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a signing key digest");
errmsg = NULL;
@ -1105,8 +1105,8 @@ test_download_status_cert(void *arg)
"downloads/cert/fp/AC4F23B5745BDD2A77997B85B1FD85D05C2E0F61/"
"82F52AF55D250115FE44D",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a signing key digest");
errmsg = NULL;
@ -1118,8 +1118,8 @@ test_download_status_cert(void *arg)
"downloads/cert/fp/C6B05DF332F74DB9A13498EE3BBC7AA2F69FCB45/"
"3A214FC21AE25B012C2ECCB5F4EC8A3602D0545D",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"Failed to get download status for this identity/"
"signing key digest pair");
@ -1133,8 +1133,8 @@ test_download_status_cert(void *arg)
"downloads/cert/fp/63CDD326DFEF0CA020BDD3FEB45A3286FE13A061/"
"3A214FC21AE25B012C2ECCB5F4EC8A3602D0545D",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"Failed to get download status for this identity/"
"signing key digest pair");
@ -1148,8 +1148,8 @@ test_download_status_cert(void *arg)
"downloads/cert/fp/63CDD326DFEF0CA020BDD3FEB45A3286FE13A061/"
"9451B8F1B10952384EB58B5F230C0BB701626C9B",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"Failed to get download status for this identity/"
"signing key digest pair");
@ -1185,8 +1185,8 @@ test_download_status_desc(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/desc/descs",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, descbr_expected_list);
tor_free(answer);
errmsg = NULL;
@ -1195,10 +1195,10 @@ test_download_status_desc(void *arg)
memcpy(&descbr_digest_1_dl, &dls_sample_1,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/desc/%s", descbr_digest_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_1_str);
tor_free(question);
tor_free(answer);
@ -1208,10 +1208,10 @@ test_download_status_desc(void *arg)
memcpy(&descbr_digest_2_dl, &dls_sample_2,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/desc/%s", descbr_digest_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_2_str);
tor_free(question);
tor_free(answer);
@ -1222,8 +1222,8 @@ test_download_status_desc(void *arg)
/* Case 1 - non-digest-length garbage after downloads/desc */
getinfo_helper_downloads(&dummy, "downloads/desc/blahdeblah",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "Unknown router descriptor download status query");
errmsg = NULL;
@ -1232,8 +1232,8 @@ test_download_status_desc(void *arg)
&dummy,
"downloads/desc/774EC52FD9A5B80A6FACZE536616E8022E3470AG",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a digest");
errmsg = NULL;
@ -1242,8 +1242,8 @@ test_download_status_desc(void *arg)
&dummy,
"downloads/desc/B05B46135B0B2C04EBE1DD6A6AE4B12D7CD2226A",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "No such descriptor digest found");
errmsg = NULL;
@ -1252,8 +1252,8 @@ test_download_status_desc(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/desc/descs",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ,
"We don't seem to have a networkstatus-flavored consensus");
errmsg = NULL;
@ -1289,8 +1289,8 @@ test_download_status_bridge(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/bridge/bridges",
&answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, descbr_expected_list);
tor_free(answer);
errmsg = NULL;
@ -1299,10 +1299,10 @@ test_download_status_bridge(void *arg)
memcpy(&descbr_digest_1_dl, &dls_sample_3,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/bridge/%s", descbr_digest_1_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_3_str);
tor_free(question);
tor_free(answer);
@ -1312,10 +1312,10 @@ test_download_status_bridge(void *arg)
memcpy(&descbr_digest_2_dl, &dls_sample_4,
sizeof(download_status_t));
tor_asprintf(&question, "downloads/bridge/%s", descbr_digest_2_str);
tt_assert(question != NULL);
tt_ptr_op(question, OP_NE, NULL);
getinfo_helper_downloads(&dummy, question, &answer, &errmsg);
tt_assert(answer != NULL);
tt_assert(errmsg == NULL);
tt_ptr_op(answer, OP_NE, NULL);
tt_ptr_op(errmsg, OP_EQ, NULL);
tt_str_op(answer, OP_EQ, dls_sample_4_str);
tor_free(question);
tor_free(answer);
@ -1326,8 +1326,8 @@ test_download_status_bridge(void *arg)
/* Case 1 - non-digest-length garbage after downloads/bridge */
getinfo_helper_downloads(&dummy, "downloads/bridge/blahdeblah",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "Unknown bridge descriptor download status query");
errmsg = NULL;
@ -1336,8 +1336,8 @@ test_download_status_bridge(void *arg)
&dummy,
"downloads/bridge/774EC52FD9A5B80A6FACZE536616E8022E3470AG",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "That didn't look like a digest");
errmsg = NULL;
@ -1346,8 +1346,8 @@ test_download_status_bridge(void *arg)
&dummy,
"downloads/bridge/B05B46135B0B2C04EBE1DD6A6AE4B12D7CD2226A",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "No such bridge identity digest found");
errmsg = NULL;
@ -1356,8 +1356,8 @@ test_download_status_bridge(void *arg)
getinfo_helper_downloads(&dummy,
"downloads/bridge/bridges",
&answer, &errmsg);
tt_assert(answer == NULL);
tt_assert(errmsg != NULL);
tt_ptr_op(answer, OP_EQ, NULL);
tt_ptr_op(errmsg, OP_NE, NULL);
tt_str_op(errmsg, OP_EQ, "We don't seem to be using bridges");
errmsg = NULL;
disable_descbr = 0;

View File

@ -1139,7 +1139,7 @@ test_crypto_mac_sha3(void *arg)
result = crypto_digest256(hmac_manual, all, all_len, DIGEST_SHA3_256);
tor_free(key_msg_concat);
tor_free(all);
tt_int_op(result, ==, 0);
tt_int_op(result, OP_EQ, 0);
}
/* Now compare the two results */
@ -1208,12 +1208,12 @@ test_crypto_pk(void *arg)
tt_assert(! crypto_pk_write_private_key_to_filename(pk1,
get_fname("pkey1")));
/* failing case for read: can't read. */
tt_assert(crypto_pk_read_private_key_from_filename(pk2,
get_fname("xyzzy")) < 0);
tt_int_op(crypto_pk_read_private_key_from_filename(pk2, get_fname("xyzzy")),
OP_LT, 0);
write_str_to_file(get_fname("xyzzy"), "foobar", 6);
/* Failing case for read: no key. */
tt_assert(crypto_pk_read_private_key_from_filename(pk2,
get_fname("xyzzy")) < 0);
tt_int_op(crypto_pk_read_private_key_from_filename(pk2, get_fname("xyzzy")),
OP_LT, 0);
tt_assert(! crypto_pk_read_private_key_from_filename(pk2,
get_fname("pkey1")));
tt_int_op(15,OP_EQ,
@ -1245,7 +1245,7 @@ test_crypto_pk(void *arg)
i = crypto_pk_asn1_encode(pk1, data1, 1024);
tt_int_op(i, OP_GT, 0);
pk2 = crypto_pk_asn1_decode(data1, i);
tt_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
tt_int_op(crypto_pk_cmp_keys(pk1, pk2), OP_EQ, 0);
/* Try with hybrid encryption wrappers. */
crypto_rand(data1, 1024);
@ -1264,9 +1264,9 @@ test_crypto_pk(void *arg)
/* Try copy_full */
crypto_pk_free(pk2);
pk2 = crypto_pk_copy_full(pk1);
tt_assert(pk2 != NULL);
tt_ptr_op(pk2, OP_NE, NULL);
tt_ptr_op(pk1, OP_NE, pk2);
tt_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
tt_int_op(crypto_pk_cmp_keys(pk1, pk2), OP_EQ, 0);
done:
if (pk1)
@ -1344,17 +1344,17 @@ test_crypto_pk_base64(void *arg)
/* Test decoding a valid key. */
pk2 = crypto_pk_base64_decode(encoded, strlen(encoded));
tt_assert(pk2);
tt_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
tt_int_op(crypto_pk_cmp_keys(pk1, pk2), OP_EQ, 0);
crypto_pk_free(pk2);
/* Test decoding a invalid key (not Base64). */
static const char *invalid_b64 = "The key is in another castle!";
pk2 = crypto_pk_base64_decode(invalid_b64, strlen(invalid_b64));
tt_assert(!pk2);
tt_ptr_op(pk2, OP_EQ, NULL);
/* Test decoding a truncated Base64 blob. */
pk2 = crypto_pk_base64_decode(encoded, strlen(encoded)/2);
tt_assert(!pk2);
tt_ptr_op(pk2, OP_EQ, NULL);
done:
crypto_pk_free(pk1);
@ -1495,7 +1495,7 @@ test_crypto_formats(void *arg)
tt_mem_op(data1,OP_EQ, data3, DIGEST_LEN);
tt_int_op(99,OP_EQ, data3[DIGEST_LEN+1]);
tt_assert(digest_from_base64(data3, "###") < 0);
tt_int_op(digest_from_base64(data3, "###"), OP_LT, 0);
/* Encoding SHA256 */
crypto_rand(data2, DIGEST256_LEN);
@ -2675,8 +2675,8 @@ test_crypto_ed25519_storage(void *arg)
tor_free(tag);
/* whitebox test: truncated keys. */
tt_int_op(0, ==, do_truncate(fname_1, 40));
tt_int_op(0, ==, do_truncate(fname_2, 40));
tt_int_op(0, OP_EQ, do_truncate(fname_1, 40));
tt_int_op(0, OP_EQ, do_truncate(fname_2, 40));
tt_int_op(-1, OP_EQ, ed25519_pubkey_read_from_file(&pub, &tag, fname_2));
tt_ptr_op(tag, OP_EQ, NULL);
tor_free(tag);
@ -2936,17 +2936,17 @@ test_crypto_failure_modes(void *arg)
(void)arg;
rv = crypto_early_init();
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
/* Check random works */
rv = crypto_rand_check_failure_mode_zero();
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
rv = crypto_rand_check_failure_mode_identical();
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
rv = crypto_rand_check_failure_mode_predict();
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
done:
;

View File

@ -26,7 +26,7 @@ test_crypto_rng_engine(void *arg)
memset(&dummy_method, 0, sizeof(dummy_method));
/* We should be a no-op if we're already on RAND_OpenSSL */
tt_int_op(0, ==, crypto_force_rand_ssleay());
tt_int_op(0, OP_EQ, crypto_force_rand_ssleay());
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
/* We should correct the method if it's a dummy. */
@ -34,10 +34,10 @@ test_crypto_rng_engine(void *arg)
#ifdef LIBRESSL_VERSION_NUMBER
/* On libressl, you can't override the RNG. */
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
tt_int_op(0, ==, crypto_force_rand_ssleay());
tt_int_op(0, OP_EQ, crypto_force_rand_ssleay());
#else
tt_assert(RAND_get_rand_method() == &dummy_method);
tt_int_op(1, ==, crypto_force_rand_ssleay());
tt_int_op(1, OP_EQ, crypto_force_rand_ssleay());
#endif
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());

View File

@ -164,10 +164,10 @@ test_libscrypt_eq_openssl(void *arg)
EVP_PBE_scrypt((const char *)"", 0, (const unsigned char *)"", 0,
N, r, p, maxmem, buf2, dk_len);
tt_int_op(libscrypt_retval, ==, 0);
tt_int_op(openssl_retval, ==, 1);
tt_int_op(libscrypt_retval, OP_EQ, 0);
tt_int_op(openssl_retval, OP_EQ, 1);
tt_mem_op(buf1, ==, buf2, 64);
tt_mem_op(buf1, OP_EQ, buf2, 64);
memset(buf1,0,64);
memset(buf2,0,64);
@ -185,10 +185,10 @@ test_libscrypt_eq_openssl(void *arg)
(const unsigned char *)"NaCl", strlen("NaCl"),
N, r, p, maxmem, buf2, dk_len);
tt_int_op(libscrypt_retval, ==, 0);
tt_int_op(openssl_retval, ==, 1);
tt_int_op(libscrypt_retval, OP_EQ, 0);
tt_int_op(openssl_retval, OP_EQ, 1);
tt_mem_op(buf1, ==, buf2, 64);
tt_mem_op(buf1, OP_EQ, buf2, 64);
memset(buf1,0,64);
memset(buf2,0,64);
@ -210,10 +210,10 @@ test_libscrypt_eq_openssl(void *arg)
strlen("SodiumChloride"),
N, r, p, maxmem, buf2, dk_len);
tt_int_op(libscrypt_retval, ==, 0);
tt_int_op(openssl_retval, ==, 1);
tt_int_op(libscrypt_retval, OP_EQ, 0);
tt_int_op(openssl_retval, OP_EQ, 1);
tt_mem_op(buf1, ==, buf2, 64);
tt_mem_op(buf1, OP_EQ, buf2, 64);
memset(buf1,0,64);
memset(buf2,0,64);
@ -234,10 +234,10 @@ test_libscrypt_eq_openssl(void *arg)
strlen("SodiumChloride"),
N, r, p, maxmem, buf2, dk_len);
tt_int_op(libscrypt_retval, ==, 0);
tt_int_op(openssl_retval, ==, 1);
tt_int_op(libscrypt_retval, OP_EQ, 0);
tt_int_op(openssl_retval, OP_EQ, 1);
tt_mem_op(buf1, ==, buf2, 64);
tt_mem_op(buf1, OP_EQ, buf2, 64);
done:
return;
@ -516,7 +516,7 @@ test_crypto_ed25519_fuzz_donna(void *arg)
unsigned i;
(void)arg;
tt_assert(sizeof(msg) == iters);
tt_uint_op(iters, OP_EQ, sizeof(msg));
crypto_rand((char*) msg, sizeof(msg));
/* Fuzz Ed25519-donna vs ref10, alternating the implementation used to

File diff suppressed because it is too large Load Diff

View File

@ -146,7 +146,7 @@ dir_common_gen_routerstatus_for_v3ns(int idx, time_t now)
break;
default:
/* Shouldn't happen */
tt_assert(0);
tt_abort();
}
if (vrs) {
vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));

View File

@ -18,9 +18,9 @@ NS(test_main)(void *arg)
uint32_t ttl_mid = MIN_DNS_TTL_AT_EXIT / 2 + MAX_DNS_TTL_AT_EXIT / 2;
tt_int_op(dns_clip_ttl(MIN_DNS_TTL_AT_EXIT - 1),==,MIN_DNS_TTL_AT_EXIT);
tt_int_op(dns_clip_ttl(ttl_mid),==,MAX_DNS_TTL_AT_EXIT);
tt_int_op(dns_clip_ttl(MAX_DNS_TTL_AT_EXIT + 1),==,MAX_DNS_TTL_AT_EXIT);
tt_int_op(dns_clip_ttl(MIN_DNS_TTL_AT_EXIT - 1),OP_EQ,MIN_DNS_TTL_AT_EXIT);
tt_int_op(dns_clip_ttl(ttl_mid),OP_EQ,MAX_DNS_TTL_AT_EXIT);
tt_int_op(dns_clip_ttl(MAX_DNS_TTL_AT_EXIT + 1),OP_EQ,MAX_DNS_TTL_AT_EXIT);
done:
return;
@ -172,10 +172,10 @@ NS(test_main)(void *arg)
retval = dns_resolve(exitconn);
tt_int_op(retval,==,1);
tt_str_op(resolved_name,==,last_resolved_hostname);
tt_int_op(retval,OP_EQ,1);
tt_str_op(resolved_name,OP_EQ,last_resolved_hostname);
tt_assert(conn_for_resolved_cell == exitconn);
tt_int_op(n_send_resolved_hostname_cell_replacement,==,
tt_int_op(n_send_resolved_hostname_cell_replacement,OP_EQ,
prev_n_send_resolved_hostname_cell_replacement + 1);
tt_assert(exitconn->on_circuit == NULL);
@ -201,12 +201,12 @@ NS(test_main)(void *arg)
retval = dns_resolve(exitconn);
tt_int_op(retval,==,1);
tt_int_op(retval,OP_EQ,1);
tt_assert(conn_for_resolved_cell == exitconn);
tt_int_op(n_send_resolved_cell_replacement,==,
tt_int_op(n_send_resolved_cell_replacement,OP_EQ,
prev_n_send_resolved_cell_replacement + 1);
tt_assert(last_resolved == fake_resolved);
tt_int_op(last_answer_type,==,0xff);
tt_int_op(last_answer_type,OP_EQ,0xff);
tt_assert(exitconn->on_circuit == NULL);
/* CASE 3: The purpose of exit connection is not EXIT_PURPOSE_RESOLVE
@ -229,12 +229,12 @@ NS(test_main)(void *arg)
retval = dns_resolve(exitconn);
tt_int_op(retval,==,1);
tt_int_op(retval,OP_EQ,1);
tt_assert(on_circuit->n_streams == exitconn);
tt_assert(exitconn->next_stream == nextconn);
tt_int_op(prev_n_send_resolved_cell_replacement,==,
tt_int_op(prev_n_send_resolved_cell_replacement,OP_EQ,
n_send_resolved_cell_replacement);
tt_int_op(prev_n_send_resolved_hostname_cell_replacement,==,
tt_int_op(prev_n_send_resolved_hostname_cell_replacement,OP_EQ,
n_send_resolved_hostname_cell_replacement);
/* CASE 4: _impl returns 0.
@ -253,8 +253,8 @@ NS(test_main)(void *arg)
retval = dns_resolve(exitconn);
tt_int_op(retval,==,0);
tt_int_op(exitconn->base_.state,==,EXIT_CONN_STATE_RESOLVING);
tt_int_op(retval,OP_EQ,0);
tt_int_op(exitconn->base_.state,OP_EQ,EXIT_CONN_STATE_RESOLVING);
tt_assert(on_circuit->resolving_streams == exitconn);
tt_assert(exitconn->next_stream == nextconn);
@ -278,12 +278,12 @@ NS(test_main)(void *arg)
retval = dns_resolve(exitconn);
tt_int_op(retval,==,-1);
tt_int_op(n_send_resolved_cell_replacement,==,
tt_int_op(retval,OP_EQ,-1);
tt_int_op(n_send_resolved_cell_replacement,OP_EQ,
prev_n_send_resolved_cell_replacement + 1);
tt_int_op(last_answer_type,==,RESOLVED_TYPE_ERROR);
tt_int_op(n_dns_cancel_pending_resolve_replacement,==,1);
tt_int_op(n_connection_free,==,prev_n_connection_free + 1);
tt_int_op(last_answer_type,OP_EQ,RESOLVED_TYPE_ERROR);
tt_int_op(n_dns_cancel_pending_resolve_replacement,OP_EQ,1);
tt_int_op(n_connection_free,OP_EQ,prev_n_connection_free + 1);
tt_assert(last_freed_conn == TO_CONN(exitconn));
done:
@ -351,9 +351,9 @@ NS(test_main)(void *arg)
resolved_addr = &(exitconn->base_.addr);
tt_int_op(retval,==,1);
tt_int_op(retval,OP_EQ,1);
tt_assert(tor_addr_eq(resolved_addr, (const tor_addr_t *)&addr_to_compare));
tt_int_op(exitconn->address_ttl,==,DEFAULT_DNS_TTL);
tt_int_op(exitconn->address_ttl,OP_EQ,DEFAULT_DNS_TTL);
done:
tor_free(on_circ);
@ -393,7 +393,7 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,-1);
tt_int_op(retval,OP_EQ,-1);
done:
tor_free(TO_CONN(exitconn)->address);
@ -436,7 +436,7 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,-1);
tt_int_op(retval,OP_EQ,-1);
done:
NS_UNMOCK(router_my_exit_policy_is_reject_star);
@ -478,7 +478,7 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,-1);
tt_int_op(retval,OP_EQ,-1);
tor_free(TO_CONN(exitconn)->address);
@ -488,7 +488,7 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,-1);
tt_int_op(retval,OP_EQ,-1);
done:
NS_UNMOCK(router_my_exit_policy_is_reject_star);
@ -546,8 +546,8 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,0);
tt_int_op(made_pending,==,1);
tt_int_op(retval,OP_EQ,0);
tt_int_op(made_pending,OP_EQ,1);
pending_conn = cache_entry->pending_connections;
@ -628,8 +628,8 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
&resolve_out);
tt_int_op(retval,==,0);
tt_int_op(made_pending,==,0);
tt_int_op(retval,OP_EQ,0);
tt_int_op(made_pending,OP_EQ,0);
tt_assert(resolve_out == cache_entry);
tt_assert(last_exitconn == exitconn);
@ -699,8 +699,8 @@ NS(test_main)(void *arg)
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
NULL);
tt_int_op(retval,==,0);
tt_int_op(made_pending,==,1);
tt_int_op(retval,OP_EQ,0);
tt_int_op(made_pending,OP_EQ,1);
cache_entry = dns_get_cache_entry(&query);
@ -712,7 +712,7 @@ NS(test_main)(void *arg)
tt_assert(pending_conn->conn == exitconn);
tt_assert(last_launched_resolve == cache_entry);
tt_str_op(cache_entry->address,==,TO_CONN(exitconn)->address);
tt_str_op(cache_entry->address,OP_EQ,TO_CONN(exitconn)->address);
done:
NS_UNMOCK(router_my_exit_policy_is_reject_star);

View File

@ -455,29 +455,29 @@ test_entry_guard_parse_from_state_failure(void *arg)
/* no selection */
eg = entry_guard_parse_from_state(
"rsa_id=596f75206d6179206e656564206120686f626270");
tt_assert(! eg);
tt_ptr_op(eg, OP_EQ, NULL);
/* no RSA ID. */
eg = entry_guard_parse_from_state("in=default nickname=Fred");
tt_assert(! eg);
tt_ptr_op(eg, OP_EQ, NULL);
/* Bad RSA ID: bad character. */
eg = entry_guard_parse_from_state(
"in=default "
"rsa_id=596f75206d6179206e656564206120686f62627q");
tt_assert(! eg);
tt_ptr_op(eg, OP_EQ, NULL);
/* Bad RSA ID: too long.*/
eg = entry_guard_parse_from_state(
"in=default "
"rsa_id=596f75206d6179206e656564206120686f6262703");
tt_assert(! eg);
tt_ptr_op(eg, OP_EQ, NULL);
/* Bad RSA ID: too short.*/
eg = entry_guard_parse_from_state(
"in=default "
"rsa_id=596f75206d6179206e65656420612");
tt_assert(! eg);
tt_ptr_op(eg, OP_EQ, NULL);
done:
entry_guard_free(eg);
@ -595,20 +595,20 @@ test_entry_guard_parse_from_state_full(void *arg)
MOCK(get_or_state,
get_or_state_replacement);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_assert(lines);
state->Guard = lines;
/* Try it first without setting the result. */
r = entry_guards_parse_state(state, 0, &msg);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
guard_selection_t *gs_br =
get_guard_selection_by_name("bridges", GS_TYPE_BRIDGE, 0);
tt_assert(!gs_br);
tt_ptr_op(gs_br, OP_EQ, NULL);
r = entry_guards_parse_state(state, 1, &msg);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
gs_br = get_guard_selection_by_name("bridges", GS_TYPE_BRIDGE, 0);
guard_selection_t *gs_df =
get_guard_selection_by_name("default", GS_TYPE_NORMAL, 0);
@ -625,7 +625,7 @@ test_entry_guard_parse_from_state_full(void *arg)
/* Try again; make sure it doesn't double-add the guards. */
r = entry_guards_parse_state(state, 1, &msg);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
gs_br = get_guard_selection_by_name("bridges", GS_TYPE_BRIDGE, 0);
gs_df = get_guard_selection_by_name("default", GS_TYPE_NORMAL, 0);
tt_assert(gs_br);
@ -730,7 +730,7 @@ test_entry_guard_parse_from_state_broken(void *arg)
MOCK(get_or_state,
get_or_state_replacement);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_assert(lines);
state->Guard = lines;
@ -742,7 +742,7 @@ test_entry_guard_parse_from_state_broken(void *arg)
/* And we shouldn't have made anything. */
guard_selection_t *gs_df =
get_guard_selection_by_name("default", GS_TYPE_NORMAL, 0);
tt_assert(gs_df == NULL);
tt_ptr_op(gs_df, OP_EQ, NULL);
tor_free(msg);
/* Now see about the set case (which shouldn't happen IRL) */
@ -750,7 +750,7 @@ test_entry_guard_parse_from_state_broken(void *arg)
tt_int_op(r, OP_LT, 0);
tt_ptr_op(msg, OP_NE, NULL);
gs_df = get_guard_selection_by_name("default", GS_TYPE_NORMAL, 0);
tt_assert(gs_df != NULL);
tt_ptr_op(gs_df, OP_NE, NULL);
tt_int_op(smartlist_len(gs_df->sampled_entry_guards), OP_EQ, 1);
done:
@ -767,26 +767,26 @@ test_entry_guard_get_guard_selection_by_name(void *arg)
guard_selection_t *gs1, *gs2, *gs3;
gs1 = get_guard_selection_by_name("unlikely", GS_TYPE_NORMAL, 0);
tt_assert(gs1 == NULL);
tt_ptr_op(gs1, OP_EQ, NULL);
gs1 = get_guard_selection_by_name("unlikely", GS_TYPE_NORMAL, 1);
tt_assert(gs1 != NULL);
tt_ptr_op(gs1, OP_NE, NULL);
gs2 = get_guard_selection_by_name("unlikely", GS_TYPE_NORMAL, 1);
tt_assert(gs2 == gs1);
gs2 = get_guard_selection_by_name("unlikely", GS_TYPE_NORMAL, 0);
tt_assert(gs2 == gs1);
gs2 = get_guard_selection_by_name("implausible", GS_TYPE_NORMAL, 0);
tt_assert(gs2 == NULL);
tt_ptr_op(gs2, OP_EQ, NULL);
gs2 = get_guard_selection_by_name("implausible", GS_TYPE_NORMAL, 1);
tt_assert(gs2 != NULL);
tt_ptr_op(gs2, OP_NE, NULL);
tt_assert(gs2 != gs1);
gs3 = get_guard_selection_by_name("implausible", GS_TYPE_NORMAL, 0);
tt_assert(gs3 == gs2);
gs3 = get_guard_selection_by_name("default", GS_TYPE_NORMAL, 0);
tt_assert(gs3 == NULL);
tt_ptr_op(gs3, OP_EQ, NULL);
gs3 = get_guard_selection_by_name("default", GS_TYPE_NORMAL, 1);
tt_assert(gs3 != NULL);
tt_ptr_op(gs3, OP_NE, NULL);
tt_assert(gs3 != gs2);
tt_assert(gs3 != gs1);
tt_assert(gs3 == get_guard_selection_info());
@ -847,16 +847,16 @@ test_entry_guard_add_single_guard(void *arg)
tt_i64_op(g1->sampled_on_date, OP_GE, now - 12*86400);
tt_i64_op(g1->sampled_on_date, OP_LE, now);
tt_str_op(g1->sampled_by_version, OP_EQ, VERSION);
tt_assert(g1->currently_listed == 1);
tt_uint_op(g1->currently_listed, OP_EQ, 1);
tt_i64_op(g1->confirmed_on_date, OP_EQ, 0);
tt_int_op(g1->confirmed_idx, OP_EQ, -1);
tt_int_op(g1->last_tried_to_connect, OP_EQ, 0);
tt_uint_op(g1->is_reachable, OP_EQ, GUARD_REACHABLE_MAYBE);
tt_i64_op(g1->failing_since, OP_EQ, 0);
tt_assert(g1->is_filtered_guard == 1);
tt_assert(g1->is_usable_filtered_guard == 1);
tt_assert(g1->is_primary == 0);
tt_assert(g1->extra_state_fields == NULL);
tt_uint_op(g1->is_filtered_guard, OP_EQ, 1);
tt_uint_op(g1->is_usable_filtered_guard, OP_EQ, 1);
tt_uint_op(g1->is_primary, OP_EQ, 0);
tt_ptr_op(g1->extra_state_fields, OP_EQ, NULL);
/* Make sure it got added. */
tt_int_op(1, OP_EQ, smartlist_len(gs->sampled_entry_guards));
@ -886,16 +886,16 @@ test_entry_guard_node_filter(void *arg)
g[i] = entry_guard_add_to_sample(gs, n[i]);
// everything starts out filtered-in
tt_assert(g[i]->is_filtered_guard == 1);
tt_assert(g[i]->is_usable_filtered_guard == 1);
tt_uint_op(g[i]->is_filtered_guard, OP_EQ, 1);
tt_uint_op(g[i]->is_usable_filtered_guard, OP_EQ, 1);
}
tt_int_op(num_reachable_filtered_guards(gs, NULL), OP_EQ, NUM);
/* Make sure refiltering doesn't hurt */
entry_guards_update_filtered_sets(gs);
for (i = 0; i < NUM; ++i) {
tt_assert(g[i]->is_filtered_guard == 1);
tt_assert(g[i]->is_usable_filtered_guard == 1);
tt_uint_op(g[i]->is_filtered_guard, OP_EQ, 1);
tt_uint_op(g[i]->is_usable_filtered_guard, OP_EQ, 1);
}
tt_int_op(num_reachable_filtered_guards(gs, NULL), OP_EQ, NUM);
@ -948,8 +948,8 @@ test_entry_guard_node_filter(void *arg)
});
entry_guards_update_filtered_sets(gs);
for (i = 0; i < NUM; ++i) {
tt_assert(g[i]->is_filtered_guard == 0);
tt_assert(g[i]->is_usable_filtered_guard == 0);
tt_uint_op(g[i]->is_filtered_guard, OP_EQ, 0);
tt_uint_op(g[i]->is_usable_filtered_guard, OP_EQ, 0);
}
tt_int_op(num_reachable_filtered_guards(gs, NULL), OP_EQ, 0);
@ -992,7 +992,7 @@ test_entry_guard_expand_sample(void *arg)
// Nothing became unusable/unfiltered, so a subsequent expand should
// make no changes.
guard = entry_guards_expand_sample(gs);
tt_assert(! guard); // no guard was added.
tt_ptr_op(guard, OP_EQ, NULL); // no guard was added.
tt_int_op(DFLT_MIN_FILTERED_SAMPLE_SIZE, OP_EQ,
num_reachable_filtered_guards(gs, NULL));
@ -1016,7 +1016,7 @@ test_entry_guard_expand_sample(void *arg)
// Still idempotent.
guard = entry_guards_expand_sample(gs);
tt_assert(! guard); // no guard was added.
tt_ptr_op(guard, OP_EQ, NULL); // no guard was added.
tt_int_op(DFLT_MIN_FILTERED_SAMPLE_SIZE, OP_EQ,
num_reachable_filtered_guards(gs, NULL));
@ -1707,7 +1707,7 @@ test_entry_guard_select_for_circuit_no_confirmed(void *arg)
tt_assert(g);
tt_assert(g->is_primary);
tt_int_op(g->confirmed_idx, OP_EQ, -1);
tt_assert(g->is_pending == 0); // primary implies non-pending.
tt_uint_op(g->is_pending, OP_EQ, 0); // primary implies non-pending.
tt_uint_op(state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
tt_i64_op(g->last_tried_to_connect, OP_EQ, approx_time());
@ -1727,7 +1727,7 @@ test_entry_guard_select_for_circuit_no_confirmed(void *arg)
tt_assert(g2);
tt_assert(g2->is_primary);
tt_int_op(g2->confirmed_idx, OP_EQ, -1);
tt_assert(g2->is_pending == 0); // primary implies non-pending.
tt_uint_op(g2->is_pending, OP_EQ, 0); // primary implies non-pending.
tt_uint_op(state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
tt_i64_op(g2->last_tried_to_connect, OP_EQ, approx_time());
@ -1755,7 +1755,7 @@ test_entry_guard_select_for_circuit_no_confirmed(void *arg)
tt_assert(g2);
tt_assert(!g2->is_primary);
tt_int_op(g2->confirmed_idx, OP_EQ, -1);
tt_assert(g2->is_pending == 1);
tt_uint_op(g2->is_pending, OP_EQ, 1);
tt_uint_op(state, OP_EQ, GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD);
tt_i64_op(g2->last_tried_to_connect, OP_EQ, approx_time());
tt_int_op(g2->is_reachable, OP_EQ, GUARD_REACHABLE_MAYBE);
@ -1813,7 +1813,7 @@ test_entry_guard_select_for_circuit_confirmed(void *arg)
tt_assert(g);
tt_assert(g->is_primary);
tt_int_op(g->confirmed_idx, OP_EQ, 0);
tt_assert(g->is_pending == 0); // primary implies non-pending.
tt_uint_op(g->is_pending, OP_EQ, 0); // primary implies non-pending.
tt_uint_op(state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
tt_i64_op(g->last_tried_to_connect, OP_EQ, approx_time());
tt_ptr_op(g, OP_EQ, smartlist_get(gs->primary_entry_guards, 0));
@ -1913,7 +1913,7 @@ test_entry_guard_select_for_circuit_highlevel_primary(void *arg)
int r = entry_guard_pick_for_circuit(gs, GUARD_USAGE_TRAFFIC, NULL,
&node, &guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_assert(node);
tt_assert(guard);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
@ -1945,7 +1945,7 @@ test_entry_guard_select_for_circuit_highlevel_primary(void *arg)
update_approx_time(start+35);
r = entry_guard_pick_for_circuit(gs, GUARD_USAGE_TRAFFIC, NULL,
&node, &guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_assert(node);
tt_assert(guard);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
@ -1981,7 +1981,7 @@ test_entry_guard_select_for_circuit_highlevel_primary(void *arg)
update_approx_time(start+60);
r = entry_guard_pick_for_circuit(gs, GUARD_USAGE_TRAFFIC, NULL,
&node, &guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_assert(node);
tt_assert(guard);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
@ -2036,7 +2036,7 @@ test_entry_guard_select_for_circuit_highlevel_confirm_other(void *arg)
&node, &guard);
tt_assert(node);
tt_assert(guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
entry_guard_failed(&guard);
circuit_guard_state_free(guard);
@ -2050,7 +2050,7 @@ test_entry_guard_select_for_circuit_highlevel_confirm_other(void *arg)
&node, &guard);
tt_assert(node);
tt_assert(guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
entry_guard_t *g = entry_guard_handle_get(guard->guard);
tt_assert(g);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD);
@ -2102,7 +2102,7 @@ test_entry_guard_select_for_circuit_highlevel_primary_retry(void *arg)
&node, &guard);
tt_assert(node);
tt_assert(guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
g = entry_guard_handle_get(guard->guard);
make_guard_confirmed(gs, g);
@ -2119,7 +2119,7 @@ test_entry_guard_select_for_circuit_highlevel_primary_retry(void *arg)
&node, &guard);
tt_assert(node);
tt_assert(guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD);
g = entry_guard_handle_get(guard->guard);
tt_int_op(g->is_primary, OP_EQ, 0);
@ -2145,7 +2145,7 @@ test_entry_guard_select_for_circuit_highlevel_primary_retry(void *arg)
/* Have a circuit to a primary guard succeed. */
r = entry_guard_pick_for_circuit(gs, GUARD_USAGE_TRAFFIC, NULL,
&node, &guard2);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_int_op(guard2->state, OP_EQ, GUARD_CIRC_STATE_USABLE_ON_COMPLETION);
u = entry_guard_succeeded(&guard2);
tt_assert(u == GUARD_USABLE_NOW);
@ -2194,7 +2194,7 @@ test_entry_guard_select_and_cancel(void *arg)
&node, &guard);
tt_assert(node);
tt_assert(guard);
tt_assert(r == 0);
tt_int_op(r, OP_EQ, 0);
tt_int_op(guard->state, OP_EQ, GUARD_CIRC_STATE_USABLE_IF_NO_BETTER_GUARD);
g = entry_guard_handle_get(guard->guard);
tt_int_op(g->is_primary, OP_EQ, 0);
@ -2202,7 +2202,7 @@ test_entry_guard_select_and_cancel(void *arg)
/* Whoops! We should never have asked for this guard. Cancel the request! */
entry_guard_cancel(&guard);
tt_assert(guard == NULL);
tt_ptr_op(guard, OP_EQ, NULL);
tt_int_op(g->is_primary, OP_EQ, 0);
tt_int_op(g->is_pending, OP_EQ, 0);

View File

@ -38,10 +38,10 @@ gen_vote_routerstatus_for_tests(const char *digest_in_hex, int is_guard)
rs->is_possible_guard = is_guard;
/* Fill in the fpr */
tt_int_op(strlen(digest_in_hex), ==, HEX_DIGEST_LEN);
tt_int_op(strlen(digest_in_hex), OP_EQ, HEX_DIGEST_LEN);
retval = base16_decode(digest_tmp, sizeof(digest_tmp),
digest_in_hex, HEX_DIGEST_LEN);
tt_int_op(retval, ==, sizeof(digest_tmp));
tt_int_op(retval, OP_EQ, sizeof(digest_tmp));
memcpy(rs->identity_digest, digest_tmp, DIGEST_LEN);
}
@ -88,7 +88,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
tor_free(guardfraction_bad);
/* This one does not have a date! Parsing should fail. */
@ -100,7 +100,7 @@ test_parse_guardfraction_file_bad(void *arg)
"guard-seen 07B5547026DF3E229806E135CFA8552D56AFBABC 5 420\n");
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
tor_free(guardfraction_bad);
/* This one has an incomplete n-inputs line, but parsing should
@ -114,7 +114,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, 2);
tt_int_op(retval, OP_EQ, 2);
tor_free(guardfraction_bad);
/* This one does not have a fingerprint in the guard line! */
@ -126,7 +126,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tor_free(guardfraction_bad);
/* This one does not even have an integer guardfraction value. */
@ -139,7 +139,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
tor_free(guardfraction_bad);
/* This one is not a percentage (not in [0, 100]) */
@ -152,7 +152,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
tor_free(guardfraction_bad);
/* This one is not a percentage either (not in [0, 100]) */
@ -164,7 +164,7 @@ test_parse_guardfraction_file_bad(void *arg)
yesterday_date_str);
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
done:
tor_free(guardfraction_bad);
@ -216,14 +216,14 @@ test_parse_guardfraction_file_good(void *arg)
/* Read the guardfraction file */
retval = dirserv_read_guardfraction_file_from_str(guardfraction_good,
routerstatuses);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
{ /* Test that routerstatus fields got filled properly */
/* The guardfraction fields of the guard should be filled. */
tt_assert(vrs_guard->status.has_guardfraction);
tt_int_op(vrs_guard->status.guardfraction_percentage,
==,
OP_EQ,
guardfraction_value);
/* The guard that was not in the guardfraction file should not have
@ -252,12 +252,12 @@ test_get_guardfraction_bandwidth(void *arg)
guard_get_guardfraction_bandwidth(&gf_bw,
orig_bw, 25);
tt_int_op(gf_bw.guard_bw, ==, 250);
tt_int_op(gf_bw.non_guard_bw, ==, 750);
tt_int_op(gf_bw.guard_bw, OP_EQ, 250);
tt_int_op(gf_bw.non_guard_bw, OP_EQ, 750);
/* Also check the 'guard_bw + non_guard_bw == original_bw'
* invariant. */
tt_int_op(gf_bw.non_guard_bw + gf_bw.guard_bw, ==, orig_bw);
tt_int_op(gf_bw.non_guard_bw + gf_bw.guard_bw, OP_EQ, orig_bw);
done:
;
@ -295,9 +295,9 @@ test_parse_guardfraction_consensus(void *arg)
retval = routerstatus_parse_guardfraction(guardfraction_str_good,
NULL, NULL,
&rs_good);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tt_assert(rs_good.has_guardfraction);
tt_int_op(rs_good.guardfraction_percentage, ==, 66);
tt_int_op(rs_good.guardfraction_percentage, OP_EQ, 66);
}
{ /* Properly formatted GuardFraction but router is not a
@ -309,7 +309,7 @@ test_parse_guardfraction_consensus(void *arg)
retval = routerstatus_parse_guardfraction(guardfraction_str_good,
NULL, NULL,
&rs_no_guard);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tt_assert(!rs_no_guard.has_guardfraction);
expect_single_log_msg_containing("Got GuardFraction for non-guard . "
"This is not supposed to happen.");
@ -323,7 +323,7 @@ test_parse_guardfraction_consensus(void *arg)
retval = routerstatus_parse_guardfraction(guardfraction_str_bad1,
NULL, NULL,
&rs_bad1);
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
tt_assert(!rs_bad1.has_guardfraction);
}
@ -334,7 +334,7 @@ test_parse_guardfraction_consensus(void *arg)
retval = routerstatus_parse_guardfraction(guardfraction_str_bad2,
NULL, NULL,
&rs_bad2);
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
tt_assert(!rs_bad2.has_guardfraction);
}
@ -375,27 +375,27 @@ test_should_apply_guardfraction(void *arg)
/* If torrc option is set to yes, we should always use
* guardfraction.*/
options->UseGuardFraction = 1;
tt_int_op(should_apply_guardfraction(&vote_disabled), ==, 1);
tt_int_op(should_apply_guardfraction(&vote_disabled), OP_EQ, 1);
/* If torrc option is set to no, we should never use
* guardfraction.*/
options->UseGuardFraction = 0;
tt_int_op(should_apply_guardfraction(&vote_enabled), ==, 0);
tt_int_op(should_apply_guardfraction(&vote_enabled), OP_EQ, 0);
/* Now let's test torrc option set to auto. */
options->UseGuardFraction = -1;
/* If torrc option is set to auto, and consensus parameter is set to
* yes, we should use guardfraction. */
tt_int_op(should_apply_guardfraction(&vote_enabled), ==, 1);
tt_int_op(should_apply_guardfraction(&vote_enabled), OP_EQ, 1);
/* If torrc option is set to auto, and consensus parameter is set to
* no, we should use guardfraction. */
tt_int_op(should_apply_guardfraction(&vote_disabled), ==, 0);
tt_int_op(should_apply_guardfraction(&vote_disabled), OP_EQ, 0);
/* If torrc option is set to auto, and consensus parameter is not
* set, we should fallback to "no". */
tt_int_op(should_apply_guardfraction(&vote_missing), ==, 0);
tt_int_op(should_apply_guardfraction(&vote_missing), OP_EQ, 0);
done:
SMARTLIST_FOREACH(vote_enabled.net_params, char *, cp, tor_free(cp));

View File

@ -83,16 +83,16 @@ helper_setup_fake_routerlist(void)
retval = router_load_routers_from_string(TEST_DESCRIPTORS,
NULL, SAVED_IN_JOURNAL,
NULL, 0, NULL);
tt_int_op(retval, ==, HELPER_NUMBER_OF_DESCRIPTORS);
tt_int_op(retval, OP_EQ, HELPER_NUMBER_OF_DESCRIPTORS);
/* Sanity checking of routerlist and nodelist. */
our_routerlist = router_get_routerlist();
tt_int_op(smartlist_len(our_routerlist->routers), ==,
tt_int_op(smartlist_len(our_routerlist->routers), OP_EQ,
HELPER_NUMBER_OF_DESCRIPTORS);
routerlist_assert_ok(our_routerlist);
our_nodelist = nodelist_get_list();
tt_int_op(smartlist_len(our_nodelist), ==, HELPER_NUMBER_OF_DESCRIPTORS);
tt_int_op(smartlist_len(our_nodelist), OP_EQ, HELPER_NUMBER_OF_DESCRIPTORS);
/* Mark all routers as non-guards but up and running! */
SMARTLIST_FOREACH_BEGIN(our_nodelist, node_t *, node) {
@ -189,7 +189,7 @@ mock_connection_connect_sockaddr(connection_t *conn,
/* We really should call tor_libevent_initialize() here. Because we don't,
* we are relying on other parts of the code not checking if the_event_base
* (and therefore event->ev_base) is NULL. */
tt_assert(connection_add_connecting(conn) == 0);
tt_int_op(connection_add_connecting(conn), OP_EQ, 0);
done:
/* Fake "connected" status */
@ -222,7 +222,7 @@ test_conn_get_connection(uint8_t state, uint8_t type, uint8_t purpose)
mock_connection_connect_sockaddr_called = 0;
in_progress = connection_connect(conn, TEST_CONN_ADDRESS_PORT, &addr,
TEST_CONN_PORT, &socket_err);
tt_assert(mock_connection_connect_sockaddr_called == 1);
tt_int_op(mock_connection_connect_sockaddr_called, OP_EQ, 1);
tt_assert(!socket_err);
tt_assert(in_progress == 0 || in_progress == 1);

View File

@ -250,7 +250,7 @@ test_hs_desc_event(void *arg)
ret = rend_compute_v2_desc_id(rend_query.descriptor_id[0],
rend_query.onion_address,
NULL, 0, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
base32_encode(desc_id_base32, sizeof(desc_id_base32),
rend_query.descriptor_id[0], DIGEST_LEN);
/* Make sure rend_compute_v2_desc_id works properly. */
@ -363,14 +363,14 @@ test_pick_tor2web_rendezvous_node(void *arg)
retval = routerset_parse(options->Tor2webRendezvousPoints,
tor2web_rendezvous_str,
"test_tor2web_rp");
tt_int_op(retval, >=, 0);
tt_int_op(retval, OP_GE, 0);
/* Pick rendezvous point. Make sure the correct one is
picked. Repeat many times to make sure it works properly. */
for (i = 0; i < 50 ; i++) {
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
tt_assert(chosen_rp);
tt_str_op(chosen_rp->ri->nickname, ==, tor2web_rendezvous_str);
tt_str_op(chosen_rp->ri->nickname, OP_EQ, tor2web_rendezvous_str);
}
done:
@ -398,13 +398,13 @@ test_pick_bad_tor2web_rendezvous_node(void *arg)
retval = routerset_parse(options->Tor2webRendezvousPoints,
tor2web_rendezvous_str,
"test_tor2web_rp");
tt_int_op(retval, >=, 0);
tt_int_op(retval, OP_GE, 0);
/* Pick rendezvous point. Since Tor2webRendezvousPoints was set to a
dummy value, we shouldn't find any eligible RPs. */
for (i = 0; i < 50 ; i++) {
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
tt_assert(!chosen_rp);
tt_ptr_op(chosen_rp, OP_EQ, NULL);
}
done:
@ -435,30 +435,30 @@ test_hs_rend_data(void *arg)
REND_NO_AUTH);
tt_assert(client);
rend_data_v2_t *client_v2 = TO_REND_DATA_V2(client);
tt_int_op(client_v2->auth_type, ==, REND_NO_AUTH);
tt_int_op(client_v2->auth_type, OP_EQ, REND_NO_AUTH);
tt_str_op(client_v2->onion_address, OP_EQ, STR_HS_ADDR);
tt_mem_op(client_v2->desc_id_fetch, OP_EQ, desc_id, sizeof(desc_id));
tt_mem_op(client_v2->descriptor_cookie, OP_EQ, client_cookie,
sizeof(client_cookie));
tt_assert(client->hsdirs_fp);
tt_int_op(smartlist_len(client->hsdirs_fp), ==, 0);
tt_int_op(smartlist_len(client->hsdirs_fp), OP_EQ, 0);
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
int ret = rend_compute_v2_desc_id(desc_id, client_v2->onion_address,
client_v2->descriptor_cookie, now, rep);
/* That shouldn't never fail. */
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_mem_op(client_v2->descriptor_id[rep], OP_EQ, desc_id,
sizeof(desc_id));
}
/* The rest should be zeroed because this is a client request. */
tt_int_op(tor_digest_is_zero(client_v2->rend_pk_digest), ==, 1);
tt_int_op(tor_digest_is_zero(client->rend_cookie), ==, 1);
tt_int_op(tor_digest_is_zero(client_v2->rend_pk_digest), OP_EQ, 1);
tt_int_op(tor_digest_is_zero(client->rend_cookie), OP_EQ, 1);
/* Test dup(). */
client_dup = rend_data_dup(client);
tt_assert(client_dup);
rend_data_v2_t *client_dup_v2 = TO_REND_DATA_V2(client_dup);
tt_int_op(client_dup_v2->auth_type, ==, client_v2->auth_type);
tt_int_op(client_dup_v2->auth_type, OP_EQ, client_v2->auth_type);
tt_str_op(client_dup_v2->onion_address, OP_EQ, client_v2->onion_address);
tt_mem_op(client_dup_v2->desc_id_fetch, OP_EQ, client_v2->desc_id_fetch,
sizeof(client_dup_v2->desc_id_fetch));
@ -467,14 +467,14 @@ test_hs_rend_data(void *arg)
sizeof(client_dup_v2->descriptor_cookie));
tt_assert(client_dup->hsdirs_fp);
tt_int_op(smartlist_len(client_dup->hsdirs_fp), ==, 0);
tt_int_op(smartlist_len(client_dup->hsdirs_fp), OP_EQ, 0);
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
tt_mem_op(client_dup_v2->descriptor_id[rep], OP_EQ,
client_v2->descriptor_id[rep], DIGEST_LEN);
}
/* The rest should be zeroed because this is a client request. */
tt_int_op(tor_digest_is_zero(client_dup_v2->rend_pk_digest), ==, 1);
tt_int_op(tor_digest_is_zero(client_dup->rend_cookie), ==, 1);
tt_int_op(tor_digest_is_zero(client_dup_v2->rend_pk_digest), OP_EQ, 1);
tt_int_op(tor_digest_is_zero(client_dup->rend_cookie), OP_EQ, 1);
rend_data_free(client);
client = NULL;
rend_data_free(client_dup);
@ -490,19 +490,19 @@ test_hs_rend_data(void *arg)
client = rend_data_client_create(NULL, desc_id, NULL, REND_BASIC_AUTH);
tt_assert(client);
client_v2 = TO_REND_DATA_V2(client);
tt_int_op(client_v2->auth_type, ==, REND_BASIC_AUTH);
tt_int_op(strlen(client_v2->onion_address), ==, 0);
tt_int_op(client_v2->auth_type, OP_EQ, REND_BASIC_AUTH);
tt_int_op(strlen(client_v2->onion_address), OP_EQ, 0);
tt_mem_op(client_v2->desc_id_fetch, OP_EQ, desc_id, sizeof(desc_id));
tt_int_op(tor_mem_is_zero(client_v2->descriptor_cookie,
sizeof(client_v2->descriptor_cookie)), ==, 1);
sizeof(client_v2->descriptor_cookie)), OP_EQ, 1);
tt_assert(client->hsdirs_fp);
tt_int_op(smartlist_len(client->hsdirs_fp), ==, 0);
tt_int_op(smartlist_len(client->hsdirs_fp), OP_EQ, 0);
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
tt_int_op(tor_digest_is_zero(client_v2->descriptor_id[rep]), ==, 1);
tt_int_op(tor_digest_is_zero(client_v2->descriptor_id[rep]), OP_EQ, 1);
}
/* The rest should be zeroed because this is a client request. */
tt_int_op(tor_digest_is_zero(client_v2->rend_pk_digest), ==, 1);
tt_int_op(tor_digest_is_zero(client->rend_cookie), ==, 1);
tt_int_op(tor_digest_is_zero(client_v2->rend_pk_digest), OP_EQ, 1);
tt_int_op(tor_digest_is_zero(client->rend_cookie), OP_EQ, 1);
rend_data_free(client);
client = NULL;
@ -516,38 +516,38 @@ test_hs_rend_data(void *arg)
rend_cookie, REND_NO_AUTH);
tt_assert(service);
rend_data_v2_t *service_v2 = TO_REND_DATA_V2(service);
tt_int_op(service_v2->auth_type, ==, REND_NO_AUTH);
tt_int_op(service_v2->auth_type, OP_EQ, REND_NO_AUTH);
tt_str_op(service_v2->onion_address, OP_EQ, STR_HS_ADDR);
tt_mem_op(service_v2->rend_pk_digest, OP_EQ, rend_pk_digest,
sizeof(rend_pk_digest));
tt_mem_op(service->rend_cookie, OP_EQ, rend_cookie, sizeof(rend_cookie));
tt_assert(service->hsdirs_fp);
tt_int_op(smartlist_len(service->hsdirs_fp), ==, 0);
tt_int_op(smartlist_len(service->hsdirs_fp), OP_EQ, 0);
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
tt_int_op(tor_digest_is_zero(service_v2->descriptor_id[rep]), ==, 1);
tt_int_op(tor_digest_is_zero(service_v2->descriptor_id[rep]), OP_EQ, 1);
}
/* The rest should be zeroed because this is a service request. */
tt_int_op(tor_digest_is_zero(service_v2->descriptor_cookie), ==, 1);
tt_int_op(tor_digest_is_zero(service_v2->desc_id_fetch), ==, 1);
tt_int_op(tor_digest_is_zero(service_v2->descriptor_cookie), OP_EQ, 1);
tt_int_op(tor_digest_is_zero(service_v2->desc_id_fetch), OP_EQ, 1);
/* Test dup(). */
service_dup = rend_data_dup(service);
rend_data_v2_t *service_dup_v2 = TO_REND_DATA_V2(service_dup);
tt_assert(service_dup);
tt_int_op(service_dup_v2->auth_type, ==, service_v2->auth_type);
tt_int_op(service_dup_v2->auth_type, OP_EQ, service_v2->auth_type);
tt_str_op(service_dup_v2->onion_address, OP_EQ, service_v2->onion_address);
tt_mem_op(service_dup_v2->rend_pk_digest, OP_EQ, service_v2->rend_pk_digest,
sizeof(service_dup_v2->rend_pk_digest));
tt_mem_op(service_dup->rend_cookie, OP_EQ, service->rend_cookie,
sizeof(service_dup->rend_cookie));
tt_assert(service_dup->hsdirs_fp);
tt_int_op(smartlist_len(service_dup->hsdirs_fp), ==, 0);
tt_int_op(smartlist_len(service_dup->hsdirs_fp), OP_EQ, 0);
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
tt_int_op(tor_digest_is_zero(service_dup_v2->descriptor_id[rep]), ==, 1);
tt_assert(tor_digest_is_zero(service_dup_v2->descriptor_id[rep]));
}
/* The rest should be zeroed because this is a service request. */
tt_int_op(tor_digest_is_zero(service_dup_v2->descriptor_cookie), ==, 1);
tt_int_op(tor_digest_is_zero(service_dup_v2->desc_id_fetch), ==, 1);
tt_int_op(tor_digest_is_zero(service_dup_v2->descriptor_cookie), OP_EQ, 1);
tt_int_op(tor_digest_is_zero(service_dup_v2->desc_id_fetch), OP_EQ, 1);
done:
rend_data_free(service);
@ -586,7 +586,7 @@ test_hs_auth_cookies(void *arg)
re = rend_auth_decode_cookie(TEST_COOKIE_ENCODED, raw_cookie, &auth_type,
&err_msg);
tt_assert(!re);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_mem_op(raw_cookie, OP_EQ, TEST_COOKIE_RAW, REND_DESC_COOKIE_LEN);
tt_int_op(auth_type, OP_EQ, REND_BASIC_AUTH);
memset(raw_cookie, 0, sizeof(raw_cookie));
@ -594,7 +594,7 @@ test_hs_auth_cookies(void *arg)
re = rend_auth_decode_cookie(TEST_COOKIE_ENCODED_STEALTH, raw_cookie,
&auth_type, &err_msg);
tt_assert(!re);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_mem_op(raw_cookie, OP_EQ, TEST_COOKIE_RAW, REND_DESC_COOKIE_LEN);
tt_int_op(auth_type, OP_EQ, REND_STEALTH_AUTH);
memset(raw_cookie, 0, sizeof(raw_cookie));
@ -603,7 +603,7 @@ test_hs_auth_cookies(void *arg)
re = rend_auth_decode_cookie(TEST_COOKIE_ENCODED "==", raw_cookie, NULL,
&err_msg);
tt_assert(!re);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_mem_op(raw_cookie, OP_EQ, TEST_COOKIE_RAW, REND_DESC_COOKIE_LEN);
/* Decoding with an unknown type should fail */
@ -671,14 +671,14 @@ test_single_onion_poisoning(void *arg)
* The data directory is required for the lockfile, which is used when
* loading keys. */
ret = check_private_dir(mock_options->DataDirectory, CPD_CREATE, NULL);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
if (create_dir_mask & CREATE_HS_DIR1) {
ret = check_private_dir(dir1, CPD_CREATE, NULL);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
}
if (create_dir_mask & CREATE_HS_DIR2) {
ret = check_private_dir(dir2, CPD_CREATE, NULL);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
}
service_1->directory = dir1;
@ -691,31 +691,31 @@ test_single_onion_poisoning(void *arg)
rend_service_port_config_t *port1 = rend_service_parse_port_config("80", " ",
&err_msg);
tt_assert(port1);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
smartlist_add(service_1->ports, port1);
rend_service_port_config_t *port2 = rend_service_parse_port_config("90", " ",
&err_msg);
/* Add port to service 2 */
tt_assert(port2);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
smartlist_add(service_2->ports, port2);
/* No services, a service to verify, no problem! */
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Either way, no problem. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Add the first service */
ret = hs_check_service_private_dir(mock_options->User, service_1->directory,
@ -728,75 +728,75 @@ test_single_onion_poisoning(void *arg)
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Either way, no problem. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Poison! Poison! Poison!
* This can only be done in HiddenServiceSingleHopMode. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_poison_new_single_onion_dir(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Poisoning twice is a no-op. */
ret = rend_service_poison_new_single_onion_dir(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Poisoned service directories, but no previous keys, no problem! */
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Either way, no problem. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Now add some keys, and we'll have a problem. */
ret = rend_service_load_all_keys(services);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Poisoned service directories with previous keys are not allowed. */
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret < 0);
tt_int_op(ret, OP_LT, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* But they are allowed if we're in non-anonymous mode. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Re-poisoning directories with existing keys is a no-op, because
* directories with existing keys are ignored. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_poison_new_single_onion_dir(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* And it keeps the poison. */
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Now add the second service: it has no key and no poison file */
ret = hs_check_service_private_dir(mock_options->User, service_2->directory,
@ -808,77 +808,77 @@ test_single_onion_poisoning(void *arg)
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret < 0);
tt_int_op(ret, OP_LT, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* But ok to add in non-anonymous mode. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Now remove the poisoning from the first service, and we have the opposite
* problem. */
poison_path = rend_service_sos_poison_path(service_1);
tt_assert(poison_path);
ret = unlink(poison_path);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Unpoisoned service directories with previous keys are ok, as are empty
* directories. */
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* But the existing unpoisoned key is not ok in non-anonymous mode, even if
* there is an empty service. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret < 0);
tt_int_op(ret, OP_LT, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Poisoning directories with existing keys is a no-op, because directories
* with existing keys are ignored. But the new directory should poison. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_poison_new_single_onion_dir(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_poison_new_single_onion_dir(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* And the old directory remains unpoisoned. */
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret < 0);
tt_int_op(ret, OP_LT, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* And the new directory should be ignored, because it has no key. */
mock_options->HiddenServiceSingleHopMode = 0;
mock_options->HiddenServiceNonAnonymousMode = 0;
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Re-poisoning directories without existing keys is a no-op. */
mock_options->HiddenServiceSingleHopMode = 1;
mock_options->HiddenServiceNonAnonymousMode = 1;
ret = rend_service_poison_new_single_onion_dir(service_1, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = rend_service_poison_new_single_onion_dir(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* And the old directory remains unpoisoned. */
ret = rend_service_verify_single_onion_poison(service_1, mock_options);
tt_assert(ret < 0);
tt_int_op(ret, OP_LT, 0);
ret = rend_service_verify_single_onion_poison(service_2, mock_options);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
done:
/* The test harness deletes the directories at exit */

View File

@ -55,7 +55,7 @@ test_directory(void *arg)
init_test();
/* Generate a valid descriptor with normal values. */
ret = ed25519_keypair_generate(&signing_kp1, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
tt_assert(desc1);
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
@ -79,7 +79,7 @@ test_directory(void *arg)
/* Tell our OOM to run and to at least remove a byte which will result in
* removing the descriptor from our cache. */
oom_size = hs_cache_handle_oom(time(NULL), 1);
tt_int_op(oom_size, >=, 1);
tt_int_op(oom_size, OP_GE, 1);
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
tt_int_op(ret, OP_EQ, 0);
}
@ -88,7 +88,7 @@ test_directory(void *arg)
{
ed25519_keypair_t signing_kp_zero;
ret = ed25519_keypair_generate(&signing_kp_zero, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
hs_descriptor_t *desc_zero_lifetime;
desc_zero_lifetime = hs_helper_build_hs_desc_with_ip(&signing_kp_zero);
tt_assert(desc_zero_lifetime);
@ -116,7 +116,7 @@ test_directory(void *arg)
tt_int_op(ret, OP_EQ, 0);
/* Cleanup our entire cache. */
oom_size = hs_cache_handle_oom(time(NULL), 1);
tt_int_op(oom_size, >=, 1);
tt_int_op(oom_size, OP_GE, 1);
hs_descriptor_free(desc_zero_lifetime);
tor_free(desc_zero_lifetime_str);
}
@ -178,7 +178,7 @@ test_clean_as_dir(void *arg)
/* Generate a valid descriptor with values. */
ret = ed25519_keypair_generate(&signing_kp1, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
tt_assert(desc1);
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
@ -188,21 +188,21 @@ test_clean_as_dir(void *arg)
/* With the lifetime being 3 hours, a cleanup shouldn't remove it. */
ret = cache_clean_v3_as_dir(now, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
/* Should be present after clean up. */
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
tt_int_op(ret, OP_EQ, 1);
/* Set a cutoff 100 seconds in the past. It should not remove the entry
* since the entry is still recent enough. */
ret = cache_clean_v3_as_dir(now, now - 100);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
/* Should be present after clean up. */
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
tt_int_op(ret, OP_EQ, 1);
/* Set a cutoff of 100 seconds in the future. It should remove the entry
* that we've just added since it's not too old for the cutoff. */
ret = cache_clean_v3_as_dir(now, now + 100);
tt_int_op(ret, >, 0);
tt_int_op(ret, OP_GT, 0);
/* Shouldn't be present after clean up. */
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
tt_int_op(ret, OP_EQ, 0);
@ -232,7 +232,7 @@ helper_fetch_desc_from_hsdir(const ed25519_public_key_t *blinded_key)
retval = ed25519_public_to_base64(hsdir_cache_key,
blinded_key);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tor_asprintf(&hsdir_query_str, GET("/tor/hs/3/%s"), hsdir_cache_key);
}
@ -291,7 +291,7 @@ test_upload_and_download_hs_desc(void *arg)
{
ed25519_keypair_t signing_kp;
retval = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
tt_assert(published_desc);
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
@ -302,7 +302,7 @@ test_upload_and_download_hs_desc(void *arg)
/* Publish descriptor to the HSDir */
{
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
tt_int_op(retval, ==, 200);
tt_int_op(retval, OP_EQ, 200);
}
/* Simulate a fetch of the previously published descriptor */
@ -355,7 +355,7 @@ test_hsdir_revision_counter_check(void *arg)
/* Generate a valid descriptor with normal values. */
{
retval = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
tt_assert(published_desc);
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
@ -366,13 +366,13 @@ test_hsdir_revision_counter_check(void *arg)
/* Publish descriptor to the HSDir */
{
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
tt_int_op(retval, ==, 200);
tt_int_op(retval, OP_EQ, 200);
}
/* Try publishing again with the same revision counter: Should fail. */
{
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
tt_int_op(retval, ==, 400);
tt_int_op(retval, OP_EQ, 400);
}
/* Fetch the published descriptor and validate the revision counter. */
@ -385,11 +385,11 @@ test_hsdir_revision_counter_check(void *arg)
retval = hs_desc_decode_descriptor(received_desc_str,
subcredential, &received_desc);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tt_assert(received_desc);
/* Check that the revision counter is correct */
tt_u64_op(received_desc->plaintext_data.revision_counter, ==, 42);
tt_u64_op(received_desc->plaintext_data.revision_counter, OP_EQ, 42);
hs_descriptor_free(received_desc);
received_desc = NULL;
@ -405,7 +405,7 @@ test_hsdir_revision_counter_check(void *arg)
tt_int_op(retval, OP_EQ, 0);
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
tt_int_op(retval, ==, 200);
tt_int_op(retval, OP_EQ, 200);
}
/* Again, fetch the published descriptor and perform the revision counter
@ -418,11 +418,11 @@ test_hsdir_revision_counter_check(void *arg)
retval = hs_desc_decode_descriptor(received_desc_str,
subcredential, &received_desc);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
tt_assert(received_desc);
/* Check that the revision counter is the latest */
tt_u64_op(received_desc->plaintext_data.revision_counter, ==, 1313);
tt_u64_op(received_desc->plaintext_data.revision_counter, OP_EQ, 1313);
}
done:
@ -452,7 +452,7 @@ test_client_cache(void *arg)
/* Generate a valid descriptor with normal values. */
{
retval = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
tt_assert(published_desc);
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,

View File

@ -100,7 +100,7 @@ helper_get_circ_and_stream_for_test(origin_circuit_t **circ_out,
or_circ->build_state->pending_final_cpath->rend_dh_handshake_state);
retval = crypto_dh_generate_public(
or_circ->build_state->pending_final_cpath->rend_dh_handshake_state);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
or_circ->rend_data = rend_data_dup(conn_rend_data);
} else {
/* prop224: Setup hs ident on the circuit */
@ -154,10 +154,10 @@ test_e2e_rend_circuit_setup_legacy(void *arg)
/* Check number of hops */
retval = cpath_get_n_hops(&or_circ->cpath);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Check that our stream is not attached on any circuits */
tt_assert(!TO_EDGE_CONN(conn)->on_circuit);
tt_ptr_op(TO_EDGE_CONN(conn)->on_circuit, OP_EQ, NULL);
/********************************************** */
@ -236,11 +236,11 @@ test_e2e_rend_circuit_setup(void *arg)
/* Check number of hops: There should be no hops yet to this circ */
retval = cpath_get_n_hops(&or_circ->cpath);
tt_int_op(retval, ==, 0);
tt_assert(!or_circ->cpath);
tt_int_op(retval, OP_EQ, 0);
tt_ptr_op(or_circ->cpath, OP_EQ, NULL);
/* Check that our stream is not attached on any circuits */
tt_assert(!TO_EDGE_CONN(conn)->on_circuit);
tt_ptr_op(TO_EDGE_CONN(conn)->on_circuit, OP_EQ, NULL);
/**********************************************/

View File

@ -138,22 +138,22 @@ test_time_period(void *arg)
/* Let's do the example in prop224 section [TIME-PERIODS] */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
&fake_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Check that the time period number is right */
tn = hs_get_time_period_num(fake_time);
tt_u64_op(tn, ==, 16903);
tt_u64_op(tn, OP_EQ, 16903);
/* Increase current time to 11:59:59 UTC and check that the time period
number is still the same */
fake_time += 3599;
tn = hs_get_time_period_num(fake_time);
tt_u64_op(tn, ==, 16903);
tt_u64_op(tn, OP_EQ, 16903);
{ /* Check start time of next time period */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
&correct_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
start_time = hs_get_start_time_of_next_time_period(fake_time);
tt_int_op(start_time, OP_EQ, correct_time);
@ -162,16 +162,16 @@ test_time_period(void *arg)
/* Now take time to 12:00:00 UTC and check that the time period rotated */
fake_time += 1;
tn = hs_get_time_period_num(fake_time);
tt_u64_op(tn, ==, 16904);
tt_u64_op(tn, OP_EQ, 16904);
/* Now also check our hs_get_next_time_period_num() function */
tn = hs_get_next_time_period_num(fake_time);
tt_u64_op(tn, ==, 16905);
tt_u64_op(tn, OP_EQ, 16905);
{ /* Check start time of next time period again */
retval = parse_rfc1123_time("Wed, 14 Apr 2016 12:00:00 UTC",
&correct_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
start_time = hs_get_start_time_of_next_time_period(fake_time);
tt_int_op(start_time, OP_EQ, correct_time);
@ -203,7 +203,7 @@ test_start_time_of_next_time_period(void *arg)
/* Do some basic tests */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
&fake_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
/* Compare it with the correct result */
format_iso_time(tbuf, next_tp_start_time);
@ -212,7 +212,7 @@ test_start_time_of_next_time_period(void *arg)
/* Another test with an edge-case time (start of TP) */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
&fake_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
format_iso_time(tbuf, next_tp_start_time);
tt_str_op("2016-04-14 12:00:00", OP_EQ, tbuf);
@ -230,7 +230,7 @@ test_start_time_of_next_time_period(void *arg)
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
&fake_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
/* Compare it with the correct result */
format_iso_time(tbuf, next_tp_start_time);
@ -238,7 +238,7 @@ test_start_time_of_next_time_period(void *arg)
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:02:00 UTC",
&fake_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
/* Compare it with the correct result */
format_iso_time(tbuf, next_tp_start_time);
@ -262,35 +262,35 @@ test_desc_overlap_period(void *arg)
dummy_consensus = tor_malloc_zero(sizeof(networkstatus_t));
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
/* Now increase the valid_after so that it goes to 11:00:00 UTC. Overlap
period is still active. */
dummy_consensus->valid_after += 3600*11;
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
/* Now increase the valid_after so that it goes to 11:59:59 UTC. Overlap
period is still active. */
dummy_consensus->valid_after += 3599;
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
/* Now increase the valid_after so that it drifts to noon, and check that
overlap mode is not active anymore. */
dummy_consensus->valid_after += 1;
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Check that overlap mode is also inactive at 23:59:59 UTC */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 23:59:59 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
done:
tor_free(dummy_consensus);
@ -322,39 +322,39 @@ test_desc_overlap_period_testnet(void *arg)
* window. Let's test it: */
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:01:59 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:02:00 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:04:00 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:05:59 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 1);
tt_int_op(retval, OP_EQ, 1);
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:06:00 UTC",
&dummy_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = hs_overlap_mode_is_active(dummy_consensus, now);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
done:
tor_free(dummy_consensus);

View File

@ -54,7 +54,7 @@ test_cert_encoding(void *arg)
/* Test the certificate encoding function. */
ret = tor_cert_encode_ed22519(cert, &encoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
/* Validated the certificate string. */
{
@ -63,7 +63,7 @@ test_cert_encoding(void *arg)
size_t b64_cert_len;
tor_cert_t *parsed_cert;
tt_int_op(strcmpstart(pos, "-----BEGIN ED25519 CERT-----\n"), ==, 0);
tt_int_op(strcmpstart(pos, "-----BEGIN ED25519 CERT-----\n"), OP_EQ, 0);
pos += strlen("-----BEGIN ED25519 CERT-----\n");
/* Isolate the base64 encoded certificate and try to decode it. */
@ -72,23 +72,23 @@ test_cert_encoding(void *arg)
b64_cert = pos;
b64_cert_len = end - pos;
ret = base64_decode(buf, sizeof(buf), b64_cert, b64_cert_len);
tt_int_op(ret, >, 0);
tt_int_op(ret, OP_GT, 0);
/* Parseable? */
parsed_cert = tor_cert_parse((uint8_t *) buf, ret);
tt_assert(parsed_cert);
/* Signature is valid? */
ret = tor_cert_checksig(parsed_cert, &kp.pubkey, now + 10);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
ret = tor_cert_eq(cert, parsed_cert);
tt_int_op(ret, ==, 1);
tt_int_op(ret, OP_EQ, 1);
/* The cert did have the signing key? */
ret= ed25519_pubkey_eq(&parsed_cert->signing_key, &kp.pubkey);
tt_int_op(ret, ==, 1);
tt_int_op(ret, OP_EQ, 1);
tor_cert_free(parsed_cert);
/* Get to the end part of the certificate. */
pos += b64_cert_len;
tt_int_op(strcmpstart(pos, "-----END ED25519 CERT-----"), ==, 0);
tt_int_op(strcmpstart(pos, "-----END ED25519 CERT-----"), OP_EQ, 0);
pos += strlen("-----END ED25519 CERT-----");
}
@ -188,22 +188,22 @@ test_link_specifier(void *arg)
spec.type = LS_IPV4;
ret = tor_addr_parse(&spec.u.ap.addr, "1.2.3.4");
tt_int_op(ret, ==, AF_INET);
tt_int_op(ret, OP_EQ, AF_INET);
b64 = encode_link_specifiers(link_specifiers);
tt_assert(b64);
/* Decode it and validate the format. */
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
tt_int_op(ret, >, 0);
tt_int_op(ret, OP_GT, 0);
/* First byte is the number of link specifier. */
tt_int_op(get_uint8(buf), ==, 1);
tt_int_op(get_uint8(buf), OP_EQ, 1);
ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
tt_int_op(ret, ==, 8);
tt_int_op(ret, OP_EQ, 8);
/* Should be 2 bytes for port and 4 bytes for IPv4. */
tt_int_op(link_specifier_get_ls_len(ls), ==, 6);
tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, 6);
ipv4 = link_specifier_get_un_ipv4_addr(ls);
tt_int_op(tor_addr_to_ipv4h(&spec.u.ap.addr), ==, ipv4);
tt_int_op(link_specifier_get_un_ipv4_port(ls), ==, spec.u.ap.port);
tt_int_op(tor_addr_to_ipv4h(&spec.u.ap.addr), OP_EQ, ipv4);
tt_int_op(link_specifier_get_un_ipv4_port(ls), OP_EQ, spec.u.ap.port);
link_specifier_free(ls);
tor_free(b64);
@ -217,24 +217,25 @@ test_link_specifier(void *arg)
spec.type = LS_IPV6;
ret = tor_addr_parse(&spec.u.ap.addr, "[1:2:3:4::]");
tt_int_op(ret, ==, AF_INET6);
tt_int_op(ret, OP_EQ, AF_INET6);
b64 = encode_link_specifiers(link_specifiers);
tt_assert(b64);
/* Decode it and validate the format. */
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
tt_int_op(ret, >, 0);
tt_int_op(ret, OP_GT, 0);
/* First byte is the number of link specifier. */
tt_int_op(get_uint8(buf), ==, 1);
tt_int_op(get_uint8(buf), OP_EQ, 1);
ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
tt_int_op(ret, ==, 20);
tt_int_op(ret, OP_EQ, 20);
/* Should be 2 bytes for port and 16 bytes for IPv6. */
tt_int_op(link_specifier_get_ls_len(ls), ==, 18);
tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, 18);
for (unsigned int i = 0; i < sizeof(ipv6); i++) {
ipv6[i] = link_specifier_get_un_ipv6_addr(ls, i);
}
tt_mem_op(tor_addr_to_in6_addr8(&spec.u.ap.addr), ==, ipv6, sizeof(ipv6));
tt_int_op(link_specifier_get_un_ipv6_port(ls), ==, spec.u.ap.port);
tt_mem_op(tor_addr_to_in6_addr8(&spec.u.ap.addr), OP_EQ, ipv6,
sizeof(ipv6));
tt_int_op(link_specifier_get_un_ipv6_port(ls), OP_EQ, spec.u.ap.port);
link_specifier_free(ls);
tor_free(b64);
@ -253,12 +254,12 @@ test_link_specifier(void *arg)
/* Decode it and validate the format. */
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
tt_int_op(ret, >, 0);
tt_int_op(ret, OP_GT, 0);
/* First byte is the number of link specifier. */
tt_int_op(get_uint8(buf), ==, 1);
tt_int_op(get_uint8(buf), OP_EQ, 1);
ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
/* 20 bytes digest + 1 byte type + 1 byte len. */
tt_int_op(ret, ==, 22);
tt_int_op(ret, OP_EQ, 22);
tt_int_op(link_specifier_getlen_un_legacy_id(ls), OP_EQ, DIGEST_LEN);
/* Digest length is 20 bytes. */
tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, DIGEST_LEN);
@ -284,10 +285,10 @@ test_encode_descriptor(void *arg)
(void) arg;
ret = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_assert(encoded);
done:
@ -309,7 +310,7 @@ test_decode_descriptor(void *arg)
(void) arg;
ret = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
hs_helper_get_subcred_from_identity_keypair(&signing_kp,
@ -320,11 +321,11 @@ test_decode_descriptor(void *arg)
tt_int_op(ret, OP_EQ, -1);
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_assert(encoded);
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_assert(decoded);
hs_helper_desc_equal(desc, decoded);
@ -333,18 +334,18 @@ test_decode_descriptor(void *arg)
{
ed25519_keypair_t signing_kp_no_ip;
ret = ed25519_keypair_generate(&signing_kp_no_ip, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
hs_helper_get_subcred_from_identity_keypair(&signing_kp_no_ip,
subcredential);
desc_no_ip = hs_helper_build_hs_desc_no_ip(&signing_kp_no_ip);
tt_assert(desc_no_ip);
tor_free(encoded);
ret = hs_desc_encode_descriptor(desc_no_ip, &signing_kp_no_ip, &encoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_assert(encoded);
hs_descriptor_free(decoded);
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_assert(decoded);
}
@ -436,11 +437,11 @@ test_decode_invalid_intro_point(void *arg)
hs_descriptor_free(desc);
desc = NULL;
ret = ed25519_keypair_generate(&signing_kp, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
const char *junk = "this is not a descriptor";
ip = decode_introduction_point(desc, junk);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
hs_desc_intro_point_free(ip);
ip = NULL;
}
@ -456,7 +457,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
hs_desc_intro_point_free(ip);
@ -483,7 +484,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
}
@ -501,7 +502,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
}
@ -518,7 +519,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
}
@ -535,7 +536,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
}
@ -552,7 +553,7 @@ test_decode_invalid_intro_point(void *arg)
encoded_ip = smartlist_join_strings(lines, "\n", 0, &len_out);
tt_assert(encoded_ip);
ip = decode_introduction_point(desc, encoded_ip);
tt_assert(!ip);
tt_ptr_op(ip, OP_EQ, NULL);
tor_free(encoded_ip);
smartlist_free(lines);
}
@ -629,7 +630,7 @@ test_decode_plaintext(void *arg)
{
size_t big = 64000;
/* Must always be bigger than HS_DESC_MAX_LEN. */
tt_int_op(HS_DESC_MAX_LEN, <, big);
tt_int_op(HS_DESC_MAX_LEN, OP_LT, big);
char *plaintext = tor_malloc_zero(big);
memset(plaintext, 'a', big);
plaintext[big - 1] = '\0';
@ -689,7 +690,7 @@ test_validate_cert(void *arg)
(void) arg;
ret = ed25519_keypair_generate(&kp, 0);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
/* Cert of type CERT_TYPE_AUTH_HS_IP_KEY. */
cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
@ -740,16 +741,16 @@ test_desc_signature(void *arg)
tor_asprintf(&data, "This is a signed descriptor\n");
ret = ed25519_sign_prefixed(&sig, (const uint8_t *) data, strlen(data),
"Tor onion service descriptor sig v3", &kp);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
ret = ed25519_signature_to_base64(sig_b64, &sig);
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
/* Build the descriptor that should be valid. */
tor_asprintf(&desc, "%ssignature %s\n", data, sig_b64);
ret = desc_sig_is_valid(sig_b64, &kp.pubkey, desc, strlen(desc));
tt_int_op(ret, ==, 1);
tt_int_op(ret, OP_EQ, 1);
/* Junk signature. */
ret = desc_sig_is_valid("JUNK", &kp.pubkey, desc, strlen(desc));
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
done:
tor_free(desc);
@ -811,8 +812,8 @@ test_parse_hs_desc_superencrypted(void *arg)
retval = decode_superencrypted(bad_superencrypted_text1,
strlen(bad_superencrypted_text1),
&encrypted_out);
tt_u64_op(retval, ==, 0);
tt_assert(!encrypted_out);
tt_u64_op(retval, OP_EQ, 0);
tt_ptr_op(encrypted_out, OP_EQ, NULL);
expect_log_msg_containing("Unrecognized desc auth type");
teardown_capture_of_logs();
}
@ -822,8 +823,8 @@ test_parse_hs_desc_superencrypted(void *arg)
retval = decode_superencrypted(bad_superencrypted_text2,
strlen(bad_superencrypted_text2),
&encrypted_out);
tt_u64_op(retval, ==, 0);
tt_assert(!encrypted_out);
tt_u64_op(retval, OP_EQ, 0);
tt_ptr_op(encrypted_out, OP_EQ, NULL);
expect_log_msg_containing("Bogus desc auth key in HS desc");
teardown_capture_of_logs();
}
@ -833,8 +834,8 @@ test_parse_hs_desc_superencrypted(void *arg)
retval = decode_superencrypted(bad_superencrypted_text3,
strlen(bad_superencrypted_text3),
&encrypted_out);
tt_u64_op(retval, ==, 0);
tt_assert(!encrypted_out);
tt_u64_op(retval, OP_EQ, 0);
tt_ptr_op(encrypted_out, OP_EQ, NULL);
expect_log_msg_containing("Length of descriptor\'s encrypted data "
"is too small.");
teardown_capture_of_logs();
@ -845,7 +846,7 @@ test_parse_hs_desc_superencrypted(void *arg)
strlen(correct_superencrypted_text),
&encrypted_out);
tt_u64_op(retval, ==, strlen(correct_encrypted_plaintext));
tt_u64_op(retval, OP_EQ, strlen(correct_encrypted_plaintext));
tt_mem_op(encrypted_out, OP_EQ, correct_encrypted_plaintext,
strlen(correct_encrypted_plaintext));

View File

@ -191,7 +191,7 @@ test_establish_intro_wrong_purpose(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
expect_log_msg_containing("Rejecting ESTABLISH_INTRO on non-OR circuit.");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
circuit_free(TO_CIRCUIT(intro_circ));
@ -225,7 +225,7 @@ test_establish_intro_wrong_keytype(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, (uint8_t *) "", 0);
expect_log_msg_containing("Empty ESTABLISH_INTRO cell.");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
circuit_free(TO_CIRCUIT(intro_circ));
@ -260,7 +260,7 @@ test_establish_intro_wrong_keytype2(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
expect_log_msg_containing("Unrecognized AUTH_KEY_TYPE 42.");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
circuit_free(TO_CIRCUIT(intro_circ));
@ -329,7 +329,7 @@ test_establish_intro_wrong_mac(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
expect_log_msg_containing("ESTABLISH_INTRO handshake_auth not as expected");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
trn_cell_establish_intro_free(cell);
@ -374,7 +374,7 @@ test_establish_intro_wrong_auth_key_len(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
expect_log_msg_containing("ESTABLISH_INTRO auth key length is invalid");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
trn_cell_establish_intro_free(cell);
@ -419,7 +419,7 @@ test_establish_intro_wrong_sig_len(void *arg)
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
expect_log_msg_containing("ESTABLISH_INTRO sig len is invalid");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
trn_cell_establish_intro_free(cell);
@ -457,7 +457,7 @@ test_establish_intro_wrong_sig(void *arg)
(size_t)cell_len);
expect_log_msg_containing("Failed to verify ESTABLISH_INTRO cell.");
teardown_capture_of_logs();
tt_int_op(retval, ==, -1);
tt_int_op(retval, OP_EQ, -1);
done:
circuit_free(TO_CIRCUIT(intro_circ));
@ -492,7 +492,7 @@ helper_establish_intro_v3(or_circuit_t *intro_circ)
/* Receive the cell */
retval = hs_intro_received_establish_intro(intro_circ, cell_body,
(size_t) cell_len);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
done:
return cell;
@ -528,7 +528,7 @@ helper_establish_intro_v2(or_circuit_t *intro_circ)
/* Receive legacy establish_intro */
retval = hs_intro_received_establish_intro(intro_circ,
cell_body, (size_t) cell_len);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
done:
return key1;
@ -547,7 +547,7 @@ test_circuitmap_free_all(void)
tt_assert(the_hs_circuitmap);
hs_circuitmap_free_all();
the_hs_circuitmap = get_hs_circuitmap();
tt_assert(!the_hs_circuitmap);
tt_ptr_op(the_hs_circuitmap, OP_EQ, NULL);
done:
;
}
@ -579,10 +579,10 @@ test_intro_point_registration(void *arg)
{
the_hs_circuitmap = get_hs_circuitmap();
tt_assert(the_hs_circuitmap);
tt_int_op(0, ==, HT_SIZE(the_hs_circuitmap));
tt_int_op(0, OP_EQ, HT_SIZE(the_hs_circuitmap));
/* Do a circuitmap query in any case */
returned_intro_circ =hs_circuitmap_get_intro_circ_v3_relay_side(&auth_key);
tt_ptr_op(returned_intro_circ, ==, NULL);
tt_ptr_op(returned_intro_circ, OP_EQ, NULL);
}
/* Create a v3 intro point */
@ -594,12 +594,12 @@ test_intro_point_registration(void *arg)
/* Check that the intro point was registered on the HS circuitmap */
the_hs_circuitmap = get_hs_circuitmap();
tt_assert(the_hs_circuitmap);
tt_int_op(1, ==, HT_SIZE(the_hs_circuitmap));
tt_int_op(1, OP_EQ, HT_SIZE(the_hs_circuitmap));
get_auth_key_from_cell(&auth_key, RELAY_COMMAND_ESTABLISH_INTRO,
establish_intro_cell);
returned_intro_circ =
hs_circuitmap_get_intro_circ_v3_relay_side(&auth_key);
tt_ptr_op(intro_circ, ==, returned_intro_circ);
tt_ptr_op(intro_circ, OP_EQ, returned_intro_circ);
}
/* Create a v2 intro point */
@ -614,14 +614,14 @@ test_intro_point_registration(void *arg)
/* Check that the circuitmap now has two elements */
the_hs_circuitmap = get_hs_circuitmap();
tt_assert(the_hs_circuitmap);
tt_int_op(2, ==, HT_SIZE(the_hs_circuitmap));
tt_int_op(2, OP_EQ, HT_SIZE(the_hs_circuitmap));
/* Check that the new element is our legacy intro circuit. */
retval = crypto_pk_get_digest(legacy_auth_key, key_digest);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
returned_intro_circ =
hs_circuitmap_get_intro_circ_v2_relay_side((uint8_t*)key_digest);
tt_ptr_op(legacy_intro_circ, ==, returned_intro_circ);
tt_ptr_op(legacy_intro_circ, OP_EQ, returned_intro_circ);
}
/* XXX Continue test and try to register a second v3 intro point with the

View File

@ -57,7 +57,7 @@ test_hs_ntor(void *arg)
&client_ephemeral_enc_keypair,
subcredential,
&client_hs_ntor_intro_cell_keys);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Service: Simulate the decryption of the received INTRODUCE1 */
retval =
@ -66,7 +66,7 @@ test_hs_ntor(void *arg)
&client_ephemeral_enc_keypair.pubkey,
subcredential,
&service_hs_ntor_intro_cell_keys);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Test that the INTRODUCE1 encryption/mac keys match! */
tt_mem_op(client_hs_ntor_intro_cell_keys.enc_key, OP_EQ,
@ -83,7 +83,7 @@ test_hs_ntor(void *arg)
&service_ephemeral_rend_keypair,
&client_ephemeral_enc_keypair.pubkey,
&service_hs_ntor_rend_cell_keys);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Client: Simulate the verification of a received RENDEZVOUS1 cell */
retval =
@ -92,7 +92,7 @@ test_hs_ntor(void *arg)
&service_intro_enc_keypair.pubkey,
&service_ephemeral_rend_keypair.pubkey,
&client_hs_ntor_rend_cell_keys);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
/* Test that the RENDEZVOUS1 key material match! */
tt_mem_op(client_hs_ntor_rend_cell_keys.rend_cell_auth_mac, OP_EQ,

View File

@ -371,7 +371,7 @@ test_access_service(void *arg)
remove_service(global_map, s);
tt_int_op(get_hs_service_map_size(), OP_EQ, 0);
query = find_service(global_map, &s->keys.identity_pk);
tt_assert(!query);
tt_ptr_op(query, OP_EQ, NULL);
/* Register back the service in the map. */
ret = register_service(global_map, s);
@ -384,7 +384,7 @@ test_access_service(void *arg)
remove_service(global_map, s);
tt_int_op(get_hs_service_map_size(), OP_EQ, 0);
query = find_service(global_map, &s->keys.identity_pk);
tt_assert(!query);
tt_ptr_op(query, OP_EQ, NULL);
/* Let's try to remove twice for fun. */
setup_full_capture_of_logs(LOG_WARN);
remove_service(global_map, s);
@ -448,7 +448,7 @@ test_service_intro_point(void *arg)
tt_mem_op(query, OP_EQ, ip, sizeof(hs_service_intro_point_t));
query = service_intro_point_find(service,
(const ed25519_public_key_t *) garbage);
tt_assert(query == NULL);
tt_ptr_op(query, OP_EQ, NULL);
/* While at it, can I find the descriptor with the intro point? */
hs_service_descriptor_t *desc_lookup =
@ -459,7 +459,7 @@ test_service_intro_point(void *arg)
/* Remove object from service descriptor and make sure it is out. */
service_intro_point_remove(service, ip);
query = service_intro_point_find(service, &ip->auth_key_kp.pubkey);
tt_assert(query == NULL);
tt_ptr_op(query, OP_EQ, NULL);
}
done:
@ -533,9 +533,9 @@ test_helper_functions(void *arg)
/* Break the ident and we should find nothing. */
memset(&ident, 0, sizeof(ident));
get_objects_from_ident(&ident, &s_lookup, &ip_lookup, &desc_lookup);
tt_assert(s_lookup == NULL);
tt_assert(ip_lookup == NULL);
tt_assert(desc_lookup == NULL);
tt_ptr_op(s_lookup, OP_EQ, NULL);
tt_ptr_op(ip_lookup, OP_EQ, NULL);
tt_ptr_op(desc_lookup, OP_EQ, NULL);
}
/* Testing get_node_from_intro_point() */
@ -550,7 +550,7 @@ test_helper_functions(void *arg)
}
} SMARTLIST_FOREACH_END(ls);
node = get_node_from_intro_point(ip);
tt_assert(node == NULL);
tt_ptr_op(node, OP_EQ, NULL);
}
/* Testing can_service_launch_intro_circuit() */

View File

@ -307,7 +307,7 @@ do_parse_test(uint8_t *plaintext, size_t plaintext_len, int phase)
/* Do early parsing */
parsed_req = rend_service_begin_parse_intro(cell, cell_len, 2, &err_msg);
tt_assert(parsed_req);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_mem_op(parsed_req->pk,OP_EQ, digest, DIGEST_LEN);
tt_assert(parsed_req->ciphertext);
tt_assert(parsed_req->ciphertext_len > 0);
@ -318,7 +318,7 @@ do_parse_test(uint8_t *plaintext, size_t plaintext_len, int phase)
/* Do decryption */
r = rend_service_decrypt_intro(parsed_req, k, &err_msg);
tt_assert(!r);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_assert(parsed_req->plaintext);
tt_assert(parsed_req->plaintext_len > 0);
@ -328,7 +328,7 @@ do_parse_test(uint8_t *plaintext, size_t plaintext_len, int phase)
/* Do late parsing */
r = rend_service_parse_intro_plaintext(parsed_req, &err_msg);
tt_assert(!r);
tt_assert(!err_msg);
tt_ptr_op(err_msg, OP_EQ, NULL);
tt_assert(parsed_req->parsed);
done:

View File

@ -20,8 +20,8 @@ test_keypin_parse_line(void *arg)
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4");
tt_assert(ent);
tt_mem_op(ent->rsa_id, ==, "here is a good sha1!", 20);
tt_mem_op(ent->ed25519_key, ==, "This ed25519 scoffs at the sha1.", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "here is a good sha1!", 20);
tt_mem_op(ent->ed25519_key, OP_EQ, "This ed25519 scoffs at the sha1.", 32);
tor_free(ent); ent = NULL;
/* Good line with extra stuff we will ignore. */
@ -29,27 +29,27 @@ test_keypin_parse_line(void *arg)
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4helloworld");
tt_assert(ent);
tt_mem_op(ent->rsa_id, ==, "here is a good sha1!", 20);
tt_mem_op(ent->ed25519_key, ==, "This ed25519 scoffs at the sha1.", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "here is a good sha1!", 20);
tt_mem_op(ent->ed25519_key, OP_EQ, "This ed25519 scoffs at the sha1.", 32);
tor_free(ent); ent = NULL;
/* Bad line: no space in the middle. */
ent = keypin_parse_journal_line(
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE?"
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4");
tt_assert(! ent);
tt_ptr_op(ent, OP_EQ, NULL);
/* Bad line: bad base64 in RSA ID */
ent = keypin_parse_journal_line(
"aGVyZSBpcyBhIGdv!2Qgc2hhMSE "
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4");
tt_assert(! ent);
tt_ptr_op(ent, OP_EQ, NULL);
/* Bad line: bad base64 in Ed25519 */
ent = keypin_parse_journal_line(
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
"VGhpcyBlZDI1NTE5IHNjb2ZmcyB!dCB0aGUgc2hhMS4");
tt_assert(! ent);
tt_ptr_op(ent, OP_EQ, NULL);
done:
tor_free(ent);
@ -82,11 +82,11 @@ test_keypin_parse_file(void *arg)
"Z2dsZSBpbiBzd29tZWVzd2FucyA aW4gdm9sdXB0YXRlIGF4ZS1oYWNrZXIgZXNzZSByaXA\n"
"cHVsdXMgY3J1bW1paSBldSBtb28 ZiBudWxsYSBzbnV2di5QTFVHSFBMT1ZFUlhZWlpZLi4\n";
tt_int_op(0, ==, keypin_load_journal_impl(data1, strlen(data1)));
tt_int_op(8, ==, smartlist_len(mock_addent_got));
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data1, strlen(data1)));
tt_int_op(8, OP_EQ, smartlist_len(mock_addent_got));
keypin_ent_t *ent = smartlist_get(mock_addent_got, 2);
tt_mem_op(ent->rsa_id, ==, "r lerkim, sed do bar", 20);
tt_mem_op(ent->ed25519_key, ==, "baloot tempor gluppitus ut labor", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "r lerkim, sed do bar", 20);
tt_mem_op(ent->ed25519_key, OP_EQ, "baloot tempor gluppitus ut labor", 32);
/* More complex example: weird lines, bogus lines,
duplicate/conflicting lines */
@ -107,24 +107,25 @@ test_keypin_parse_file(void *arg)
"ZHMgc3BlYWsgdHJ1dGgsIGFuZCA aXQgd2FzIHRydaUgdGhhdCBhbGwgdGhlIG1hc3Rlcgo\n"
;
tt_int_op(0, ==, keypin_load_journal_impl(data2, strlen(data2)));
tt_int_op(13, ==, smartlist_len(mock_addent_got));
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data2, strlen(data2)));
tt_int_op(13, OP_EQ, smartlist_len(mock_addent_got));
ent = smartlist_get(mock_addent_got, 9);
tt_mem_op(ent->rsa_id, ==, "\"You have made a goo", 20);
tt_mem_op(ent->ed25519_key, ==, "d beginning.\" But no more. Wizar", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "\"You have made a goo", 20);
tt_mem_op(ent->ed25519_key, OP_EQ, "d beginning.\" But no more. Wizar", 32);
ent = smartlist_get(mock_addent_got, 12);
tt_mem_op(ent->rsa_id, ==, "ds speak truth, and ", 20);
tt_mem_op(ent->ed25519_key, ==, "it was tru\xa5 that all the master\n", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "ds speak truth, and ", 20);
tt_mem_op(ent->ed25519_key, OP_EQ,
"it was tru\xa5 that all the master\n", 32);
/* File truncated before NL */
const char data3[] =
"Tm8gZHJhZ29uIGNhbiByZXNpc3Q IHRoZSBmYXNjaW5hdGlvbiBvZiByaWRkbGluZyB0YWw";
tt_int_op(0, ==, keypin_load_journal_impl(data3, strlen(data3)));
tt_int_op(14, ==, smartlist_len(mock_addent_got));
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data3, strlen(data3)));
tt_int_op(14, OP_EQ, smartlist_len(mock_addent_got));
ent = smartlist_get(mock_addent_got, 13);
tt_mem_op(ent->rsa_id, ==, "No dragon can resist", 20);
tt_mem_op(ent->ed25519_key, ==, " the fascination of riddling tal", 32);
tt_mem_op(ent->rsa_id, OP_EQ, "No dragon can resist", 20);
tt_mem_op(ent->ed25519_key, OP_EQ, " the fascination of riddling tal", 32);
done:
keypin_clear();
@ -141,32 +142,32 @@ test_keypin_add_entry(void *arg)
(void)arg;
keypin_clear();
tt_int_op(KEYPIN_ADDED, ==, ADD("ambassadors-at-large",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("ambassadors-at-large",
"bread-and-butter thing-in-itself"));
tt_int_op(KEYPIN_ADDED, ==, ADD("gentleman-adventurer",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("gentleman-adventurer",
"cloak-and-dagger what's-his-face"));
tt_int_op(KEYPIN_FOUND, ==, ADD("ambassadors-at-large",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("ambassadors-at-large",
"bread-and-butter thing-in-itself"));
tt_int_op(KEYPIN_FOUND, ==, ADD("ambassadors-at-large",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("ambassadors-at-large",
"bread-and-butter thing-in-itself"));
tt_int_op(KEYPIN_FOUND, ==, ADD("gentleman-adventurer",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("gentleman-adventurer",
"cloak-and-dagger what's-his-face"));
tt_int_op(KEYPIN_ADDED, ==, ADD("Johnnies-come-lately",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("Johnnies-come-lately",
"run-of-the-mill root-mean-square"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("gentleman-adventurer",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("gentleman-adventurer",
"hypersentimental closefistedness"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("disestablismentarian",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("disestablismentarian",
"cloak-and-dagger what's-his-face"));
tt_int_op(KEYPIN_FOUND, ==, ADD("gentleman-adventurer",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("gentleman-adventurer",
"cloak-and-dagger what's-his-face"));
tt_int_op(KEYPIN_NOT_FOUND, ==, LONE_RSA("Llanfairpwllgwyngyll"));
tt_int_op(KEYPIN_MISMATCH, ==, LONE_RSA("Johnnies-come-lately"));
tt_int_op(KEYPIN_NOT_FOUND, OP_EQ, LONE_RSA("Llanfairpwllgwyngyll"));
tt_int_op(KEYPIN_MISMATCH, OP_EQ, LONE_RSA("Johnnies-come-lately"));
done:
keypin_clear();
@ -179,51 +180,51 @@ test_keypin_journal(void *arg)
char *contents = NULL;
const char *fname = get_fname("keypin-journal");
tt_int_op(0, ==, keypin_load_journal(fname)); /* ENOENT is okay */
tt_int_op(0, OP_EQ, keypin_load_journal(fname)); /* ENOENT is okay */
update_approx_time(1217709000);
tt_int_op(0, ==, keypin_open_journal(fname));
tt_int_op(0, OP_EQ, keypin_open_journal(fname));
tt_int_op(KEYPIN_ADDED, ==, ADD("king-of-the-herrings",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("king-of-the-herrings",
"good-for-nothing attorney-at-law"));
tt_int_op(KEYPIN_ADDED, ==, ADD("yellowish-red-yellow",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("yellowish-red-yellow",
"salt-and-pepper high-muck-a-muck"));
tt_int_op(KEYPIN_FOUND, ==, ADD("yellowish-red-yellow",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("yellowish-red-yellow",
"salt-and-pepper high-muck-a-muck"));
keypin_close_journal();
keypin_clear();
tt_int_op(0, ==, keypin_load_journal(fname));
tt_int_op(0, OP_EQ, keypin_load_journal(fname));
update_approx_time(1231041600);
tt_int_op(0, ==, keypin_open_journal(fname));
tt_int_op(KEYPIN_FOUND, ==, ADD("yellowish-red-yellow",
tt_int_op(0, OP_EQ, keypin_open_journal(fname));
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("yellowish-red-yellow",
"salt-and-pepper high-muck-a-muck"));
tt_int_op(KEYPIN_ADDED, ==, ADD("theatre-in-the-round",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("theatre-in-the-round",
"holier-than-thou jack-in-the-box"));
tt_int_op(KEYPIN_ADDED, ==, ADD("no-deposit-no-return",
tt_int_op(KEYPIN_ADDED, OP_EQ, ADD("no-deposit-no-return",
"across-the-board will-o-the-wisp"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("intellectualizations",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("intellectualizations",
"salt-and-pepper high-muck-a-muck"));
keypin_close_journal();
keypin_clear();
tt_int_op(0, ==, keypin_load_journal(fname));
tt_int_op(0, OP_EQ, keypin_load_journal(fname));
update_approx_time(1412278354);
tt_int_op(0, ==, keypin_open_journal(fname));
tt_int_op(KEYPIN_FOUND, ==, ADD("yellowish-red-yellow",
tt_int_op(0, OP_EQ, keypin_open_journal(fname));
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("yellowish-red-yellow",
"salt-and-pepper high-muck-a-muck"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("intellectualizations",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("intellectualizations",
"salt-and-pepper high-muck-a-muck"));
tt_int_op(KEYPIN_FOUND, ==, ADD("theatre-in-the-round",
tt_int_op(KEYPIN_FOUND, OP_EQ, ADD("theatre-in-the-round",
"holier-than-thou jack-in-the-box"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("counterrevolutionary",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("counterrevolutionary",
"holier-than-thou jack-in-the-box"));
tt_int_op(KEYPIN_MISMATCH, ==, ADD("no-deposit-no-return",
tt_int_op(KEYPIN_MISMATCH, OP_EQ, ADD("no-deposit-no-return",
"floccinaucinihilipilificationism"));
keypin_close_journal();
contents = read_file_to_str(fname, RFTS_BIN, NULL);
tt_assert(contents);
tt_str_op(contents,==,
tt_str_op(contents,OP_EQ,
"\n"
"@opened-at 2008-08-02 20:30:00\n"
"a2luZy1vZi10aGUtaGVycmluZ3M Z29vZC1mb3Itbm90aGluZyBhdHRvcm5leS1hdC1sYXc\n"

View File

@ -136,7 +136,7 @@ test_link_handshake_certs_ok(void *arg)
* actually generate a CERTS cell.
*/
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
key1, key2, 86400), ==, 0);
key1, key2, 86400), OP_EQ, 0);
if (with_ed) {
/* If we're making a CERTS cell for an ed handshake, let's make sure we
@ -155,63 +155,63 @@ test_link_handshake_certs_ok(void *arg)
c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
c1->link_proto = 3;
tt_int_op(connection_init_or_handshake_state(c1, 1), ==, 0);
tt_int_op(connection_init_or_handshake_state(c1, 1), OP_EQ, 0);
/* c2 has started_here == 0 */
c2->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
c2->link_proto = 3;
tt_int_op(connection_init_or_handshake_state(c2, 0), ==, 0);
tt_int_op(connection_init_or_handshake_state(c2, 0), OP_EQ, 0);
tt_int_op(0, ==, connection_or_send_certs_cell(c1));
tt_int_op(0, OP_EQ, connection_or_send_certs_cell(c1));
tt_assert(mock_got_var_cell);
cell1 = mock_got_var_cell;
tt_int_op(0, ==, connection_or_send_certs_cell(c2));
tt_int_op(0, OP_EQ, connection_or_send_certs_cell(c2));
tt_assert(mock_got_var_cell);
cell2 = mock_got_var_cell;
tt_int_op(cell1->command, ==, CELL_CERTS);
tt_int_op(cell1->payload_len, >, 1);
tt_int_op(cell1->command, OP_EQ, CELL_CERTS);
tt_int_op(cell1->payload_len, OP_GT, 1);
tt_int_op(cell2->command, ==, CELL_CERTS);
tt_int_op(cell2->payload_len, >, 1);
tt_int_op(cell2->command, OP_EQ, CELL_CERTS);
tt_int_op(cell2->payload_len, OP_GT, 1);
tt_int_op(cell1->payload_len, ==,
tt_int_op(cell1->payload_len, OP_EQ,
certs_cell_parse(&cc1, cell1->payload, cell1->payload_len));
tt_int_op(cell2->payload_len, ==,
tt_int_op(cell2->payload_len, OP_EQ,
certs_cell_parse(&cc2, cell2->payload, cell2->payload_len));
if (with_ed) {
tt_int_op(5, ==, cc1->n_certs);
tt_int_op(5, ==, cc2->n_certs);
tt_int_op(5, OP_EQ, cc1->n_certs);
tt_int_op(5, OP_EQ, cc2->n_certs);
} else {
tt_int_op(2, ==, cc1->n_certs);
tt_int_op(2, ==, cc2->n_certs);
tt_int_op(2, OP_EQ, cc1->n_certs);
tt_int_op(2, OP_EQ, cc2->n_certs);
}
tt_int_op(certs_cell_get_certs(cc1, 0)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc1, 0)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_AUTH);
tt_int_op(certs_cell_get_certs(cc1, 1)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc1, 1)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_ID);
tt_int_op(certs_cell_get_certs(cc2, 0)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc2, 0)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_LINK);
tt_int_op(certs_cell_get_certs(cc2, 1)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc2, 1)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_ID);
if (with_ed) {
tt_int_op(certs_cell_get_certs(cc1, 2)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc1, 2)->cert_type, OP_EQ,
CERTTYPE_ED_ID_SIGN);
tt_int_op(certs_cell_get_certs(cc1, 3)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc1, 3)->cert_type, OP_EQ,
CERTTYPE_ED_SIGN_AUTH);
tt_int_op(certs_cell_get_certs(cc1, 4)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc1, 4)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_EDID);
tt_int_op(certs_cell_get_certs(cc2, 2)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc2, 2)->cert_type, OP_EQ,
CERTTYPE_ED_ID_SIGN);
tt_int_op(certs_cell_get_certs(cc2, 3)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc2, 3)->cert_type, OP_EQ,
CERTTYPE_ED_SIGN_LINK);
tt_int_op(certs_cell_get_certs(cc2, 4)->cert_type, ==,
tt_int_op(certs_cell_get_certs(cc2, 4)->cert_type, OP_EQ,
CERTTYPE_RSA1024_ID_EDID);
}
@ -240,8 +240,8 @@ test_link_handshake_certs_ok(void *arg)
tor_assert(c1->handshake_state->authenticated);
tt_assert(c1->handshake_state->received_certs_cell);
tt_assert(c1->handshake_state->certs->auth_cert == NULL);
tt_assert(c1->handshake_state->certs->ed_sign_auth == NULL);
tt_ptr_op(c1->handshake_state->certs->auth_cert, OP_EQ, NULL);
tt_ptr_op(c1->handshake_state->certs->ed_sign_auth, OP_EQ, NULL);
tt_assert(c1->handshake_state->certs->id_cert);
if (with_ed) {
tt_assert(c1->handshake_state->certs->ed_sign_link);
@ -250,9 +250,9 @@ test_link_handshake_certs_ok(void *arg)
tt_assert(c1->handshake_state->authenticated_rsa);
tt_assert(c1->handshake_state->authenticated_ed25519);
} else {
tt_assert(c1->handshake_state->certs->ed_sign_link == NULL);
tt_assert(c1->handshake_state->certs->ed_rsa_crosscert == NULL);
tt_assert(c1->handshake_state->certs->ed_id_sign == NULL);
tt_ptr_op(c1->handshake_state->certs->ed_sign_link, OP_EQ, NULL);
tt_ptr_op(c1->handshake_state->certs->ed_rsa_crosscert, OP_EQ, NULL);
tt_ptr_op(c1->handshake_state->certs->ed_id_sign, OP_EQ, NULL);
tt_assert(c1->handshake_state->authenticated_rsa);
tt_assert(! c1->handshake_state->authenticated_ed25519);
}
@ -278,9 +278,9 @@ test_link_handshake_certs_ok(void *arg)
tt_assert(c2->handshake_state->certs->ed_id_sign);
} else {
tt_assert(c2->handshake_state->certs->auth_cert);
tt_assert(c2->handshake_state->certs->ed_sign_auth == NULL);
tt_assert(c2->handshake_state->certs->ed_rsa_crosscert == NULL);
tt_assert(c2->handshake_state->certs->ed_id_sign == NULL);
tt_ptr_op(c2->handshake_state->certs->ed_sign_auth, OP_EQ, NULL);
tt_ptr_op(c2->handshake_state->certs->ed_rsa_crosscert, OP_EQ, NULL);
tt_ptr_op(c2->handshake_state->certs->ed_id_sign, OP_EQ, NULL);
}
tt_assert(c2->handshake_state->certs->id_cert);
tt_assert(tor_mem_is_zero(
@ -376,14 +376,14 @@ recv_certs_setup(const struct testcase_t *test)
tor_addr_from_ipv4h(&d->c->base_.addr, 0x801f0127);
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
d->chan->conn = d->c;
tt_int_op(connection_init_or_handshake_state(d->c, 1), ==, 0);
tt_int_op(connection_init_or_handshake_state(d->c, 1), OP_EQ, 0);
d->c->link_proto = 4;
d->key1 = pk_generate(2);
d->key2 = pk_generate(3);
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
d->key1, d->key2, 86400), ==, 0);
d->key1, d->key2, 86400), OP_EQ, 0);
if (is_ed) {
init_mock_ed_keys(d->key2);
} else {
@ -452,7 +452,7 @@ recv_certs_setup(const struct testcase_t *test)
d->cell->command = CELL_CERTS;
n = certs_cell_encode(d->cell->payload, 4096, d->ccell);
tt_int_op(n, >, 0);
tt_int_op(n, OP_GT, 0);
d->cell->payload_len = n;
MOCK(tor_tls_cert_matches_key, mock_tls_cert_matches_key);
@ -465,9 +465,9 @@ recv_certs_setup(const struct testcase_t *test)
mock_peer_cert = tor_x509_cert_dup(a);
}
tt_int_op(0, ==, d->c->handshake_state->received_certs_cell);
tt_int_op(0, ==, mock_send_authenticate_called);
tt_int_op(0, ==, mock_send_netinfo_called);
tt_int_op(0, OP_EQ, d->c->handshake_state->received_certs_cell);
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
return d;
done:
@ -485,25 +485,25 @@ test_link_handshake_recv_certs_ok(void *arg)
{
certs_data_t *d = arg;
channel_tls_process_certs_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(d->c->handshake_state->authenticated, ==, 1);
tt_int_op(d->c->handshake_state->authenticated_rsa, ==, 1);
tt_int_op(d->c->handshake_state->received_certs_cell, ==, 1);
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
tt_assert(d->c->handshake_state->certs->auth_cert == NULL);
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(d->c->handshake_state->authenticated, OP_EQ, 1);
tt_int_op(d->c->handshake_state->authenticated_rsa, OP_EQ, 1);
tt_int_op(d->c->handshake_state->received_certs_cell, OP_EQ, 1);
tt_ptr_op(d->c->handshake_state->certs->id_cert, OP_NE, NULL);
tt_ptr_op(d->c->handshake_state->certs->auth_cert, OP_EQ, NULL);
if (d->is_ed) {
tt_assert(d->c->handshake_state->certs->ed_id_sign != NULL);
tt_assert(d->c->handshake_state->certs->ed_sign_link != NULL);
tt_assert(d->c->handshake_state->certs->ed_sign_auth == NULL);
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert != NULL);
tt_int_op(d->c->handshake_state->authenticated_ed25519, ==, 1);
tt_ptr_op(d->c->handshake_state->certs->ed_id_sign, OP_NE, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_link, OP_NE, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_auth, OP_EQ, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_rsa_crosscert, OP_NE, NULL);
tt_int_op(d->c->handshake_state->authenticated_ed25519, OP_EQ, 1);
} else {
tt_assert(d->c->handshake_state->certs->ed_id_sign == NULL);
tt_assert(d->c->handshake_state->certs->ed_sign_link == NULL);
tt_assert(d->c->handshake_state->certs->ed_sign_auth == NULL);
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert == NULL);
tt_int_op(d->c->handshake_state->authenticated_ed25519, ==, 0);
tt_ptr_op(d->c->handshake_state->certs->ed_id_sign, OP_EQ, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_link, OP_EQ, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_auth, OP_EQ, NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_rsa_crosscert, OP_EQ, NULL);
tt_int_op(d->c->handshake_state->authenticated_ed25519, OP_EQ, 0);
}
done:
@ -517,17 +517,17 @@ test_link_handshake_recv_certs_ok_server(void *arg)
d->c->handshake_state->started_here = 0;
d->c->handshake_state->certs->started_here = 0;
channel_tls_process_certs_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(d->c->handshake_state->authenticated, ==, 0);
tt_int_op(d->c->handshake_state->received_certs_cell, ==, 1);
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
tt_assert(d->c->handshake_state->certs->link_cert == NULL);
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(d->c->handshake_state->authenticated, OP_EQ, 0);
tt_int_op(d->c->handshake_state->received_certs_cell, OP_EQ, 1);
tt_ptr_op(d->c->handshake_state->certs->id_cert, OP_NE, NULL);
tt_ptr_op(d->c->handshake_state->certs->link_cert, OP_EQ, NULL);
if (d->is_ed) {
tt_assert(d->c->handshake_state->certs->ed_sign_auth != NULL);
tt_assert(d->c->handshake_state->certs->auth_cert == NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_auth, OP_NE, NULL);
tt_ptr_op(d->c->handshake_state->certs->auth_cert, OP_EQ, NULL);
} else {
tt_assert(d->c->handshake_state->certs->ed_sign_auth == NULL);
tt_assert(d->c->handshake_state->certs->auth_cert != NULL);
tt_ptr_op(d->c->handshake_state->certs->ed_sign_auth, OP_EQ, NULL);
tt_ptr_op(d->c->handshake_state->certs->auth_cert, OP_NE, NULL);
}
done:
@ -543,11 +543,11 @@ test_link_handshake_recv_certs_ok_server(void *arg)
setup_capture_of_logs(LOG_INFO); \
{ code ; } \
channel_tls_process_certs_cell(d->cell, d->chan); \
tt_int_op(1, ==, mock_close_called); \
tt_int_op(0, ==, mock_send_authenticate_called); \
tt_int_op(0, ==, mock_send_netinfo_called); \
tt_int_op(0, ==, d->c->handshake_state->authenticated_rsa); \
tt_int_op(0, ==, d->c->handshake_state->authenticated_ed25519); \
tt_int_op(1, OP_EQ, mock_close_called); \
tt_int_op(0, OP_EQ, mock_send_authenticate_called); \
tt_int_op(0, OP_EQ, mock_send_netinfo_called); \
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_rsa); \
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_ed25519); \
if (require_failure_message) { \
expect_log_msg_containing(require_failure_message); \
} \
@ -603,7 +603,7 @@ CERTS_FAIL(truncated_5, /* ed25519 */
const char *msg = certs_cell_check(d->ccell); \
if (msg) puts(msg); \
ssize_t n = certs_cell_encode(d->cell->payload, 4096, d->ccell); \
tt_int_op(n, >, 0); \
tt_int_op(n, OP_GT, 0); \
d->cell->payload_len = n; \
} while (0)
@ -686,9 +686,9 @@ test_link_handshake_recv_certs_missing_id(void *arg) /* ed25519 */
/* This handshake succeeds, but since we have no ID cert, we will
* just do the RSA handshake. */
channel_tls_process_certs_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(0, ==, d->c->handshake_state->authenticated_ed25519);
tt_int_op(1, ==, d->c->handshake_state->authenticated_rsa);
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_ed25519);
tt_int_op(1, OP_EQ, d->c->handshake_state->authenticated_rsa);
done:
;
}
@ -697,7 +697,7 @@ CERTS_FAIL(missing_signing_key, /* ed25519 */
require_failure_message = "No Ed25519 signing key";
tt_int_op(certs_cell_getlen_certs(d->ccell), OP_EQ, 5);
certs_cell_cert_t *cert = certs_cell_get_certs(d->ccell, 2);
tt_int_op(cert->cert_type, ==, CERTTYPE_ED_ID_SIGN);
tt_int_op(cert->cert_type, OP_EQ, CERTTYPE_ED_ID_SIGN);
/* replace this with a valid master->signing cert, but with no
* signing key. */
const ed25519_keypair_t *mk = get_master_identity_keypair();
@ -905,28 +905,28 @@ test_link_handshake_send_authchallenge(void *arg)
crypto_pk_t *rsa0 = pk_generate(0), *rsa1 = pk_generate(1);
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
rsa0, rsa1, 86400), ==, 0);
rsa0, rsa1, 86400), OP_EQ, 0);
init_mock_ed_keys(rsa0);
MOCK(connection_or_write_var_cell_to_buf, mock_write_var_cell);
tt_int_op(connection_init_or_handshake_state(c1, 0), ==, 0);
tt_int_op(connection_init_or_handshake_state(c1, 0), OP_EQ, 0);
c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
tt_assert(! mock_got_var_cell);
tt_int_op(0, ==, connection_or_send_auth_challenge_cell(c1));
tt_ptr_op(mock_got_var_cell, OP_EQ, NULL);
tt_int_op(0, OP_EQ, connection_or_send_auth_challenge_cell(c1));
cell1 = mock_got_var_cell;
tt_int_op(0, ==, connection_or_send_auth_challenge_cell(c1));
tt_int_op(0, OP_EQ, connection_or_send_auth_challenge_cell(c1));
cell2 = mock_got_var_cell;
tt_int_op(38, ==, cell1->payload_len);
tt_int_op(38, ==, cell2->payload_len);
tt_int_op(0, ==, cell1->circ_id);
tt_int_op(0, ==, cell2->circ_id);
tt_int_op(CELL_AUTH_CHALLENGE, ==, cell1->command);
tt_int_op(CELL_AUTH_CHALLENGE, ==, cell2->command);
tt_int_op(38, OP_EQ, cell1->payload_len);
tt_int_op(38, OP_EQ, cell2->payload_len);
tt_int_op(0, OP_EQ, cell1->circ_id);
tt_int_op(0, OP_EQ, cell2->circ_id);
tt_int_op(CELL_AUTH_CHALLENGE, OP_EQ, cell1->command);
tt_int_op(CELL_AUTH_CHALLENGE, OP_EQ, cell2->command);
tt_mem_op("\x00\x02\x00\x01\x00\x03", ==, cell1->payload + 32, 6);
tt_mem_op("\x00\x02\x00\x01\x00\x03", ==, cell2->payload + 32, 6);
tt_mem_op(cell1->payload, !=, cell2->payload, 32);
tt_mem_op("\x00\x02\x00\x01\x00\x03", OP_EQ, cell1->payload + 32, 6);
tt_mem_op("\x00\x02\x00\x01\x00\x03", OP_EQ, cell2->payload + 32, 6);
tt_mem_op(cell1->payload, OP_NE, cell2->payload, 32);
done:
UNMOCK(connection_or_write_var_cell_to_buf);
@ -974,7 +974,7 @@ recv_authchallenge_setup(const struct testcase_t *test)
d->c->base_.address = tor_strdup("HaveAnAddress");
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
d->chan->conn = d->c;
tt_int_op(connection_init_or_handshake_state(d->c, 1), ==, 0);
tt_int_op(connection_init_or_handshake_state(d->c, 1), OP_EQ, 0);
d->c->link_proto = 4;
d->c->handshake_state->received_certs_cell = 1;
d->cell = var_cell_new(128);
@ -989,9 +989,9 @@ recv_authchallenge_setup(const struct testcase_t *test)
MOCK(connection_or_close_for_error, mock_close_for_err);
MOCK(connection_or_send_netinfo, mock_send_netinfo);
MOCK(connection_or_send_authenticate_cell, mock_send_authenticate);
tt_int_op(0, ==, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, ==, mock_send_authenticate_called);
tt_int_op(0, ==, mock_send_netinfo_called);
tt_int_op(0, OP_EQ, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
return d;
done:
@ -1010,11 +1010,11 @@ test_link_handshake_recv_authchallenge_ok(void *arg)
authchallenge_data_t *d = arg;
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
tt_int_op(1, ==, mock_send_authenticate_called);
tt_int_op(1, ==, mock_send_netinfo_called);
tt_int_op(1, ==, mock_send_authenticate_called_with_type); /* RSA */
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
tt_int_op(1, OP_EQ, mock_send_authenticate_called);
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
tt_int_op(1, OP_EQ, mock_send_authenticate_called_with_type); /* RSA */
done:
;
}
@ -1029,11 +1029,11 @@ test_link_handshake_recv_authchallenge_ok_ed25519(void *arg)
d->cell->payload[39] = 3;
d->cell->payload_len += 2;
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
tt_int_op(1, ==, mock_send_authenticate_called);
tt_int_op(1, ==, mock_send_netinfo_called);
tt_int_op(3, ==, mock_send_authenticate_called_with_type); /* Ed25519 */
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
tt_int_op(1, OP_EQ, mock_send_authenticate_called);
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
tt_int_op(3, OP_EQ, mock_send_authenticate_called_with_type); /* Ed25519 */
done:
;
}
@ -1045,10 +1045,10 @@ test_link_handshake_recv_authchallenge_ok_noserver(void *arg)
get_options_mutable()->ORPort_set = 0;
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, ==, mock_send_authenticate_called);
tt_int_op(0, ==, mock_send_netinfo_called);
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
done:
;
}
@ -1060,10 +1060,10 @@ test_link_handshake_recv_authchallenge_ok_unrecognized(void *arg)
d->cell->payload[37] = 99;
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
tt_int_op(0, ==, mock_close_called);
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, ==, mock_send_authenticate_called);
tt_int_op(1, ==, mock_send_netinfo_called);
tt_int_op(0, OP_EQ, mock_close_called);
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
done:
;
}
@ -1077,9 +1077,9 @@ test_link_handshake_recv_authchallenge_ok_unrecognized(void *arg)
setup_capture_of_logs(LOG_INFO); \
{ code ; } \
channel_tls_process_auth_challenge_cell(d->cell, d->chan); \
tt_int_op(1, ==, mock_close_called); \
tt_int_op(0, ==, mock_send_authenticate_called); \
tt_int_op(0, ==, mock_send_netinfo_called); \
tt_int_op(1, OP_EQ, mock_close_called); \
tt_int_op(0, OP_EQ, mock_send_authenticate_called); \
tt_int_op(0, OP_EQ, mock_send_netinfo_called); \
if (require_failure_message) { \
expect_log_msg_containing(require_failure_message); \
} \
@ -1197,17 +1197,17 @@ authenticate_data_setup(const struct testcase_t *test)
d->key1 = pk_generate(2);
d->key2 = pk_generate(3);
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
d->key1, d->key2, 86400), ==, 0);
d->key1, d->key2, 86400), OP_EQ, 0);
init_mock_ed_keys(d->key2);
d->c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
d->c1->link_proto = 3;
tt_int_op(connection_init_or_handshake_state(d->c1, 1), ==, 0);
tt_int_op(connection_init_or_handshake_state(d->c1, 1), OP_EQ, 0);
d->c2->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
d->c2->link_proto = 3;
tt_int_op(connection_init_or_handshake_state(d->c2, 0), ==, 0);
tt_int_op(connection_init_or_handshake_state(d->c2, 0), OP_EQ, 0);
var_cell_t *cell = var_cell_new(16);
cell->command = CELL_CERTS;
or_handshake_state_record_var_cell(d->c1, d->c1->handshake_state, cell, 1);
@ -1260,7 +1260,7 @@ authenticate_data_setup(const struct testcase_t *test)
authtype = AUTHTYPE_ED25519_SHA256_RFC5705;
else
authtype = AUTHTYPE_RSA_SHA256_TLSSECRET;
tt_int_op(0, ==, connection_or_send_authenticate_cell(d->c1, authtype));
tt_int_op(0, OP_EQ, connection_or_send_authenticate_cell(d->c1, authtype));
tt_assert(mock_got_var_cell);
d->cell = mock_got_var_cell;
@ -1285,65 +1285,65 @@ test_link_handshake_auth_cell(void *arg)
crypto_pk_t *auth_pubkey = NULL;
/* Is the cell well-formed on the outer layer? */
tt_int_op(d->cell->command, ==, CELL_AUTHENTICATE);
tt_int_op(d->cell->payload[0], ==, 0);
tt_int_op(d->cell->command, OP_EQ, CELL_AUTHENTICATE);
tt_int_op(d->cell->payload[0], OP_EQ, 0);
if (d->is_ed)
tt_int_op(d->cell->payload[1], ==, 3);
tt_int_op(d->cell->payload[1], OP_EQ, 3);
else
tt_int_op(d->cell->payload[1], ==, 1);
tt_int_op(ntohs(get_uint16(d->cell->payload + 2)), ==,
tt_int_op(d->cell->payload[1], OP_EQ, 1);
tt_int_op(ntohs(get_uint16(d->cell->payload + 2)), OP_EQ,
d->cell->payload_len - 4);
/* Check it out for plausibility... */
auth_ctx_t ctx;
ctx.is_ed = d->is_ed;
tt_int_op(d->cell->payload_len-4, ==, auth1_parse(&auth1,
tt_int_op(d->cell->payload_len-4, OP_EQ, auth1_parse(&auth1,
d->cell->payload+4,
d->cell->payload_len - 4, &ctx));
tt_assert(auth1);
if (d->is_ed) {
tt_mem_op(auth1->type, ==, "AUTH0003", 8);
tt_mem_op(auth1->type, OP_EQ, "AUTH0003", 8);
} else {
tt_mem_op(auth1->type, ==, "AUTH0001", 8);
tt_mem_op(auth1->type, OP_EQ, "AUTH0001", 8);
}
tt_mem_op(auth1->tlssecrets, ==, "int getRandomNumber(){return 4;}", 32);
tt_mem_op(auth1->tlssecrets, OP_EQ, "int getRandomNumber(){return 4;}", 32);
/* Is the signature okay? */
const uint8_t *start = d->cell->payload+4, *end = auth1->end_of_signed;
if (d->is_ed) {
ed25519_signature_t sig;
tt_int_op(auth1_getlen_sig(auth1), ==, ED25519_SIG_LEN);
tt_int_op(auth1_getlen_sig(auth1), OP_EQ, ED25519_SIG_LEN);
memcpy(&sig.sig, auth1_getarray_sig(auth1), ED25519_SIG_LEN);
tt_assert(!ed25519_checksig(&sig, start, end-start,
&get_current_auth_keypair()->pubkey));
} else {
uint8_t sig[128];
uint8_t digest[32];
tt_int_op(auth1_getlen_sig(auth1), >, 120);
tt_int_op(auth1_getlen_sig(auth1), OP_GT, 120);
auth_pubkey = tor_tls_cert_get_key(
d->c2->handshake_state->certs->auth_cert);
int n = crypto_pk_public_checksig(
auth_pubkey,
(char*)sig, sizeof(sig), (char*)auth1_getarray_sig(auth1),
auth1_getlen_sig(auth1));
tt_int_op(n, ==, 32);
tt_int_op(n, OP_EQ, 32);
crypto_digest256((char*)digest,
(const char*)start, end-start, DIGEST_SHA256);
tt_mem_op(sig, ==, digest, 32);
tt_mem_op(sig, OP_EQ, digest, 32);
}
/* Then feed it to c2. */
tt_int_op(d->c2->handshake_state->authenticated, ==, 0);
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 0);
channel_tls_process_authenticate_cell(d->cell, d->chan2);
tt_int_op(mock_close_called, ==, 0);
tt_int_op(d->c2->handshake_state->authenticated, ==, 1);
tt_int_op(mock_close_called, OP_EQ, 0);
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 1);
if (d->is_ed) {
tt_int_op(d->c2->handshake_state->authenticated_ed25519, ==, 1);
tt_int_op(d->c2->handshake_state->authenticated_rsa, ==, 1);
tt_int_op(d->c2->handshake_state->authenticated_ed25519, OP_EQ, 1);
tt_int_op(d->c2->handshake_state->authenticated_rsa, OP_EQ, 1);
} else {
tt_int_op(d->c2->handshake_state->authenticated_ed25519, ==, 0);
tt_int_op(d->c2->handshake_state->authenticated_rsa, ==, 1);
tt_int_op(d->c2->handshake_state->authenticated_ed25519, OP_EQ, 0);
tt_int_op(d->c2->handshake_state->authenticated_rsa, OP_EQ, 1);
}
done:
@ -1359,10 +1359,10 @@ test_link_handshake_auth_cell(void *arg)
const char *require_failure_message = NULL; \
setup_capture_of_logs(LOG_INFO); \
{ code ; } \
tt_int_op(d->c2->handshake_state->authenticated, ==, 0); \
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 0); \
channel_tls_process_authenticate_cell(d->cell, d->chan2); \
tt_int_op(mock_close_called, ==, 1); \
tt_int_op(d->c2->handshake_state->authenticated, ==, 0); \
tt_int_op(mock_close_called, OP_EQ, 1); \
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 0); \
if (require_failure_message) { \
expect_log_msg_containing(require_failure_message); \
} \
@ -1390,8 +1390,8 @@ test_link_handshake_auth_already_authenticated(void *arg)
setup_capture_of_logs(LOG_INFO);
d->c2->handshake_state->authenticated = 1;
channel_tls_process_authenticate_cell(d->cell, d->chan2);
tt_int_op(mock_close_called, ==, 1);
tt_int_op(d->c2->handshake_state->authenticated, ==, 1);
tt_int_op(mock_close_called, OP_EQ, 1);
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 1);
expect_log_msg_containing("The peer is already authenticated");
done:
teardown_capture_of_logs();
@ -1425,7 +1425,7 @@ AUTHENTICATE_FAIL(truncated_2,
d->cell->payload[3]++)
AUTHENTICATE_FAIL(tooshort_1,
require_failure_message = "Authenticator was too short";
tt_int_op(d->cell->payload_len, >=, 260);
tt_int_op(d->cell->payload_len, OP_GE, 260);
d->cell->payload[2] -= 1;
d->cell->payload_len -= 256;)
AUTHENTICATE_FAIL(badcontent,

View File

@ -107,7 +107,7 @@ test_sigsafe_err(void *arg)
close(STDERR_FILENO);
content = read_file_to_str(fn, 0, NULL);
tt_assert(content != NULL);
tt_ptr_op(content, OP_NE, NULL);
tor_split_lines(lines, content, (int)strlen(content));
tt_int_op(smartlist_len(lines), OP_GE, 5);
@ -140,7 +140,7 @@ test_ratelim(void *arg)
char *msg = NULL;
msg = rate_limit_log(&ten_min, now);
tt_assert(msg != NULL);
tt_ptr_op(msg, OP_NE, NULL);
tt_str_op(msg, OP_EQ, ""); /* nothing was suppressed. */
tt_int_op(ten_min.last_allowed, OP_EQ, now);
@ -150,14 +150,14 @@ test_ratelim(void *arg)
for (i = 0; i < 9; ++i) {
now += 60; /* one minute has passed. */
msg = rate_limit_log(&ten_min, now);
tt_assert(msg == NULL);
tt_ptr_op(msg, OP_EQ, NULL);
tt_int_op(ten_min.last_allowed, OP_EQ, start);
tt_int_op(ten_min.n_calls_since_last_time, OP_EQ, i + 1);
}
now += 240; /* Okay, we can be done. */
msg = rate_limit_log(&ten_min, now);
tt_assert(msg != NULL);
tt_ptr_op(msg, OP_NE, NULL);
tt_str_op(msg, OP_EQ,
" [9 similar message(s) suppressed in last 600 seconds]");
done:

View File

@ -464,7 +464,7 @@ test_md_generate(void *arg)
microdesc_free(md);
md = NULL;
md = dirvote_create_microdescriptor(ri, 21);
tt_str_op(md->body, ==, test_md_18);
tt_str_op(md->body, OP_EQ, test_md_18);
routerinfo_free(ri);
ri = router_parse_entry_from_string(test_ri2, NULL, 0, 0, NULL, NULL);
@ -472,12 +472,12 @@ test_md_generate(void *arg)
microdesc_free(md);
md = NULL;
md = dirvote_create_microdescriptor(ri, 18);
tt_str_op(md->body, ==, test_md2_18);
tt_str_op(md->body, OP_EQ, test_md2_18);
microdesc_free(md);
md = NULL;
md = dirvote_create_microdescriptor(ri, 21);
tt_str_op(md->body, ==, test_md2_21);
tt_str_op(md->body, OP_EQ, test_md2_21);
tt_assert(ed25519_pubkey_eq(md->ed25519_identity_pkey,
&ri->cache_info.signing_key_cert->signing_key));
@ -823,14 +823,14 @@ test_md_corrupt_desc(void *arg)
"@last-listed 2015-06-22 10:00:00\n"
"onion-k\n",
NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
tt_int_op(smartlist_len(sl), ==, 0);
tt_int_op(smartlist_len(sl), OP_EQ, 0);
smartlist_free(sl);
sl = microdescs_add_to_cache(get_microdesc_cache(),
"@last-listed 2015-06-22 10:00:00\n"
"wiggly\n",
NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
tt_int_op(smartlist_len(sl), ==, 0);
tt_int_op(smartlist_len(sl), OP_EQ, 0);
smartlist_free(sl);
tor_asprintf(&cp, "%s\n%s", test_md1, "@foobar\nonion-wobble\n");
@ -838,7 +838,7 @@ test_md_corrupt_desc(void *arg)
sl = microdescs_add_to_cache(get_microdesc_cache(),
cp, cp+strlen(cp),
SAVED_IN_JOURNAL, 0, time(NULL), NULL);
tt_int_op(smartlist_len(sl), ==, 0);
tt_int_op(smartlist_len(sl), OP_EQ, 0);
done:
tor_free(cp);

View File

@ -52,7 +52,7 @@ kill_conn_list_mock(smartlist_t *conns)
{
++kill_conn_list_calls;
tt_assert(conns != NULL);
tt_ptr_op(conns, OP_NE, NULL);
kill_conn_list_killed += smartlist_len(conns);
@ -248,7 +248,7 @@ close_for_error_mock(or_connection_t *orconn, int flush)
{
(void)flush;
tt_assert(orconn != NULL);
tt_ptr_op(orconn, OP_NE, NULL);
++cfe_calls;
done:
@ -264,7 +264,7 @@ mark_for_close_oos_mock(connection_t *conn,
(void)line;
(void)file;
tt_assert(conn != NULL);
tt_ptr_op(conn, OP_NE, NULL);
++mark_calls;
done:
@ -298,8 +298,8 @@ test_oos_kill_conn_list(void *arg)
dir_c2->base_.purpose = DIR_PURPOSE_MIN_;
c2 = TO_CONN(dir_c2);
tt_assert(c1 != NULL);
tt_assert(c2 != NULL);
tt_ptr_op(c1, OP_NE, NULL);
tt_ptr_op(c2, OP_NE, NULL);
/* Make list */
l = smartlist_new();
@ -345,7 +345,7 @@ get_num_circuits_mock(or_connection_t *conn)
{
int circs = 0;
tt_assert(conn != NULL);
tt_ptr_op(conn, OP_NE, NULL);
if (conns_with_circs &&
smartlist_contains(conns_with_circs, TO_CONN(conn))) {
@ -397,7 +397,7 @@ test_oos_pick_oos_victims(void *arg)
/* Try picking one */
picked = pick_oos_victims(1);
/* It should be the one with circuits */
tt_assert(picked != NULL);
tt_ptr_op(picked, OP_NE, NULL);
tt_int_op(smartlist_len(picked), OP_EQ, 1);
tt_assert(smartlist_contains(picked, smartlist_get(conns_for_mock, 0)));
smartlist_free(picked);
@ -405,14 +405,14 @@ test_oos_pick_oos_victims(void *arg)
/* Try picking none */
picked = pick_oos_victims(0);
/* We should get an empty list */
tt_assert(picked != NULL);
tt_ptr_op(picked, OP_NE, NULL);
tt_int_op(smartlist_len(picked), OP_EQ, 0);
smartlist_free(picked);
/* Try picking two */
picked = pick_oos_victims(2);
/* We should get both active orconns */
tt_assert(picked != NULL);
tt_ptr_op(picked, OP_NE, NULL);
tt_int_op(smartlist_len(picked), OP_EQ, 2);
tt_assert(smartlist_contains(picked, smartlist_get(conns_for_mock, 0)));
tt_assert(smartlist_contains(picked, smartlist_get(conns_for_mock, 1)));

View File

@ -299,7 +299,7 @@ test_have_enough_mem_for_dircache(void *arg)
/* 300 MB RAM available, DirCache enabled */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(300), &msg);
tt_int_op(r, OP_EQ, 0);
tt_assert(!msg);
tt_ptr_op(msg, OP_EQ, NULL);
/* 200 MB RAM available, DirCache enabled */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(200), &msg);
@ -322,7 +322,7 @@ test_have_enough_mem_for_dircache(void *arg)
/* 300 MB RAM available, DirCache enabled, Bridge */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(300), &msg);
tt_int_op(r, OP_EQ, 0);
tt_assert(!msg);
tt_ptr_op(msg, OP_EQ, NULL);
/* 200 MB RAM available, DirCache enabled, Bridge */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(200), &msg);
@ -345,7 +345,7 @@ test_have_enough_mem_for_dircache(void *arg)
/* 200 MB RAM available, DirCache disabled */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(200), &msg);
tt_int_op(r, OP_EQ, 0);
tt_assert(!msg);
tt_ptr_op(msg, OP_EQ, NULL);
/* 300 MB RAM available, DirCache disabled */
r = have_enough_mem_for_dircache(opt, MEGABYTEIFY(300), &msg);
@ -430,24 +430,24 @@ get_options_test_data(const char *conf)
result->opt->ConnectionPadding = -1; // default must be "auto"
rv = config_get_lines(conf, &cl, 1);
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
rv = config_assign(&options_format, result->opt, cl, 0, &msg);
if (msg) {
/* Display the parse error message by comparing it with an empty string */
tt_str_op(msg, OP_EQ, "");
}
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
config_free_lines(cl);
result->opt->LogTimeGranularity = 1;
result->opt->TokenBucketRefillInterval = 1;
rv = config_get_lines(TEST_OPTIONS_OLD_VALUES, &cl, 1);
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
rv = config_assign(&options_format, result->def_opt, cl, 0, &msg);
if (msg) {
/* Display the parse error message by comparing it with an empty string */
tt_str_op(msg, OP_EQ, "");
}
tt_assert(rv == 0);
tt_int_op(rv, OP_EQ, 0);
done:
config_free_lines(cl);

View File

@ -59,7 +59,7 @@ test_policy_summary_helper_family_flags(const char *policy_str,
summary = policy_summarize(policy, family);
tt_assert(summary != NULL);
tt_ptr_op(summary, OP_NE, NULL);
tt_str_op(summary,OP_EQ, expected_summary);
short_policy = parse_short_policy(summary);
@ -147,7 +147,7 @@ test_policies_general(void *arg)
p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
tt_int_op(ADDR_POLICY_REJECT,OP_EQ, p->policy_type);
tor_addr_from_ipv4h(&tar, 0xc0a80000u);
tt_int_op(0,OP_EQ, tor_addr_compare(&p->addr, &tar, CMP_EXACT));
@ -192,75 +192,75 @@ test_policies_general(void *arg)
policy3 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject *:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy3, p);
p = router_parse_addr_policy_item_from_string("accept *:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy3, p);
policy4 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept *:443", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy4, p);
p = router_parse_addr_policy_item_from_string("accept *:443", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy4, p);
policy5 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject 0.0.0.0/8:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 169.254.0.0/16:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 127.0.0.0/8:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*",
-1, &malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 10.0.0.0/8:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 172.16.0.0/12:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 80.190.250.90:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject *:1-65534", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject *:65535", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("accept *:1-65535", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy5, p);
policy6 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 43.3.0.0/9:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy6, p);
policy7 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 0.0.0.0/8:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy7, p);
tt_int_op(0, OP_EQ, policies_parse_exit_policy(NULL, &policy8,
@ -282,13 +282,13 @@ test_policies_general(void *arg)
policy10 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept6 *:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy10, p);
policy11 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject6 *:*", -1,
&malformed_list);
tt_assert(p != NULL);
tt_ptr_op(p, OP_NE, NULL);
smartlist_add(policy11, p);
tt_assert(!exit_policy_is_general_exit(policy));
@ -392,21 +392,21 @@ test_policies_general(void *arg)
p = router_parse_addr_policy_item_from_string("acce::abcd",
ADDR_POLICY_ACCEPT,
&malformed_list);
tt_assert(!p);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
malformed_list = 0;
p = router_parse_addr_policy_item_from_string("7:1234",
ADDR_POLICY_ACCEPT,
&malformed_list);
tt_assert(!p);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
malformed_list = 0;
p = router_parse_addr_policy_item_from_string("::",
ADDR_POLICY_ACCEPT,
&malformed_list);
tt_assert(!p);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
malformed_list = 0;
@ -968,63 +968,63 @@ test_policies_general(void *arg)
/* Make sure that IPv4 addresses are ignored in accept6/reject6 lines. */
p = router_parse_addr_policy_item_from_string("accept6 1.2.3.4:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(!malformed_list);
p = router_parse_addr_policy_item_from_string("reject6 2.4.6.0/24:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(!malformed_list);
p = router_parse_addr_policy_item_from_string("accept6 *4:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(!malformed_list);
/* Make sure malformed policies are detected as such. */
p = router_parse_addr_policy_item_from_string("bad_token *4:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("accept6 **:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("accept */15:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("reject6 */:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("accept 127.0.0.1/33:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("accept6 [::1]/129:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("reject 8.8.8.8/-1:*", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("reject 8.8.4.4:10-5", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
p = router_parse_addr_policy_item_from_string("reject 1.2.3.4:-1", -1,
&malformed_list);
tt_assert(p == NULL);
tt_ptr_op(p, OP_EQ, NULL);
tt_assert(malformed_list);
/* Test a too-long policy. */
@ -1148,7 +1148,7 @@ test_policies_reject_exit_address(void *arg)
/* test that IPv4 addresses are rejected on an IPv4-only exit */
policies_parse_exit_policy_reject_private(&policy, 0, ipv4_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1158,12 +1158,12 @@ test_policies_reject_exit_address(void *arg)
* on IPv4-only exits, so policies_parse_exit_policy_reject_private doesn't
* need to do anything) */
policies_parse_exit_policy_reject_private(&policy, 0, ipv6_list, 0, 0);
tt_assert(policy == NULL);
tt_ptr_op(policy, OP_EQ, NULL);
/* test that only IPv4 addresses are rejected on an IPv4-only exit */
policies_parse_exit_policy_reject_private(&policy, 0, both_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1171,7 +1171,7 @@ test_policies_reject_exit_address(void *arg)
/* Test that lists with duplicate entries produce the same results */
policies_parse_exit_policy_reject_private(&policy, 0, dupl_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1181,7 +1181,7 @@ test_policies_reject_exit_address(void *arg)
/* test that IPv4 addresses are rejected on an IPv4/IPv6 exit */
policies_parse_exit_policy_reject_private(&policy, 1, ipv4_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1189,7 +1189,7 @@ test_policies_reject_exit_address(void *arg)
/* test that IPv6 addresses are rejected on an IPv4/IPv6 exit */
policies_parse_exit_policy_reject_private(&policy, 1, ipv6_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv6_addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1197,7 +1197,7 @@ test_policies_reject_exit_address(void *arg)
/* test that IPv4 and IPv6 addresses are rejected on an IPv4/IPv6 exit */
policies_parse_exit_policy_reject_private(&policy, 1, both_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 2);
tt_int_op(smartlist_len(policy), OP_EQ, 2);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
tt_assert(test_policy_has_address_helper(policy, &ipv6_addr));
addr_policy_list_free(policy);
@ -1206,7 +1206,7 @@ test_policies_reject_exit_address(void *arg)
/* Test that lists with duplicate entries produce the same results */
policies_parse_exit_policy_reject_private(&policy, 1, dupl_list, 0, 0);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 2);
tt_int_op(smartlist_len(policy), OP_EQ, 2);
tt_assert(test_policy_has_address_helper(policy, &ipv4_addr));
tt_assert(test_policy_has_address_helper(policy, &ipv6_addr));
addr_policy_list_free(policy);
@ -1258,7 +1258,7 @@ test_policies_reject_port_address(void *arg)
* with IPv6 addresses on IPv4-only exits) */
policies_parse_exit_policy_reject_private(&policy, 0, NULL, 0, 1);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 1);
tt_int_op(smartlist_len(policy), OP_EQ, 1);
tt_assert(test_policy_has_address_helper(policy, &ipv4_port->addr));
addr_policy_list_free(policy);
policy = NULL;
@ -1266,7 +1266,7 @@ test_policies_reject_port_address(void *arg)
/* test that IPv4 and IPv6 ports are rejected on an IPv4/IPv6 exit */
policies_parse_exit_policy_reject_private(&policy, 1, NULL, 0, 1);
tt_assert(policy);
tt_assert(smartlist_len(policy) == 2);
tt_int_op(smartlist_len(policy), OP_EQ, 2);
tt_assert(test_policy_has_address_helper(policy, &ipv4_port->addr));
tt_assert(test_policy_has_address_helper(policy, &ipv6_port->addr));
addr_policy_list_free(policy);
@ -1337,7 +1337,7 @@ test_policies_reject_interface_address(void *arg)
/* test that no addresses are rejected when none are supplied/requested */
policies_parse_exit_policy_reject_private(&policy, 0, NULL, 0, 0);
tt_assert(policy == NULL);
tt_ptr_op(policy, OP_EQ, NULL);
/* test that only IPv4 interface addresses are rejected on an IPv4-only exit
* (and allow for duplicates)
@ -1372,7 +1372,7 @@ test_policies_reject_interface_address(void *arg)
/* test that no addresses are rejected when none are supplied/requested */
policies_parse_exit_policy_reject_private(&policy, 0, NULL, 0, 0);
tt_assert(policy == NULL);
tt_ptr_op(policy, OP_EQ, NULL);
/* test that only IPv4 interface addresses are rejected on an IPv4-only exit
*/
@ -1528,15 +1528,15 @@ test_policies_getinfo_helper_policies(void *arg)
memset(&mock_my_routerinfo, 0, sizeof(mock_my_routerinfo));
rv = getinfo_helper_policies(NULL, "exit-policy/default", &answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tor_free(answer);
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/default",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tor_free(answer);
@ -1550,15 +1550,15 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/relay",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) == 0);
tor_free(answer);
rv = getinfo_helper_policies(NULL, "exit-policy/ipv4", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
ipv4_len = strlen(answer);
tt_assert(ipv4_len == 0 || ipv4_len == strlen(DEFAULT_POLICY_STRING));
tt_assert(ipv4_len == 0 || !strcasecmp(answer, DEFAULT_POLICY_STRING));
@ -1566,8 +1566,8 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/ipv6", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
ipv6_len = strlen(answer);
tt_assert(ipv6_len == 0 || ipv6_len == strlen(DEFAULT_POLICY_STRING));
tt_assert(ipv6_len == 0 || !strcasecmp(answer, DEFAULT_POLICY_STRING));
@ -1575,8 +1575,8 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/full", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
/* It's either empty or it's the default */
tt_assert(strlen(answer) == 0 || !strcasecmp(answer, DEFAULT_POLICY_STRING));
tor_free(answer);
@ -1599,8 +1599,8 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/relay",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tor_free(answer);
@ -1609,8 +1609,8 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/relay",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tor_free(answer);
@ -1619,8 +1619,8 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/relay",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tor_free(answer);
@ -1629,31 +1629,31 @@ test_policies_getinfo_helper_policies(void *arg)
rv = getinfo_helper_policies(NULL, "exit-policy/reject-private/relay",
&answer, &errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) == 0);
tor_free(answer);
rv = getinfo_helper_policies(NULL, "exit-policy/ipv4", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
ipv4_len = strlen(answer);
tt_assert(ipv4_len > 0);
tor_free(answer);
rv = getinfo_helper_policies(NULL, "exit-policy/ipv6", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
ipv6_len = strlen(answer);
tt_assert(ipv6_len > 0);
tor_free(answer);
rv = getinfo_helper_policies(NULL, "exit-policy/full", &answer,
&errmsg);
tt_assert(rv == 0);
tt_assert(answer != NULL);
tt_int_op(rv, OP_EQ, 0);
tt_ptr_op(answer, OP_NE, NULL);
tt_assert(strlen(answer) > 0);
tt_assert(strlen(answer) == ipv4_len + ipv6_len + 1);
tor_free(answer);
@ -1746,34 +1746,34 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.ClientUseIPv6 = 1;
mock_options.UseBridges = 0;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Preferring IPv4 */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 0),
OP_EQ, 0);
/* Preferring IPv6 */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 1)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 1)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 1)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 1)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 1),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 1),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 1),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 1),
OP_EQ, 0);
/* Test the function's address matching with UseBridges on */
memset(&mock_options, 0, sizeof(or_options_t));
@ -1781,46 +1781,46 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.ClientUseIPv6 = 1;
mock_options.UseBridges = 1;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Preferring IPv4 */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 0),
OP_EQ, 0);
/* Preferring IPv6 */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 1)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 1)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 1)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 1)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 1, 1),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 1, 1),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 1, 1),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 1, 1),
OP_EQ, 0);
/* bridge clients always use IPv6, regardless of ClientUseIPv6 */
mock_options.ClientUseIPv4 = 1;
mock_options.ClientUseIPv6 = 0;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Test the function's address matching with IPv4 on */
memset(&mock_options, 0, sizeof(or_options_t));
@ -1828,14 +1828,14 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.ClientUseIPv6 = 0;
mock_options.UseBridges = 0;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Test the function's address matching with IPv6 on */
memset(&mock_options, 0, sizeof(or_options_t));
@ -1843,14 +1843,14 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.ClientUseIPv6 = 1;
mock_options.UseBridges = 0;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Test the function's address matching with ClientUseIPv4 0.
* This means "use IPv6" regardless of the other settings. */
@ -1859,14 +1859,14 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.ClientUseIPv6 = 0;
mock_options.UseBridges = 0;
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&r_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&r_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* Test the function's address matching for unusual inputs */
memset(&mock_options, 0, sizeof(or_options_t));
@ -1875,27 +1875,28 @@ test_policies_fascist_firewall_allows_address(void *arg)
mock_options.UseBridges = 1;
/* NULL and tor_addr_is_null addresses are rejected */
tt_assert(fascist_firewall_allows_address(NULL, port, policy, 0, 0) == 0);
tt_assert(fascist_firewall_allows_address(&n_ipv4_addr, port, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&n_ipv6_addr, port, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(NULL, port, policy, 0, 0), OP_EQ,
0);
tt_int_op(fascist_firewall_allows_address(&n_ipv4_addr, port, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&n_ipv6_addr, port, policy, 0, 0),
OP_EQ, 0);
/* zero ports are rejected */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, 0, policy, 0, 0)
== 0);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, 0, policy, 0, 0)
== 0);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, 0, policy, 0, 0),
OP_EQ, 0);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, 0, policy, 0, 0),
OP_EQ, 0);
/* NULL and empty policies accept everything */
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, NULL, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, NULL, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv4_addr, port, e_policy, 0, 0)
== 1);
tt_assert(fascist_firewall_allows_address(&ipv6_addr, port, e_policy, 0, 0)
== 1);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, NULL, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, NULL, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv4_addr, port, e_policy, 0, 0),
OP_EQ, 1);
tt_int_op(fascist_firewall_allows_address(&ipv6_addr, port, e_policy, 0, 0),
OP_EQ, 1);
done:
addr_policy_free(item);
@ -2032,12 +2033,12 @@ test_policies_fascist_firewall_choose_address(void *arg)
== &ipv6_or_ap);
/* null both OR addresses */
tt_assert(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 0,
FIREWALL_OR_CONNECTION, 0, 1)
== NULL);
tt_assert(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 1,
FIREWALL_OR_CONNECTION, 0, 0)
== NULL);
tt_ptr_op(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 0,
FIREWALL_OR_CONNECTION, 0, 1),
OP_EQ, NULL);
tt_ptr_op(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 1,
FIREWALL_OR_CONNECTION, 0, 0),
OP_EQ, NULL);
/* null preferred Dir addresses */
tt_assert(fascist_firewall_choose_address(&ipv4_dir_ap, &n_ipv6_ap, 0,
@ -2048,12 +2049,12 @@ test_policies_fascist_firewall_choose_address(void *arg)
== &ipv6_dir_ap);
/* null both Dir addresses */
tt_assert(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 0,
FIREWALL_DIR_CONNECTION, 0, 1)
== NULL);
tt_assert(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 1,
FIREWALL_DIR_CONNECTION, 0, 0)
== NULL);
tt_ptr_op(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 0,
FIREWALL_DIR_CONNECTION, 0, 1),
OP_EQ, NULL);
tt_ptr_op(fascist_firewall_choose_address(&n_ipv4_ap, &n_ipv6_ap, 1,
FIREWALL_DIR_CONNECTION, 0, 0),
OP_EQ, NULL);
/* Prefer IPv4 but want IPv6 (contradictory) */
tt_assert(fascist_firewall_choose_address(&ipv4_or_ap, &ipv6_or_ap, 0,

View File

@ -88,27 +88,27 @@ test_protover_parse_fail(void *arg)
/* random junk */
elts = parse_protocol_list("!!3@*");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
/* Missing equals sign in an entry */
elts = parse_protocol_list("Link=4 Haprauxymatyve Desc=9");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
/* Missing word. */
elts = parse_protocol_list("Link=4 =3 Desc=9");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
/* Broken numbers */
elts = parse_protocol_list("Link=fred");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
elts = parse_protocol_list("Link=1,fred");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
elts = parse_protocol_list("Link=1,fred,3");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
/* Broken range */
elts = parse_protocol_list("Link=1,9-8,3");
tt_assert(elts == NULL);
tt_ptr_op(elts, OP_EQ, NULL);
done:
;
@ -151,16 +151,16 @@ test_protover_all_supported(void *arg)
char *msg = NULL;
tt_assert(protover_all_supported(NULL, &msg));
tt_assert(msg == NULL);
tt_ptr_op(msg, OP_EQ, NULL);
tt_assert(protover_all_supported("", &msg));
tt_assert(msg == NULL);
tt_ptr_op(msg, OP_EQ, NULL);
// Some things that we do support
tt_assert(protover_all_supported("Link=3-4", &msg));
tt_assert(msg == NULL);
tt_ptr_op(msg, OP_EQ, NULL);
tt_assert(protover_all_supported("Link=3-4 Desc=2", &msg));
tt_assert(msg == NULL);
tt_ptr_op(msg, OP_EQ, NULL);
// Some things we don't support
tt_assert(! protover_all_supported("Wombat=9", &msg));

View File

@ -40,34 +40,34 @@ test_pt_parsing(void *arg)
/* incomplete cmethod */
strlcpy(line,"CMETHOD trebuchet",sizeof(line));
tt_assert(parse_cmethod_line(line, mp) < 0);
tt_int_op(parse_cmethod_line(line, mp), OP_LT, 0);
reset_mp(mp);
/* wrong proxy type */
strlcpy(line,"CMETHOD trebuchet dog 127.0.0.1:1999",sizeof(line));
tt_assert(parse_cmethod_line(line, mp) < 0);
tt_int_op(parse_cmethod_line(line, mp), OP_LT, 0);
reset_mp(mp);
/* wrong addrport */
strlcpy(line,"CMETHOD trebuchet socks4 abcd",sizeof(line));
tt_assert(parse_cmethod_line(line, mp) < 0);
tt_int_op(parse_cmethod_line(line, mp), OP_LT, 0);
reset_mp(mp);
/* correct line */
strlcpy(line,"CMETHOD trebuchet socks5 127.0.0.1:1999",sizeof(line));
tt_assert(parse_cmethod_line(line, mp) == 0);
tt_assert(smartlist_len(mp->transports) == 1);
tt_int_op(parse_cmethod_line(line, mp), OP_EQ, 0);
tt_int_op(smartlist_len(mp->transports), OP_EQ, 1);
transport = smartlist_get(mp->transports, 0);
/* test registered address of transport */
tor_addr_parse(&test_addr, "127.0.0.1");
tt_assert(tor_addr_eq(&test_addr, &transport->addr));
/* test registered port of transport */
tt_assert(transport->port == 1999);
tt_uint_op(transport->port, OP_EQ, 1999);
/* test registered SOCKS version of transport */
tt_assert(transport->socks_version == PROXY_SOCKS5);
tt_int_op(transport->socks_version, OP_EQ, PROXY_SOCKS5);
/* test registered name of transport */
tt_str_op(transport->name,OP_EQ, "trebuchet");
@ -75,26 +75,26 @@ test_pt_parsing(void *arg)
/* incomplete smethod */
strlcpy(line,"SMETHOD trebuchet",sizeof(line));
tt_assert(parse_smethod_line(line, mp) < 0);
tt_int_op(parse_smethod_line(line, mp), OP_LT, 0);
reset_mp(mp);
/* wrong addr type */
strlcpy(line,"SMETHOD trebuchet abcd",sizeof(line));
tt_assert(parse_smethod_line(line, mp) < 0);
tt_int_op(parse_smethod_line(line, mp), OP_LT, 0);
reset_mp(mp);
/* cowwect */
strlcpy(line,"SMETHOD trebuchy 127.0.0.2:2999",sizeof(line));
tt_assert(parse_smethod_line(line, mp) == 0);
tt_assert(smartlist_len(mp->transports) == 1);
tt_int_op(parse_smethod_line(line, mp), OP_EQ, 0);
tt_int_op(smartlist_len(mp->transports), OP_EQ, 1);
transport = smartlist_get(mp->transports, 0);
/* test registered address of transport */
tor_addr_parse(&test_addr, "127.0.0.2");
tt_assert(tor_addr_eq(&test_addr, &transport->addr));
/* test registered port of transport */
tt_assert(transport->port == 2999);
tt_uint_op(transport->port, OP_EQ, 2999);
/* test registered name of transport */
tt_str_op(transport->name,OP_EQ, "trebuchy");
@ -104,7 +104,7 @@ test_pt_parsing(void *arg)
strlcpy(line,"SMETHOD trebuchet 127.0.0.1:9999 "
"ARGS:counterweight=3,sling=snappy",
sizeof(line));
tt_assert(parse_smethod_line(line, mp) == 0);
tt_int_op(parse_smethod_line(line, mp), OP_EQ, 0);
tt_int_op(1, OP_EQ, smartlist_len(mp->transports));
{
const transport_t *transport_ = smartlist_get(mp->transports, 0);
@ -119,15 +119,15 @@ test_pt_parsing(void *arg)
/* unsupported version */
strlcpy(line,"VERSION 666",sizeof(line));
tt_assert(parse_version(line, mp) < 0);
tt_int_op(parse_version(line, mp), OP_LT, 0);
/* incomplete VERSION */
strlcpy(line,"VERSION ",sizeof(line));
tt_assert(parse_version(line, mp) < 0);
tt_int_op(parse_version(line, mp), OP_LT, 0);
/* correct VERSION */
strlcpy(line,"VERSION 1",sizeof(line));
tt_assert(parse_version(line, mp) == 0);
tt_int_op(parse_version(line, mp), OP_EQ, 0);
done:
reset_mp(mp);
@ -461,7 +461,7 @@ test_get_pt_proxy_uri(void *arg)
/* Test with no proxy. */
uri = get_pt_proxy_uri();
tt_assert(uri == NULL);
tt_ptr_op(uri, OP_EQ, NULL);
/* Test with a SOCKS4 proxy. */
options->Socks4Proxy = tor_strdup("192.0.2.1:1080");

View File

@ -91,14 +91,14 @@ test_relay_append_cell_to_circuit_queue(void *arg)
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), nchan, cell,
CELL_DIRECTION_OUT, 0);
new_count = get_mock_scheduler_has_waiting_cells_count();
tt_int_op(new_count, ==, old_count + 1);
tt_int_op(new_count, OP_EQ, old_count + 1);
/* Now try the reverse direction */
old_count = get_mock_scheduler_has_waiting_cells_count();
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), pchan, cell,
CELL_DIRECTION_IN, 0);
new_count = get_mock_scheduler_has_waiting_cells_count();
tt_int_op(new_count, ==, old_count + 1);
tt_int_op(new_count, OP_EQ, old_count + 1);
UNMOCK(scheduler_channel_has_waiting_cells);

View File

@ -946,9 +946,9 @@ test_rend_cache_free_all(void *data)
rend_cache_free_all();
tt_assert(!rend_cache);
tt_assert(!rend_cache_v2_dir);
tt_assert(!rend_cache_failure);
tt_ptr_op(rend_cache, OP_EQ, NULL);
tt_ptr_op(rend_cache_v2_dir, OP_EQ, NULL);
tt_ptr_op(rend_cache_failure, OP_EQ, NULL);
tt_assert(!rend_cache_total_allocation);
done:

View File

@ -38,7 +38,7 @@ test_replaycache_alloc(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
done:
if (r) replaycache_free(r);
@ -54,15 +54,15 @@ test_replaycache_badalloc(void *arg)
/* Negative horizon should fail */
(void)arg;
r = replaycache_new(-600, 300);
tt_assert(r == NULL);
tt_ptr_op(r, OP_EQ, NULL);
/* Negative interval should get adjusted to zero */
r = replaycache_new(600, -300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
tt_int_op(r->scrub_interval,OP_EQ, 0);
replaycache_free(r);
/* Negative horizon and negative interval should still fail */
r = replaycache_new(-600, -300);
tt_assert(r == NULL);
tt_ptr_op(r, OP_EQ, NULL);
done:
if (r) replaycache_free(r);
@ -90,7 +90,7 @@ test_replaycache_miss(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -123,7 +123,7 @@ test_replaycache_hit(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -161,7 +161,7 @@ test_replaycache_age(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -193,7 +193,7 @@ test_replaycache_elapsed(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -220,7 +220,7 @@ test_replaycache_noexpire(void *arg)
(void)arg;
r = replaycache_new(0, 0);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -251,7 +251,7 @@ test_replaycache_scrub(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
/* Set up like in test_replaycache_hit() */
result =
@ -294,7 +294,7 @@ test_replaycache_future(void *arg)
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
/* Set up like in test_replaycache_hit() */
result =
@ -343,7 +343,7 @@ test_replaycache_realtime(void *arg)
/* Test the realtime as well as *_internal() entry points */
(void)arg;
r = replaycache_new(600, 300);
tt_assert(r != NULL);
tt_ptr_op(r, OP_NE, NULL);
/* This should miss */
result =

View File

@ -92,8 +92,8 @@ test_routerkeys_ed_certs(void *args)
uint8_t *junk = NULL;
char *base64 = NULL;
tt_int_op(0,==,ed25519_keypair_generate(&kp1, 0));
tt_int_op(0,==,ed25519_keypair_generate(&kp2, 0));
tt_int_op(0,OP_EQ,ed25519_keypair_generate(&kp1, 0));
tt_int_op(0,OP_EQ,ed25519_keypair_generate(&kp2, 0));
for (int i = 0; i <= 1; ++i) {
uint32_t flags = i ? CERT_FLAG_INCLUDE_SIGNING_KEY : 0;
@ -101,45 +101,45 @@ test_routerkeys_ed_certs(void *args)
cert[i] = tor_cert_create(&kp1, 5, &kp2.pubkey, now, 10000, flags);
tt_assert(cert[i]);
tt_assert(cert[i]->sig_bad == 0);
tt_assert(cert[i]->sig_ok == 1);
tt_assert(cert[i]->cert_expired == 0);
tt_assert(cert[i]->cert_valid == 1);
tt_int_op(cert[i]->cert_type, ==, 5);
tt_mem_op(cert[i]->signed_key.pubkey, ==, &kp2.pubkey.pubkey, 32);
tt_mem_op(cert[i]->signing_key.pubkey, ==, &kp1.pubkey.pubkey, 32);
tt_int_op(cert[i]->signing_key_included, ==, i);
tt_uint_op(cert[i]->sig_bad, OP_EQ, 0);
tt_uint_op(cert[i]->sig_ok, OP_EQ, 1);
tt_uint_op(cert[i]->cert_expired, OP_EQ, 0);
tt_uint_op(cert[i]->cert_valid, OP_EQ, 1);
tt_int_op(cert[i]->cert_type, OP_EQ, 5);
tt_mem_op(cert[i]->signed_key.pubkey, OP_EQ, &kp2.pubkey.pubkey, 32);
tt_mem_op(cert[i]->signing_key.pubkey, OP_EQ, &kp1.pubkey.pubkey, 32);
tt_int_op(cert[i]->signing_key_included, OP_EQ, i);
tt_assert(cert[i]->encoded);
tt_int_op(cert[i]->encoded_len, ==, 104 + 36 * i);
tt_int_op(cert[i]->encoded[0], ==, 1);
tt_int_op(cert[i]->encoded[1], ==, 5);
tt_int_op(cert[i]->encoded_len, OP_EQ, 104 + 36 * i);
tt_int_op(cert[i]->encoded[0], OP_EQ, 1);
tt_int_op(cert[i]->encoded[1], OP_EQ, 5);
parsed_cert[i] = tor_cert_parse(cert[i]->encoded, cert[i]->encoded_len);
tt_assert(parsed_cert[i]);
tt_int_op(cert[i]->encoded_len, ==, parsed_cert[i]->encoded_len);
tt_mem_op(cert[i]->encoded, ==, parsed_cert[i]->encoded,
tt_int_op(cert[i]->encoded_len, OP_EQ, parsed_cert[i]->encoded_len);
tt_mem_op(cert[i]->encoded, OP_EQ, parsed_cert[i]->encoded,
cert[i]->encoded_len);
tt_assert(parsed_cert[i]->sig_bad == 0);
tt_assert(parsed_cert[i]->sig_ok == 0);
tt_assert(parsed_cert[i]->cert_expired == 0);
tt_assert(parsed_cert[i]->cert_valid == 0);
tt_uint_op(parsed_cert[i]->sig_bad, OP_EQ, 0);
tt_uint_op(parsed_cert[i]->sig_ok, OP_EQ, 0);
tt_uint_op(parsed_cert[i]->cert_expired, OP_EQ, 0);
tt_uint_op(parsed_cert[i]->cert_valid, OP_EQ, 0);
/* Expired */
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now + 30000),
<, 0);
tt_assert(parsed_cert[i]->cert_expired == 1);
OP_LT, 0);
tt_uint_op(parsed_cert[i]->cert_expired, OP_EQ, 1);
parsed_cert[i]->cert_expired = 0;
/* Wrong key */
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp2.pubkey, now), <, 0);
tt_assert(parsed_cert[i]->sig_bad== 1);
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp2.pubkey, now), OP_LT, 0);
tt_uint_op(parsed_cert[i]->sig_bad, OP_EQ, 1);
parsed_cert[i]->sig_bad = 0;
/* Missing key */
int ok = tor_cert_checksig(parsed_cert[i], NULL, now);
tt_int_op(ok < 0, ==, i == 0);
tt_assert(parsed_cert[i]->sig_bad == 0);
tt_int_op(ok < 0, OP_EQ, i == 0);
tt_uint_op(parsed_cert[i]->sig_bad, OP_EQ, 0);
tt_assert(parsed_cert[i]->sig_ok == (i != 0));
tt_assert(parsed_cert[i]->cert_valid == (i != 0));
parsed_cert[i]->sig_bad = 0;
@ -147,29 +147,29 @@ test_routerkeys_ed_certs(void *args)
parsed_cert[i]->cert_valid = 0;
/* Right key */
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now), ==, 0);
tt_assert(parsed_cert[i]->sig_bad == 0);
tt_assert(parsed_cert[i]->sig_ok == 1);
tt_assert(parsed_cert[i]->cert_expired == 0);
tt_assert(parsed_cert[i]->cert_valid == 1);
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now), OP_EQ, 0);
tt_uint_op(parsed_cert[i]->sig_bad, OP_EQ, 0);
tt_uint_op(parsed_cert[i]->sig_ok, OP_EQ, 1);
tt_uint_op(parsed_cert[i]->cert_expired, OP_EQ, 0);
tt_uint_op(parsed_cert[i]->cert_valid, OP_EQ, 1);
}
/* Now try some junky certs. */
/* - Truncated */
nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len-1);
tt_ptr_op(NULL, ==, nocert);
tt_ptr_op(NULL, OP_EQ, nocert);
/* - First byte modified */
cert[0]->encoded[0] = 99;
nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len);
tt_ptr_op(NULL, ==, nocert);
tt_ptr_op(NULL, OP_EQ, nocert);
cert[0]->encoded[0] = 1;
/* - Extra byte at the end*/
junk = tor_malloc_zero(cert[0]->encoded_len + 1);
memcpy(junk, cert[0]->encoded, cert[0]->encoded_len);
nocert = tor_cert_parse(junk, cert[0]->encoded_len+1);
tt_ptr_op(NULL, ==, nocert);
tt_ptr_op(NULL, OP_EQ, nocert);
/* - Multiple signing key instances */
tor_free(junk);
@ -183,7 +183,7 @@ test_routerkeys_ed_certs(void *args)
junk[77] = 32; /* extlen */
junk[78] = 4; /* exttype */
nocert = tor_cert_parse(junk, 104 + 36 * 2);
tt_ptr_op(NULL, ==, nocert);
tt_ptr_op(NULL, OP_EQ, nocert);
done:
tor_cert_free(cert[0]);
@ -211,11 +211,12 @@ test_routerkeys_ed_key_create(void *arg)
kp2 = ed_key_new(kp1, INIT_ED_KEY_NEEDCERT, now, 3600, 4, &cert);
tt_assert(kp2);
tt_assert(cert);
tt_mem_op(&cert->signed_key, ==, &kp2->pubkey, sizeof(ed25519_public_key_t));
tt_mem_op(&cert->signed_key, OP_EQ, &kp2->pubkey,
sizeof(ed25519_public_key_t));
tt_assert(! cert->signing_key_included);
tt_int_op(cert->valid_until, >=, now);
tt_int_op(cert->valid_until, <=, now+7200);
tt_int_op(cert->valid_until, OP_GE, now);
tt_int_op(cert->valid_until, OP_LE, now+7200);
/* Create a new key-including certificate signed by kp1 */
ed25519_keypair_free(kp2);
@ -227,8 +228,10 @@ test_routerkeys_ed_key_create(void *arg)
tt_assert(kp2);
tt_assert(cert);
tt_assert(cert->signing_key_included);
tt_mem_op(&cert->signed_key, ==, &kp2->pubkey, sizeof(ed25519_public_key_t));
tt_mem_op(&cert->signing_key, ==, &kp1->pubkey,sizeof(ed25519_public_key_t));
tt_mem_op(&cert->signed_key, OP_EQ, &kp2->pubkey,
sizeof(ed25519_public_key_t));
tt_mem_op(&cert->signing_key, OP_EQ, &kp1->pubkey,
sizeof(ed25519_public_key_t));
done:
ed25519_keypair_free(kp1);
@ -261,8 +264,8 @@ test_routerkeys_ed_key_init_basic(void *arg)
NULL, now, 0, 7, &cert);
tt_assert(kp1 != NULL);
tt_assert(cert == NULL);
tt_int_op(stat(get_fname("test_ed_key_1_cert"), &st), <, 0);
tt_int_op(stat(get_fname("test_ed_key_1_secret_key"), &st), ==, 0);
tt_int_op(stat(get_fname("test_ed_key_1_cert"), &st), OP_LT, 0);
tt_int_op(stat(get_fname("test_ed_key_1_secret_key"), &st), OP_EQ, 0);
/* Fail to load if we say we need a cert */
kp2 = ed_key_init_from_file(fname1, INIT_ED_KEY_NEEDCERT, LOG_INFO,
@ -279,14 +282,14 @@ test_routerkeys_ed_key_init_basic(void *arg)
NULL, now, 0, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert == NULL);
tt_mem_op(kp1, ==, kp2, sizeof(*kp1));
tt_mem_op(kp1, OP_EQ, kp2, sizeof(*kp1));
ed25519_keypair_free(kp2); kp2 = NULL;
kp2 = ed_key_init_from_file(fname1, 0, LOG_INFO,
NULL, now, 0, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert == NULL);
tt_mem_op(kp1, ==, kp2, sizeof(*kp1));
tt_mem_op(kp1, OP_EQ, kp2, sizeof(*kp1));
ed25519_keypair_free(kp2); kp2 = NULL;
/* Now create a key with a cert. */
@ -295,34 +298,34 @@ test_routerkeys_ed_key_init_basic(void *arg)
LOG_INFO, kp1, now, 7200, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert != NULL);
tt_mem_op(kp1, !=, kp2, sizeof(*kp1));
tt_int_op(stat(get_fname("test_ed_key_2_cert"), &st), ==, 0);
tt_int_op(stat(get_fname("test_ed_key_2_secret_key"), &st), ==, 0);
tt_mem_op(kp1, OP_NE, kp2, sizeof(*kp1));
tt_int_op(stat(get_fname("test_ed_key_2_cert"), &st), OP_EQ, 0);
tt_int_op(stat(get_fname("test_ed_key_2_secret_key"), &st), OP_EQ, 0);
tt_assert(cert->cert_valid == 1);
tt_mem_op(&cert->signed_key, ==, &kp2->pubkey, 32);
tt_mem_op(&cert->signed_key, OP_EQ, &kp2->pubkey, 32);
/* Now verify we can load the cert... */
kp3 = ed_key_init_from_file(fname2, (INIT_ED_KEY_CREATE|
INIT_ED_KEY_NEEDCERT),
LOG_INFO, kp1, now, 7200, 7, &cert2);
tt_mem_op(kp2, ==, kp3, sizeof(*kp2));
tt_mem_op(cert2->encoded, ==, cert->encoded, cert->encoded_len);
tt_mem_op(kp2, OP_EQ, kp3, sizeof(*kp2));
tt_mem_op(cert2->encoded, OP_EQ, cert->encoded, cert->encoded_len);
ed25519_keypair_free(kp3); kp3 = NULL;
tor_cert_free(cert2); cert2 = NULL;
/* ... even without create... */
kp3 = ed_key_init_from_file(fname2, INIT_ED_KEY_NEEDCERT,
LOG_INFO, kp1, now, 7200, 7, &cert2);
tt_mem_op(kp2, ==, kp3, sizeof(*kp2));
tt_mem_op(cert2->encoded, ==, cert->encoded, cert->encoded_len);
tt_mem_op(kp2, OP_EQ, kp3, sizeof(*kp2));
tt_mem_op(cert2->encoded, OP_EQ, cert->encoded, cert->encoded_len);
ed25519_keypair_free(kp3); kp3 = NULL;
tor_cert_free(cert2); cert2 = NULL;
/* ... but that we don't crash or anything if we say we don't want it. */
kp3 = ed_key_init_from_file(fname2, INIT_ED_KEY_NEEDCERT,
LOG_INFO, kp1, now, 7200, 7, NULL);
tt_mem_op(kp2, ==, kp3, sizeof(*kp2));
tt_mem_op(kp2, OP_EQ, kp3, sizeof(*kp2));
ed25519_keypair_free(kp3); kp3 = NULL;
/* Fail if we're told the wrong signing key */
@ -367,16 +370,16 @@ test_routerkeys_ed_key_init_split(void *arg)
LOG_INFO, NULL, now, 0, 7, &cert);
tt_assert(kp1 != NULL);
tt_assert(cert == NULL);
tt_int_op(stat(get_fname("test_ed_key_3_cert"), &st), <, 0);
tt_int_op(stat(get_fname("test_ed_key_3_secret_key"), &st), ==, 0);
tt_int_op(stat(get_fname("test_ed_key_3_public_key"), &st), ==, 0);
tt_int_op(stat(get_fname("test_ed_key_3_cert"), &st), OP_LT, 0);
tt_int_op(stat(get_fname("test_ed_key_3_secret_key"), &st), OP_EQ, 0);
tt_int_op(stat(get_fname("test_ed_key_3_public_key"), &st), OP_EQ, 0);
/* Load it. */
kp2 = ed_key_init_from_file(fname1, flags|INIT_ED_KEY_CREATE,
LOG_INFO, NULL, now, 0, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert == NULL);
tt_mem_op(kp1, ==, kp2, sizeof(*kp2));
tt_mem_op(kp1, OP_EQ, kp2, sizeof(*kp2));
ed25519_keypair_free(kp2); kp2 = NULL;
/* Okay, try killing the secret key and loading it. */
@ -385,7 +388,7 @@ test_routerkeys_ed_key_init_split(void *arg)
LOG_INFO, NULL, now, 0, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert == NULL);
tt_mem_op(&kp1->pubkey, ==, &kp2->pubkey, sizeof(kp2->pubkey));
tt_mem_op(&kp1->pubkey, OP_EQ, &kp2->pubkey, sizeof(kp2->pubkey));
tt_assert(tor_mem_is_zero((char*)kp2->seckey.seckey,
sizeof(kp2->seckey.seckey)));
ed25519_keypair_free(kp2); kp2 = NULL;
@ -395,7 +398,7 @@ test_routerkeys_ed_key_init_split(void *arg)
LOG_INFO, NULL, now, 0, 7, &cert);
tt_assert(kp2 != NULL);
tt_assert(cert == NULL);
tt_mem_op(&kp1->pubkey, ==, &kp2->pubkey, sizeof(kp2->pubkey));
tt_mem_op(&kp1->pubkey, OP_EQ, &kp2->pubkey, sizeof(kp2->pubkey));
tt_assert(tor_mem_is_zero((char*)kp2->seckey.seckey,
sizeof(kp2->seckey.seckey)));
ed25519_keypair_free(kp2); kp2 = NULL;
@ -450,8 +453,8 @@ test_routerkeys_ed_keys_init_all(void *arg)
options->DataDirectory = dir;
tt_int_op(1, ==, load_ed_keys(options, now));
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
tt_assert(get_master_identity_key());
tt_assert(get_master_identity_key());
tt_assert(get_master_signing_keypair());
@ -465,21 +468,21 @@ test_routerkeys_ed_keys_init_all(void *arg)
link_cert = tor_cert_dup(get_current_link_cert_cert());
/* Call load_ed_keys again, but nothing has changed. */
tt_int_op(0, ==, load_ed_keys(options, now));
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
tt_mem_op(&auth, ==, get_current_auth_keypair(), sizeof(auth));
tt_int_op(0, OP_EQ, load_ed_keys(options, now));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, OP_EQ, get_master_signing_keypair(), sizeof(sign));
tt_mem_op(&auth, OP_EQ, get_current_auth_keypair(), sizeof(auth));
tt_assert(tor_cert_eq(link_cert, get_current_link_cert_cert()));
/* Force a reload: we make new link/auth keys. */
routerkeys_free_all();
tt_int_op(1, ==, load_ed_keys(options, now));
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, OP_EQ, get_master_signing_keypair(), sizeof(sign));
tt_assert(tor_cert_eq(link_cert, get_current_link_cert_cert()));
tt_mem_op(&auth, !=, get_current_auth_keypair(), sizeof(auth));
tt_mem_op(&auth, OP_NE, get_current_auth_keypair(), sizeof(auth));
tt_assert(get_master_signing_key_cert());
tt_assert(get_current_link_cert_cert());
tt_assert(get_current_auth_key_cert());
@ -488,12 +491,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
/* Force a link/auth-key regeneration by advancing time. */
tt_int_op(0, ==, load_ed_keys(options, now+3*86400));
tt_int_op(0, ==, generate_ed_link_cert(options, now+3*86400, 0));
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
tt_int_op(0, OP_EQ, load_ed_keys(options, now+3*86400));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now+3*86400, 0));
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, OP_EQ, get_master_signing_keypair(), sizeof(sign));
tt_assert(! tor_cert_eq(link_cert, get_current_link_cert_cert()));
tt_mem_op(&auth, !=, get_current_auth_keypair(), sizeof(auth));
tt_mem_op(&auth, OP_NE, get_current_auth_keypair(), sizeof(auth));
tt_assert(get_master_signing_key_cert());
tt_assert(get_current_link_cert_cert());
tt_assert(get_current_auth_key_cert());
@ -502,12 +505,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
/* Force a signing-key regeneration by advancing time. */
tt_int_op(1, ==, load_ed_keys(options, now+100*86400));
tt_int_op(0, ==, generate_ed_link_cert(options, now+100*86400, 0));
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, !=, get_master_signing_keypair(), sizeof(sign));
tt_int_op(1, OP_EQ, load_ed_keys(options, now+100*86400));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now+100*86400, 0));
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, OP_NE, get_master_signing_keypair(), sizeof(sign));
tt_assert(! tor_cert_eq(link_cert, get_current_link_cert_cert()));
tt_mem_op(&auth, !=, get_current_auth_keypair(), sizeof(auth));
tt_mem_op(&auth, OP_NE, get_current_auth_keypair(), sizeof(auth));
tt_assert(get_master_signing_key_cert());
tt_assert(get_current_link_cert_cert());
tt_assert(get_current_auth_key_cert());
@ -520,12 +523,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
routerkeys_free_all();
unlink(get_fname("test_ed_keys_init_all/keys/"
"ed25519_master_id_secret_key"));
tt_int_op(1, ==, load_ed_keys(options, now));
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
tt_mem_op(&sign, OP_EQ, get_master_signing_keypair(), sizeof(sign));
tt_assert(! tor_cert_eq(link_cert, get_current_link_cert_cert()));
tt_mem_op(&auth, !=, get_current_auth_keypair(), sizeof(auth));
tt_mem_op(&auth, OP_NE, get_current_auth_keypair(), sizeof(auth));
tt_assert(get_master_signing_key_cert());
tt_assert(get_current_link_cert_cert());
tt_assert(get_current_auth_key_cert());
@ -535,7 +538,7 @@ test_routerkeys_ed_keys_init_all(void *arg)
log_global_min_severity_ = LOG_ERR; /* Suppress warnings.
* XXX (better way to do this)? */
routerkeys_free_all();
tt_int_op(-1, ==, load_ed_keys(options, now+200*86400));
tt_int_op(-1, OP_EQ, load_ed_keys(options, now+200*86400));
done:
tor_free(dir);
@ -556,20 +559,20 @@ test_routerkeys_cross_certify_ntor(void *args)
time_t now = time(NULL);
int sign;
tt_int_op(0, ==, ed25519_public_from_base64(&master_key,
tt_int_op(0, OP_EQ, ed25519_public_from_base64(&master_key,
"IamwritingthesetestsOnARainyAfternoonin2014"));
tt_int_op(0, ==, curve25519_keypair_generate(&onion_keys, 0));
tt_int_op(0, OP_EQ, curve25519_keypair_generate(&onion_keys, 0));
cert = make_ntor_onion_key_crosscert(&onion_keys,
&master_key,
now, 10000,
&sign);
tt_assert(cert);
tt_assert(sign == 0 || sign == 1);
tt_int_op(cert->cert_type, ==, CERT_TYPE_ONION_ID);
tt_int_op(1, ==, ed25519_pubkey_eq(&cert->signed_key, &master_key));
tt_int_op(0, ==, ed25519_public_key_from_curve25519_public_key(
tt_int_op(cert->cert_type, OP_EQ, CERT_TYPE_ONION_ID);
tt_int_op(1, OP_EQ, ed25519_pubkey_eq(&cert->signed_key, &master_key));
tt_int_op(0, OP_EQ, ed25519_public_key_from_curve25519_public_key(
&onion_check_key, &onion_keys.pubkey, sign));
tt_int_op(0, ==, tor_cert_checksig(cert, &onion_check_key, now));
tt_int_op(0, OP_EQ, tor_cert_checksig(cert, &onion_check_key, now));
done:
tor_cert_free(cert);
@ -587,7 +590,7 @@ test_routerkeys_cross_certify_tap(void *args)
char buf[128];
int n;
tt_int_op(0, ==, ed25519_public_from_base64(&master_key,
tt_int_op(0, OP_EQ, ed25519_public_from_base64(&master_key,
"IAlreadyWroteTestsForRouterdescsUsingTheseX"));
cc = make_tap_onion_key_crosscert(onion_key,
@ -598,14 +601,14 @@ test_routerkeys_cross_certify_tap(void *args)
n = crypto_pk_public_checksig(onion_key, buf, sizeof(buf),
(char*)cc, cc_len);
tt_int_op(n,>,0);
tt_int_op(n,==,52);
tt_int_op(n,OP_GT,0);
tt_int_op(n,OP_EQ,52);
crypto_pk_get_digest(id_key, digest);
tt_mem_op(buf,==,digest,20);
tt_mem_op(buf+20,==,master_key.pubkey,32);
tt_mem_op(buf,OP_EQ,digest,20);
tt_mem_op(buf+20,OP_EQ,master_key.pubkey,32);
tt_int_op(0, ==, check_tap_onion_key_crosscert(cc, cc_len,
tt_int_op(0, OP_EQ, check_tap_onion_key_crosscert(cc, cc_len,
onion_key, &master_key, (uint8_t*)digest));
done:

View File

@ -117,7 +117,7 @@ test_routerlist_launch_descriptor_downloads(void *arg)
MOCK(initiate_descriptor_downloads, mock_initiate_descriptor_downloads);
launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC, downloadable,
NULL, now);
tt_int_op(3, ==, count);
tt_int_op(3, OP_EQ, count);
UNMOCK(initiate_descriptor_downloads);
done:
@ -148,24 +148,24 @@ construct_consensus(char **consensus_text_md)
&v1, &n_vrs, now, 1);
networkstatus_vote_free(vote);
tt_assert(v1);
tt_int_op(n_vrs, ==, 4);
tt_int_op(smartlist_len(v1->routerstatus_list), ==, 4);
tt_int_op(n_vrs, OP_EQ, 4);
tt_int_op(smartlist_len(v1->routerstatus_list), OP_EQ, 4);
dir_common_construct_vote_2(&vote, cert2, sign_skey_2,
&dir_common_gen_routerstatus_for_v3ns,
&v2, &n_vrs, now, 1);
networkstatus_vote_free(vote);
tt_assert(v2);
tt_int_op(n_vrs, ==, 4);
tt_int_op(smartlist_len(v2->routerstatus_list), ==, 4);
tt_int_op(n_vrs, OP_EQ, 4);
tt_int_op(smartlist_len(v2->routerstatus_list), OP_EQ, 4);
dir_common_construct_vote_3(&vote, cert3, sign_skey_3,
&dir_common_gen_routerstatus_for_v3ns,
&v3, &n_vrs, now, 1);
tt_assert(v3);
tt_int_op(n_vrs, ==, 4);
tt_int_op(smartlist_len(v3->routerstatus_list), ==, 4);
tt_int_op(n_vrs, OP_EQ, 4);
tt_int_op(smartlist_len(v3->routerstatus_list), OP_EQ, 4);
networkstatus_vote_free(vote);
votes = smartlist_new();
smartlist_add(votes, v1);
@ -247,16 +247,16 @@ test_router_pick_directory_server_impl(void *arg)
/* No consensus available, fail early */
rs = router_pick_directory_server_impl(V3_DIRINFO, (const int) 0, NULL);
tt_assert(rs == NULL);
tt_ptr_op(rs, OP_EQ, NULL);
construct_consensus(&consensus_text_md);
tt_assert(consensus_text_md);
con_md = networkstatus_parse_vote_from_string(consensus_text_md, NULL,
NS_TYPE_CONSENSUS);
tt_assert(con_md);
tt_int_op(con_md->flavor,==, FLAV_MICRODESC);
tt_int_op(con_md->flavor,OP_EQ, FLAV_MICRODESC);
tt_assert(con_md->routerstatus_list);
tt_int_op(smartlist_len(con_md->routerstatus_list), ==, 3);
tt_int_op(smartlist_len(con_md->routerstatus_list), OP_EQ, 3);
tt_assert(!networkstatus_set_current_consensus_from_ns(con_md,
"microdesc"));
@ -287,7 +287,7 @@ test_router_pick_directory_server_impl(void *arg)
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
/* We should not fail now we have a consensus and routerstatus_list
* and nodelist are populated. */
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
/* Manipulate the nodes so we get the dir server we expect */
router1_id = tor_malloc(DIGEST_LEN);
@ -306,7 +306,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router1->is_running = 0;
node_router3->is_running = 0;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router2_id, DIGEST_LEN));
rs = NULL;
node_router1->is_running = 1;
@ -319,7 +319,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router1->rs->dir_port = 0;
node_router3->rs->dir_port = 0;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router2_id, DIGEST_LEN));
rs = NULL;
node_router1->rs->is_v2_dir = 1;
@ -330,7 +330,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router1->is_valid = 0;
node_router3->is_valid = 0;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router2_id, DIGEST_LEN));
rs = NULL;
node_router1->is_valid = 1;
@ -341,7 +341,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router2->rs->last_dir_503_at = now;
node_router3->rs->last_dir_503_at = now;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router1_id, DIGEST_LEN));
node_router2->rs->last_dir_503_at = 0;
node_router3->rs->last_dir_503_at = 0;
@ -358,13 +358,13 @@ test_router_pick_directory_server_impl(void *arg)
node_router2->rs->or_port = 443;
node_router3->rs->or_port = 442;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router3_id, DIGEST_LEN));
node_router1->rs->or_port = 442;
node_router2->rs->or_port = 443;
node_router3->rs->or_port = 444;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router1_id, DIGEST_LEN));
/* Fascist firewall and overloaded */
@ -373,7 +373,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router3->rs->or_port = 442;
node_router3->rs->last_dir_503_at = now;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router1_id, DIGEST_LEN));
node_router3->rs->last_dir_503_at = 0;
@ -391,7 +391,7 @@ test_router_pick_directory_server_impl(void *arg)
node_router3->rs->dir_port = 81;
node_router1->rs->last_dir_503_at = now;
rs = router_pick_directory_server_impl(V3_DIRINFO, flags, NULL);
tt_assert(rs != NULL);
tt_ptr_op(rs, OP_NE, NULL);
tt_assert(tor_memeq(rs->identity_digest, router1_id, DIGEST_LEN));
node_router1->rs->last_dir_503_at = 0;
@ -449,27 +449,27 @@ test_routerlist_router_is_already_dir_fetching(void *arg)
/* Test that we never get 1 from a NULL connection */
mocked_connection = NULL;
tt_assert(router_is_already_dir_fetching(&test_ap, 1, 1) == 0);
tt_assert(router_is_already_dir_fetching(&test_ap, 1, 0) == 0);
tt_assert(router_is_already_dir_fetching(&test_ap, 0, 1) == 0);
tt_int_op(router_is_already_dir_fetching(&test_ap, 1, 1), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&test_ap, 1, 0), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&test_ap, 0, 1), OP_EQ, 0);
/* We always expect 0 in these cases */
tt_assert(router_is_already_dir_fetching(&test_ap, 0, 0) == 0);
tt_assert(router_is_already_dir_fetching(NULL, 1, 1) == 0);
tt_assert(router_is_already_dir_fetching(&null_addr_ap, 1, 1) == 0);
tt_assert(router_is_already_dir_fetching(&zero_port_ap, 1, 1) == 0);
tt_int_op(router_is_already_dir_fetching(&test_ap, 0, 0), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(NULL, 1, 1), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&null_addr_ap, 1, 1), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&zero_port_ap, 1, 1), OP_EQ, 0);
/* Test that we get 1 with a connection in the appropriate circumstances */
mocked_connection = connection_new(CONN_TYPE_DIR, AF_INET);
tt_assert(router_is_already_dir_fetching(&test_ap, 1, 1) == 1);
tt_assert(router_is_already_dir_fetching(&test_ap, 1, 0) == 1);
tt_assert(router_is_already_dir_fetching(&test_ap, 0, 1) == 1);
tt_int_op(router_is_already_dir_fetching(&test_ap, 1, 1), OP_EQ, 1);
tt_int_op(router_is_already_dir_fetching(&test_ap, 1, 0), OP_EQ, 1);
tt_int_op(router_is_already_dir_fetching(&test_ap, 0, 1), OP_EQ, 1);
/* Test that we get 0 even with a connection in the appropriate
* circumstances */
tt_assert(router_is_already_dir_fetching(&test_ap, 0, 0) == 0);
tt_assert(router_is_already_dir_fetching(NULL, 1, 1) == 0);
tt_assert(router_is_already_dir_fetching(&null_addr_ap, 1, 1) == 0);
tt_assert(router_is_already_dir_fetching(&zero_port_ap, 1, 1) == 0);
tt_int_op(router_is_already_dir_fetching(&test_ap, 0, 0), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(NULL, 1, 1), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&null_addr_ap, 1, 1), OP_EQ, 0);
tt_int_op(router_is_already_dir_fetching(&zero_port_ap, 1, 1), OP_EQ, 0);
done:
/* If a connection is never set up, connection_free chokes on it. */

View File

@ -68,14 +68,14 @@ static void test_scheduler_queue_heuristic(void *arg);
static void
mock_event_free_all(void)
{
tt_assert(mock_event_base != NULL);
tt_ptr_op(mock_event_base, OP_NE, NULL);
if (mock_event_base) {
event_base_free(mock_event_base);
mock_event_base = NULL;
}
tt_ptr_op(mock_event_base, ==, NULL);
tt_ptr_op(mock_event_base, OP_EQ, NULL);
done:
return;
@ -86,7 +86,7 @@ mock_event_init(void)
{
struct event_config *cfg = NULL;
tt_ptr_op(mock_event_base, ==, NULL);
tt_ptr_op(mock_event_base, OP_EQ, NULL);
/*
* Really cut down from tor_libevent_initialize of
@ -104,7 +104,7 @@ mock_event_init(void)
event_config_free(cfg);
}
tt_assert(mock_event_base != NULL);
tt_ptr_op(mock_event_base, OP_NE, NULL);
done:
return;
@ -181,7 +181,7 @@ channel_flush_some_cells_mock(channel_t *chan, ssize_t num_cells)
char unlimited = 0;
flush_mock_channel_t *found = NULL;
tt_assert(chan != NULL);
tt_ptr_op(chan, OP_NE, NULL);
if (chan) {
if (num_cells < 0) {
num_cells = 0;
@ -234,8 +234,8 @@ circuitmux_compare_muxes_mock(circuitmux_t *cmux_1,
{
int result = 0;
tt_assert(cmux_1 != NULL);
tt_assert(cmux_2 != NULL);
tt_ptr_op(cmux_1, OP_NE, NULL);
tt_ptr_op(cmux_2, OP_NE, NULL);
if (cmux_1 != cmux_2) {
if (cmux_1 == mock_ccm_tgt_1 && cmux_2 == mock_ccm_tgt_2) result = -1;
@ -261,7 +261,7 @@ circuitmux_get_policy_mock(circuitmux_t *cmux)
{
const circuitmux_policy_t *result = NULL;
tt_assert(cmux != NULL);
tt_ptr_op(cmux, OP_NE, NULL);
if (cmux) {
if (cmux == mock_cgp_tgt_1) result = mock_cgp_val_1;
else if (cmux == mock_cgp_tgt_2) result = mock_cgp_val_2;
@ -326,7 +326,7 @@ test_scheduler_channel_states(void *arg)
*/
MOCK(scheduler_run, scheduler_run_noop_mock);
tt_int_op(smartlist_len(channels_pending), ==, 0);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 0);
/* Set up a fake channel */
ch1 = new_fake_channel();
@ -341,7 +341,7 @@ test_scheduler_channel_states(void *arg)
tt_assert(ch1->registered);
/* It should start off in SCHED_CHAN_IDLE */
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_IDLE);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_IDLE);
/* Now get another one */
ch2 = new_fake_channel();
@ -353,39 +353,39 @@ test_scheduler_channel_states(void *arg)
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
scheduler_channel_has_waiting_cells(ch1);
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_WAITING_TO_WRITE);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_TO_WRITE);
/* This should send it to SCHED_CHAN_PENDING */
scheduler_channel_wants_writes(ch1);
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 1);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
scheduler_channel_wants_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/* Drop ch2 back to idle */
scheduler_channel_doesnt_want_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_IDLE);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_IDLE);
/* ...and back to SCHED_CHAN_WAITING_FOR_CELLS */
scheduler_channel_wants_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/* ...and this should kick ch2 into SCHED_CHAN_PENDING */
scheduler_channel_has_waiting_cells(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 2);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
/* This should send ch2 to SCHED_CHAN_WAITING_TO_WRITE */
scheduler_channel_doesnt_want_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_TO_WRITE);
tt_int_op(smartlist_len(channels_pending), ==, 1);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_TO_WRITE);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
/* ...and back to SCHED_CHAN_PENDING */
scheduler_channel_wants_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 2);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
/* Now we exercise scheduler_touch_channel */
old_count = scheduler_compare_channels_mock_ctr;
@ -394,14 +394,14 @@ test_scheduler_channel_states(void *arg)
/* Close */
channel_mark_for_close(ch1);
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSING);
channel_mark_for_close(ch2);
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSING);
channel_closed(ch1);
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSED);
ch1 = NULL;
channel_closed(ch2);
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSED);
ch2 = NULL;
/* Shut things down */
@ -464,21 +464,21 @@ test_scheduler_compare_channels(void *arg)
/* Equal-channel case */
result = scheduler_compare_channels(&c1, &c1);
tt_int_op(result, ==, 0);
tt_int_op(result, OP_EQ, 0);
/* Distinct channels, distinct policies */
result = scheduler_compare_channels(&c1, &c2);
tt_int_op(result, ==, -1);
tt_int_op(result, OP_EQ, -1);
result = scheduler_compare_channels(&c2, &c1);
tt_int_op(result, ==, 1);
tt_int_op(result, OP_EQ, 1);
/* Distinct channels, same policy */
tor_free(mock_cgp_val_2);
mock_cgp_val_2 = mock_cgp_val_1;
result = scheduler_compare_channels(&c1, &c2);
tt_int_op(result, ==, -1);
tt_int_op(result, OP_EQ, -1);
result = scheduler_compare_channels(&c2, &c1);
tt_int_op(result, ==, 1);
tt_int_op(result, OP_EQ, 1);
done:
@ -507,24 +507,24 @@ test_scheduler_initfree(void *arg)
{
(void)arg;
tt_ptr_op(channels_pending, ==, NULL);
tt_ptr_op(run_sched_ev, ==, NULL);
tt_ptr_op(channels_pending, OP_EQ, NULL);
tt_ptr_op(run_sched_ev, OP_EQ, NULL);
mock_event_init();
MOCK(tor_libevent_get_base, tor_libevent_get_base_mock);
scheduler_init();
tt_assert(channels_pending != NULL);
tt_assert(run_sched_ev != NULL);
tt_ptr_op(channels_pending, OP_NE, NULL);
tt_ptr_op(run_sched_ev, OP_NE, NULL);
scheduler_free_all();
UNMOCK(tor_libevent_get_base);
mock_event_free_all();
tt_ptr_op(channels_pending, ==, NULL);
tt_ptr_op(run_sched_ev, ==, NULL);
tt_ptr_op(channels_pending, OP_EQ, NULL);
tt_ptr_op(run_sched_ev, OP_EQ, NULL);
done:
return;
@ -553,7 +553,7 @@ test_scheduler_loop(void *arg)
*/
MOCK(scheduler_run, scheduler_run_noop_mock);
tt_int_op(smartlist_len(channels_pending), ==, 0);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 0);
/* Set up a fake channel */
ch1 = new_fake_channel();
@ -570,7 +570,7 @@ test_scheduler_loop(void *arg)
channel_change_state_open(ch1);
/* It should start off in SCHED_CHAN_IDLE */
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_IDLE);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_IDLE);
/* Now get another one */
ch2 = new_fake_channel();
@ -584,34 +584,34 @@ test_scheduler_loop(void *arg)
* zero and we'll get coverage of that exception case in scheduler_run()
*/
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPENING);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPENING);
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
scheduler_channel_has_waiting_cells(ch1);
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_WAITING_TO_WRITE);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_TO_WRITE);
/* This should send it to SCHED_CHAN_PENDING */
scheduler_channel_wants_writes(ch1);
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 1);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
scheduler_channel_wants_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/* Drop ch2 back to idle */
scheduler_channel_doesnt_want_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_IDLE);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_IDLE);
/* ...and back to SCHED_CHAN_WAITING_FOR_CELLS */
scheduler_channel_wants_writes(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/* ...and this should kick ch2 into SCHED_CHAN_PENDING */
scheduler_channel_has_waiting_cells(ch2);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 2);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
/*
* Now we've got two pending channels and need to fire off
@ -629,11 +629,11 @@ test_scheduler_loop(void *arg)
* Assert that they're still in the states we left and aren't still
* pending
*/
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPENING);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPENING);
tt_assert(ch1->scheduler_state != SCHED_CHAN_PENDING);
tt_assert(ch2->scheduler_state != SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 0);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 0);
/* Now, finish opening ch2, and get both back to pending */
channel_change_state_open(ch2);
@ -641,11 +641,11 @@ test_scheduler_loop(void *arg)
scheduler_channel_wants_writes(ch2);
scheduler_channel_has_waiting_cells(ch1);
scheduler_channel_has_waiting_cells(ch2);
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPEN);
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), ==, 2);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPEN);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
/* Now, set up the channel_flush_some_cells() mock */
MOCK(channel_flush_some_cells, channel_flush_some_cells_mock);
@ -675,24 +675,24 @@ test_scheduler_loop(void *arg)
* ch1 should have gone to SCHED_CHAN_WAITING_FOR_CELLS, with 16 flushed
* and 32 writeable.
*/
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/*
* ...ch2 should also have gone to SCHED_CHAN_WAITING_FOR_CELLS, with
* channel_more_to_flush() returning false and channel_num_cells_writeable()
* > 0/
*/
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_FOR_CELLS);
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_FOR_CELLS);
/* Close */
channel_mark_for_close(ch1);
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSING);
channel_mark_for_close(ch2);
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSING);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSING);
channel_closed(ch1);
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSED);
ch1 = NULL;
channel_closed(ch2);
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSED);
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSED);
ch2 = NULL;
/* Shut things down */
@ -724,22 +724,22 @@ test_scheduler_queue_heuristic(void *arg)
/* Not yet inited case */
scheduler_update_queue_heuristic(now - 180);
tt_u64_op(queue_heuristic, ==, 0);
tt_int_op(queue_heuristic_timestamp, ==, now - 180);
tt_u64_op(queue_heuristic, OP_EQ, 0);
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 180);
queue_heuristic = 1000000000L;
queue_heuristic_timestamp = now - 120;
scheduler_update_queue_heuristic(now - 119);
tt_u64_op(queue_heuristic, ==, 500000000L);
tt_int_op(queue_heuristic_timestamp, ==, now - 119);
tt_u64_op(queue_heuristic, OP_EQ, 500000000L);
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 119);
scheduler_update_queue_heuristic(now - 116);
tt_u64_op(queue_heuristic, ==, 62500000L);
tt_int_op(queue_heuristic_timestamp, ==, now - 116);
tt_u64_op(queue_heuristic, OP_EQ, 62500000L);
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 116);
qh = scheduler_get_queue_heuristic();
tt_u64_op(qh, ==, 0);
tt_u64_op(qh, OP_EQ, 0);
done:
return;

View File

@ -73,58 +73,58 @@ test_get_sr_protocol_phase(void *arg)
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 23:59:00 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_REVEAL);
tt_int_op(phase, OP_EQ, SR_PHASE_REVEAL);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 00:00:00 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_COMMIT);
tt_int_op(phase, OP_EQ, SR_PHASE_COMMIT);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 00:00:01 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_COMMIT);
tt_int_op(phase, OP_EQ, SR_PHASE_COMMIT);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 11:59:00 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_COMMIT);
tt_int_op(phase, OP_EQ, SR_PHASE_COMMIT);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 12:00:00 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_REVEAL);
tt_int_op(phase, OP_EQ, SR_PHASE_REVEAL);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 12:00:01 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_REVEAL);
tt_int_op(phase, OP_EQ, SR_PHASE_REVEAL);
}
{
retval = parse_rfc1123_time("Wed, 20 Apr 2015 13:00:00 UTC", &the_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
phase = get_sr_protocol_phase(the_time);
tt_int_op(phase, ==, SR_PHASE_REVEAL);
tt_int_op(phase, OP_EQ, SR_PHASE_REVEAL);
}
done:
@ -147,7 +147,7 @@ test_get_state_valid_until_time(void *arg)
/* Get the valid until time if called at 00:00:01 */
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_until_time = get_state_valid_until_time(current_time);
/* Compare it with the correct result */
@ -158,7 +158,7 @@ test_get_state_valid_until_time(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 19:22:00 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
@ -168,7 +168,7 @@ test_get_state_valid_until_time(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:00 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
@ -178,7 +178,7 @@ test_get_state_valid_until_time(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_until_time = get_state_valid_until_time(current_time);
format_iso_time(tbuf, valid_until_time);
@ -204,7 +204,7 @@ test_get_start_time_of_current_run(void *arg)
/* Get start time if called at 00:00:01 */
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
@ -216,7 +216,7 @@ test_get_start_time_of_current_run(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:59 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
@ -228,7 +228,7 @@ test_get_start_time_of_current_run(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
@ -247,7 +247,7 @@ test_get_start_time_of_current_run(void *arg)
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:15:32 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
run_start_time =
sr_state_get_start_time_of_current_protocol_run(current_time);
@ -290,15 +290,15 @@ test_get_sr_protocol_duration(void *arg)
(void) arg;
/* Check that by default an SR phase is 12 hours */
tt_int_op(sr_state_get_phase_duration(), ==, 12*60*60);
tt_int_op(sr_state_get_protocol_run_duration(), ==, 24*60*60);
tt_int_op(sr_state_get_phase_duration(), OP_EQ, 12*60*60);
tt_int_op(sr_state_get_protocol_run_duration(), OP_EQ, 24*60*60);
/* Now alter the voting interval and check that the SR phase is 2 mins long
* if voting happens every 10 seconds (10*12 seconds = 2 mins) */
or_options_t *options = get_options_mutable();
options->V3AuthVotingInterval = 10;
tt_int_op(sr_state_get_phase_duration(), ==, 2*60);
tt_int_op(sr_state_get_protocol_run_duration(), ==, 4*60);
tt_int_op(sr_state_get_phase_duration(), OP_EQ, 2*60);
tt_int_op(sr_state_get_protocol_run_duration(), OP_EQ, 4*60);
done: ;
}
@ -329,11 +329,11 @@ test_get_next_valid_after_time(void *arg)
retval = parse_rfc1123_time("Mon, 13 Jan 2016 16:00:00 UTC",
&mock_consensus->fresh_until);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
retval = parse_rfc1123_time("Mon, 13 Jan 2016 15:00:00 UTC",
&mock_consensus->valid_after);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
MOCK(networkstatus_get_live_consensus,
mock_networkstatus_get_live_consensus);
@ -343,7 +343,7 @@ test_get_next_valid_after_time(void *arg)
/* Get the valid after time if called at 00:00:00 */
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_after_time = get_next_valid_after_time(current_time);
/* Compare it with the correct result */
@ -355,7 +355,7 @@ test_get_next_valid_after_time(void *arg)
/* Get the valid until time if called at 00:00:01 */
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_after_time = get_next_valid_after_time(current_time);
/* Compare it with the correct result */
@ -366,7 +366,7 @@ test_get_next_valid_after_time(void *arg)
{
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:30:01 UTC",
&current_time);
tt_int_op(retval, ==, 0);
tt_int_op(retval, OP_EQ, 0);
valid_after_time = get_next_valid_after_time(current_time);
/* Compare it with the correct result */
@ -418,18 +418,18 @@ test_sr_commit(void *arg)
tt_assert(!tor_mem_is_zero((char *) our_commit->random_number,
sizeof(our_commit->random_number)));
/* Commit and reveal timestamp should be the same. */
tt_u64_op(our_commit->commit_ts, ==, our_commit->reveal_ts);
tt_u64_op(our_commit->commit_ts, OP_EQ, our_commit->reveal_ts);
/* We should have a hashed reveal. */
tt_assert(!tor_mem_is_zero(our_commit->hashed_reveal,
sizeof(our_commit->hashed_reveal)));
/* Do we have a valid encoded commit and reveal. Note the following only
* tests if the generated values are correct. Their could be a bug in
* the decode function but we test them seperately. */
tt_int_op(0, ==, reveal_decode(our_commit->encoded_reveal,
tt_int_op(0, OP_EQ, reveal_decode(our_commit->encoded_reveal,
&test_commit));
tt_int_op(0, ==, commit_decode(our_commit->encoded_commit,
tt_int_op(0, OP_EQ, commit_decode(our_commit->encoded_commit,
&test_commit));
tt_int_op(0, ==, verify_commit_and_reveal(our_commit));
tt_int_op(0, OP_EQ, verify_commit_and_reveal(our_commit));
}
/* Let's make sure our verify commit and reveal function works. We'll
@ -442,21 +442,21 @@ test_sr_commit(void *arg)
/* Timestamp MUST match. */
test_commit.commit_ts = test_commit.reveal_ts - 42;
setup_full_capture_of_logs(LOG_WARN);
tt_int_op(-1, ==, verify_commit_and_reveal(&test_commit));
tt_int_op(-1, OP_EQ, verify_commit_and_reveal(&test_commit));
expect_log_msg_containing("doesn't match reveal timestamp");
teardown_capture_of_logs();
memcpy(&test_commit, our_commit, sizeof(test_commit));
tt_int_op(0, ==, verify_commit_and_reveal(&test_commit));
tt_int_op(0, OP_EQ, verify_commit_and_reveal(&test_commit));
/* Hashed reveal must match the H(encoded_reveal). */
memset(test_commit.hashed_reveal, 'X',
sizeof(test_commit.hashed_reveal));
setup_full_capture_of_logs(LOG_WARN);
tt_int_op(-1, ==, verify_commit_and_reveal(&test_commit));
tt_int_op(-1, OP_EQ, verify_commit_and_reveal(&test_commit));
expect_single_log_msg_containing("doesn't match the commit value");
teardown_capture_of_logs();
memcpy(&test_commit, our_commit, sizeof(test_commit));
tt_int_op(0, ==, verify_commit_and_reveal(&test_commit));
tt_int_op(0, OP_EQ, verify_commit_and_reveal(&test_commit));
}
/* We'll build a list of values from our commit that our parsing function
@ -510,26 +510,26 @@ test_encoding(void *arg)
/* Hash random number because we don't expose bytes of the RNG. */
ret = crypto_digest256(hashed_rand, raw_rand,
sizeof(raw_rand), SR_DIGEST_ALG);
tt_int_op(0, ==, ret);
tt_int_op(0, OP_EQ, ret);
/* Hash reveal value. */
tt_int_op(SR_REVEAL_BASE64_LEN, ==, strlen(encoded_reveal));
tt_int_op(SR_REVEAL_BASE64_LEN, OP_EQ, strlen(encoded_reveal));
ret = crypto_digest256(hashed_reveal, encoded_reveal,
strlen(encoded_reveal), SR_DIGEST_ALG);
tt_int_op(0, ==, ret);
tt_int_op(SR_COMMIT_BASE64_LEN, ==, strlen(encoded_commit));
tt_int_op(0, OP_EQ, ret);
tt_int_op(SR_COMMIT_BASE64_LEN, OP_EQ, strlen(encoded_commit));
/* Test our commit/reveal decode functions. */
{
/* Test the reveal encoded value. */
tt_int_op(0, ==, reveal_decode(encoded_reveal, &parsed_commit));
tt_u64_op(ts, ==, parsed_commit.reveal_ts);
tt_int_op(0, OP_EQ, reveal_decode(encoded_reveal, &parsed_commit));
tt_u64_op(ts, OP_EQ, parsed_commit.reveal_ts);
tt_mem_op(hashed_rand, OP_EQ, parsed_commit.random_number,
sizeof(hashed_rand));
/* Test the commit encoded value. */
memset(&parsed_commit, 0, sizeof(parsed_commit));
tt_int_op(0, ==, commit_decode(encoded_commit, &parsed_commit));
tt_u64_op(ts, ==, parsed_commit.commit_ts);
tt_int_op(0, OP_EQ, commit_decode(encoded_commit, &parsed_commit));
tt_u64_op(ts, OP_EQ, parsed_commit.commit_ts);
tt_mem_op(encoded_commit, OP_EQ, parsed_commit.encoded_commit,
sizeof(parsed_commit.encoded_commit));
tt_mem_op(hashed_reveal, OP_EQ, parsed_commit.hashed_reveal,
@ -544,7 +544,7 @@ test_encoding(void *arg)
memcpy(parsed_commit.random_number, hashed_rand,
sizeof(parsed_commit.random_number));
ret = reveal_encode(&parsed_commit, encoded, sizeof(encoded));
tt_int_op(SR_REVEAL_BASE64_LEN, ==, ret);
tt_int_op(SR_REVEAL_BASE64_LEN, OP_EQ, ret);
tt_mem_op(encoded_reveal, OP_EQ, encoded, strlen(encoded_reveal));
}
@ -555,7 +555,7 @@ test_encoding(void *arg)
memcpy(parsed_commit.hashed_reveal, hashed_reveal,
sizeof(parsed_commit.hashed_reveal));
ret = commit_encode(&parsed_commit, encoded, sizeof(encoded));
tt_int_op(SR_COMMIT_BASE64_LEN, ==, ret);
tt_int_op(SR_COMMIT_BASE64_LEN, OP_EQ, ret);
tt_mem_op(encoded_commit, OP_EQ, encoded, strlen(encoded_commit));
}
@ -632,7 +632,7 @@ test_vote(void *arg)
tt_assert(lines);
/* Split the lines. We expect 2 here. */
ret = smartlist_split_string(chunks, lines, "\n", SPLIT_IGNORE_BLANK, 0);
tt_int_op(ret, ==, 4);
tt_int_op(ret, OP_EQ, 4);
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "shared-rand-participate");
/* Get our commitment line and will validate it agains our commit. The
* format is as follow:
@ -642,7 +642,7 @@ test_vote(void *arg)
char *commit_line = smartlist_get(chunks, 1);
tt_assert(commit_line);
ret = smartlist_split_string(tokens, commit_line, " ", 0, 0);
tt_int_op(ret, ==, 6);
tt_int_op(ret, OP_EQ, 6);
tt_str_op(smartlist_get(tokens, 0), OP_EQ, "shared-rand-commit");
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "1");
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
@ -650,7 +650,7 @@ test_vote(void *arg)
char digest[DIGEST_LEN];
base16_decode(digest, sizeof(digest), smartlist_get(tokens, 3),
HEX_DIGEST_LEN);
tt_mem_op(digest, ==, our_commit->rsa_identity, sizeof(digest));
tt_mem_op(digest, OP_EQ, our_commit->rsa_identity, sizeof(digest));
tt_str_op(smartlist_get(tokens, 4), OP_EQ, our_commit->encoded_commit);
tt_str_op(smartlist_get(tokens, 5), OP_EQ, our_commit->encoded_reveal)
;
@ -666,7 +666,7 @@ test_vote(void *arg)
/* Set valid flag explicitly here to compare since it's not set by
* simply parsing the commit. */
parsed_commit->valid = 1;
tt_mem_op(parsed_commit, ==, our_commit, sizeof(*our_commit));
tt_mem_op(parsed_commit, OP_EQ, our_commit, sizeof(*our_commit));
/* minor cleanup */
SMARTLIST_FOREACH(tokens, char *, s, tor_free(s));
@ -676,7 +676,7 @@ test_vote(void *arg)
char *prev_srv_line = smartlist_get(chunks, 2);
tt_assert(prev_srv_line);
ret = smartlist_split_string(tokens, prev_srv_line, " ", 0, 0);
tt_int_op(ret, ==, 3);
tt_int_op(ret, OP_EQ, 3);
tt_str_op(smartlist_get(tokens, 0), OP_EQ, "shared-rand-previous-value");
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "42");
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
@ -690,7 +690,7 @@ test_vote(void *arg)
char *current_srv_line = smartlist_get(chunks, 3);
tt_assert(current_srv_line);
ret = smartlist_split_string(tokens, current_srv_line, " ", 0, 0);
tt_int_op(ret, ==, 3);
tt_int_op(ret, OP_EQ, 3);
tt_str_op(smartlist_get(tokens, 0), OP_EQ, "shared-rand-current-value");
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "128");
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
@ -743,7 +743,7 @@ test_state_load_from_disk(void *arg)
/* First try with a nonexistent path. */
ret = disk_state_load_from_disk_impl("NONEXISTENTNONEXISTENT");
tt_assert(ret == -ENOENT);
tt_int_op(ret, OP_EQ, -ENOENT);
/* Now create a mock state directory and state file */
#ifdef _WIN32
@ -751,9 +751,9 @@ test_state_load_from_disk(void *arg)
#else
ret = mkdir(dir, 0700);
#endif
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
ret = write_str_to_file(sr_state_path, sr_state_str, 0);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Try to load the directory itself. Should fail. */
ret = disk_state_load_from_disk_impl(dir);
@ -761,11 +761,11 @@ test_state_load_from_disk(void *arg)
/* State should be non-existent at this point. */
the_sr_state = get_sr_state();
tt_assert(!the_sr_state);
tt_ptr_op(the_sr_state, OP_EQ, NULL);
/* Now try to load the correct file! */
ret = disk_state_load_from_disk_impl(sr_state_path);
tt_assert(ret == 0);
tt_int_op(ret, OP_EQ, 0);
/* Check the content of the state */
/* XXX check more deeply!!! */
@ -803,7 +803,7 @@ test_sr_setup_commits(void)
tt_assert(auth_cert);
options->AuthoritativeDir = 1;
tt_int_op(0, ==, load_ed_keys(options, now));
tt_int_op(0, OP_EQ, load_ed_keys(options, now));
}
/* Generate three dummy commits according to sr_srv_calc_ref.py . Then
@ -889,7 +889,7 @@ test_sr_setup_commits(void)
save_commit_to_state(commit_b);
save_commit_to_state(commit_c);
save_commit_to_state(commit_d);
tt_int_op(digestmap_size(get_sr_state()->commits), ==, 4);
tt_int_op(digestmap_size(get_sr_state()->commits), OP_EQ, 4);
/* Now during REVEAL phase save commit D by restoring its reveal. */
set_sr_phase(SR_PHASE_REVEAL);
@ -934,9 +934,9 @@ test_sr_compute_srv(void *arg)
/* Check the result against the test vector */
current_srv = sr_state_get_current_srv();
tt_assert(current_srv);
tt_u64_op(current_srv->num_reveals, ==, 3);
tt_u64_op(current_srv->num_reveals, OP_EQ, 3);
tt_str_op(hex_str((char*)current_srv->value, 32),
==,
OP_EQ,
SRV_TEST_VECTOR);
done:
@ -992,7 +992,7 @@ test_sr_get_majority_srv_from_votes(void *arg)
/* Since it's only one vote with an SRV, it should not achieve majority and
hence no SRV will be returned. */
chosen_srv = get_majority_srv_from_votes(votes, 1);
tt_assert(!chosen_srv);
tt_ptr_op(chosen_srv, OP_EQ, NULL);
{ /* Now put in 8 more votes. Let SRV_1 have majority. */
int i;
@ -1011,21 +1011,21 @@ test_sr_get_majority_srv_from_votes(void *arg)
smartlist_add(votes, vote);
}
tt_int_op(smartlist_len(votes), ==, 9);
tt_int_op(smartlist_len(votes), OP_EQ, 9);
}
/* Now we achieve majority for SRV_1, but not the AuthDirNumSRVAgreements
requirement. So still not picking an SRV. */
set_num_srv_agreements(8);
chosen_srv = get_majority_srv_from_votes(votes, 1);
tt_assert(!chosen_srv);
tt_ptr_op(chosen_srv, OP_EQ, NULL);
/* We will now lower the AuthDirNumSRVAgreements requirement by tweaking the
* consensus parameter and we will try again. This time it should work. */
set_num_srv_agreements(7);
chosen_srv = get_majority_srv_from_votes(votes, 1);
tt_assert(chosen_srv);
tt_u64_op(chosen_srv->num_reveals, ==, 42);
tt_u64_op(chosen_srv->num_reveals, OP_EQ, 42);
tt_mem_op(chosen_srv->value, OP_EQ, SRV_1, sizeof(chosen_srv->value));
done:
@ -1049,7 +1049,7 @@ test_utils(void *arg)
memcpy(srv->value, srv_value, sizeof(srv->value));
dup_srv = srv_dup(srv);
tt_assert(dup_srv);
tt_u64_op(dup_srv->num_reveals, ==, srv->num_reveals);
tt_u64_op(dup_srv->num_reveals, OP_EQ, srv->num_reveals);
tt_mem_op(dup_srv->value, OP_EQ, srv->value, sizeof(srv->value));
tor_free(srv);
tor_free(dup_srv);
@ -1069,10 +1069,10 @@ test_utils(void *arg)
sr_commit_t commit1, commit2;
memcpy(commit1.encoded_commit, payload, sizeof(commit1.encoded_commit));
memcpy(commit2.encoded_commit, payload, sizeof(commit2.encoded_commit));
tt_int_op(commitments_are_the_same(&commit1, &commit2), ==, 1);
tt_int_op(commitments_are_the_same(&commit1, &commit2), OP_EQ, 1);
/* Let's corrupt one of them. */
memset(commit1.encoded_commit, 'A', sizeof(commit1.encoded_commit));
tt_int_op(commitments_are_the_same(&commit1, &commit2), ==, 0);
tt_int_op(commitments_are_the_same(&commit1, &commit2), OP_EQ, 0);
}
/* Testing commit_is_authoritative(). */
@ -1083,32 +1083,32 @@ test_utils(void *arg)
tt_assert(!crypto_pk_generate_key(k));
tt_int_op(0, ==, crypto_pk_get_digest(k, digest));
tt_int_op(0, OP_EQ, crypto_pk_get_digest(k, digest));
memcpy(commit.rsa_identity, digest, sizeof(commit.rsa_identity));
tt_int_op(commit_is_authoritative(&commit, digest), ==, 1);
tt_int_op(commit_is_authoritative(&commit, digest), OP_EQ, 1);
/* Change the pubkey. */
memset(commit.rsa_identity, 0, sizeof(commit.rsa_identity));
tt_int_op(commit_is_authoritative(&commit, digest), ==, 0);
tt_int_op(commit_is_authoritative(&commit, digest), OP_EQ, 0);
crypto_pk_free(k);
}
/* Testing get_phase_str(). */
{
tt_str_op(get_phase_str(SR_PHASE_REVEAL), ==, "reveal");
tt_str_op(get_phase_str(SR_PHASE_COMMIT), ==, "commit");
tt_str_op(get_phase_str(SR_PHASE_REVEAL), OP_EQ, "reveal");
tt_str_op(get_phase_str(SR_PHASE_COMMIT), OP_EQ, "commit");
}
/* Testing phase transition */
{
init_authority_state();
set_sr_phase(SR_PHASE_COMMIT);
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), ==, 1);
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), ==, 0);
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), OP_EQ, 1);
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), OP_EQ, 0);
set_sr_phase(SR_PHASE_REVEAL);
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), ==, 0);
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), ==, 1);
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), OP_EQ, 0);
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), OP_EQ, 1);
/* Junk. */
tt_int_op(is_phase_transition(42), ==, 1);
tt_int_op(is_phase_transition(42), OP_EQ, 1);
}
done:
@ -1136,24 +1136,24 @@ test_state_transition(void *arg)
sr_commit_t *commit = sr_generate_our_commit(now, mock_cert);
tt_assert(commit);
sr_state_add_commit(commit);
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
/* Let's test our delete feature. */
sr_state_delete_commits();
tt_int_op(digestmap_size(state->commits), ==, 0);
tt_int_op(digestmap_size(state->commits), OP_EQ, 0);
/* Add it back so we can continue the rest of the test because after
* deletiong our commit will be freed so generate a new one. */
commit = sr_generate_our_commit(now, mock_cert);
tt_assert(commit);
sr_state_add_commit(commit);
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
state->n_reveal_rounds = 42;
state->n_commit_rounds = 43;
state->n_protocol_runs = 44;
reset_state_for_new_protocol_run(now);
tt_int_op(state->n_reveal_rounds, ==, 0);
tt_int_op(state->n_commit_rounds, ==, 0);
tt_u64_op(state->n_protocol_runs, ==, 45);
tt_int_op(digestmap_size(state->commits), ==, 0);
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
tt_int_op(state->n_commit_rounds, OP_EQ, 0);
tt_u64_op(state->n_protocol_runs, OP_EQ, 45);
tt_int_op(digestmap_size(state->commits), OP_EQ, 0);
}
/* Test SRV rotation in our state. */
@ -1166,7 +1166,7 @@ test_state_transition(void *arg)
state_rotate_srv();
prev = sr_state_get_previous_srv();
tt_assert(prev == cur);
tt_assert(!sr_state_get_current_srv());
tt_ptr_op(sr_state_get_current_srv(), OP_EQ, NULL);
sr_state_clean_srvs();
}
@ -1191,18 +1191,18 @@ test_state_transition(void *arg)
/* Also, make sure we did change the current. */
tt_assert(sr_state_get_current_srv() != cur);
/* We should have our commitment alone. */
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(state->n_reveal_rounds, ==, 0);
tt_int_op(state->n_commit_rounds, ==, 0);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
tt_int_op(state->n_commit_rounds, OP_EQ, 0);
/* 46 here since we were at 45 just before. */
tt_u64_op(state->n_protocol_runs, ==, 46);
tt_u64_op(state->n_protocol_runs, OP_EQ, 46);
}
/* Cleanup of SRVs. */
{
sr_state_clean_srvs();
tt_assert(!sr_state_get_current_srv());
tt_assert(!sr_state_get_previous_srv());
tt_ptr_op(sr_state_get_current_srv(), OP_EQ, NULL);
tt_ptr_op(sr_state_get_previous_srv(), OP_EQ, NULL);
}
done:
@ -1239,21 +1239,21 @@ test_keep_commit(void *arg)
/* Set us in COMMIT phase for starter. */
set_sr_phase(SR_PHASE_COMMIT);
/* We should never keep a commit from a non authoritative authority. */
tt_int_op(should_keep_commit(commit, fp, SR_PHASE_COMMIT), ==, 0);
tt_int_op(should_keep_commit(commit, fp, SR_PHASE_COMMIT), OP_EQ, 0);
/* This should NOT be kept because it has a reveal value in it. */
tt_assert(commit_has_reveal_value(commit));
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_COMMIT), ==, 0);
SR_PHASE_COMMIT), OP_EQ, 0);
/* Add it to the state which should return to not keep it. */
sr_state_add_commit(commit);
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_COMMIT), ==, 0);
SR_PHASE_COMMIT), OP_EQ, 0);
/* Remove it from state so we can continue our testing. */
digestmap_remove(state->commits, commit->rsa_identity);
/* Let's remove our reveal value which should make it OK to keep it. */
memset(commit->encoded_reveal, 0, sizeof(commit->encoded_reveal));
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_COMMIT), ==, 1);
SR_PHASE_COMMIT), OP_EQ, 1);
/* Let's reset our commit and go into REVEAL phase. */
sr_commit_free(commit);
@ -1265,17 +1265,17 @@ test_keep_commit(void *arg)
memset(dup_commit->encoded_reveal, 0, sizeof(dup_commit->encoded_reveal));
set_sr_phase(SR_PHASE_REVEAL);
/* We should never keep a commit from a non authoritative authority. */
tt_int_op(should_keep_commit(commit, fp, SR_PHASE_REVEAL), ==, 0);
tt_int_op(should_keep_commit(commit, fp, SR_PHASE_REVEAL), OP_EQ, 0);
/* We shouldn't accept a commit that is not in our state. */
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_REVEAL), ==, 0);
SR_PHASE_REVEAL), OP_EQ, 0);
/* Important to add the commit _without_ the reveal here. */
sr_state_add_commit(dup_commit);
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
/* Our commit should be valid that is authoritative, contains a reveal, be
* in the state and commitment and reveal values match. */
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_REVEAL), ==, 1);
SR_PHASE_REVEAL), OP_EQ, 1);
/* The commit shouldn't be kept if it's not verified that is no matchin
* hashed reveal. */
{
@ -1286,7 +1286,7 @@ test_keep_commit(void *arg)
memset(commit->hashed_reveal, 0, sizeof(commit->hashed_reveal));
setup_full_capture_of_logs(LOG_WARN);
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_REVEAL), ==, 0);
SR_PHASE_REVEAL), OP_EQ, 0);
expect_log_msg_containing("doesn't match the commit value.");
expect_log_msg_containing("has an invalid reveal value.");
assert_log_predicate(mock_saved_log_n_entries() == 2,
@ -1297,11 +1297,11 @@ test_keep_commit(void *arg)
}
/* We shouldn't keep a commit that has no reveal. */
tt_int_op(should_keep_commit(dup_commit, dup_commit->rsa_identity,
SR_PHASE_REVEAL), ==, 0);
SR_PHASE_REVEAL), OP_EQ, 0);
/* We must not keep a commit that is not the same from the commit phase. */
memset(commit->encoded_commit, 0, sizeof(commit->encoded_commit));
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
SR_PHASE_REVEAL), ==, 0);
SR_PHASE_REVEAL), OP_EQ, 0);
done:
teardown_capture_of_logs();
@ -1339,35 +1339,35 @@ test_state_update(void *arg)
/* We are in COMMIT phase here and we'll trigger a state update but no
* transition. */
sr_state_update(commit_phase_time);
tt_int_op(state->valid_after, ==, commit_phase_time);
tt_int_op(state->n_commit_rounds, ==, 1);
tt_int_op(state->phase, ==, SR_PHASE_COMMIT);
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(state->valid_after, OP_EQ, commit_phase_time);
tt_int_op(state->n_commit_rounds, OP_EQ, 1);
tt_int_op(state->phase, OP_EQ, SR_PHASE_COMMIT);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
/* We are still in the COMMIT phase here but we'll trigger a state
* transition to the REVEAL phase. */
sr_state_update(reveal_phase_time);
tt_int_op(state->phase, ==, SR_PHASE_REVEAL);
tt_int_op(state->valid_after, ==, reveal_phase_time);
tt_int_op(state->phase, OP_EQ, SR_PHASE_REVEAL);
tt_int_op(state->valid_after, OP_EQ, reveal_phase_time);
/* Only our commit should be in there. */
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(state->n_reveal_rounds, ==, 1);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
tt_int_op(state->n_reveal_rounds, OP_EQ, 1);
/* We can't update a state with a valid after _lower_ than the creation
* time so here it is. */
sr_state_update(commit_phase_time);
tt_int_op(state->valid_after, ==, reveal_phase_time);
tt_int_op(state->valid_after, OP_EQ, reveal_phase_time);
/* Finally, let's go back in COMMIT phase so we can test the state update
* of a new protocol run. */
state->valid_after = 0;
sr_state_update(commit_phase_time);
tt_int_op(state->valid_after, ==, commit_phase_time);
tt_int_op(state->n_commit_rounds, ==, 1);
tt_int_op(state->n_reveal_rounds, ==, 0);
tt_u64_op(state->n_protocol_runs, ==, 1);
tt_int_op(state->phase, ==, SR_PHASE_COMMIT);
tt_int_op(digestmap_size(state->commits), ==, 1);
tt_int_op(state->valid_after, OP_EQ, commit_phase_time);
tt_int_op(state->n_commit_rounds, OP_EQ, 1);
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
tt_u64_op(state->n_protocol_runs, OP_EQ, 1);
tt_int_op(state->phase, OP_EQ, SR_PHASE_COMMIT);
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
tt_assert(state->current_srv);
done:

View File

@ -61,8 +61,9 @@ test_socks_4_unsupported_commands(void *ptr)
/* SOCKS 4 Send BIND [02] to IP address 2.2.2.2:4369 */
ADD_DATA(buf, "\x04\x02\x11\x11\x02\x02\x02\x02\x00");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == -1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, -1);
tt_int_op(4,OP_EQ, socks->socks_version);
tt_int_op(0,OP_EQ, socks->replylen); /* XXX: shouldn't tor reply? */
@ -80,8 +81,9 @@ test_socks_4_supported_commands(void *ptr)
/* SOCKS 4 Send CONNECT [01] to IP address 2.2.2.2:4370 */
ADD_DATA(buf, "\x04\x01\x11\x12\x02\x02\x02\x03\x00");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(4,OP_EQ, socks->socks_version);
tt_int_op(0,OP_EQ, socks->replylen); /* XXX: shouldn't tor reply? */
tt_int_op(SOCKS_COMMAND_CONNECT,OP_EQ, socks->command);
@ -95,8 +97,9 @@ test_socks_4_supported_commands(void *ptr)
/* SOCKS 4 Send CONNECT [01] to IP address 2.2.2.2:4369 with userid*/
ADD_DATA(buf, "\x04\x01\x11\x12\x02\x02\x02\x04me\x00");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(4,OP_EQ, socks->socks_version);
tt_int_op(0,OP_EQ, socks->replylen); /* XXX: shouldn't tor reply? */
tt_int_op(SOCKS_COMMAND_CONNECT,OP_EQ, socks->command);
@ -112,8 +115,9 @@ test_socks_4_supported_commands(void *ptr)
/* SOCKS 4a Send RESOLVE [F0] request for torproject.org */
ADD_DATA(buf, "\x04\xF0\x01\x01\x00\x00\x00\x02me\x00torproject.org\x00");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(4,OP_EQ, socks->socks_version);
tt_int_op(0,OP_EQ, socks->replylen); /* XXX: shouldn't tor reply? */
tt_str_op("torproject.org",OP_EQ, socks->address);
@ -218,8 +222,9 @@ test_socks_5_supported_commands(void *ptr)
/* SOCKS 5 Send RESOLVE [F0] request for torproject.org:4369 */
ADD_DATA(buf, "\x05\x01\x00");
ADD_DATA(buf, "\x05\xF0\x00\x03\x0Etorproject.org\x01\x02");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(5,OP_EQ, socks->socks_version);
tt_int_op(2,OP_EQ, socks->replylen);
tt_int_op(5,OP_EQ, socks->reply[0]);
@ -236,8 +241,8 @@ test_socks_5_supported_commands(void *ptr)
ADD_DATA(buf, "\x05\xF0\x00\x03\x07");
ADD_DATA(buf, "8.8.8.8");
ADD_DATA(buf, "\x11\x11");
tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
== 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),
OP_EQ, 1);
tt_str_op("8.8.8.8", OP_EQ, socks->address);
tt_int_op(4369, OP_EQ, socks->port);
@ -253,8 +258,8 @@ test_socks_5_supported_commands(void *ptr)
ADD_DATA(buf, "\x05\xF0\x00\x03\x27");
ADD_DATA(buf, "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
ADD_DATA(buf, "\x01\x02");
tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
== -1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),
OP_EQ, -1);
tt_str_op("2001:0db8:85a3:0000:0000:8a2e:0370:7334", OP_EQ, socks->address);
tt_int_op(258, OP_EQ, socks->port);
@ -266,8 +271,9 @@ test_socks_5_supported_commands(void *ptr)
/* SOCKS 5 Send RESOLVE_PTR [F1] for IP address 2.2.2.5 */
ADD_DATA(buf, "\x05\x01\x00");
ADD_DATA(buf, "\x05\xF1\x00\x01\x02\x02\x02\x05\x01\x03");
tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(5,OP_EQ, socks->socks_version);
tt_int_op(2,OP_EQ, socks->replylen);
tt_int_op(5,OP_EQ, socks->reply[0]);
@ -378,9 +384,9 @@ test_socks_5_authenticate_with_data(void *ptr)
/* SOCKS 5 Send username/password */
/* SOCKS 5 Send CONNECT [01] to IP address 2.2.2.2:4369 */
ADD_DATA(buf, "\x01\x02me\x03you\x05\x01\x00\x01\x02\x02\x02\x02\x11\x11");
tt_assert(fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks) == 1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, 1);
tt_int_op(5,OP_EQ, socks->socks_version);
tt_int_op(2,OP_EQ, socks->replylen);
tt_int_op(1,OP_EQ, socks->reply[0]);
@ -406,9 +412,9 @@ test_socks_5_auth_before_negotiation(void *ptr)
/* SOCKS 5 Send username/password */
ADD_DATA(buf, "\x01\x02me\x02me");
tt_assert(fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks) == -1);
tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks),
OP_EQ, -1);
tt_int_op(0,OP_EQ, socks->socks_version);
tt_int_op(0,OP_EQ, socks->replylen);
tt_int_op(0,OP_EQ, socks->reply[0]);

View File

@ -889,8 +889,8 @@ NS(logv)(int severity, log_domain_mask_t domain, const char *funcname,
tt_str_op(format, OP_EQ,
"Average packaged cell fullness: %2.3f%%. "
"TLS write overhead: %.f%%");
tt_double_op(fabs(va_arg(ap, double) - 50.0), <=, DBL_EPSILON);
tt_double_op(fabs(va_arg(ap, double) - 0.0), <=, DBL_EPSILON);
tt_double_op(fabs(va_arg(ap, double) - 50.0), OP_LE, DBL_EPSILON);
tt_double_op(fabs(va_arg(ap, double) - 0.0), OP_LE, DBL_EPSILON);
break;
default:
tt_abort_msg("unexpected call to logv()"); // TODO: prettyprint args
@ -1039,7 +1039,7 @@ NS(logv)(int severity, log_domain_mask_t domain,
"Average packaged cell fullness: %2.3f%%. "
"TLS write overhead: %.f%%");
tt_int_op(fabs(va_arg(ap, double) - 100.0) <= DBL_EPSILON, OP_EQ, 1);
tt_double_op(fabs(va_arg(ap, double) - 100.0), <=, DBL_EPSILON);
tt_double_op(fabs(va_arg(ap, double) - 100.0), OP_LE, DBL_EPSILON);
break;
default:
tt_abort_msg("unexpected call to logv()"); // TODO: prettyprint args

View File

@ -338,7 +338,7 @@ test_storagedir_read_labeled(void *arg)
tt_assert(labels->next->next);
tt_str_op(labels->next->next->key, OP_EQ, "Yadda");
tt_str_op(labels->next->next->value, OP_EQ, "yadda.");
tt_assert(labels->next->next->next == NULL);
tt_ptr_op(labels->next->next->next, OP_EQ, NULL);
/* Try reading this time. */
sz = 0;

View File

@ -139,8 +139,8 @@ test_threads_basic(void *arg)
!strcmp(strmap_get(thread_test_strmap_, "thread 2"),
strmap_get(thread_test_strmap_, "last to run")));
tt_int_op(thread_fns_failed, ==, 0);
tt_int_op(thread_fn_tid1, !=, thread_fn_tid2);
tt_int_op(thread_fns_failed, OP_EQ, 0);
tt_int_op(thread_fn_tid1, OP_NE, thread_fn_tid2);
done:
tor_free(s1);
@ -275,14 +275,14 @@ test_threads_conditionvar(void *arg)
SPIN();
tor_mutex_release(ti->mutex);
tt_int_op(ti->value, ==, 1337);
tt_int_op(ti->value, OP_EQ, 1337);
if (!timeout) {
tt_int_op(ti->n_shutdown, ==, 4);
tt_int_op(ti->n_shutdown, OP_EQ, 4);
} else {
tor_sleep_msec(200);
tor_mutex_acquire(ti->mutex);
tt_int_op(ti->n_shutdown, ==, 2);
tt_int_op(ti->n_timeouts, ==, 2);
tt_int_op(ti->n_shutdown, OP_EQ, 2);
tt_int_op(ti->n_timeouts, OP_EQ, 2);
tor_mutex_release(ti->mutex);
}

View File

@ -136,7 +136,7 @@ test_tortls_tor_tls_new(void *data)
SSL_CTX_free(client_tls_context->ctx);
client_tls_context->ctx = NULL;
tls = tor_tls_new(-1, 0);
tt_assert(!tls);
tt_ptr_op(tls, OP_EQ, NULL);
#ifndef OPENSSL_OPAQUE
method = give_me_a_test_method();
@ -144,7 +144,7 @@ test_tortls_tor_tls_new(void *data)
method->num_ciphers = fake_num_ciphers;
client_tls_context->ctx = ctx;
tls = tor_tls_new(-1, 0);
tt_assert(!tls);
tt_ptr_op(tls, OP_EQ, NULL);
#endif
done:

View File

@ -70,7 +70,7 @@ test_util_read_until_eof_impl(const char *fname, size_t file_len,
fd = open(fifo_name, O_RDONLY|O_BINARY);
tt_int_op(fd, OP_GE, 0);
str = read_file_to_str_until_eof(fd, read_limit, &sz);
tt_assert(str != NULL);
tt_ptr_op(str, OP_NE, NULL);
if (read_limit < file_len)
tt_int_op(sz, OP_EQ, read_limit);
@ -1674,14 +1674,14 @@ test_util_config_line_crlf(void *arg)
tt_assert(str);
tt_str_op(k,OP_EQ,"Hello");
tt_str_op(v,OP_EQ,"world");
tt_assert(!err);
tt_ptr_op(err, OP_EQ, NULL);
tor_free(k); tor_free(v);
str = parse_config_line_from_str_verbose(str, &k, &v, &err);
tt_assert(str);
tt_str_op(k,OP_EQ,"Hello");
tt_str_op(v,OP_EQ,"nice big world");
tt_assert(!err);
tt_ptr_op(err, OP_EQ, NULL);
tor_free(k); tor_free(v);
tt_str_op(str,OP_EQ, "");
@ -1941,7 +1941,7 @@ test_util_strmisc(void *arg)
tt_assert(!tor_mem_is_zero(buf, 10));
/* Test 'escaped' */
tt_assert(NULL == escaped(NULL));
tt_ptr_op(escaped(NULL), OP_EQ, NULL);
tt_str_op("\"\"",OP_EQ, escaped(""));
tt_str_op("\"abcd\"",OP_EQ, escaped("abcd"));
tt_str_op("\"\\\\ \\n\\r\\t\\\"\\'\"",OP_EQ, escaped("\\ \n\r\t\"'"));
@ -1999,23 +1999,23 @@ test_util_strmisc(void *arg)
/* Test memmem and memstr */
{
const char *haystack = "abcde";
tt_assert(!tor_memmem(haystack, 5, "ef", 2));
tt_ptr_op(tor_memmem(haystack, 5, "ef", 2), OP_EQ, NULL);
tt_ptr_op(tor_memmem(haystack, 5, "cd", 2),OP_EQ, haystack + 2);
tt_ptr_op(tor_memmem(haystack, 5, "cde", 3),OP_EQ, haystack + 2);
tt_assert(!tor_memmem(haystack, 4, "cde", 3));
tt_ptr_op(tor_memmem(haystack, 4, "cde", 3), OP_EQ, NULL);
haystack = "ababcad";
tt_ptr_op(tor_memmem(haystack, 7, "abc", 3),OP_EQ, haystack + 2);
tt_ptr_op(tor_memmem(haystack, 7, "ad", 2),OP_EQ, haystack + 5);
tt_ptr_op(tor_memmem(haystack, 7, "cad", 3),OP_EQ, haystack + 4);
tt_assert(!tor_memmem(haystack, 7, "dadad", 5));
tt_assert(!tor_memmem(haystack, 7, "abcdefghij", 10));
tt_ptr_op(tor_memmem(haystack, 7, "dadad", 5), OP_EQ, NULL);
tt_ptr_op(tor_memmem(haystack, 7, "abcdefghij", 10), OP_EQ, NULL);
/* memstr */
tt_ptr_op(tor_memstr(haystack, 7, "abc"),OP_EQ, haystack + 2);
tt_ptr_op(tor_memstr(haystack, 7, "cad"),OP_EQ, haystack + 4);
tt_assert(!tor_memstr(haystack, 6, "cad"));
tt_assert(!tor_memstr(haystack, 7, "cadd"));
tt_assert(!tor_memstr(haystack, 7, "fe"));
tt_assert(!tor_memstr(haystack, 7, "ababcade"));
tt_ptr_op(tor_memstr(haystack, 6, "cad"), OP_EQ, NULL);
tt_ptr_op(tor_memstr(haystack, 7, "cadd"), OP_EQ, NULL);
tt_ptr_op(tor_memstr(haystack, 7, "fe"), OP_EQ, NULL);
tt_ptr_op(tor_memstr(haystack, 7, "ababcade"), OP_EQ, NULL);
}
/* Test hex_str */
@ -2260,15 +2260,15 @@ test_util_compress_impl(compress_method_t method)
tt_assert(tor_compress_supports_method(method));
if (method != NO_METHOD) {
tt_assert(tor_compress_version_str(method) != NULL);
tt_assert(tor_compress_header_version_str(method) != NULL);
tt_ptr_op(tor_compress_version_str(method), OP_NE, NULL);
tt_ptr_op(tor_compress_header_version_str(method), OP_NE, NULL);
}
buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ");
tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD);
tt_assert(!tor_compress(&buf2, &len1, buf1, strlen(buf1)+1, method));
tt_assert(buf2 != NULL);
tt_ptr_op(buf2, OP_NE, NULL);
if (method == NO_METHOD) {
// The identity transform doesn't actually compress, and it isn't
// detectable as "the identity transform."
@ -2280,7 +2280,7 @@ test_util_compress_impl(compress_method_t method)
}
tt_assert(!tor_uncompress(&buf3, &len2, buf2, len1, method, 1, LOG_INFO));
tt_assert(buf3 != NULL);
tt_ptr_op(buf3, OP_NE, NULL);
tt_int_op(strlen(buf1) + 1, OP_EQ, len2);
tt_str_op(buf1, OP_EQ, buf3);
tt_int_op(buf3[len2], OP_EQ, 0);
@ -2327,7 +2327,7 @@ test_util_compress_impl(compress_method_t method)
if (method != NO_METHOD) {
tt_assert(tor_uncompress(&buf3, &len2, buf2, len1-16,
method, 1, LOG_INFO));
tt_assert(buf3 == NULL);
tt_ptr_op(buf3, OP_EQ, NULL);
}
done:
@ -2534,7 +2534,7 @@ test_util_mmap(void *arg)
crypto_rand(buf, buflen);
mapping = tor_mmap_file(fname1);
tt_assert(! mapping);
tt_ptr_op(mapping, OP_EQ, NULL);
write_str_to_file(fname1, "Short file.", 1);
@ -2563,7 +2563,7 @@ test_util_mmap(void *arg)
/* Make sure that we fail to map a no-longer-existent file. */
mapping = tor_mmap_file(fname1);
tt_assert(! mapping);
tt_ptr_op(mapping, OP_EQ, NULL);
/* Now try a big file that stretches across a few pages and isn't aligned */
write_bytes_to_file(fname2, buf, buflen, 1);
@ -3631,8 +3631,8 @@ test_util_strtok(void *arg)
}
tor_snprintf(buf, sizeof(buf), "%s", pad1);
tor_snprintf(buf2, sizeof(buf2), "%s", pad2);
tt_assert(NULL == tor_strtok_r_impl(buf, " ", &cp1));
tt_assert(NULL == tor_strtok_r_impl(buf2, ".!..;!", &cp2));
tt_ptr_op(tor_strtok_r_impl(buf, " ", &cp1), OP_EQ, NULL);
tt_ptr_op(tor_strtok_r_impl(buf2, ".!..;!", &cp2), OP_EQ, NULL);
tor_snprintf(buf, sizeof(buf),
"%sGraved on the dark in gestures of descent%s", pad1, pad1);
@ -4376,7 +4376,7 @@ test_util_split_lines(void *ptr)
/* Check we have not got too many lines */
tt_int_op(MAX_SPLIT_LINE_COUNT, OP_GT, j);
/* Check that there actually should be a line here */
tt_assert(tests[i].split_line[j] != NULL);
tt_ptr_op(tests[i].split_line[j], OP_NE, NULL);
log_info(LD_GENERAL, "Line %d of test %d, should be <%s>",
j, i, tests[i].split_line[j]);
/* Check that the line is as expected */
@ -4492,11 +4492,11 @@ test_util_di_map(void *arg)
char dflt_entry[] = "'You have made a good beginning', but no more";
tt_int_op(32, ==, sizeof(key1));
tt_int_op(32, ==, sizeof(key2));
tt_int_op(32, ==, sizeof(key3));
tt_int_op(32, OP_EQ, sizeof(key1));
tt_int_op(32, OP_EQ, sizeof(key2));
tt_int_op(32, OP_EQ, sizeof(key3));
tt_ptr_op(dflt_entry, ==, dimap_search(dimap, key1, dflt_entry));
tt_ptr_op(dflt_entry, OP_EQ, dimap_search(dimap, key1, dflt_entry));
char *str1 = tor_strdup("You are precisely as big as what you love"
" and precisely as small as what you allow"
@ -4514,10 +4514,10 @@ test_util_di_map(void *arg)
dimap_add_entry(&dimap, key2, str2);
dimap_add_entry(&dimap, key3, str3);
tt_ptr_op(str1, ==, dimap_search(dimap, key1, dflt_entry));
tt_ptr_op(str3, ==, dimap_search(dimap, key3, dflt_entry));
tt_ptr_op(str2, ==, dimap_search(dimap, key2, dflt_entry));
tt_ptr_op(dflt_entry, ==, dimap_search(dimap, key4, dflt_entry));
tt_ptr_op(str1, OP_EQ, dimap_search(dimap, key1, dflt_entry));
tt_ptr_op(str3, OP_EQ, dimap_search(dimap, key3, dflt_entry));
tt_ptr_op(str2, OP_EQ, dimap_search(dimap, key2, dflt_entry));
tt_ptr_op(dflt_entry, OP_EQ, dimap_search(dimap, key4, dflt_entry));
done:
dimap_free(dimap, tor_free_);
@ -4984,34 +4984,34 @@ test_util_round_to_next_multiple_of(void *arg)
{
(void)arg;
tt_u64_op(round_uint64_to_next_multiple_of(0,1), ==, 0);
tt_u64_op(round_uint64_to_next_multiple_of(0,7), ==, 0);
tt_u64_op(round_uint64_to_next_multiple_of(0,1), OP_EQ, 0);
tt_u64_op(round_uint64_to_next_multiple_of(0,7), OP_EQ, 0);
tt_u64_op(round_uint64_to_next_multiple_of(99,1), ==, 99);
tt_u64_op(round_uint64_to_next_multiple_of(99,7), ==, 105);
tt_u64_op(round_uint64_to_next_multiple_of(99,9), ==, 99);
tt_u64_op(round_uint64_to_next_multiple_of(99,1), OP_EQ, 99);
tt_u64_op(round_uint64_to_next_multiple_of(99,7), OP_EQ, 105);
tt_u64_op(round_uint64_to_next_multiple_of(99,9), OP_EQ, 99);
tt_u64_op(round_uint64_to_next_multiple_of(UINT64_MAX,2), ==,
tt_u64_op(round_uint64_to_next_multiple_of(UINT64_MAX,2), OP_EQ,
UINT64_MAX);
tt_int_op(round_uint32_to_next_multiple_of(0,1), ==, 0);
tt_int_op(round_uint32_to_next_multiple_of(0,7), ==, 0);
tt_int_op(round_uint32_to_next_multiple_of(0,1), OP_EQ, 0);
tt_int_op(round_uint32_to_next_multiple_of(0,7), OP_EQ, 0);
tt_int_op(round_uint32_to_next_multiple_of(99,1), ==, 99);
tt_int_op(round_uint32_to_next_multiple_of(99,7), ==, 105);
tt_int_op(round_uint32_to_next_multiple_of(99,9), ==, 99);
tt_int_op(round_uint32_to_next_multiple_of(99,1), OP_EQ, 99);
tt_int_op(round_uint32_to_next_multiple_of(99,7), OP_EQ, 105);
tt_int_op(round_uint32_to_next_multiple_of(99,9), OP_EQ, 99);
tt_int_op(round_uint32_to_next_multiple_of(UINT32_MAX,2), ==,
tt_int_op(round_uint32_to_next_multiple_of(UINT32_MAX,2), OP_EQ,
UINT32_MAX);
tt_uint_op(round_to_next_multiple_of(0,1), ==, 0);
tt_uint_op(round_to_next_multiple_of(0,7), ==, 0);
tt_uint_op(round_to_next_multiple_of(0,1), OP_EQ, 0);
tt_uint_op(round_to_next_multiple_of(0,7), OP_EQ, 0);
tt_uint_op(round_to_next_multiple_of(99,1), ==, 99);
tt_uint_op(round_to_next_multiple_of(99,7), ==, 105);
tt_uint_op(round_to_next_multiple_of(99,9), ==, 99);
tt_uint_op(round_to_next_multiple_of(99,1), OP_EQ, 99);
tt_uint_op(round_to_next_multiple_of(99,7), OP_EQ, 105);
tt_uint_op(round_to_next_multiple_of(99,9), OP_EQ, 99);
tt_uint_op(round_to_next_multiple_of(UINT_MAX,2), ==,
tt_uint_op(round_to_next_multiple_of(UINT_MAX,2), OP_EQ,
UINT_MAX);
done:
;
@ -5032,26 +5032,26 @@ test_util_laplace(void *arg)
const double delta_f = 15.0, epsilon = 0.3; /* b = 15.0 / 0.3 = 50.0 */
(void)arg;
tt_i64_op(INT64_MIN, ==, sample_laplace_distribution(mu, b, 0.0));
tt_i64_op(-69, ==, sample_laplace_distribution(mu, b, 0.01));
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.5));
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.51));
tt_i64_op(117, ==, sample_laplace_distribution(mu, b, 0.99));
tt_i64_op(INT64_MIN, OP_EQ, sample_laplace_distribution(mu, b, 0.0));
tt_i64_op(-69, OP_EQ, sample_laplace_distribution(mu, b, 0.01));
tt_i64_op(24, OP_EQ, sample_laplace_distribution(mu, b, 0.5));
tt_i64_op(24, OP_EQ, sample_laplace_distribution(mu, b, 0.51));
tt_i64_op(117, OP_EQ, sample_laplace_distribution(mu, b, 0.99));
/* >>> laplace.ppf([0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99],
* ... loc = 0, scale = 50)
* array([ -inf, -80.47189562, -34.65735903, 0. ,
* 34.65735903, 80.47189562, 195.60115027])
*/
tt_i64_op(INT64_MIN + 20, ==,
tt_i64_op(INT64_MIN + 20, OP_EQ,
add_laplace_noise(20, 0.0, delta_f, epsilon));
tt_i64_op(-60, ==, add_laplace_noise(20, 0.1, delta_f, epsilon));
tt_i64_op(-14, ==, add_laplace_noise(20, 0.25, delta_f, epsilon));
tt_i64_op(20, ==, add_laplace_noise(20, 0.5, delta_f, epsilon));
tt_i64_op(54, ==, add_laplace_noise(20, 0.75, delta_f, epsilon));
tt_i64_op(100, ==, add_laplace_noise(20, 0.9, delta_f, epsilon));
tt_i64_op(215, ==, add_laplace_noise(20, 0.99, delta_f, epsilon));
tt_i64_op(-60, OP_EQ, add_laplace_noise(20, 0.1, delta_f, epsilon));
tt_i64_op(-14, OP_EQ, add_laplace_noise(20, 0.25, delta_f, epsilon));
tt_i64_op(20, OP_EQ, add_laplace_noise(20, 0.5, delta_f, epsilon));
tt_i64_op(54, OP_EQ, add_laplace_noise(20, 0.75, delta_f, epsilon));
tt_i64_op(100, OP_EQ, add_laplace_noise(20, 0.9, delta_f, epsilon));
tt_i64_op(215, OP_EQ, add_laplace_noise(20, 0.99, delta_f, epsilon));
/* Test extreme values of signal with maximally negative values of noise
* 1.0000000000000002 is the smallest number > 1
@ -5064,54 +5064,54 @@ test_util_laplace(void *arg)
*/
const double noscale_df = 1.0, noscale_eps = 1.0;
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(0, 0.0, noscale_df, noscale_eps));
/* is it clipped to INT64_MIN? */
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(-1, 0.0, noscale_df, noscale_eps));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(INT64_MIN, 0.0,
noscale_df, noscale_eps));
/* ... even when scaled? */
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(0, 0.0, delta_f, epsilon));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(0, 0.0,
DBL_MAX, 1));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(INT64_MIN, 0.0,
DBL_MAX, 1));
/* does it play nice with INT64_MAX? */
tt_i64_op((INT64_MIN + INT64_MAX), ==,
tt_i64_op((INT64_MIN + INT64_MAX), OP_EQ,
add_laplace_noise(INT64_MAX, 0.0,
noscale_df, noscale_eps));
/* do near-zero fractional values work? */
const double min_dbl_error = 0.0000000000000002;
tt_i64_op(-35, ==,
tt_i64_op(-35, OP_EQ,
add_laplace_noise(0, min_dbl_error,
noscale_df, noscale_eps));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(INT64_MIN, min_dbl_error,
noscale_df, noscale_eps));
tt_i64_op((-35 + INT64_MAX), ==,
tt_i64_op((-35 + INT64_MAX), OP_EQ,
add_laplace_noise(INT64_MAX, min_dbl_error,
noscale_df, noscale_eps));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(0, min_dbl_error,
DBL_MAX, 1));
tt_i64_op((INT64_MAX + INT64_MIN), ==,
tt_i64_op((INT64_MAX + INT64_MIN), OP_EQ,
add_laplace_noise(INT64_MAX, min_dbl_error,
DBL_MAX, 1));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
add_laplace_noise(INT64_MIN, min_dbl_error,
DBL_MAX, 1));
/* does it play nice with INT64_MAX? */
tt_i64_op((INT64_MAX - 35), ==,
tt_i64_op((INT64_MAX - 35), OP_EQ,
add_laplace_noise(INT64_MAX, min_dbl_error,
noscale_df, noscale_eps));
@ -5126,31 +5126,31 @@ test_util_laplace(void *arg)
const double max_dbl_lt_one = 0.9999999999999998;
/* do near-one fractional values work? */
tt_i64_op(35, ==,
tt_i64_op(35, OP_EQ,
add_laplace_noise(0, max_dbl_lt_one, noscale_df, noscale_eps));
/* is it clipped to INT64_MAX? */
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
add_laplace_noise(INT64_MAX - 35, max_dbl_lt_one,
noscale_df, noscale_eps));
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
add_laplace_noise(INT64_MAX - 34, max_dbl_lt_one,
noscale_df, noscale_eps));
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
noscale_df, noscale_eps));
/* ... even when scaled? */
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
delta_f, epsilon));
tt_i64_op((INT64_MIN + INT64_MAX), ==,
tt_i64_op((INT64_MIN + INT64_MAX), OP_EQ,
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
DBL_MAX, 1));
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
DBL_MAX, 1));
/* does it play nice with INT64_MIN? */
tt_i64_op((INT64_MIN + 35), ==,
tt_i64_op((INT64_MIN + 35), OP_EQ,
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
noscale_df, noscale_eps));
@ -5163,32 +5163,32 @@ test_util_clamp_double_to_int64(void *arg)
{
(void)arg;
tt_i64_op(INT64_MIN, ==, clamp_double_to_int64(-INFINITY_DBL));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ, clamp_double_to_int64(-INFINITY_DBL));
tt_i64_op(INT64_MIN, OP_EQ,
clamp_double_to_int64(-1.0 * pow(2.0, 64.0) - 1.0));
tt_i64_op(INT64_MIN, ==,
tt_i64_op(INT64_MIN, OP_EQ,
clamp_double_to_int64(-1.0 * pow(2.0, 63.0) - 1.0));
tt_i64_op(((uint64_t) -1) << 53, ==,
tt_i64_op(((uint64_t) -1) << 53, OP_EQ,
clamp_double_to_int64(-1.0 * pow(2.0, 53.0)));
tt_i64_op((((uint64_t) -1) << 53) + 1, ==,
tt_i64_op((((uint64_t) -1) << 53) + 1, OP_EQ,
clamp_double_to_int64(-1.0 * pow(2.0, 53.0) + 1.0));
tt_i64_op(-1, ==, clamp_double_to_int64(-1.0));
tt_i64_op(0, ==, clamp_double_to_int64(-0.9));
tt_i64_op(0, ==, clamp_double_to_int64(-0.1));
tt_i64_op(0, ==, clamp_double_to_int64(0.0));
tt_i64_op(0, ==, clamp_double_to_int64(NAN_DBL));
tt_i64_op(0, ==, clamp_double_to_int64(0.1));
tt_i64_op(0, ==, clamp_double_to_int64(0.9));
tt_i64_op(1, ==, clamp_double_to_int64(1.0));
tt_i64_op((((int64_t) 1) << 53) - 1, ==,
tt_i64_op(-1, OP_EQ, clamp_double_to_int64(-1.0));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(-0.9));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(-0.1));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.0));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(NAN_DBL));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.1));
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.9));
tt_i64_op(1, OP_EQ, clamp_double_to_int64(1.0));
tt_i64_op((((int64_t) 1) << 53) - 1, OP_EQ,
clamp_double_to_int64(pow(2.0, 53.0) - 1.0));
tt_i64_op(((int64_t) 1) << 53, ==,
tt_i64_op(((int64_t) 1) << 53, OP_EQ,
clamp_double_to_int64(pow(2.0, 53.0)));
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
clamp_double_to_int64(pow(2.0, 63.0)));
tt_i64_op(INT64_MAX, ==,
tt_i64_op(INT64_MAX, OP_EQ,
clamp_double_to_int64(pow(2.0, 64.0)));
tt_i64_op(INT64_MAX, ==, clamp_double_to_int64(INFINITY_DBL));
tt_i64_op(INT64_MAX, OP_EQ, clamp_double_to_int64(INFINITY_DBL));
done:
;
@ -5556,25 +5556,25 @@ test_util_pwdb(void *arg)
/* Uncached case. */
/* Let's assume that we exist. */
me = tor_getpwuid(getuid());
tt_assert(me != NULL);
tt_ptr_op(me, OP_NE, NULL);
name = tor_strdup(me->pw_name);
/* Uncached case */
me2 = tor_getpwnam(name);
tt_assert(me2 != NULL);
tt_ptr_op(me2, OP_NE, NULL);
tt_int_op(me2->pw_uid, OP_EQ, getuid());
/* Cached case */
me3 = tor_getpwuid(getuid());
tt_assert(me3 != NULL);
tt_ptr_op(me3, OP_NE, NULL);
tt_str_op(me3->pw_name, OP_EQ, name);
me3 = tor_getpwnam(name);
tt_assert(me3 != NULL);
tt_ptr_op(me3, OP_NE, NULL);
tt_int_op(me3->pw_uid, OP_EQ, getuid());
dir = get_user_homedir(name);
tt_assert(dir != NULL);
tt_ptr_op(dir, OP_NE, NULL);
/* Try failing cases. First find a user that doesn't exist by name */
char randbytes[4];
@ -5594,7 +5594,7 @@ test_util_pwdb(void *arg)
/* We should do a LOG_ERR */
setup_full_capture_of_logs(LOG_ERR);
dir = get_user_homedir(badname);
tt_assert(dir == NULL);
tt_ptr_op(dir, OP_EQ, NULL);
expect_log_msg_containing("not found");
tt_int_op(smartlist_len(mock_saved_logs()), OP_EQ, 1);
teardown_capture_of_logs();

View File

@ -345,7 +345,7 @@ test_util_format_base32_decode(void *arg)
const char *src = "mjwgc2dcnrswqmjs";
ret = base32_decode(dst, strlen(expected), src, strlen(src));
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_str_op(expected, OP_EQ, dst);
}
@ -356,7 +356,7 @@ test_util_format_base32_decode(void *arg)
const char *src = "mjwgc2dcnrswq";
ret = base32_decode(dst, strlen(expected), src, strlen(src));
tt_int_op(ret, ==, 0);
tt_int_op(ret, OP_EQ, 0);
tt_mem_op(expected, OP_EQ, dst, strlen(expected));
}
@ -364,9 +364,9 @@ test_util_format_base32_decode(void *arg)
{
/* Invalid character '#'. */
ret = base32_decode(dst, real_dstlen, "#abcde", 6);
tt_int_op(ret, ==, -1);
tt_int_op(ret, OP_EQ, -1);
/* Make sure the destination buffer has been zeroed even on error. */
tt_int_op(tor_mem_is_zero(dst, real_dstlen), ==, 1);
tt_int_op(tor_mem_is_zero(dst, real_dstlen), OP_EQ, 1);
}
done:

View File

@ -78,7 +78,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
return;
}
tt_assert(process_handle != NULL);
tt_ptr_op(process_handle, OP_NE, NULL);
/* When a spawned process forks, fails, then exits very quickly,
* (this typically occurs when exec fails)