mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Fix operator usage in src/test/*.c
This patch fixes the operator usage in src/test/*.c to use the symbolic operators instead of the normal C comparison operators. This patch was generated using: ./scripts/coccinelle/test-operator-cleanup src/test/*.[ch]
This commit is contained in:
parent
9e1fa95920
commit
c4744a01cc
@ -45,8 +45,8 @@
|
|||||||
* you're doing. */
|
* you're doing. */
|
||||||
#define tt_double_eq(a,b) \
|
#define tt_double_eq(a,b) \
|
||||||
STMT_BEGIN \
|
STMT_BEGIN \
|
||||||
tt_double_op((a), >=, (b)); \
|
tt_double_op((a), OP_GE, (b)); \
|
||||||
tt_double_op((a), <=, (b)); \
|
tt_double_op((a), OP_LE, (b)); \
|
||||||
STMT_END
|
STMT_END
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -233,7 +233,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
|
|||||||
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in));
|
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,
|
tt_assert(sockaddr_in_are_equal((struct sockaddr_in *)sockaddr_to_check,
|
||||||
ipv4_sockaddr_local));
|
ipv4_sockaddr_local));
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
|
|||||||
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in));
|
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,
|
tt_assert(sockaddr_in_are_equal((struct sockaddr_in *)sockaddr_to_check,
|
||||||
ipv4_sockaddr_remote));
|
ipv4_sockaddr_remote));
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ test_address_ifaddrs_to_smartlist(void *arg)
|
|||||||
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
tor_addr_to_sockaddr(tor_addr,0,sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in6));
|
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,
|
tt_assert(sockaddr_in6_are_equal((struct sockaddr_in6*)sockaddr_to_check,
|
||||||
ipv6_sockaddr));
|
ipv6_sockaddr));
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ test_address_get_if_addrs_win32(void *arg)
|
|||||||
|
|
||||||
results = get_interface_addresses_win32(LOG_ERR, AF_UNSPEC);
|
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_localhost_tor_addr(results));
|
||||||
tt_assert(!smartlist_contains_null_tor_addr(results));
|
tt_assert(!smartlist_contains_null_tor_addr(results));
|
||||||
|
|
||||||
@ -456,14 +456,14 @@ test_address_ifreq_to_smartlist(void *arg)
|
|||||||
ifc->ifc_ifcu.ifcu_req = ifr;
|
ifc->ifc_ifcu.ifcu_req = ifr;
|
||||||
|
|
||||||
results = ifreq_to_smartlist(ifc->ifc_buf,ifc->ifc_len);
|
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);
|
tor_addr = smartlist_get(results, 0);
|
||||||
addr_len =
|
addr_len =
|
||||||
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
|
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in));
|
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));
|
tt_assert(sockaddr_in_are_equal(sockaddr,sockaddr_to_check));
|
||||||
|
|
||||||
ifr = tor_realloc(ifr,2*sizeof(struct ifreq));
|
ifr = tor_realloc(ifr,2*sizeof(struct ifreq));
|
||||||
@ -479,14 +479,14 @@ test_address_ifreq_to_smartlist(void *arg)
|
|||||||
smartlist_free(results);
|
smartlist_free(results);
|
||||||
|
|
||||||
results = ifreq_to_smartlist(ifc->ifc_buf,ifc->ifc_len);
|
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);
|
tor_addr = smartlist_get(results, 0);
|
||||||
addr_len =
|
addr_len =
|
||||||
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
|
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in));
|
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));
|
tt_assert(sockaddr_in_are_equal(sockaddr,sockaddr_to_check));
|
||||||
|
|
||||||
tor_addr = smartlist_get(results, 1);
|
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,
|
tor_addr_to_sockaddr(tor_addr,0,(struct sockaddr *)sockaddr_to_check,
|
||||||
sizeof(struct sockaddr_in));
|
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));
|
tt_assert(sockaddr_in_are_equal(sockaddr_eth1,sockaddr_to_check));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -633,7 +633,7 @@ test_address_udp_socket_trick_whitebox(void *arg)
|
|||||||
get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
|
get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
|
||||||
AF_INET, addr_from_hack);
|
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));
|
tt_assert(tor_addr_eq_ipv4h(addr_from_hack, 0x1720f676));
|
||||||
|
|
||||||
/* Now, lets do an IPv6 case. */
|
/* 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,
|
get_interface_address6_via_udp_socket_hack(LOG_DEBUG,
|
||||||
AF_INET6, addr_from_hack);
|
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,
|
tor_addr_to_sockaddr(addr_from_hack,0,(struct sockaddr *)ipv6_to_check,
|
||||||
sizeof(struct sockaddr_in6));
|
sizeof(struct sockaddr_in6));
|
||||||
@ -693,7 +693,7 @@ test_address_udp_socket_trick_blackbox(void *arg)
|
|||||||
AF_INET,
|
AF_INET,
|
||||||
&addr4_to_check);
|
&addr4_to_check);
|
||||||
|
|
||||||
tt_int_op(retval,==,retval_reference);
|
tt_int_op(retval,OP_EQ,retval_reference);
|
||||||
tt_assert( (retval == -1 && retval_reference == -1) ||
|
tt_assert( (retval == -1 && retval_reference == -1) ||
|
||||||
(tor_addr_compare(&addr4,&addr4_to_check,CMP_EXACT) == 0) );
|
(tor_addr_compare(&addr4,&addr4_to_check,CMP_EXACT) == 0) );
|
||||||
|
|
||||||
@ -702,7 +702,7 @@ test_address_udp_socket_trick_blackbox(void *arg)
|
|||||||
AF_INET6,
|
AF_INET6,
|
||||||
&addr6_to_check);
|
&addr6_to_check);
|
||||||
|
|
||||||
tt_int_op(retval,==,retval_reference);
|
tt_int_op(retval,OP_EQ,retval_reference);
|
||||||
tt_assert( (retval == -1 && retval_reference == -1) ||
|
tt_assert( (retval == -1 && retval_reference == -1) ||
|
||||||
(tor_addr_compare(&addr6,&addr6_to_check,CMP_EXACT) == 0) );
|
(tor_addr_compare(&addr6,&addr6_to_check,CMP_EXACT) == 0) );
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ test_address_get_if_addrs_list_internal(void *arg)
|
|||||||
/* When the network is down, a system might not have any non-local
|
/* When the network is down, a system might not have any non-local
|
||||||
* non-multicast addresseses, not even internal ones.
|
* non-multicast addresseses, not even internal ones.
|
||||||
* Unit tests shouldn't fail because of this. */
|
* 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_localhost_tor_addr(results));
|
||||||
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
||||||
@ -778,7 +778,7 @@ test_address_get_if_addrs_list_no_internal(void *arg)
|
|||||||
|
|
||||||
tt_assert(results != NULL);
|
tt_assert(results != NULL);
|
||||||
/* Work even on systems with only internal IPv4 addresses */
|
/* 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_localhost_tor_addr(results));
|
||||||
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
||||||
@ -820,7 +820,7 @@ test_address_get_if_addrs6_list_internal(void *arg)
|
|||||||
|
|
||||||
tt_assert(results != NULL);
|
tt_assert(results != NULL);
|
||||||
/* Work even on systems without IPv6 interfaces */
|
/* 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_localhost_tor_addr(results));
|
||||||
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
||||||
@ -863,7 +863,7 @@ test_address_get_if_addrs6_list_no_internal(void *arg)
|
|||||||
|
|
||||||
tt_assert(results != NULL);
|
tt_assert(results != NULL);
|
||||||
/* Work even on systems without IPv6 interfaces */
|
/* 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_localhost_tor_addr(results));
|
||||||
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
tt_assert(!smartlist_contains_multicast_tor_addr(results));
|
||||||
@ -928,11 +928,11 @@ test_address_get_if_addrs_internal_fail(void *arg)
|
|||||||
|
|
||||||
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 1);
|
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 1);
|
||||||
tt_assert(results1 != NULL);
|
tt_assert(results1 != NULL);
|
||||||
tt_int_op(smartlist_len(results1),==,0);
|
tt_int_op(smartlist_len(results1),OP_EQ,0);
|
||||||
|
|
||||||
results2 = get_interface_address_list(LOG_ERR, 1);
|
results2 = get_interface_address_list(LOG_ERR, 1);
|
||||||
tt_assert(results2 != NULL);
|
tt_assert(results2 != NULL);
|
||||||
tt_int_op(smartlist_len(results2),==,0);
|
tt_int_op(smartlist_len(results2),OP_EQ,0);
|
||||||
|
|
||||||
rv = get_interface_address6(LOG_ERR, AF_INET6, &ipv6_addr);
|
rv = get_interface_address6(LOG_ERR, AF_INET6, &ipv6_addr);
|
||||||
tt_assert(rv == -1);
|
tt_assert(rv == -1);
|
||||||
@ -962,11 +962,11 @@ test_address_get_if_addrs_no_internal_fail(void *arg)
|
|||||||
|
|
||||||
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 0);
|
results1 = get_interface_address6_list(LOG_ERR, AF_INET6, 0);
|
||||||
tt_assert(results1 != NULL);
|
tt_assert(results1 != NULL);
|
||||||
tt_int_op(smartlist_len(results1),==,0);
|
tt_int_op(smartlist_len(results1),OP_EQ,0);
|
||||||
|
|
||||||
results2 = get_interface_address_list(LOG_ERR, 0);
|
results2 = get_interface_address_list(LOG_ERR, 0);
|
||||||
tt_assert(results2 != NULL);
|
tt_assert(results2 != NULL);
|
||||||
tt_int_op(smartlist_len(results2),==,0);
|
tt_int_op(smartlist_len(results2),OP_EQ,0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
UNMOCK(get_interface_addresses_raw);
|
UNMOCK(get_interface_addresses_raw);
|
||||||
|
@ -762,11 +762,11 @@ test_buffers_tls_read_mocked(void *arg)
|
|||||||
buf = buf_new();
|
buf = buf_new();
|
||||||
|
|
||||||
next_reply_val[0] = 1024;
|
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[0] = 5000;
|
||||||
next_reply_val[1] = 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:
|
done:
|
||||||
UNMOCK(tor_tls_read);
|
UNMOCK(tor_tls_read);
|
||||||
@ -831,8 +831,8 @@ test_buffers_find_contentlen(void *arg)
|
|||||||
r = buf_http_find_content_length(tmp, headerlen, &sz);
|
r = buf_http_find_content_length(tmp, headerlen, &sz);
|
||||||
tor_free(tmp);
|
tor_free(tmp);
|
||||||
log_debug(LD_DIR, "%d: %s", i, escaped(results[i].headers));
|
log_debug(LD_DIR, "%d: %s", i, escaped(results[i].headers));
|
||||||
tt_int_op(r, ==, results[i].r);
|
tt_int_op(r, OP_EQ, results[i].r);
|
||||||
tt_int_op(sz, ==, results[i].contentlen);
|
tt_int_op(sz, OP_EQ, results[i].contentlen);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
|
@ -268,7 +268,7 @@ static const char *
|
|||||||
chan_test_get_remote_descr(channel_t *ch, int flags)
|
chan_test_get_remote_descr(channel_t *ch, int flags)
|
||||||
{
|
{
|
||||||
tt_assert(ch);
|
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:
|
done:
|
||||||
return "Fake channel for unit tests; no real endpoint";
|
return "Fake channel for unit tests; no real endpoint";
|
||||||
@ -552,24 +552,24 @@ test_channel_dumpstats(void *arg)
|
|||||||
channel_dumpstats(LOG_DEBUG);
|
channel_dumpstats(LOG_DEBUG);
|
||||||
|
|
||||||
/* Assert that we hit the mock */
|
/* 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 */
|
/* Close the channel */
|
||||||
channel_mark_for_close(ch);
|
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);
|
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 */
|
/* Try again and hit the finished channel */
|
||||||
channel_dumpstats(LOG_DEBUG);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
/* Now we should hit nothing */
|
/* Now we should hit nothing */
|
||||||
channel_dumpstats(LOG_DEBUG);
|
channel_dumpstats(LOG_DEBUG);
|
||||||
tt_int_op(dump_statistics_mock_matches, ==, 2);
|
tt_int_op(dump_statistics_mock_matches, OP_EQ, 2);
|
||||||
|
|
||||||
/* Unmock */
|
/* Unmock */
|
||||||
UNMOCK(channel_dump_statistics);
|
UNMOCK(channel_dump_statistics);
|
||||||
@ -594,7 +594,7 @@ test_channel_dumpstats(void *arg)
|
|||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
channel_write_cell(ch, cell);
|
channel_write_cell(ch, cell);
|
||||||
cell = NULL;
|
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_bytes_xmitted > 0);
|
||||||
tt_assert(ch->n_cells_xmitted > 0);
|
tt_assert(ch->n_cells_xmitted > 0);
|
||||||
|
|
||||||
@ -602,14 +602,14 @@ test_channel_dumpstats(void *arg)
|
|||||||
channel_set_cell_handlers(ch,
|
channel_set_cell_handlers(ch,
|
||||||
chan_test_cell_handler,
|
chan_test_cell_handler,
|
||||||
chan_test_var_cell_handler);
|
chan_test_var_cell_handler);
|
||||||
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_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), ==, chan_test_var_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));
|
cell = tor_malloc_zero(sizeof(cell_t));
|
||||||
make_fake_cell(cell);
|
make_fake_cell(cell);
|
||||||
old_count = test_chan_fixed_cells_recved;
|
old_count = test_chan_fixed_cells_recved;
|
||||||
channel_queue_cell(ch, cell);
|
channel_queue_cell(ch, cell);
|
||||||
tor_free(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_bytes_recved > 0);
|
||||||
tt_assert(ch->n_cells_recved > 0);
|
tt_assert(ch->n_cells_recved > 0);
|
||||||
|
|
||||||
@ -619,13 +619,13 @@ test_channel_dumpstats(void *arg)
|
|||||||
ch->is_canonical = chan_test_is_canonical;
|
ch->is_canonical = chan_test_is_canonical;
|
||||||
old_count = test_dumpstats_calls;
|
old_count = test_dumpstats_calls;
|
||||||
channel_dump_statistics(ch, LOG_DEBUG);
|
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 */
|
/* Close the channel */
|
||||||
channel_mark_for_close(ch);
|
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);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -664,21 +664,21 @@ test_channel_flush(void *arg)
|
|||||||
make_fake_cell(cell);
|
make_fake_cell(cell);
|
||||||
channel_write_cell(ch, cell);
|
channel_write_cell(ch, cell);
|
||||||
/* It should be queued, so assert that we didn't write it */
|
/* 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 */
|
/* Queue a var cell */
|
||||||
v_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
v_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
||||||
make_fake_var_cell(v_cell);
|
make_fake_var_cell(v_cell);
|
||||||
channel_write_var_cell(ch, v_cell);
|
channel_write_var_cell(ch, v_cell);
|
||||||
/* It should be queued, so assert that we didn't write it */
|
/* 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 */
|
/* Try a packed cell now */
|
||||||
p_cell = packed_cell_new();
|
p_cell = packed_cell_new();
|
||||||
tt_assert(p_cell);
|
tt_assert(p_cell);
|
||||||
channel_write_packed_cell(ch, p_cell);
|
channel_write_packed_cell(ch, p_cell);
|
||||||
/* It should be queued, so assert that we didn't write it */
|
/* 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 */
|
/* Now allow writes through again */
|
||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
@ -687,7 +687,7 @@ test_channel_flush(void *arg)
|
|||||||
channel_flush_cells(ch);
|
channel_flush_cells(ch);
|
||||||
|
|
||||||
/* All three should have gone through */
|
/* 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:
|
done:
|
||||||
tor_free(ch);
|
tor_free(ch);
|
||||||
@ -728,9 +728,9 @@ test_channel_flushmux(void *arg)
|
|||||||
|
|
||||||
result = channel_flush_some_cells(ch, 1);
|
result = channel_flush_some_cells(ch, 1);
|
||||||
|
|
||||||
tt_int_op(result, ==, 1);
|
tt_int_op(result, OP_EQ, 1);
|
||||||
tt_int_op(test_cells_written, ==, old_count + 1);
|
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
|
||||||
tt_int_op(test_cmux_cells, ==, 0);
|
tt_int_op(test_cmux_cells, OP_EQ, 0);
|
||||||
|
|
||||||
/* Now try it without accepting to force them into the queue */
|
/* Now try it without accepting to force them into the queue */
|
||||||
test_chan_accept_cells = 0;
|
test_chan_accept_cells = 0;
|
||||||
@ -740,19 +740,19 @@ test_channel_flushmux(void *arg)
|
|||||||
result = channel_flush_some_cells(ch, 1);
|
result = channel_flush_some_cells(ch, 1);
|
||||||
|
|
||||||
/* We should not have actually flushed any */
|
/* We should not have actually flushed any */
|
||||||
tt_int_op(result, ==, 0);
|
tt_int_op(result, OP_EQ, 0);
|
||||||
tt_int_op(test_cells_written, ==, old_count + 1);
|
tt_int_op(test_cells_written, OP_EQ, old_count + 1);
|
||||||
/* But we should have gotten to the fake cellgen loop */
|
/* 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 */
|
/* ...and we should have a queued cell */
|
||||||
q_len_after = chan_cell_queue_len(&(ch->outgoing_queue));
|
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 */
|
/* Now accept cells again and drain the queue */
|
||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
channel_flush_cells(ch);
|
channel_flush_cells(ch);
|
||||||
tt_int_op(test_cells_written, ==, old_count + 2);
|
tt_int_op(test_cells_written, OP_EQ, old_count + 2);
|
||||||
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), ==, 0);
|
tt_int_op(chan_cell_queue_len(&(ch->outgoing_queue)), OP_EQ, 0);
|
||||||
|
|
||||||
test_target_cmux = NULL;
|
test_target_cmux = NULL;
|
||||||
test_cmux_cells = 0;
|
test_cmux_cells = 0;
|
||||||
@ -803,8 +803,8 @@ test_channel_incoming(void *arg)
|
|||||||
chan_test_cell_handler,
|
chan_test_cell_handler,
|
||||||
chan_test_var_cell_handler);
|
chan_test_var_cell_handler);
|
||||||
/* Test cell handler getters */
|
/* Test cell handler getters */
|
||||||
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_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), ==, chan_test_var_cell_handler);
|
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ, chan_test_var_cell_handler);
|
||||||
|
|
||||||
/* Try to register it */
|
/* Try to register it */
|
||||||
channel_register(ch);
|
channel_register(ch);
|
||||||
@ -812,7 +812,7 @@ test_channel_incoming(void *arg)
|
|||||||
|
|
||||||
/* Open it */
|
/* Open it */
|
||||||
channel_change_state_open(ch);
|
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 */
|
/* Receive a fixed cell */
|
||||||
cell = tor_malloc_zero(sizeof(cell_t));
|
cell = tor_malloc_zero(sizeof(cell_t));
|
||||||
@ -820,7 +820,7 @@ test_channel_incoming(void *arg)
|
|||||||
old_count = test_chan_fixed_cells_recved;
|
old_count = test_chan_fixed_cells_recved;
|
||||||
channel_queue_cell(ch, cell);
|
channel_queue_cell(ch, cell);
|
||||||
tor_free(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 */
|
/* Receive a variable-size cell */
|
||||||
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
||||||
@ -828,13 +828,13 @@ test_channel_incoming(void *arg)
|
|||||||
old_count = test_chan_var_cells_recved;
|
old_count = test_chan_var_cells_recved;
|
||||||
channel_queue_var_cell(ch, var_cell);
|
channel_queue_var_cell(ch, var_cell);
|
||||||
tor_free(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 */
|
/* Close it */
|
||||||
channel_mark_for_close(ch);
|
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);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -896,13 +896,13 @@ test_channel_lifecycle(void *arg)
|
|||||||
make_fake_cell(cell);
|
make_fake_cell(cell);
|
||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
channel_write_cell(ch1, cell);
|
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 */
|
/* Move it to OPEN and flush */
|
||||||
channel_change_state_open(ch1);
|
channel_change_state_open(ch1);
|
||||||
|
|
||||||
/* Queue should drain */
|
/* 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 */
|
/* Get another one */
|
||||||
ch2 = new_fake_channel();
|
ch2 = new_fake_channel();
|
||||||
@ -915,41 +915,41 @@ test_channel_lifecycle(void *arg)
|
|||||||
tt_assert(ch2->registered);
|
tt_assert(ch2->registered);
|
||||||
|
|
||||||
/* Check counters */
|
/* Check counters */
|
||||||
tt_int_op(test_doesnt_want_writes_count, ==, init_doesnt_want_writes_count);
|
tt_int_op(test_doesnt_want_writes_count, OP_EQ, init_doesnt_want_writes_count);
|
||||||
tt_int_op(test_releases_count, ==, init_releases_count);
|
tt_int_op(test_releases_count, OP_EQ, init_releases_count);
|
||||||
|
|
||||||
/* Move ch1 to MAINT */
|
/* Move ch1 to MAINT */
|
||||||
channel_change_state(ch1, CHANNEL_STATE_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);
|
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 */
|
/* Move ch2 to OPEN */
|
||||||
channel_change_state_open(ch2);
|
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);
|
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 */
|
/* Move ch1 back to OPEN */
|
||||||
channel_change_state_open(ch1);
|
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);
|
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 */
|
/* Mark ch2 for close */
|
||||||
channel_mark_for_close(ch2);
|
channel_mark_for_close(ch2);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSING);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSING);
|
||||||
tt_int_op(test_doesnt_want_writes_count, ==,
|
tt_int_op(test_doesnt_want_writes_count, OP_EQ,
|
||||||
init_doesnt_want_writes_count + 1);
|
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 */
|
/* Shut down channels */
|
||||||
channel_free_all();
|
channel_free_all();
|
||||||
ch1 = ch2 = NULL;
|
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);
|
init_doesnt_want_writes_count + 1);
|
||||||
/* channel_free() calls scheduler_release_channel() */
|
/* 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:
|
done:
|
||||||
free_fake_channel(ch1);
|
free_fake_channel(ch1);
|
||||||
@ -1001,11 +1001,11 @@ test_channel_lifecycle_2(void *arg)
|
|||||||
|
|
||||||
/* Try to close it */
|
/* Try to close it */
|
||||||
channel_mark_for_close(ch);
|
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 */
|
/* Finish closing it */
|
||||||
chan_test_finish_close(ch);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1022,9 +1022,9 @@ test_channel_lifecycle_2(void *arg)
|
|||||||
|
|
||||||
/* Error exit from lower layer */
|
/* Error exit from lower layer */
|
||||||
chan_test_error(ch);
|
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);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1038,19 +1038,19 @@ test_channel_lifecycle_2(void *arg)
|
|||||||
|
|
||||||
/* Finish opening it */
|
/* Finish opening it */
|
||||||
channel_change_state_open(ch);
|
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 */
|
/* Go to maintenance state */
|
||||||
channel_change_state(ch, CHANNEL_STATE_MAINT);
|
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 */
|
/* Lower layer close */
|
||||||
channel_mark_for_close(ch);
|
channel_mark_for_close(ch);
|
||||||
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
|
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
|
||||||
|
|
||||||
/* Finish */
|
/* Finish */
|
||||||
chan_test_finish_close(ch);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1067,19 +1067,19 @@ test_channel_lifecycle_2(void *arg)
|
|||||||
|
|
||||||
/* Finish opening it */
|
/* Finish opening it */
|
||||||
channel_change_state_open(ch);
|
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 */
|
/* Go to maintenance state */
|
||||||
channel_change_state(ch, CHANNEL_STATE_MAINT);
|
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 */
|
/* Lower layer close */
|
||||||
channel_close_from_lower_layer(ch);
|
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 */
|
/* Finish */
|
||||||
chan_test_finish_close(ch);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1093,19 +1093,19 @@ test_channel_lifecycle_2(void *arg)
|
|||||||
|
|
||||||
/* Finish opening it */
|
/* Finish opening it */
|
||||||
channel_change_state_open(ch);
|
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 */
|
/* Go to maintenance state */
|
||||||
channel_change_state(ch, CHANNEL_STATE_MAINT);
|
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 */
|
/* Lower layer close */
|
||||||
chan_test_error(ch);
|
chan_test_error(ch);
|
||||||
tt_int_op(ch->state, ==, CHANNEL_STATE_CLOSING);
|
tt_int_op(ch->state, OP_EQ, CHANNEL_STATE_CLOSING);
|
||||||
|
|
||||||
/* Finish */
|
/* Finish */
|
||||||
chan_test_finish_close(ch);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1142,11 +1142,11 @@ test_channel_multi(void *arg)
|
|||||||
|
|
||||||
/* Initial queue size update */
|
/* Initial queue size update */
|
||||||
channel_update_xmit_queue_size(ch1);
|
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);
|
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();
|
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 */
|
/* Queue some cells, check queue estimates */
|
||||||
cell = tor_malloc_zero(sizeof(cell_t));
|
cell = tor_malloc_zero(sizeof(cell_t));
|
||||||
@ -1159,10 +1159,10 @@ test_channel_multi(void *arg)
|
|||||||
|
|
||||||
channel_update_xmit_queue_size(ch1);
|
channel_update_xmit_queue_size(ch1);
|
||||||
channel_update_xmit_queue_size(ch2);
|
channel_update_xmit_queue_size(ch2);
|
||||||
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 0);
|
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 0);
|
||||||
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();
|
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 */
|
/* Stop accepting cells at lower layer */
|
||||||
test_chan_accept_cells = 0;
|
test_chan_accept_cells = 0;
|
||||||
@ -1173,18 +1173,18 @@ test_channel_multi(void *arg)
|
|||||||
channel_write_cell(ch1, cell);
|
channel_write_cell(ch1, cell);
|
||||||
|
|
||||||
channel_update_xmit_queue_size(ch1);
|
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();
|
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));
|
cell = tor_malloc_zero(sizeof(cell_t));
|
||||||
make_fake_cell(cell);
|
make_fake_cell(cell);
|
||||||
channel_write_cell(ch2, cell);
|
channel_write_cell(ch2, cell);
|
||||||
|
|
||||||
channel_update_xmit_queue_size(ch2);
|
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();
|
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 */
|
/* Allow cells through again */
|
||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
@ -1195,10 +1195,10 @@ test_channel_multi(void *arg)
|
|||||||
/* Update and check queue sizes */
|
/* Update and check queue sizes */
|
||||||
channel_update_xmit_queue_size(ch1);
|
channel_update_xmit_queue_size(ch1);
|
||||||
channel_update_xmit_queue_size(ch2);
|
channel_update_xmit_queue_size(ch2);
|
||||||
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 512);
|
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 512);
|
||||||
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();
|
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 */
|
/* Flush chan 1 */
|
||||||
channel_flush_cells(ch1);
|
channel_flush_cells(ch1);
|
||||||
@ -1206,10 +1206,10 @@ test_channel_multi(void *arg)
|
|||||||
/* Update and check queue sizes */
|
/* Update and check queue sizes */
|
||||||
channel_update_xmit_queue_size(ch1);
|
channel_update_xmit_queue_size(ch1);
|
||||||
channel_update_xmit_queue_size(ch2);
|
channel_update_xmit_queue_size(ch2);
|
||||||
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 0);
|
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 0);
|
||||||
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();
|
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 */
|
/* Now block again */
|
||||||
test_chan_accept_cells = 0;
|
test_chan_accept_cells = 0;
|
||||||
@ -1227,10 +1227,10 @@ test_channel_multi(void *arg)
|
|||||||
/* Check the estimates */
|
/* Check the estimates */
|
||||||
channel_update_xmit_queue_size(ch1);
|
channel_update_xmit_queue_size(ch1);
|
||||||
channel_update_xmit_queue_size(ch2);
|
channel_update_xmit_queue_size(ch2);
|
||||||
tt_u64_op(ch1->bytes_queued_for_xmit, ==, 512);
|
tt_u64_op(ch1->bytes_queued_for_xmit, OP_EQ, 512);
|
||||||
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();
|
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 */
|
/* Now close channel 2; it should be subtracted from the global queue */
|
||||||
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
||||||
@ -1238,7 +1238,7 @@ test_channel_multi(void *arg)
|
|||||||
UNMOCK(scheduler_release_channel);
|
UNMOCK(scheduler_release_channel);
|
||||||
|
|
||||||
global_queue_estimate = channel_get_global_queue_estimate();
|
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
|
* Since the fake channels aren't registered, channel_free_all() can't
|
||||||
@ -1249,7 +1249,7 @@ test_channel_multi(void *arg)
|
|||||||
UNMOCK(scheduler_release_channel);
|
UNMOCK(scheduler_release_channel);
|
||||||
|
|
||||||
global_queue_estimate = channel_get_global_queue_estimate();
|
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 */
|
/* Now free everything */
|
||||||
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
||||||
@ -1297,7 +1297,7 @@ test_channel_queue_impossible(void *arg)
|
|||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
|
|
||||||
/* Assert that the queue is initially empty */
|
/* 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*/
|
/* Get a fresh cell and write it to the channel*/
|
||||||
cell = tor_malloc_zero(sizeof(cell_t));
|
cell = tor_malloc_zero(sizeof(cell_t));
|
||||||
@ -1306,11 +1306,11 @@ test_channel_queue_impossible(void *arg)
|
|||||||
channel_write_cell(ch, cell);
|
channel_write_cell(ch, cell);
|
||||||
|
|
||||||
/* Now it should be queued */
|
/* 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));
|
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
|
||||||
tt_assert(q);
|
tt_assert(q);
|
||||||
if (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);
|
tt_assert((uintptr_t)q->u.fixed.cell == cellintptr);
|
||||||
}
|
}
|
||||||
/* Do perverse things to it */
|
/* Do perverse things to it */
|
||||||
@ -1324,7 +1324,7 @@ test_channel_queue_impossible(void *arg)
|
|||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
channel_change_state_open(ch);
|
channel_change_state_open(ch);
|
||||||
tt_assert(test_cells_written == old_count);
|
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 */
|
/* Same thing but for a var_cell */
|
||||||
|
|
||||||
@ -1336,11 +1336,11 @@ test_channel_queue_impossible(void *arg)
|
|||||||
channel_write_var_cell(ch, var_cell);
|
channel_write_var_cell(ch, var_cell);
|
||||||
|
|
||||||
/* Check that it's queued */
|
/* 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));
|
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
|
||||||
tt_assert(q);
|
tt_assert(q);
|
||||||
if (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);
|
tt_assert((uintptr_t)q->u.var.var_cell == cellintptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1352,7 +1352,7 @@ test_channel_queue_impossible(void *arg)
|
|||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
channel_change_state_open(ch);
|
channel_change_state_open(ch);
|
||||||
tt_assert(test_cells_written == old_count);
|
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 */
|
/* Same thing with a packed_cell */
|
||||||
|
|
||||||
@ -1364,11 +1364,11 @@ test_channel_queue_impossible(void *arg)
|
|||||||
channel_write_packed_cell(ch, packed_cell);
|
channel_write_packed_cell(ch, packed_cell);
|
||||||
|
|
||||||
/* Check that it's queued */
|
/* 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));
|
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
|
||||||
tt_assert(q);
|
tt_assert(q);
|
||||||
if (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);
|
tt_assert((uintptr_t)q->u.packed.packed_cell == cellintptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1380,7 +1380,7 @@ test_channel_queue_impossible(void *arg)
|
|||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
channel_change_state_open(ch);
|
channel_change_state_open(ch);
|
||||||
tt_assert(test_cells_written == old_count);
|
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 */
|
/* Unknown cell type case */
|
||||||
test_chan_accept_cells = 0;
|
test_chan_accept_cells = 0;
|
||||||
@ -1391,11 +1391,11 @@ test_channel_queue_impossible(void *arg)
|
|||||||
channel_write_cell(ch, cell);
|
channel_write_cell(ch, cell);
|
||||||
|
|
||||||
/* Check that it's queued */
|
/* 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));
|
q = TOR_SIMPLEQ_FIRST(&(ch->outgoing_queue));
|
||||||
tt_assert(q);
|
tt_assert(q);
|
||||||
if (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);
|
tt_assert((uintptr_t)q->u.fixed.cell == cellintptr);
|
||||||
}
|
}
|
||||||
/* Clobber it, including the queue entry type */
|
/* Clobber it, including the queue entry type */
|
||||||
@ -1408,9 +1408,9 @@ test_channel_queue_impossible(void *arg)
|
|||||||
tor_capture_bugs_(1);
|
tor_capture_bugs_(1);
|
||||||
channel_change_state_open(ch);
|
channel_change_state_open(ch);
|
||||||
tt_assert(test_cells_written == old_count);
|
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_();
|
tor_end_capture_bugs_();
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1455,8 +1455,8 @@ test_channel_queue_incoming(void *arg)
|
|||||||
ch->cmux = circuitmux_alloc();
|
ch->cmux = circuitmux_alloc();
|
||||||
|
|
||||||
/* Test cell handler getters */
|
/* Test cell handler getters */
|
||||||
tt_ptr_op(channel_get_cell_handler(ch), ==, NULL);
|
tt_ptr_op(channel_get_cell_handler(ch), OP_EQ, NULL);
|
||||||
tt_ptr_op(channel_get_var_cell_handler(ch), ==, NULL);
|
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ, NULL);
|
||||||
|
|
||||||
/* Try to register it */
|
/* Try to register it */
|
||||||
channel_register(ch);
|
channel_register(ch);
|
||||||
@ -1464,7 +1464,7 @@ test_channel_queue_incoming(void *arg)
|
|||||||
|
|
||||||
/* Open it */
|
/* Open it */
|
||||||
channel_change_state_open(ch);
|
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 */
|
/* Assert that the incoming queue is empty */
|
||||||
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
|
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
|
||||||
@ -1475,7 +1475,7 @@ test_channel_queue_incoming(void *arg)
|
|||||||
channel_queue_cell(ch, cell);
|
channel_queue_cell(ch, cell);
|
||||||
|
|
||||||
/* Assert that the incoming queue has one entry */
|
/* 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 */
|
/* Queue an incoming var cell */
|
||||||
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
var_cell = tor_malloc_zero(sizeof(var_cell_t) + CELL_PAYLOAD_SIZE);
|
||||||
@ -1483,7 +1483,7 @@ test_channel_queue_incoming(void *arg)
|
|||||||
channel_queue_var_cell(ch, var_cell);
|
channel_queue_var_cell(ch, var_cell);
|
||||||
|
|
||||||
/* Assert that the incoming queue has two entries */
|
/* 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
|
* Install cell handlers; this will drain the queue, so save the old
|
||||||
@ -1494,12 +1494,12 @@ test_channel_queue_incoming(void *arg)
|
|||||||
channel_set_cell_handlers(ch,
|
channel_set_cell_handlers(ch,
|
||||||
chan_test_cell_handler,
|
chan_test_cell_handler,
|
||||||
chan_test_var_cell_handler);
|
chan_test_var_cell_handler);
|
||||||
tt_ptr_op(channel_get_cell_handler(ch), ==, chan_test_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), ==, chan_test_var_cell_handler);
|
tt_ptr_op(channel_get_var_cell_handler(ch), OP_EQ, chan_test_var_cell_handler);
|
||||||
|
|
||||||
/* Assert cells were received */
|
/* Assert cells were received */
|
||||||
tt_int_op(test_chan_fixed_cells_recved, ==, old_fixed_count + 1);
|
tt_int_op(test_chan_fixed_cells_recved, OP_EQ, old_fixed_count + 1);
|
||||||
tt_int_op(test_chan_var_cells_recved, ==, old_var_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;
|
* Assert that the pointers are different from the cells we allocated;
|
||||||
@ -1508,17 +1508,17 @@ test_channel_queue_incoming(void *arg)
|
|||||||
* delivery. These pointers will have already been freed by the time
|
* delivery. These pointers will have already been freed by the time
|
||||||
* we get here, so don't dereference them.
|
* 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_fixed_cell_ptr, OP_NE, cell);
|
||||||
tt_ptr_op(test_chan_last_seen_var_cell_ptr, !=, var_cell);
|
tt_ptr_op(test_chan_last_seen_var_cell_ptr, OP_NE, var_cell);
|
||||||
|
|
||||||
/* Assert queue is now empty */
|
/* Assert queue is now empty */
|
||||||
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
|
tt_assert(TOR_SIMPLEQ_EMPTY(&(ch->incoming_queue)));
|
||||||
|
|
||||||
/* Close it; this contains an assertion that the incoming queue is empty */
|
/* Close it; this contains an assertion that the incoming queue is empty */
|
||||||
channel_mark_for_close(ch);
|
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);
|
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();
|
channel_run_cleanup();
|
||||||
ch = NULL;
|
ch = NULL;
|
||||||
|
|
||||||
@ -1548,14 +1548,14 @@ test_channel_queue_size(void *arg)
|
|||||||
|
|
||||||
/* Initial queue size update */
|
/* Initial queue size update */
|
||||||
channel_update_xmit_queue_size(ch);
|
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();
|
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 */
|
/* Test the call-through to our fake lower layer */
|
||||||
n = channel_num_cells_writeable(ch);
|
n = channel_num_cells_writeable(ch);
|
||||||
/* chan_test_num_cells_writeable() always returns 32 */
|
/* 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()
|
* Now we queue some cells and check that channel_num_cells_writeable()
|
||||||
@ -1574,32 +1574,32 @@ test_channel_queue_size(void *arg)
|
|||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
channel_write_cell(ch, cell);
|
channel_write_cell(ch, cell);
|
||||||
/* Assert that it got queued, not written through, correctly */
|
/* 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 */
|
/* Now check chan_test_num_cells_writeable() again */
|
||||||
n = channel_num_cells_writeable(ch);
|
n = channel_num_cells_writeable(ch);
|
||||||
tt_int_op(n, ==, 0); /* Should return 0 since we're in CHANNEL_STATE_MAINT */
|
tt_int_op(n, OP_EQ, 0); /* Should return 0 since we're in CHANNEL_STATE_MAINT */
|
||||||
|
|
||||||
/* Update queue size estimates */
|
/* Update queue size estimates */
|
||||||
channel_update_xmit_queue_size(ch);
|
channel_update_xmit_queue_size(ch);
|
||||||
/* One cell, times an overhead factor of 1.0 */
|
/* 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 */
|
/* Try a different overhead factor */
|
||||||
test_overhead_estimate = 0.5;
|
test_overhead_estimate = 0.5;
|
||||||
/* This one should be ignored since it's below 1.0 */
|
/* This one should be ignored since it's below 1.0 */
|
||||||
channel_update_xmit_queue_size(ch);
|
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 */
|
/* Now try a larger one */
|
||||||
test_overhead_estimate = 2.0;
|
test_overhead_estimate = 2.0;
|
||||||
channel_update_xmit_queue_size(ch);
|
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 */
|
/* Go back to 1.0 */
|
||||||
test_overhead_estimate = 1.0;
|
test_overhead_estimate = 1.0;
|
||||||
channel_update_xmit_queue_size(ch);
|
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 */
|
/* Check the global estimate too */
|
||||||
global_queue_estimate = channel_get_global_queue_estimate();
|
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 */
|
/* Go to open */
|
||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
@ -1609,37 +1609,37 @@ test_channel_queue_size(void *arg)
|
|||||||
* It should try to write, but we aren't accepting cells right now, so
|
* It should try to write, but we aren't accepting cells right now, so
|
||||||
* it'll requeue
|
* 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 */
|
/* Check the queue size again */
|
||||||
channel_update_xmit_queue_size(ch);
|
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();
|
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
|
* Now the cell is in the queue, and we're open, so we should get 31
|
||||||
* writeable cells.
|
* writeable cells.
|
||||||
*/
|
*/
|
||||||
n = channel_num_cells_writeable(ch);
|
n = channel_num_cells_writeable(ch);
|
||||||
tt_int_op(n, ==, 31);
|
tt_int_op(n, OP_EQ, 31);
|
||||||
|
|
||||||
/* Accept cells again */
|
/* Accept cells again */
|
||||||
test_chan_accept_cells = 1;
|
test_chan_accept_cells = 1;
|
||||||
/* ...and re-process the queue */
|
/* ...and re-process the queue */
|
||||||
old_count = test_cells_written;
|
old_count = test_cells_written;
|
||||||
channel_flush_cells(ch);
|
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 */
|
/* Should have 32 writeable now */
|
||||||
n = channel_num_cells_writeable(ch);
|
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 */
|
/* Should have queue size estimate of zero */
|
||||||
channel_update_xmit_queue_size(ch);
|
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();
|
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 */
|
/* Okay, now we're done with this one */
|
||||||
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
MOCK(scheduler_release_channel, scheduler_release_channel_mock);
|
||||||
|
@ -142,7 +142,7 @@ test_channeltls_num_bytes_queued(void *arg)
|
|||||||
tlschan_buf_datalen_mock_size = 1024;
|
tlschan_buf_datalen_mock_size = 1024;
|
||||||
MOCK(buf_datalen, tlschan_buf_datalen_mock);
|
MOCK(buf_datalen, tlschan_buf_datalen_mock);
|
||||||
len = ch->num_bytes_queued(ch);
|
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
|
* We also cover num_cells_writeable here; since wide_circ_ids = 0 on
|
||||||
* the fake tlschans, cell_network_size returns 512, and so with
|
* the fake tlschans, cell_network_size returns 512, and so with
|
||||||
@ -151,7 +151,7 @@ test_channeltls_num_bytes_queued(void *arg)
|
|||||||
* - 2 cells.
|
* - 2 cells.
|
||||||
*/
|
*/
|
||||||
n = ch->num_cells_writeable(ch);
|
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);
|
UNMOCK(buf_datalen);
|
||||||
tlschan_buf_datalen_mock_target = NULL;
|
tlschan_buf_datalen_mock_target = NULL;
|
||||||
tlschan_buf_datalen_mock_size = 0;
|
tlschan_buf_datalen_mock_size = 0;
|
||||||
@ -302,7 +302,7 @@ tlschan_fake_close_method(channel_t *chan)
|
|||||||
channel_tls_t *tlschan = NULL;
|
channel_tls_t *tlschan = NULL;
|
||||||
|
|
||||||
tt_assert(chan != NULL);
|
tt_assert(chan != NULL);
|
||||||
tt_int_op(chan->magic, ==, TLS_CHAN_MAGIC);
|
tt_int_op(chan->magic, OP_EQ, TLS_CHAN_MAGIC);
|
||||||
|
|
||||||
tlschan = BASE_CHAN_TO_TLS(chan);
|
tlschan = BASE_CHAN_TO_TLS(chan);
|
||||||
tt_assert(tlschan != NULL);
|
tt_assert(tlschan != NULL);
|
||||||
|
@ -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));
|
circuit_t *circ = tor_malloc(sizeof(circuit_t));
|
||||||
circ->marked_for_close = 1;
|
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:
|
done:
|
||||||
tor_free(circ);
|
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));
|
circuit_t *circ = tor_malloc(sizeof(circuit_t));
|
||||||
circ->timestamp_dirty = 1;
|
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:
|
done:
|
||||||
tor_free(circ);
|
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));
|
circuit_t *circ = tor_malloc(sizeof(circuit_t));
|
||||||
circ->purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
|
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:
|
done:
|
||||||
tor_free(circ);
|
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));
|
circuit_t *circ = tor_malloc(sizeof(circuit_t));
|
||||||
circ->purpose = CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT;
|
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:
|
done:
|
||||||
tor_free(circ);
|
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));
|
circuit_t *circ = tor_malloc(sizeof(circuit_t));
|
||||||
circ->purpose = CIRCUIT_PURPOSE_OR;
|
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:
|
done:
|
||||||
tor_free(circ);
|
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);
|
circuit_t *circ = dummy_origin_circuit_new(30);
|
||||||
mark_circuit_unusable_for_new_conns(TO_ORIGIN_CIRCUIT(circ));
|
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:
|
done:
|
||||||
circuit_free(circ);
|
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 = tor_malloc_zero(sizeof(cpath_build_state_t));
|
||||||
oc->build_state->onehop_tunnel = 1;
|
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:
|
done:
|
||||||
circuit_free(circ);
|
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 = tor_malloc_zero(sizeof(cpath_build_state_t));
|
||||||
oc->build_state->onehop_tunnel = 0;
|
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:
|
done:
|
||||||
circuit_free(circ);
|
circuit_free(circ);
|
||||||
@ -165,7 +165,7 @@ test_needs_exit_circuits_ret_false_for_predicted_ports_and_path(void *arg)
|
|||||||
int needs_capacity = 0;
|
int needs_capacity = 0;
|
||||||
|
|
||||||
time_t now = time(NULL);
|
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:
|
done:
|
||||||
UNMOCK(circuit_all_predicted_ports_handled);
|
UNMOCK(circuit_all_predicted_ports_handled);
|
||||||
@ -183,7 +183,7 @@ test_needs_exit_circuits_ret_false_for_non_exit_consensus_path(void *arg)
|
|||||||
MOCK(router_have_consensus_path, mock_router_have_unknown_consensus_path);
|
MOCK(router_have_consensus_path, mock_router_have_unknown_consensus_path);
|
||||||
|
|
||||||
time_t now = time(NULL);
|
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:
|
done:
|
||||||
UNMOCK(circuit_all_predicted_ports_handled);
|
UNMOCK(circuit_all_predicted_ports_handled);
|
||||||
@ -202,7 +202,7 @@ test_needs_exit_circuits_ret_true_for_predicted_ports_and_path(void *arg)
|
|||||||
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
|
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
|
||||||
|
|
||||||
time_t now = time(NULL);
|
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:
|
done:
|
||||||
UNMOCK(circuit_all_predicted_ports_handled);
|
UNMOCK(circuit_all_predicted_ports_handled);
|
||||||
@ -214,7 +214,7 @@ test_needs_circuits_for_build_ret_false_consensus_path_unknown(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
MOCK(router_have_consensus_path, mock_router_have_unknown_consensus_path);
|
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: ;
|
done: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ test_needs_circuits_for_build_ret_false_if_num_less_than_max(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
|
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:
|
done:
|
||||||
UNMOCK(router_have_consensus_path);
|
UNMOCK(router_have_consensus_path);
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ test_needs_circuits_for_build_returns_true_when_more_are_needed(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
MOCK(router_have_consensus_path, mock_router_have_exit_consensus_path);
|
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:
|
done:
|
||||||
UNMOCK(router_have_consensus_path);
|
UNMOCK(router_have_consensus_path);
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ test_config_resolve_my_address(void *arg)
|
|||||||
&method_used,&hostname_out);
|
&method_used,&hostname_out);
|
||||||
|
|
||||||
tt_want(retval == 0);
|
tt_want(retval == 0);
|
||||||
tt_want_str_op(method_used,==,"CONFIGURED");
|
tt_want_str_op(method_used,OP_EQ,"CONFIGURED");
|
||||||
tt_want(hostname_out == NULL);
|
tt_want(hostname_out == NULL);
|
||||||
tt_assert(resolved_addr == 0x80348069);
|
tt_assert(resolved_addr == 0x80348069);
|
||||||
|
|
||||||
@ -1164,8 +1164,8 @@ test_config_resolve_my_address(void *arg)
|
|||||||
|
|
||||||
tt_want(retval == 0);
|
tt_want(retval == 0);
|
||||||
tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
|
tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
|
||||||
tt_want_str_op(method_used,==,"RESOLVED");
|
tt_want_str_op(method_used,OP_EQ,"RESOLVED");
|
||||||
tt_want_str_op(hostname_out,==,"www.torproject.org");
|
tt_want_str_op(hostname_out,OP_EQ,"www.torproject.org");
|
||||||
tt_assert(resolved_addr == 0x01010101);
|
tt_assert(resolved_addr == 0x01010101);
|
||||||
|
|
||||||
UNMOCK(tor_lookup_hostname);
|
UNMOCK(tor_lookup_hostname);
|
||||||
@ -1196,8 +1196,8 @@ test_config_resolve_my_address(void *arg)
|
|||||||
tt_want(retval == 0);
|
tt_want(retval == 0);
|
||||||
tt_want(n_gethostname_replacement == prev_n_gethostname_replacement + 1);
|
tt_want(n_gethostname_replacement == prev_n_gethostname_replacement + 1);
|
||||||
tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
|
tt_want(n_hostname_01010101 == prev_n_hostname_01010101 + 1);
|
||||||
tt_want_str_op(method_used,==,"GETHOSTNAME");
|
tt_want_str_op(method_used,OP_EQ,"GETHOSTNAME");
|
||||||
tt_want_str_op(hostname_out,==,"onionrouter!");
|
tt_want_str_op(hostname_out,OP_EQ,"onionrouter!");
|
||||||
tt_assert(resolved_addr == 0x01010101);
|
tt_assert(resolved_addr == 0x01010101);
|
||||||
|
|
||||||
UNMOCK(tor_gethostname);
|
UNMOCK(tor_gethostname);
|
||||||
@ -1285,11 +1285,11 @@ test_config_resolve_my_address(void *arg)
|
|||||||
&method_used,&hostname_out);
|
&method_used,&hostname_out);
|
||||||
|
|
||||||
tt_want(retval == 0);
|
tt_want(retval == 0);
|
||||||
tt_want_int_op(n_gethostname_replacement, ==,
|
tt_want_int_op(n_gethostname_replacement, OP_EQ,
|
||||||
prev_n_gethostname_replacement + 1);
|
prev_n_gethostname_replacement + 1);
|
||||||
tt_want_int_op(n_get_interface_address, ==,
|
tt_want_int_op(n_get_interface_address, OP_EQ,
|
||||||
prev_n_get_interface_address + 1);
|
prev_n_get_interface_address + 1);
|
||||||
tt_want_str_op(method_used,==,"INTERFACE");
|
tt_want_str_op(method_used,OP_EQ,"INTERFACE");
|
||||||
tt_want(hostname_out == NULL);
|
tt_want(hostname_out == NULL);
|
||||||
tt_assert(resolved_addr == 0x08080808);
|
tt_assert(resolved_addr == 0x08080808);
|
||||||
|
|
||||||
@ -1345,7 +1345,7 @@ test_config_resolve_my_address(void *arg)
|
|||||||
tt_want(n_hostname_failure == prev_n_hostname_failure + 1);
|
tt_want(n_hostname_failure == prev_n_hostname_failure + 1);
|
||||||
tt_want(n_gethostname_replacement == prev_n_gethostname_replacement + 1);
|
tt_want(n_gethostname_replacement == prev_n_gethostname_replacement + 1);
|
||||||
tt_want(retval == 0);
|
tt_want(retval == 0);
|
||||||
tt_want_str_op(method_used,==,"INTERFACE");
|
tt_want_str_op(method_used,OP_EQ,"INTERFACE");
|
||||||
tt_assert(resolved_addr == 0x09090909);
|
tt_assert(resolved_addr == 0x09090909);
|
||||||
|
|
||||||
UNMOCK(tor_lookup_hostname);
|
UNMOCK(tor_lookup_hostname);
|
||||||
@ -1419,7 +1419,7 @@ test_config_resolve_my_address(void *arg)
|
|||||||
tt_want(n_hostname_localhost == prev_n_hostname_localhost + 1);
|
tt_want(n_hostname_localhost == prev_n_hostname_localhost + 1);
|
||||||
tt_want(n_get_interface_address6 == prev_n_get_interface_address6 + 1);
|
tt_want(n_get_interface_address6 == prev_n_get_interface_address6 + 1);
|
||||||
|
|
||||||
tt_str_op(method_used,==,"INTERFACE");
|
tt_str_op(method_used,OP_EQ,"INTERFACE");
|
||||||
tt_assert(!hostname_out);
|
tt_assert(!hostname_out);
|
||||||
tt_assert(retval == 0);
|
tt_assert(retval == 0);
|
||||||
|
|
||||||
|
@ -510,22 +510,22 @@ test_container_smartlist_pos(void *arg)
|
|||||||
smartlist_add_strdup(sl, "function");
|
smartlist_add_strdup(sl, "function");
|
||||||
|
|
||||||
/* Test string_pos */
|
/* Test string_pos */
|
||||||
tt_int_op(smartlist_string_pos(NULL, "Fred"), ==, -1);
|
tt_int_op(smartlist_string_pos(NULL, "Fred"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_string_pos(sl, "Fred"), ==, -1);
|
tt_int_op(smartlist_string_pos(sl, "Fred"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_string_pos(sl, "This"), ==, 0);
|
tt_int_op(smartlist_string_pos(sl, "This"), OP_EQ, 0);
|
||||||
tt_int_op(smartlist_string_pos(sl, "a"), ==, 2);
|
tt_int_op(smartlist_string_pos(sl, "a"), OP_EQ, 2);
|
||||||
tt_int_op(smartlist_string_pos(sl, "function"), ==, 6);
|
tt_int_op(smartlist_string_pos(sl, "function"), OP_EQ, 6);
|
||||||
|
|
||||||
/* Test pos */
|
/* Test pos */
|
||||||
tt_int_op(smartlist_pos(NULL, "Fred"), ==, -1);
|
tt_int_op(smartlist_pos(NULL, "Fred"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_pos(sl, "Fred"), ==, -1);
|
tt_int_op(smartlist_pos(sl, "Fred"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_pos(sl, "This"), ==, -1);
|
tt_int_op(smartlist_pos(sl, "This"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_pos(sl, "a"), ==, -1);
|
tt_int_op(smartlist_pos(sl, "a"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_pos(sl, "function"), ==, -1);
|
tt_int_op(smartlist_pos(sl, "function"), OP_EQ, -1);
|
||||||
tt_int_op(smartlist_pos(sl, smartlist_get(sl,0)), ==, 0);
|
tt_int_op(smartlist_pos(sl, smartlist_get(sl,0)), OP_EQ, 0);
|
||||||
tt_int_op(smartlist_pos(sl, smartlist_get(sl,2)), ==, 2);
|
tt_int_op(smartlist_pos(sl, smartlist_get(sl,2)), OP_EQ, 2);
|
||||||
tt_int_op(smartlist_pos(sl, smartlist_get(sl,5)), ==, 5);
|
tt_int_op(smartlist_pos(sl, smartlist_get(sl,5)), OP_EQ, 5);
|
||||||
tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), ==, 6);
|
tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), OP_EQ, 6);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
|
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));
|
tt_assert(15 == median_time(times, 5));
|
||||||
|
|
||||||
int32_t int32s[] = { -5, -10, -50, 100 };
|
int32_t int32s[] = { -5, -10, -50, 100 };
|
||||||
tt_int_op(-5, ==, median_int32(int32s, 1));
|
tt_int_op(-5, OP_EQ, median_int32(int32s, 1));
|
||||||
tt_int_op(-10, ==, median_int32(int32s, 2));
|
tt_int_op(-10, OP_EQ, median_int32(int32s, 2));
|
||||||
tt_int_op(-10, ==, median_int32(int32s, 3));
|
tt_int_op(-10, OP_EQ, median_int32(int32s, 3));
|
||||||
tt_int_op(-10, ==, median_int32(int32s, 4));
|
tt_int_op(-10, OP_EQ, median_int32(int32s, 4));
|
||||||
|
|
||||||
long longs[] = { -30, 30, 100, -100, 7 };
|
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:
|
done:
|
||||||
;
|
;
|
||||||
@ -1153,31 +1153,31 @@ test_container_smartlist_most_frequent(void *arg)
|
|||||||
const char *cp;
|
const char *cp;
|
||||||
|
|
||||||
cp = smartlist_get_most_frequent_string_(sl, &count);
|
cp = smartlist_get_most_frequent_string_(sl, &count);
|
||||||
tt_int_op(count, ==, 0);
|
tt_int_op(count, OP_EQ, 0);
|
||||||
tt_ptr_op(cp, ==, NULL);
|
tt_ptr_op(cp, OP_EQ, NULL);
|
||||||
|
|
||||||
/* String must be sorted before we call get_most_frequent */
|
/* String must be sorted before we call get_most_frequent */
|
||||||
smartlist_split_string(sl, "abc:def:ghi", ":", 0, 0);
|
smartlist_split_string(sl, "abc:def:ghi", ":", 0, 0);
|
||||||
|
|
||||||
cp = smartlist_get_most_frequent_string_(sl, &count);
|
cp = smartlist_get_most_frequent_string_(sl, &count);
|
||||||
tt_int_op(count, ==, 1);
|
tt_int_op(count, OP_EQ, 1);
|
||||||
tt_str_op(cp, ==, "ghi"); /* Ties broken in favor of later element */
|
tt_str_op(cp, OP_EQ, "ghi"); /* Ties broken in favor of later element */
|
||||||
|
|
||||||
smartlist_split_string(sl, "def:ghi", ":", 0, 0);
|
smartlist_split_string(sl, "def:ghi", ":", 0, 0);
|
||||||
smartlist_sort_strings(sl);
|
smartlist_sort_strings(sl);
|
||||||
|
|
||||||
cp = smartlist_get_most_frequent_string_(sl, &count);
|
cp = smartlist_get_most_frequent_string_(sl, &count);
|
||||||
tt_int_op(count, ==, 2);
|
tt_int_op(count, OP_EQ, 2);
|
||||||
tt_ptr_op(cp, !=, NULL);
|
tt_ptr_op(cp, OP_NE, NULL);
|
||||||
tt_str_op(cp, ==, "ghi"); /* Ties broken in favor of later element */
|
tt_str_op(cp, OP_EQ, "ghi"); /* Ties broken in favor of later element */
|
||||||
|
|
||||||
smartlist_split_string(sl, "def:abc:qwop", ":", 0, 0);
|
smartlist_split_string(sl, "def:abc:qwop", ":", 0, 0);
|
||||||
smartlist_sort_strings(sl);
|
smartlist_sort_strings(sl);
|
||||||
|
|
||||||
cp = smartlist_get_most_frequent_string_(sl, &count);
|
cp = smartlist_get_most_frequent_string_(sl, &count);
|
||||||
tt_int_op(count, ==, 3);
|
tt_int_op(count, OP_EQ, 3);
|
||||||
tt_ptr_op(cp, !=, NULL);
|
tt_ptr_op(cp, OP_NE, NULL);
|
||||||
tt_str_op(cp, ==, "def"); /* No tie */
|
tt_str_op(cp, OP_EQ, "def"); /* No tie */
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
|
SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
|
||||||
@ -1206,7 +1206,7 @@ test_container_smartlist_sort_ptrs(void *arg)
|
|||||||
smartlist_shuffle(sl);
|
smartlist_shuffle(sl);
|
||||||
smartlist_sort_pointers(sl);
|
smartlist_sort_pointers(sl);
|
||||||
for (j = 0; j < ARRAY_LENGTH(arrayptrs); ++j) {
|
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)
|
} while (0)
|
||||||
|
|
||||||
/* Both NULL, so equal */
|
/* 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. */
|
/* One NULL, not equal. */
|
||||||
tt_int_op(0, ==, smartlist_strings_eq(NULL, sl1));
|
tt_int_op(0, OP_EQ, smartlist_strings_eq(NULL, sl1));
|
||||||
tt_int_op(0, ==, smartlist_strings_eq(sl1, NULL));
|
tt_int_op(0, OP_EQ, smartlist_strings_eq(sl1, NULL));
|
||||||
|
|
||||||
/* Both empty, both equal. */
|
/* Both empty, both equal. */
|
||||||
EQ_SHOULD_SAY("", "", 1);
|
EQ_SHOULD_SAY("", "", 1);
|
||||||
|
@ -1139,7 +1139,7 @@ test_crypto_mac_sha3(void *arg)
|
|||||||
result = crypto_digest256(hmac_manual, all, all_len, DIGEST_SHA3_256);
|
result = crypto_digest256(hmac_manual, all, all_len, DIGEST_SHA3_256);
|
||||||
tor_free(key_msg_concat);
|
tor_free(key_msg_concat);
|
||||||
tor_free(all);
|
tor_free(all);
|
||||||
tt_int_op(result, ==, 0);
|
tt_int_op(result, OP_EQ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now compare the two results */
|
/* Now compare the two results */
|
||||||
@ -2675,8 +2675,8 @@ test_crypto_ed25519_storage(void *arg)
|
|||||||
tor_free(tag);
|
tor_free(tag);
|
||||||
|
|
||||||
/* whitebox test: truncated keys. */
|
/* whitebox test: truncated keys. */
|
||||||
tt_int_op(0, ==, do_truncate(fname_1, 40));
|
tt_int_op(0, OP_EQ, do_truncate(fname_1, 40));
|
||||||
tt_int_op(0, ==, do_truncate(fname_2, 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_int_op(-1, OP_EQ, ed25519_pubkey_read_from_file(&pub, &tag, fname_2));
|
||||||
tt_ptr_op(tag, OP_EQ, NULL);
|
tt_ptr_op(tag, OP_EQ, NULL);
|
||||||
tor_free(tag);
|
tor_free(tag);
|
||||||
|
@ -26,7 +26,7 @@ test_crypto_rng_engine(void *arg)
|
|||||||
memset(&dummy_method, 0, sizeof(dummy_method));
|
memset(&dummy_method, 0, sizeof(dummy_method));
|
||||||
|
|
||||||
/* We should be a no-op if we're already on RAND_OpenSSL */
|
/* 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());
|
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
|
||||||
|
|
||||||
/* We should correct the method if it's a dummy. */
|
/* We should correct the method if it's a dummy. */
|
||||||
@ -34,10 +34,10 @@ test_crypto_rng_engine(void *arg)
|
|||||||
#ifdef LIBRESSL_VERSION_NUMBER
|
#ifdef LIBRESSL_VERSION_NUMBER
|
||||||
/* On libressl, you can't override the RNG. */
|
/* On libressl, you can't override the RNG. */
|
||||||
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
|
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
|
#else
|
||||||
tt_assert(RAND_get_rand_method() == &dummy_method);
|
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
|
#endif
|
||||||
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
|
tt_assert(RAND_get_rand_method() == RAND_OpenSSL());
|
||||||
|
|
||||||
|
@ -164,10 +164,10 @@ test_libscrypt_eq_openssl(void *arg)
|
|||||||
EVP_PBE_scrypt((const char *)"", 0, (const unsigned char *)"", 0,
|
EVP_PBE_scrypt((const char *)"", 0, (const unsigned char *)"", 0,
|
||||||
N, r, p, maxmem, buf2, dk_len);
|
N, r, p, maxmem, buf2, dk_len);
|
||||||
|
|
||||||
tt_int_op(libscrypt_retval, ==, 0);
|
tt_int_op(libscrypt_retval, OP_EQ, 0);
|
||||||
tt_int_op(openssl_retval, ==, 1);
|
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(buf1,0,64);
|
||||||
memset(buf2,0,64);
|
memset(buf2,0,64);
|
||||||
@ -185,10 +185,10 @@ test_libscrypt_eq_openssl(void *arg)
|
|||||||
(const unsigned char *)"NaCl", strlen("NaCl"),
|
(const unsigned char *)"NaCl", strlen("NaCl"),
|
||||||
N, r, p, maxmem, buf2, dk_len);
|
N, r, p, maxmem, buf2, dk_len);
|
||||||
|
|
||||||
tt_int_op(libscrypt_retval, ==, 0);
|
tt_int_op(libscrypt_retval, OP_EQ, 0);
|
||||||
tt_int_op(openssl_retval, ==, 1);
|
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(buf1,0,64);
|
||||||
memset(buf2,0,64);
|
memset(buf2,0,64);
|
||||||
@ -210,10 +210,10 @@ test_libscrypt_eq_openssl(void *arg)
|
|||||||
strlen("SodiumChloride"),
|
strlen("SodiumChloride"),
|
||||||
N, r, p, maxmem, buf2, dk_len);
|
N, r, p, maxmem, buf2, dk_len);
|
||||||
|
|
||||||
tt_int_op(libscrypt_retval, ==, 0);
|
tt_int_op(libscrypt_retval, OP_EQ, 0);
|
||||||
tt_int_op(openssl_retval, ==, 1);
|
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(buf1,0,64);
|
||||||
memset(buf2,0,64);
|
memset(buf2,0,64);
|
||||||
@ -234,10 +234,10 @@ test_libscrypt_eq_openssl(void *arg)
|
|||||||
strlen("SodiumChloride"),
|
strlen("SodiumChloride"),
|
||||||
N, r, p, maxmem, buf2, dk_len);
|
N, r, p, maxmem, buf2, dk_len);
|
||||||
|
|
||||||
tt_int_op(libscrypt_retval, ==, 0);
|
tt_int_op(libscrypt_retval, OP_EQ, 0);
|
||||||
tt_int_op(openssl_retval, ==, 1);
|
tt_int_op(openssl_retval, OP_EQ, 1);
|
||||||
|
|
||||||
tt_mem_op(buf1, ==, buf2, 64);
|
tt_mem_op(buf1, OP_EQ, buf2, 64);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
|
@ -3695,8 +3695,8 @@ test_dir_purpose_needs_anonymity_returns_true_by_default(void *arg)
|
|||||||
|
|
||||||
tor_capture_bugs_(1);
|
tor_capture_bugs_(1);
|
||||||
setup_full_capture_of_logs(LOG_WARN);
|
setup_full_capture_of_logs(LOG_WARN);
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(0, 0, NULL));
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, 0, NULL));
|
||||||
tt_int_op(1, ==, smartlist_len(tor_get_captured_bug_log_()));
|
tt_int_op(1, OP_EQ, smartlist_len(tor_get_captured_bug_log_()));
|
||||||
expect_single_log_msg_containing("Called with dir_purpose=0");
|
expect_single_log_msg_containing("Called with dir_purpose=0");
|
||||||
|
|
||||||
tor_end_capture_bugs_();
|
tor_end_capture_bugs_();
|
||||||
@ -3710,10 +3710,10 @@ test_dir_purpose_needs_anonymity_returns_true_for_bridges(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE, NULL));
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE, NULL));
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE,
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE,
|
||||||
"foobar"));
|
"foobar"));
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
|
||||||
ROUTER_PURPOSE_BRIDGE, NULL));
|
ROUTER_PURPOSE_BRIDGE, NULL));
|
||||||
done: ;
|
done: ;
|
||||||
}
|
}
|
||||||
@ -3722,7 +3722,7 @@ static void
|
|||||||
test_dir_purpose_needs_anonymity_returns_false_for_own_bridge_desc(void *arg)
|
test_dir_purpose_needs_anonymity_returns_false_for_own_bridge_desc(void *arg)
|
||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC,
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC,
|
||||||
ROUTER_PURPOSE_BRIDGE,
|
ROUTER_PURPOSE_BRIDGE,
|
||||||
"authority.z"));
|
"authority.z"));
|
||||||
done: ;
|
done: ;
|
||||||
@ -3733,12 +3733,12 @@ test_dir_purpose_needs_anonymity_returns_true_for_sensitive_purpose(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(
|
||||||
DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
|
DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
|
||||||
ROUTER_PURPOSE_GENERAL, NULL));
|
ROUTER_PURPOSE_GENERAL, NULL));
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(
|
||||||
DIR_PURPOSE_UPLOAD_RENDDESC_V2, 0, NULL));
|
DIR_PURPOSE_UPLOAD_RENDDESC_V2, 0, NULL));
|
||||||
tt_int_op(1, ==, purpose_needs_anonymity(
|
tt_int_op(1, OP_EQ, purpose_needs_anonymity(
|
||||||
DIR_PURPOSE_FETCH_RENDDESC_V2, 0, NULL));
|
DIR_PURPOSE_FETCH_RENDDESC_V2, 0, NULL));
|
||||||
done: ;
|
done: ;
|
||||||
}
|
}
|
||||||
@ -3748,24 +3748,24 @@ test_dir_purpose_needs_anonymity_ret_false_for_non_sensitive_conn(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_DIR,
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_DIR,
|
||||||
ROUTER_PURPOSE_GENERAL, NULL));
|
ROUTER_PURPOSE_GENERAL, NULL));
|
||||||
tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_VOTE, 0, NULL));
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_VOTE, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_SIGNATURES, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_SIGNATURES, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL));
|
||||||
tt_int_op(0, ==, purpose_needs_anonymity(
|
tt_int_op(0, OP_EQ, purpose_needs_anonymity(
|
||||||
DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0, NULL));
|
DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CONSENSUS, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CONSENSUS, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_EXTRAINFO, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_EXTRAINFO, 0, NULL));
|
||||||
tt_int_op(0, ==,
|
tt_int_op(0, OP_EQ,
|
||||||
purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, 0, NULL));
|
purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, 0, NULL));
|
||||||
done: ;
|
done: ;
|
||||||
}
|
}
|
||||||
@ -3818,9 +3818,9 @@ test_dir_packages(void *arg)
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
#define BAD(s) \
|
#define BAD(s) \
|
||||||
tt_int_op(0, ==, validate_recommended_package_line(s));
|
tt_int_op(0, OP_EQ, validate_recommended_package_line(s));
|
||||||
#define GOOD(s) \
|
#define GOOD(s) \
|
||||||
tt_int_op(1, ==, validate_recommended_package_line(s));
|
tt_int_op(1, OP_EQ, validate_recommended_package_line(s));
|
||||||
GOOD("tor 0.2.6.3-alpha "
|
GOOD("tor 0.2.6.3-alpha "
|
||||||
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
"http://torproject.example.com/dist/tor-0.2.6.3-alpha.tar.gz "
|
||||||
"sha256=sssdlkfjdsklfjdskfljasdklfj");
|
"sha256=sssdlkfjdsklfjdskfljasdklfj");
|
||||||
@ -3937,7 +3937,7 @@ test_dir_packages(void *arg)
|
|||||||
|
|
||||||
res = compute_consensus_package_lines(votes);
|
res = compute_consensus_package_lines(votes);
|
||||||
tt_assert(res);
|
tt_assert(res);
|
||||||
tt_str_op(res, ==,
|
tt_str_op(res, OP_EQ,
|
||||||
"package cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m\n"
|
"package cbc 99.1.11.1.1 http://example.com/cbc/ cubehash=ahooy sha512=m\n"
|
||||||
"package clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz\n"
|
"package clownshoes 22alpha3 http://quumble.example.com/ blake2=fooz\n"
|
||||||
"package clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa\n"
|
"package clownshoes 22alpha4 http://quumble.example.cam/ blake2=fooa\n"
|
||||||
@ -4359,9 +4359,9 @@ test_dir_download_status_increment(void *arg)
|
|||||||
mock_get_options_calls = 0;
|
mock_get_options_calls = 0;
|
||||||
next_at = download_status_increment_failure(&dls_failure, 503, "test", 0,
|
next_at = download_status_increment_failure(&dls_failure, 503, "test", 0,
|
||||||
current_time);
|
current_time);
|
||||||
tt_i64_op(next_at, ==, current_time + delay2);
|
tt_i64_op(next_at, OP_EQ, current_time + delay2);
|
||||||
tt_int_op(download_status_get_n_failures(&dls_failure), ==, 2);
|
tt_int_op(download_status_get_n_failures(&dls_failure), OP_EQ, 2);
|
||||||
tt_int_op(download_status_get_n_attempts(&dls_failure), ==, 2);
|
tt_int_op(download_status_get_n_attempts(&dls_failure), OP_EQ, 2);
|
||||||
tt_assert(mock_get_options_calls >= 1);
|
tt_assert(mock_get_options_calls >= 1);
|
||||||
|
|
||||||
/* Check that failure increments do happen on 503 for servers */
|
/* Check that failure increments do happen on 503 for servers */
|
||||||
@ -5053,7 +5053,7 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5066,21 +5066,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_1));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5088,8 +5088,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (2) Fire off dump_desc() twice; this still should trigger no cleanup.
|
* (2) Fire off dump_desc() twice; this still should trigger no cleanup.
|
||||||
@ -5101,14 +5101,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5117,21 +5117,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2) + strlen(test_desc_3));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2) + strlen(test_desc_3));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5139,8 +5139,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (3) Three calls to dump_desc cause a FIFO cleanup
|
* (3) Three calls to dump_desc cause a FIFO cleanup
|
||||||
@ -5152,14 +5152,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5168,14 +5168,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_4) + strlen(test_desc_1));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_4) + strlen(test_desc_1));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Third time - we should unlink the dump of test_desc_4 here */
|
/* Third time - we should unlink the dump of test_desc_4 here */
|
||||||
@ -5184,21 +5184,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_1) + strlen(test_desc_2));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1) + strlen(test_desc_2));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 1);
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
||||||
tt_int_op(write_str_count, ==, 3);
|
tt_int_op(write_str_count, OP_EQ, 3);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5206,8 +5206,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (4) But repeating one (A B B) doesn't overflow and cleanup
|
* (4) But repeating one (A B B) doesn't overflow and cleanup
|
||||||
@ -5219,14 +5219,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5235,14 +5235,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3) + strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3) + strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Third time */
|
/* Third time */
|
||||||
@ -5251,21 +5251,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3) + strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3) + strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5273,8 +5273,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (5) Same for the (A B A) repetition
|
* (5) Same for the (A B A) repetition
|
||||||
@ -5286,14 +5286,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_1));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5302,14 +5302,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_1) + strlen(test_desc_2));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1) + strlen(test_desc_2));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Third time */
|
/* Third time */
|
||||||
@ -5318,21 +5318,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_1) + strlen(test_desc_2));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_1) + strlen(test_desc_2));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5340,8 +5340,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (6) (A B B C) triggering overflow on C causes A, not B to be unlinked
|
* (6) (A B B C) triggering overflow on C causes A, not B to be unlinked
|
||||||
@ -5353,14 +5353,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5369,14 +5369,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3) + strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3) + strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Third time */
|
/* Third time */
|
||||||
@ -5385,14 +5385,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_3) + strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_3) + strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
||||||
@ -5401,21 +5401,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_4) + strlen(test_desc_1));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_4) + strlen(test_desc_1));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 1);
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
||||||
tt_int_op(write_str_count, ==, 3);
|
tt_int_op(write_str_count, OP_EQ, 3);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_1_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5423,8 +5423,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (7) (A B A C) triggering overflow on C causes B, not A to be unlinked
|
* (7) (A B A C) triggering overflow on C causes B, not A to be unlinked
|
||||||
@ -5436,14 +5436,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 1);
|
tt_int_op(write_str_count, OP_EQ, 1);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_2_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Second time */
|
/* Second time */
|
||||||
@ -5452,14 +5452,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2) + strlen(test_desc_3));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2) + strlen(test_desc_3));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Third time */
|
/* Third time */
|
||||||
@ -5468,14 +5468,14 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2) + strlen(test_desc_3));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2) + strlen(test_desc_3));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 2);
|
tt_int_op(write_str_count, OP_EQ, 2);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_3_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
/* Fourth time - we should unlink the dump of test_desc_3 here */
|
||||||
@ -5484,21 +5484,21 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
/*
|
/*
|
||||||
* Assert things about the FIFO state
|
* Assert things about the FIFO state
|
||||||
*/
|
*/
|
||||||
tt_u64_op(len_descs_dumped, ==, strlen(test_desc_2) + strlen(test_desc_4));
|
tt_u64_op(len_descs_dumped, OP_EQ, strlen(test_desc_2) + strlen(test_desc_4));
|
||||||
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
tt_assert(descs_dumped != NULL && smartlist_len(descs_dumped) == 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assert things about the mocks
|
* Assert things about the mocks
|
||||||
*/
|
*/
|
||||||
tt_int_op(unlinked_count, ==, 1);
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
||||||
tt_int_op(write_str_count, ==, 3);
|
tt_int_op(write_str_count, OP_EQ, 3);
|
||||||
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
tt_mem_op(last_write_str_hash, OP_EQ, test_desc_4_hash, DIGEST_SHA256);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the FIFO and check its state
|
* Reset the FIFO and check its state
|
||||||
*/
|
*/
|
||||||
dump_desc_fifo_cleanup();
|
dump_desc_fifo_cleanup();
|
||||||
tt_u64_op(len_descs_dumped, ==, 0);
|
tt_u64_op(len_descs_dumped, OP_EQ, 0);
|
||||||
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
tt_assert(descs_dumped == NULL || smartlist_len(descs_dumped) == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5506,8 +5506,8 @@ test_dir_dump_unparseable_descriptors(void *data)
|
|||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
mock_write_str_to_file_reset();
|
mock_write_str_to_file_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
tt_int_op(write_str_count, ==, 0);
|
tt_int_op(write_str_count, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
@ -5617,43 +5617,43 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
reset_read_file_to_str_mock();
|
reset_read_file_to_str_mock();
|
||||||
|
|
||||||
/* Check state of unlink mock */
|
/* Check state of unlink mock */
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
|
|
||||||
/* Some cases that should fail before trying to read the file */
|
/* Some cases that should fail before trying to read the file */
|
||||||
ent = dump_desc_populate_one_file(dirname, "bar");
|
ent = dump_desc_populate_one_file(dirname, "bar");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 1);
|
tt_int_op(unlinked_count, OP_EQ, 1);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
ent = dump_desc_populate_one_file(dirname, "unparseable-desc");
|
ent = dump_desc_populate_one_file(dirname, "unparseable-desc");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 2);
|
tt_int_op(unlinked_count, OP_EQ, 2);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
ent = dump_desc_populate_one_file(dirname, "unparseable-desc.baz");
|
ent = dump_desc_populate_one_file(dirname, "unparseable-desc.baz");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 3);
|
tt_int_op(unlinked_count, OP_EQ, 3);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
ent = dump_desc_populate_one_file(
|
ent = dump_desc_populate_one_file(
|
||||||
dirname,
|
dirname,
|
||||||
"unparseable-desc.08AE85E90461F59E");
|
"unparseable-desc.08AE85E90461F59E");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 4);
|
tt_int_op(unlinked_count, OP_EQ, 4);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
ent = dump_desc_populate_one_file(
|
ent = dump_desc_populate_one_file(
|
||||||
dirname,
|
dirname,
|
||||||
"unparseable-desc.08AE85E90461F59EDF0981323F3A70D02B55AB54B44B04F"
|
"unparseable-desc.08AE85E90461F59EDF0981323F3A70D02B55AB54B44B04F"
|
||||||
"287D72F7B72F242E85C8CB0EDA8854A99");
|
"287D72F7B72F242E85C8CB0EDA8854A99");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 5);
|
tt_int_op(unlinked_count, OP_EQ, 5);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
/* This is a correct-length digest but base16_decode() will fail */
|
/* This is a correct-length digest but base16_decode() will fail */
|
||||||
ent = dump_desc_populate_one_file(
|
ent = dump_desc_populate_one_file(
|
||||||
@ -5661,9 +5661,9 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
"unparseable-desc.68219B8BGE64B705A6FFC728C069DC596216D60A7D7520C"
|
"unparseable-desc.68219B8BGE64B705A6FFC728C069DC596216D60A7D7520C"
|
||||||
"D5ECE250D912E686B");
|
"D5ECE250D912E686B");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 6);
|
tt_int_op(unlinked_count, OP_EQ, 6);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 0);
|
tt_int_op(read_call_count, OP_EQ, 0);
|
||||||
|
|
||||||
/* This one has a correctly formed filename and should try reading */
|
/* This one has a correctly formed filename and should try reading */
|
||||||
|
|
||||||
@ -5673,9 +5673,9 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
"unparseable-desc.DF0981323F3A70D02B55AB54B44B04F287D72F7B72F242E"
|
"unparseable-desc.DF0981323F3A70D02B55AB54B44B04F287D72F7B72F242E"
|
||||||
"85C8CB0EDA8854A99");
|
"85C8CB0EDA8854A99");
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 7);
|
tt_int_op(unlinked_count, OP_EQ, 7);
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
tt_int_op(read_call_count, ==, 1);
|
tt_int_op(read_call_count, OP_EQ, 1);
|
||||||
|
|
||||||
/* This read will succeed but the digest won't match the file content */
|
/* This read will succeed but the digest won't match the file content */
|
||||||
fname =
|
fname =
|
||||||
@ -5689,9 +5689,9 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
ent = dump_desc_populate_one_file(dirname, fname);
|
ent = dump_desc_populate_one_file(dirname, fname);
|
||||||
enforce_expected_filename = 0;
|
enforce_expected_filename = 0;
|
||||||
tt_assert(ent == NULL);
|
tt_assert(ent == NULL);
|
||||||
tt_int_op(unlinked_count, ==, 8);
|
tt_int_op(unlinked_count, OP_EQ, 8);
|
||||||
tt_int_op(read_count, ==, 1);
|
tt_int_op(read_count, OP_EQ, 1);
|
||||||
tt_int_op(read_call_count, ==, 2);
|
tt_int_op(read_call_count, OP_EQ, 2);
|
||||||
tor_free(expected_filename);
|
tor_free(expected_filename);
|
||||||
tor_free(file_content);
|
tor_free(file_content);
|
||||||
|
|
||||||
@ -5705,12 +5705,12 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
file_stat.st_mtime = 789012;
|
file_stat.st_mtime = 789012;
|
||||||
ent = dump_desc_populate_one_file(dirname, fname);
|
ent = dump_desc_populate_one_file(dirname, fname);
|
||||||
tt_assert(ent != NULL);
|
tt_assert(ent != NULL);
|
||||||
tt_int_op(unlinked_count, ==, 8);
|
tt_int_op(unlinked_count, OP_EQ, 8);
|
||||||
tt_int_op(read_count, ==, 2);
|
tt_int_op(read_count, OP_EQ, 2);
|
||||||
tt_int_op(read_call_count, ==, 3);
|
tt_int_op(read_call_count, OP_EQ, 3);
|
||||||
tt_str_op(ent->filename, OP_EQ, expected_filename);
|
tt_str_op(ent->filename, OP_EQ, expected_filename);
|
||||||
tt_int_op(ent->len, ==, file_content_len);
|
tt_int_op(ent->len, OP_EQ, file_content_len);
|
||||||
tt_int_op(ent->when, ==, file_stat.st_mtime);
|
tt_int_op(ent->when, OP_EQ, file_stat.st_mtime);
|
||||||
tor_free(ent->filename);
|
tor_free(ent->filename);
|
||||||
tor_free(ent);
|
tor_free(ent);
|
||||||
tor_free(expected_filename);
|
tor_free(expected_filename);
|
||||||
@ -5719,9 +5719,9 @@ test_dir_populate_dump_desc_fifo(void *data)
|
|||||||
* Reset the mocks and check their state
|
* Reset the mocks and check their state
|
||||||
*/
|
*/
|
||||||
mock_unlink_reset();
|
mock_unlink_reset();
|
||||||
tt_int_op(unlinked_count, ==, 0);
|
tt_int_op(unlinked_count, OP_EQ, 0);
|
||||||
reset_read_file_to_str_mock();
|
reset_read_file_to_str_mock();
|
||||||
tt_int_op(read_count, ==, 0);
|
tt_int_op(read_count, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
@ -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;
|
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(MIN_DNS_TTL_AT_EXIT - 1),OP_EQ,MIN_DNS_TTL_AT_EXIT);
|
||||||
tt_int_op(dns_clip_ttl(ttl_mid),==,MAX_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),==,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:
|
done:
|
||||||
return;
|
return;
|
||||||
@ -172,10 +172,10 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
retval = dns_resolve(exitconn);
|
retval = dns_resolve(exitconn);
|
||||||
|
|
||||||
tt_int_op(retval,==,1);
|
tt_int_op(retval,OP_EQ,1);
|
||||||
tt_str_op(resolved_name,==,last_resolved_hostname);
|
tt_str_op(resolved_name,OP_EQ,last_resolved_hostname);
|
||||||
tt_assert(conn_for_resolved_cell == exitconn);
|
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);
|
prev_n_send_resolved_hostname_cell_replacement + 1);
|
||||||
tt_assert(exitconn->on_circuit == NULL);
|
tt_assert(exitconn->on_circuit == NULL);
|
||||||
|
|
||||||
@ -201,12 +201,12 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
retval = dns_resolve(exitconn);
|
retval = dns_resolve(exitconn);
|
||||||
|
|
||||||
tt_int_op(retval,==,1);
|
tt_int_op(retval,OP_EQ,1);
|
||||||
tt_assert(conn_for_resolved_cell == exitconn);
|
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);
|
prev_n_send_resolved_cell_replacement + 1);
|
||||||
tt_assert(last_resolved == fake_resolved);
|
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);
|
tt_assert(exitconn->on_circuit == NULL);
|
||||||
|
|
||||||
/* CASE 3: The purpose of exit connection is not EXIT_PURPOSE_RESOLVE
|
/* 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);
|
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(on_circuit->n_streams == exitconn);
|
||||||
tt_assert(exitconn->next_stream == nextconn);
|
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);
|
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);
|
n_send_resolved_hostname_cell_replacement);
|
||||||
|
|
||||||
/* CASE 4: _impl returns 0.
|
/* CASE 4: _impl returns 0.
|
||||||
@ -253,8 +253,8 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
retval = dns_resolve(exitconn);
|
retval = dns_resolve(exitconn);
|
||||||
|
|
||||||
tt_int_op(retval,==,0);
|
tt_int_op(retval,OP_EQ,0);
|
||||||
tt_int_op(exitconn->base_.state,==,EXIT_CONN_STATE_RESOLVING);
|
tt_int_op(exitconn->base_.state,OP_EQ,EXIT_CONN_STATE_RESOLVING);
|
||||||
tt_assert(on_circuit->resolving_streams == exitconn);
|
tt_assert(on_circuit->resolving_streams == exitconn);
|
||||||
tt_assert(exitconn->next_stream == nextconn);
|
tt_assert(exitconn->next_stream == nextconn);
|
||||||
|
|
||||||
@ -278,12 +278,12 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
retval = dns_resolve(exitconn);
|
retval = dns_resolve(exitconn);
|
||||||
|
|
||||||
tt_int_op(retval,==,-1);
|
tt_int_op(retval,OP_EQ,-1);
|
||||||
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);
|
prev_n_send_resolved_cell_replacement + 1);
|
||||||
tt_int_op(last_answer_type,==,RESOLVED_TYPE_ERROR);
|
tt_int_op(last_answer_type,OP_EQ,RESOLVED_TYPE_ERROR);
|
||||||
tt_int_op(n_dns_cancel_pending_resolve_replacement,==,1);
|
tt_int_op(n_dns_cancel_pending_resolve_replacement,OP_EQ,1);
|
||||||
tt_int_op(n_connection_free,==,prev_n_connection_free + 1);
|
tt_int_op(n_connection_free,OP_EQ,prev_n_connection_free + 1);
|
||||||
tt_assert(last_freed_conn == TO_CONN(exitconn));
|
tt_assert(last_freed_conn == TO_CONN(exitconn));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -351,9 +351,9 @@ NS(test_main)(void *arg)
|
|||||||
|
|
||||||
resolved_addr = &(exitconn->base_.addr);
|
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_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:
|
done:
|
||||||
tor_free(on_circ);
|
tor_free(on_circ);
|
||||||
@ -393,7 +393,7 @@ NS(test_main)(void *arg)
|
|||||||
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,-1);
|
tt_int_op(retval,OP_EQ,-1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(TO_CONN(exitconn)->address);
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,-1);
|
tt_int_op(retval,OP_EQ,-1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
NS_UNMOCK(router_my_exit_policy_is_reject_star);
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,-1);
|
tt_int_op(retval,OP_EQ,-1);
|
||||||
|
|
||||||
tor_free(TO_CONN(exitconn)->address);
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,-1);
|
tt_int_op(retval,OP_EQ,-1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
NS_UNMOCK(router_my_exit_policy_is_reject_star);
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,0);
|
tt_int_op(retval,OP_EQ,0);
|
||||||
tt_int_op(made_pending,==,1);
|
tt_int_op(made_pending,OP_EQ,1);
|
||||||
|
|
||||||
pending_conn = cache_entry->pending_connections;
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
&resolve_out);
|
&resolve_out);
|
||||||
|
|
||||||
tt_int_op(retval,==,0);
|
tt_int_op(retval,OP_EQ,0);
|
||||||
tt_int_op(made_pending,==,0);
|
tt_int_op(made_pending,OP_EQ,0);
|
||||||
tt_assert(resolve_out == cache_entry);
|
tt_assert(resolve_out == cache_entry);
|
||||||
|
|
||||||
tt_assert(last_exitconn == exitconn);
|
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,
|
retval = dns_resolve_impl(exitconn, 1, on_circ, NULL, &made_pending,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tt_int_op(retval,==,0);
|
tt_int_op(retval,OP_EQ,0);
|
||||||
tt_int_op(made_pending,==,1);
|
tt_int_op(made_pending,OP_EQ,1);
|
||||||
|
|
||||||
cache_entry = dns_get_cache_entry(&query);
|
cache_entry = dns_get_cache_entry(&query);
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ NS(test_main)(void *arg)
|
|||||||
tt_assert(pending_conn->conn == exitconn);
|
tt_assert(pending_conn->conn == exitconn);
|
||||||
|
|
||||||
tt_assert(last_launched_resolve == cache_entry);
|
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:
|
done:
|
||||||
NS_UNMOCK(router_my_exit_policy_is_reject_star);
|
NS_UNMOCK(router_my_exit_policy_is_reject_star);
|
||||||
|
@ -38,10 +38,10 @@ gen_vote_routerstatus_for_tests(const char *digest_in_hex, int is_guard)
|
|||||||
rs->is_possible_guard = is_guard;
|
rs->is_possible_guard = is_guard;
|
||||||
|
|
||||||
/* Fill in the fpr */
|
/* 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),
|
retval = base16_decode(digest_tmp, sizeof(digest_tmp),
|
||||||
digest_in_hex, HEX_DIGEST_LEN);
|
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);
|
memcpy(rs->identity_digest, digest_tmp, DIGEST_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ test_parse_guardfraction_file_bad(void *arg)
|
|||||||
yesterday_date_str);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one does not have a date! Parsing should fail. */
|
/* 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");
|
"guard-seen 07B5547026DF3E229806E135CFA8552D56AFBABC 5 420\n");
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one has an incomplete n-inputs line, but parsing should
|
/* 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);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one does not have a fingerprint in the guard line! */
|
/* 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);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one does not even have an integer guardfraction value. */
|
/* This one does not even have an integer guardfraction value. */
|
||||||
@ -139,7 +139,7 @@ test_parse_guardfraction_file_bad(void *arg)
|
|||||||
yesterday_date_str);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one is not a percentage (not in [0, 100]) */
|
/* This one is not a percentage (not in [0, 100]) */
|
||||||
@ -152,7 +152,7 @@ test_parse_guardfraction_file_bad(void *arg)
|
|||||||
yesterday_date_str);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
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);
|
tor_free(guardfraction_bad);
|
||||||
|
|
||||||
/* This one is not a percentage either (not in [0, 100]) */
|
/* 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);
|
yesterday_date_str);
|
||||||
|
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
retval = dirserv_read_guardfraction_file_from_str(guardfraction_bad, NULL);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(guardfraction_bad);
|
tor_free(guardfraction_bad);
|
||||||
@ -216,14 +216,14 @@ test_parse_guardfraction_file_good(void *arg)
|
|||||||
/* Read the guardfraction file */
|
/* Read the guardfraction file */
|
||||||
retval = dirserv_read_guardfraction_file_from_str(guardfraction_good,
|
retval = dirserv_read_guardfraction_file_from_str(guardfraction_good,
|
||||||
routerstatuses);
|
routerstatuses);
|
||||||
tt_int_op(retval, ==, 1);
|
tt_int_op(retval, OP_EQ, 1);
|
||||||
|
|
||||||
{ /* Test that routerstatus fields got filled properly */
|
{ /* Test that routerstatus fields got filled properly */
|
||||||
|
|
||||||
/* The guardfraction fields of the guard should be filled. */
|
/* The guardfraction fields of the guard should be filled. */
|
||||||
tt_assert(vrs_guard->status.has_guardfraction);
|
tt_assert(vrs_guard->status.has_guardfraction);
|
||||||
tt_int_op(vrs_guard->status.guardfraction_percentage,
|
tt_int_op(vrs_guard->status.guardfraction_percentage,
|
||||||
==,
|
OP_EQ,
|
||||||
guardfraction_value);
|
guardfraction_value);
|
||||||
|
|
||||||
/* The guard that was not in the guardfraction file should not have
|
/* 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,
|
guard_get_guardfraction_bandwidth(&gf_bw,
|
||||||
orig_bw, 25);
|
orig_bw, 25);
|
||||||
|
|
||||||
tt_int_op(gf_bw.guard_bw, ==, 250);
|
tt_int_op(gf_bw.guard_bw, OP_EQ, 250);
|
||||||
tt_int_op(gf_bw.non_guard_bw, ==, 750);
|
tt_int_op(gf_bw.non_guard_bw, OP_EQ, 750);
|
||||||
|
|
||||||
/* Also check the 'guard_bw + non_guard_bw == original_bw'
|
/* Also check the 'guard_bw + non_guard_bw == original_bw'
|
||||||
* invariant. */
|
* 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:
|
done:
|
||||||
;
|
;
|
||||||
@ -295,9 +295,9 @@ test_parse_guardfraction_consensus(void *arg)
|
|||||||
retval = routerstatus_parse_guardfraction(guardfraction_str_good,
|
retval = routerstatus_parse_guardfraction(guardfraction_str_good,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&rs_good);
|
&rs_good);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
tt_assert(rs_good.has_guardfraction);
|
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
|
{ /* 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,
|
retval = routerstatus_parse_guardfraction(guardfraction_str_good,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&rs_no_guard);
|
&rs_no_guard);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
tt_assert(!rs_no_guard.has_guardfraction);
|
tt_assert(!rs_no_guard.has_guardfraction);
|
||||||
expect_single_log_msg_containing("Got GuardFraction for non-guard . "
|
expect_single_log_msg_containing("Got GuardFraction for non-guard . "
|
||||||
"This is not supposed to happen.");
|
"This is not supposed to happen.");
|
||||||
@ -323,7 +323,7 @@ test_parse_guardfraction_consensus(void *arg)
|
|||||||
retval = routerstatus_parse_guardfraction(guardfraction_str_bad1,
|
retval = routerstatus_parse_guardfraction(guardfraction_str_bad1,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&rs_bad1);
|
&rs_bad1);
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
tt_assert(!rs_bad1.has_guardfraction);
|
tt_assert(!rs_bad1.has_guardfraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ test_parse_guardfraction_consensus(void *arg)
|
|||||||
retval = routerstatus_parse_guardfraction(guardfraction_str_bad2,
|
retval = routerstatus_parse_guardfraction(guardfraction_str_bad2,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
&rs_bad2);
|
&rs_bad2);
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
tt_assert(!rs_bad2.has_guardfraction);
|
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
|
/* If torrc option is set to yes, we should always use
|
||||||
* guardfraction.*/
|
* guardfraction.*/
|
||||||
options->UseGuardFraction = 1;
|
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
|
/* If torrc option is set to no, we should never use
|
||||||
* guardfraction.*/
|
* guardfraction.*/
|
||||||
options->UseGuardFraction = 0;
|
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. */
|
/* Now let's test torrc option set to auto. */
|
||||||
options->UseGuardFraction = -1;
|
options->UseGuardFraction = -1;
|
||||||
|
|
||||||
/* If torrc option is set to auto, and consensus parameter is set to
|
/* If torrc option is set to auto, and consensus parameter is set to
|
||||||
* yes, we should use guardfraction. */
|
* 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
|
/* If torrc option is set to auto, and consensus parameter is set to
|
||||||
* no, we should use guardfraction. */
|
* 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
|
/* If torrc option is set to auto, and consensus parameter is not
|
||||||
* set, we should fallback to "no". */
|
* 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:
|
done:
|
||||||
SMARTLIST_FOREACH(vote_enabled.net_params, char *, cp, tor_free(cp));
|
SMARTLIST_FOREACH(vote_enabled.net_params, char *, cp, tor_free(cp));
|
||||||
|
@ -83,16 +83,16 @@ helper_setup_fake_routerlist(void)
|
|||||||
retval = router_load_routers_from_string(TEST_DESCRIPTORS,
|
retval = router_load_routers_from_string(TEST_DESCRIPTORS,
|
||||||
NULL, SAVED_IN_JOURNAL,
|
NULL, SAVED_IN_JOURNAL,
|
||||||
NULL, 0, NULL);
|
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. */
|
/* Sanity checking of routerlist and nodelist. */
|
||||||
our_routerlist = router_get_routerlist();
|
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);
|
HELPER_NUMBER_OF_DESCRIPTORS);
|
||||||
routerlist_assert_ok(our_routerlist);
|
routerlist_assert_ok(our_routerlist);
|
||||||
|
|
||||||
our_nodelist = nodelist_get_list();
|
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! */
|
/* Mark all routers as non-guards but up and running! */
|
||||||
SMARTLIST_FOREACH_BEGIN(our_nodelist, node_t *, node) {
|
SMARTLIST_FOREACH_BEGIN(our_nodelist, node_t *, node) {
|
||||||
|
@ -250,7 +250,7 @@ test_hs_desc_event(void *arg)
|
|||||||
ret = rend_compute_v2_desc_id(rend_query.descriptor_id[0],
|
ret = rend_compute_v2_desc_id(rend_query.descriptor_id[0],
|
||||||
rend_query.onion_address,
|
rend_query.onion_address,
|
||||||
NULL, 0, 0);
|
NULL, 0, 0);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
base32_encode(desc_id_base32, sizeof(desc_id_base32),
|
base32_encode(desc_id_base32, sizeof(desc_id_base32),
|
||||||
rend_query.descriptor_id[0], DIGEST_LEN);
|
rend_query.descriptor_id[0], DIGEST_LEN);
|
||||||
/* Make sure rend_compute_v2_desc_id works properly. */
|
/* 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,
|
retval = routerset_parse(options->Tor2webRendezvousPoints,
|
||||||
tor2web_rendezvous_str,
|
tor2web_rendezvous_str,
|
||||||
"test_tor2web_rp");
|
"test_tor2web_rp");
|
||||||
tt_int_op(retval, >=, 0);
|
tt_int_op(retval, OP_GE, 0);
|
||||||
|
|
||||||
/* Pick rendezvous point. Make sure the correct one is
|
/* Pick rendezvous point. Make sure the correct one is
|
||||||
picked. Repeat many times to make sure it works properly. */
|
picked. Repeat many times to make sure it works properly. */
|
||||||
for (i = 0; i < 50 ; i++) {
|
for (i = 0; i < 50 ; i++) {
|
||||||
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
|
chosen_rp = pick_tor2web_rendezvous_node(flags, options);
|
||||||
tt_assert(chosen_rp);
|
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:
|
done:
|
||||||
@ -398,7 +398,7 @@ test_pick_bad_tor2web_rendezvous_node(void *arg)
|
|||||||
retval = routerset_parse(options->Tor2webRendezvousPoints,
|
retval = routerset_parse(options->Tor2webRendezvousPoints,
|
||||||
tor2web_rendezvous_str,
|
tor2web_rendezvous_str,
|
||||||
"test_tor2web_rp");
|
"test_tor2web_rp");
|
||||||
tt_int_op(retval, >=, 0);
|
tt_int_op(retval, OP_GE, 0);
|
||||||
|
|
||||||
/* Pick rendezvous point. Since Tor2webRendezvousPoints was set to a
|
/* Pick rendezvous point. Since Tor2webRendezvousPoints was set to a
|
||||||
dummy value, we shouldn't find any eligible RPs. */
|
dummy value, we shouldn't find any eligible RPs. */
|
||||||
@ -435,30 +435,30 @@ test_hs_rend_data(void *arg)
|
|||||||
REND_NO_AUTH);
|
REND_NO_AUTH);
|
||||||
tt_assert(client);
|
tt_assert(client);
|
||||||
rend_data_v2_t *client_v2 = TO_REND_DATA_V2(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_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->desc_id_fetch, OP_EQ, desc_id, sizeof(desc_id));
|
||||||
tt_mem_op(client_v2->descriptor_cookie, OP_EQ, client_cookie,
|
tt_mem_op(client_v2->descriptor_cookie, OP_EQ, client_cookie,
|
||||||
sizeof(client_cookie));
|
sizeof(client_cookie));
|
||||||
tt_assert(client->hsdirs_fp);
|
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++) {
|
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
|
||||||
int ret = rend_compute_v2_desc_id(desc_id, client_v2->onion_address,
|
int ret = rend_compute_v2_desc_id(desc_id, client_v2->onion_address,
|
||||||
client_v2->descriptor_cookie, now, rep);
|
client_v2->descriptor_cookie, now, rep);
|
||||||
/* That shouldn't never fail. */
|
/* 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,
|
tt_mem_op(client_v2->descriptor_id[rep], OP_EQ, desc_id,
|
||||||
sizeof(desc_id));
|
sizeof(desc_id));
|
||||||
}
|
}
|
||||||
/* The rest should be zeroed because this is a client request. */
|
/* 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_v2->rend_pk_digest), OP_EQ, 1);
|
||||||
tt_int_op(tor_digest_is_zero(client->rend_cookie), ==, 1);
|
tt_int_op(tor_digest_is_zero(client->rend_cookie), OP_EQ, 1);
|
||||||
|
|
||||||
/* Test dup(). */
|
/* Test dup(). */
|
||||||
client_dup = rend_data_dup(client);
|
client_dup = rend_data_dup(client);
|
||||||
tt_assert(client_dup);
|
tt_assert(client_dup);
|
||||||
rend_data_v2_t *client_dup_v2 = TO_REND_DATA_V2(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_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,
|
tt_mem_op(client_dup_v2->desc_id_fetch, OP_EQ, client_v2->desc_id_fetch,
|
||||||
sizeof(client_dup_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));
|
sizeof(client_dup_v2->descriptor_cookie));
|
||||||
|
|
||||||
tt_assert(client_dup->hsdirs_fp);
|
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++) {
|
for (rep = 0; rep < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; rep++) {
|
||||||
tt_mem_op(client_dup_v2->descriptor_id[rep], OP_EQ,
|
tt_mem_op(client_dup_v2->descriptor_id[rep], OP_EQ,
|
||||||
client_v2->descriptor_id[rep], DIGEST_LEN);
|
client_v2->descriptor_id[rep], DIGEST_LEN);
|
||||||
}
|
}
|
||||||
/* The rest should be zeroed because this is a client request. */
|
/* 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_v2->rend_pk_digest), OP_EQ, 1);
|
||||||
tt_int_op(tor_digest_is_zero(client_dup->rend_cookie), ==, 1);
|
tt_int_op(tor_digest_is_zero(client_dup->rend_cookie), OP_EQ, 1);
|
||||||
rend_data_free(client);
|
rend_data_free(client);
|
||||||
client = NULL;
|
client = NULL;
|
||||||
rend_data_free(client_dup);
|
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);
|
client = rend_data_client_create(NULL, desc_id, NULL, REND_BASIC_AUTH);
|
||||||
tt_assert(client);
|
tt_assert(client);
|
||||||
client_v2 = TO_REND_DATA_V2(client);
|
client_v2 = TO_REND_DATA_V2(client);
|
||||||
tt_int_op(client_v2->auth_type, ==, REND_BASIC_AUTH);
|
tt_int_op(client_v2->auth_type, OP_EQ, REND_BASIC_AUTH);
|
||||||
tt_int_op(strlen(client_v2->onion_address), ==, 0);
|
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_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,
|
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_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++) {
|
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. */
|
/* 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_v2->rend_pk_digest), OP_EQ, 1);
|
||||||
tt_int_op(tor_digest_is_zero(client->rend_cookie), ==, 1);
|
tt_int_op(tor_digest_is_zero(client->rend_cookie), OP_EQ, 1);
|
||||||
rend_data_free(client);
|
rend_data_free(client);
|
||||||
client = NULL;
|
client = NULL;
|
||||||
|
|
||||||
@ -516,38 +516,38 @@ test_hs_rend_data(void *arg)
|
|||||||
rend_cookie, REND_NO_AUTH);
|
rend_cookie, REND_NO_AUTH);
|
||||||
tt_assert(service);
|
tt_assert(service);
|
||||||
rend_data_v2_t *service_v2 = TO_REND_DATA_V2(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_str_op(service_v2->onion_address, OP_EQ, STR_HS_ADDR);
|
||||||
tt_mem_op(service_v2->rend_pk_digest, OP_EQ, rend_pk_digest,
|
tt_mem_op(service_v2->rend_pk_digest, OP_EQ, rend_pk_digest,
|
||||||
sizeof(rend_pk_digest));
|
sizeof(rend_pk_digest));
|
||||||
tt_mem_op(service->rend_cookie, OP_EQ, rend_cookie, sizeof(rend_cookie));
|
tt_mem_op(service->rend_cookie, OP_EQ, rend_cookie, sizeof(rend_cookie));
|
||||||
tt_assert(service->hsdirs_fp);
|
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++) {
|
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. */
|
/* 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->descriptor_cookie), OP_EQ, 1);
|
||||||
tt_int_op(tor_digest_is_zero(service_v2->desc_id_fetch), ==, 1);
|
tt_int_op(tor_digest_is_zero(service_v2->desc_id_fetch), OP_EQ, 1);
|
||||||
|
|
||||||
/* Test dup(). */
|
/* Test dup(). */
|
||||||
service_dup = rend_data_dup(service);
|
service_dup = rend_data_dup(service);
|
||||||
rend_data_v2_t *service_dup_v2 = TO_REND_DATA_V2(service_dup);
|
rend_data_v2_t *service_dup_v2 = TO_REND_DATA_V2(service_dup);
|
||||||
tt_assert(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_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,
|
tt_mem_op(service_dup_v2->rend_pk_digest, OP_EQ, service_v2->rend_pk_digest,
|
||||||
sizeof(service_dup_v2->rend_pk_digest));
|
sizeof(service_dup_v2->rend_pk_digest));
|
||||||
tt_mem_op(service_dup->rend_cookie, OP_EQ, service->rend_cookie,
|
tt_mem_op(service_dup->rend_cookie, OP_EQ, service->rend_cookie,
|
||||||
sizeof(service_dup->rend_cookie));
|
sizeof(service_dup->rend_cookie));
|
||||||
tt_assert(service_dup->hsdirs_fp);
|
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++) {
|
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_int_op(tor_digest_is_zero(service_dup_v2->descriptor_id[rep]), OP_EQ, 1);
|
||||||
}
|
}
|
||||||
/* The rest should be zeroed because this is a service request. */
|
/* 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->descriptor_cookie), OP_EQ, 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->desc_id_fetch), OP_EQ, 1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
rend_data_free(service);
|
rend_data_free(service);
|
||||||
|
@ -55,7 +55,7 @@ test_directory(void *arg)
|
|||||||
init_test();
|
init_test();
|
||||||
/* Generate a valid descriptor with normal values. */
|
/* Generate a valid descriptor with normal values. */
|
||||||
ret = ed25519_keypair_generate(&signing_kp1, 0);
|
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);
|
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
|
||||||
tt_assert(desc1);
|
tt_assert(desc1);
|
||||||
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
|
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
|
/* Tell our OOM to run and to at least remove a byte which will result in
|
||||||
* removing the descriptor from our cache. */
|
* removing the descriptor from our cache. */
|
||||||
oom_size = hs_cache_handle_oom(time(NULL), 1);
|
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);
|
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||||
tt_int_op(ret, OP_EQ, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ test_directory(void *arg)
|
|||||||
{
|
{
|
||||||
ed25519_keypair_t signing_kp_zero;
|
ed25519_keypair_t signing_kp_zero;
|
||||||
ret = ed25519_keypair_generate(&signing_kp_zero, 0);
|
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;
|
hs_descriptor_t *desc_zero_lifetime;
|
||||||
desc_zero_lifetime = hs_helper_build_hs_desc_with_ip(&signing_kp_zero);
|
desc_zero_lifetime = hs_helper_build_hs_desc_with_ip(&signing_kp_zero);
|
||||||
tt_assert(desc_zero_lifetime);
|
tt_assert(desc_zero_lifetime);
|
||||||
@ -116,7 +116,7 @@ test_directory(void *arg)
|
|||||||
tt_int_op(ret, OP_EQ, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
/* Cleanup our entire cache. */
|
/* Cleanup our entire cache. */
|
||||||
oom_size = hs_cache_handle_oom(time(NULL), 1);
|
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);
|
hs_descriptor_free(desc_zero_lifetime);
|
||||||
tor_free(desc_zero_lifetime_str);
|
tor_free(desc_zero_lifetime_str);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ test_clean_as_dir(void *arg)
|
|||||||
|
|
||||||
/* Generate a valid descriptor with values. */
|
/* Generate a valid descriptor with values. */
|
||||||
ret = ed25519_keypair_generate(&signing_kp1, 0);
|
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);
|
desc1 = hs_helper_build_hs_desc_with_ip(&signing_kp1);
|
||||||
tt_assert(desc1);
|
tt_assert(desc1);
|
||||||
ret = hs_desc_encode_descriptor(desc1, &signing_kp1, &desc1_str);
|
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. */
|
/* With the lifetime being 3 hours, a cleanup shouldn't remove it. */
|
||||||
ret = cache_clean_v3_as_dir(now, 0);
|
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. */
|
/* Should be present after clean up. */
|
||||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||||
tt_int_op(ret, OP_EQ, 1);
|
tt_int_op(ret, OP_EQ, 1);
|
||||||
/* Set a cutoff 100 seconds in the past. It should not remove the entry
|
/* Set a cutoff 100 seconds in the past. It should not remove the entry
|
||||||
* since the entry is still recent enough. */
|
* since the entry is still recent enough. */
|
||||||
ret = cache_clean_v3_as_dir(now, now - 100);
|
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. */
|
/* Should be present after clean up. */
|
||||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||||
tt_int_op(ret, OP_EQ, 1);
|
tt_int_op(ret, OP_EQ, 1);
|
||||||
/* Set a cutoff of 100 seconds in the future. It should remove the entry
|
/* 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. */
|
* that we've just added since it's not too old for the cutoff. */
|
||||||
ret = cache_clean_v3_as_dir(now, now + 100);
|
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. */
|
/* Shouldn't be present after clean up. */
|
||||||
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
ret = hs_cache_lookup_as_dir(3, helper_get_hsdir_query(desc1), NULL);
|
||||||
tt_int_op(ret, OP_EQ, 0);
|
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,
|
retval = ed25519_public_to_base64(hsdir_cache_key,
|
||||||
blinded_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);
|
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;
|
ed25519_keypair_t signing_kp;
|
||||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
tt_assert(published_desc);
|
tt_assert(published_desc);
|
||||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
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 */
|
/* Publish descriptor to the HSDir */
|
||||||
{
|
{
|
||||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
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 */
|
/* 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. */
|
/* Generate a valid descriptor with normal values. */
|
||||||
{
|
{
|
||||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
tt_assert(published_desc);
|
tt_assert(published_desc);
|
||||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
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 */
|
/* Publish descriptor to the HSDir */
|
||||||
{
|
{
|
||||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
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. */
|
/* Try publishing again with the same revision counter: Should fail. */
|
||||||
{
|
{
|
||||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
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. */
|
/* 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,
|
retval = hs_desc_decode_descriptor(received_desc_str,
|
||||||
subcredential, &received_desc);
|
subcredential, &received_desc);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
tt_assert(received_desc);
|
tt_assert(received_desc);
|
||||||
|
|
||||||
/* Check that the revision counter is correct */
|
/* 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);
|
hs_descriptor_free(received_desc);
|
||||||
received_desc = NULL;
|
received_desc = NULL;
|
||||||
@ -405,7 +405,7 @@ test_hsdir_revision_counter_check(void *arg)
|
|||||||
tt_int_op(retval, OP_EQ, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
retval = handle_post_hs_descriptor("/tor/hs/3/publish",published_desc_str);
|
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
|
/* 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,
|
retval = hs_desc_decode_descriptor(received_desc_str,
|
||||||
subcredential, &received_desc);
|
subcredential, &received_desc);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
tt_assert(received_desc);
|
tt_assert(received_desc);
|
||||||
|
|
||||||
/* Check that the revision counter is the latest */
|
/* 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:
|
done:
|
||||||
@ -452,7 +452,7 @@ test_client_cache(void *arg)
|
|||||||
/* Generate a valid descriptor with normal values. */
|
/* Generate a valid descriptor with normal values. */
|
||||||
{
|
{
|
||||||
retval = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
published_desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
tt_assert(published_desc);
|
tt_assert(published_desc);
|
||||||
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
retval = hs_desc_encode_descriptor(published_desc, &signing_kp,
|
||||||
|
@ -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);
|
or_circ->build_state->pending_final_cpath->rend_dh_handshake_state);
|
||||||
retval = crypto_dh_generate_public(
|
retval = crypto_dh_generate_public(
|
||||||
or_circ->build_state->pending_final_cpath->rend_dh_handshake_state);
|
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);
|
or_circ->rend_data = rend_data_dup(conn_rend_data);
|
||||||
} else {
|
} else {
|
||||||
/* prop224: Setup hs ident on the circuit */
|
/* prop224: Setup hs ident on the circuit */
|
||||||
@ -154,7 +154,7 @@ test_e2e_rend_circuit_setup_legacy(void *arg)
|
|||||||
|
|
||||||
/* Check number of hops */
|
/* Check number of hops */
|
||||||
retval = cpath_get_n_hops(&or_circ->cpath);
|
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 */
|
/* Check that our stream is not attached on any circuits */
|
||||||
tt_assert(!TO_EDGE_CONN(conn)->on_circuit);
|
tt_assert(!TO_EDGE_CONN(conn)->on_circuit);
|
||||||
@ -236,7 +236,7 @@ test_e2e_rend_circuit_setup(void *arg)
|
|||||||
|
|
||||||
/* Check number of hops: There should be no hops yet to this circ */
|
/* Check number of hops: There should be no hops yet to this circ */
|
||||||
retval = cpath_get_n_hops(&or_circ->cpath);
|
retval = cpath_get_n_hops(&or_circ->cpath);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
tt_assert(!or_circ->cpath);
|
tt_assert(!or_circ->cpath);
|
||||||
|
|
||||||
/* Check that our stream is not attached on any circuits */
|
/* Check that our stream is not attached on any circuits */
|
||||||
|
@ -138,22 +138,22 @@ test_time_period(void *arg)
|
|||||||
/* Let's do the example in prop224 section [TIME-PERIODS] */
|
/* Let's do the example in prop224 section [TIME-PERIODS] */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
|
||||||
&fake_time);
|
&fake_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
/* Check that the time period number is right */
|
/* Check that the time period number is right */
|
||||||
tn = hs_get_time_period_num(fake_time);
|
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
|
/* Increase current time to 11:59:59 UTC and check that the time period
|
||||||
number is still the same */
|
number is still the same */
|
||||||
fake_time += 3599;
|
fake_time += 3599;
|
||||||
tn = hs_get_time_period_num(fake_time);
|
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 */
|
{ /* Check start time of next time period */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
|
||||||
&correct_time);
|
&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);
|
start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
tt_int_op(start_time, OP_EQ, correct_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 */
|
/* Now take time to 12:00:00 UTC and check that the time period rotated */
|
||||||
fake_time += 1;
|
fake_time += 1;
|
||||||
tn = hs_get_time_period_num(fake_time);
|
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 */
|
/* Now also check our hs_get_next_time_period_num() function */
|
||||||
tn = hs_get_next_time_period_num(fake_time);
|
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 */
|
{ /* Check start time of next time period again */
|
||||||
retval = parse_rfc1123_time("Wed, 14 Apr 2016 12:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 14 Apr 2016 12:00:00 UTC",
|
||||||
&correct_time);
|
&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);
|
start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
tt_int_op(start_time, OP_EQ, correct_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 */
|
/* Do some basic tests */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 11:00:00 UTC",
|
||||||
&fake_time);
|
&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);
|
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
/* Compare it with the correct result */
|
/* Compare it with the correct result */
|
||||||
format_iso_time(tbuf, next_tp_start_time);
|
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) */
|
/* Another test with an edge-case time (start of TP) */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 12:00:00 UTC",
|
||||||
&fake_time);
|
&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);
|
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
format_iso_time(tbuf, next_tp_start_time);
|
format_iso_time(tbuf, next_tp_start_time);
|
||||||
tt_str_op("2016-04-14 12:00:00", OP_EQ, tbuf);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
|
||||||
&fake_time);
|
&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);
|
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
/* Compare it with the correct result */
|
/* Compare it with the correct result */
|
||||||
format_iso_time(tbuf, next_tp_start_time);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:02:00 UTC",
|
||||||
&fake_time);
|
&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);
|
next_tp_start_time = hs_get_start_time_of_next_time_period(fake_time);
|
||||||
/* Compare it with the correct result */
|
/* Compare it with the correct result */
|
||||||
format_iso_time(tbuf, next_tp_start_time);
|
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));
|
dummy_consensus = tor_malloc_zero(sizeof(networkstatus_t));
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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
|
/* Now increase the valid_after so that it goes to 11:00:00 UTC. Overlap
|
||||||
period is still active. */
|
period is still active. */
|
||||||
dummy_consensus->valid_after += 3600*11;
|
dummy_consensus->valid_after += 3600*11;
|
||||||
retval = hs_overlap_mode_is_active(dummy_consensus, now);
|
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
|
/* Now increase the valid_after so that it goes to 11:59:59 UTC. Overlap
|
||||||
period is still active. */
|
period is still active. */
|
||||||
dummy_consensus->valid_after += 3599;
|
dummy_consensus->valid_after += 3599;
|
||||||
retval = hs_overlap_mode_is_active(dummy_consensus, now);
|
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
|
/* Now increase the valid_after so that it drifts to noon, and check that
|
||||||
overlap mode is not active anymore. */
|
overlap mode is not active anymore. */
|
||||||
dummy_consensus->valid_after += 1;
|
dummy_consensus->valid_after += 1;
|
||||||
retval = hs_overlap_mode_is_active(dummy_consensus, now);
|
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 */
|
/* Check that overlap mode is also inactive at 23:59:59 UTC */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 23:59:59 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 23:59:59 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
retval = hs_overlap_mode_is_active(dummy_consensus, now);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(dummy_consensus);
|
tor_free(dummy_consensus);
|
||||||
@ -322,39 +322,39 @@ test_desc_overlap_period_testnet(void *arg)
|
|||||||
* window. Let's test it: */
|
* window. Let's test it: */
|
||||||
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:00:00 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:01:59 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:02:00 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:04:00 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:05:59 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
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",
|
retval = parse_rfc1123_time("Wed, 13 Apr 2016 00:06:00 UTC",
|
||||||
&dummy_consensus->valid_after);
|
&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);
|
retval = hs_overlap_mode_is_active(dummy_consensus, now);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(dummy_consensus);
|
tor_free(dummy_consensus);
|
||||||
|
@ -54,7 +54,7 @@ test_cert_encoding(void *arg)
|
|||||||
|
|
||||||
/* Test the certificate encoding function. */
|
/* Test the certificate encoding function. */
|
||||||
ret = tor_cert_encode_ed22519(cert, &encoded);
|
ret = tor_cert_encode_ed22519(cert, &encoded);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
|
|
||||||
/* Validated the certificate string. */
|
/* Validated the certificate string. */
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ test_cert_encoding(void *arg)
|
|||||||
size_t b64_cert_len;
|
size_t b64_cert_len;
|
||||||
tor_cert_t *parsed_cert;
|
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");
|
pos += strlen("-----BEGIN ED25519 CERT-----\n");
|
||||||
|
|
||||||
/* Isolate the base64 encoded certificate and try to decode it. */
|
/* Isolate the base64 encoded certificate and try to decode it. */
|
||||||
@ -72,23 +72,23 @@ test_cert_encoding(void *arg)
|
|||||||
b64_cert = pos;
|
b64_cert = pos;
|
||||||
b64_cert_len = end - pos;
|
b64_cert_len = end - pos;
|
||||||
ret = base64_decode(buf, sizeof(buf), b64_cert, b64_cert_len);
|
ret = base64_decode(buf, sizeof(buf), b64_cert, b64_cert_len);
|
||||||
tt_int_op(ret, >, 0);
|
tt_int_op(ret, OP_GT, 0);
|
||||||
/* Parseable? */
|
/* Parseable? */
|
||||||
parsed_cert = tor_cert_parse((uint8_t *) buf, ret);
|
parsed_cert = tor_cert_parse((uint8_t *) buf, ret);
|
||||||
tt_assert(parsed_cert);
|
tt_assert(parsed_cert);
|
||||||
/* Signature is valid? */
|
/* Signature is valid? */
|
||||||
ret = tor_cert_checksig(parsed_cert, &kp.pubkey, now + 10);
|
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);
|
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? */
|
/* The cert did have the signing key? */
|
||||||
ret= ed25519_pubkey_eq(&parsed_cert->signing_key, &kp.pubkey);
|
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);
|
tor_cert_free(parsed_cert);
|
||||||
|
|
||||||
/* Get to the end part of the certificate. */
|
/* Get to the end part of the certificate. */
|
||||||
pos += b64_cert_len;
|
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-----");
|
pos += strlen("-----END ED25519 CERT-----");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,22 +188,22 @@ test_link_specifier(void *arg)
|
|||||||
|
|
||||||
spec.type = LS_IPV4;
|
spec.type = LS_IPV4;
|
||||||
ret = tor_addr_parse(&spec.u.ap.addr, "1.2.3.4");
|
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);
|
b64 = encode_link_specifiers(link_specifiers);
|
||||||
tt_assert(b64);
|
tt_assert(b64);
|
||||||
|
|
||||||
/* Decode it and validate the format. */
|
/* Decode it and validate the format. */
|
||||||
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
|
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. */
|
/* 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);
|
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. */
|
/* 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);
|
ipv4 = link_specifier_get_un_ipv4_addr(ls);
|
||||||
tt_int_op(tor_addr_to_ipv4h(&spec.u.ap.addr), ==, ipv4);
|
tt_int_op(tor_addr_to_ipv4h(&spec.u.ap.addr), OP_EQ, ipv4);
|
||||||
tt_int_op(link_specifier_get_un_ipv4_port(ls), ==, spec.u.ap.port);
|
tt_int_op(link_specifier_get_un_ipv4_port(ls), OP_EQ, spec.u.ap.port);
|
||||||
|
|
||||||
link_specifier_free(ls);
|
link_specifier_free(ls);
|
||||||
tor_free(b64);
|
tor_free(b64);
|
||||||
@ -217,24 +217,24 @@ test_link_specifier(void *arg)
|
|||||||
|
|
||||||
spec.type = LS_IPV6;
|
spec.type = LS_IPV6;
|
||||||
ret = tor_addr_parse(&spec.u.ap.addr, "[1:2:3:4::]");
|
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);
|
b64 = encode_link_specifiers(link_specifiers);
|
||||||
tt_assert(b64);
|
tt_assert(b64);
|
||||||
|
|
||||||
/* Decode it and validate the format. */
|
/* Decode it and validate the format. */
|
||||||
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
|
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. */
|
/* 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);
|
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. */
|
/* 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++) {
|
for (unsigned int i = 0; i < sizeof(ipv6); i++) {
|
||||||
ipv6[i] = link_specifier_get_un_ipv6_addr(ls, 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_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), ==, spec.u.ap.port);
|
tt_int_op(link_specifier_get_un_ipv6_port(ls), OP_EQ, spec.u.ap.port);
|
||||||
|
|
||||||
link_specifier_free(ls);
|
link_specifier_free(ls);
|
||||||
tor_free(b64);
|
tor_free(b64);
|
||||||
@ -253,12 +253,12 @@ test_link_specifier(void *arg)
|
|||||||
|
|
||||||
/* Decode it and validate the format. */
|
/* Decode it and validate the format. */
|
||||||
ret = base64_decode(buf, sizeof(buf), b64, strlen(b64));
|
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. */
|
/* 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);
|
ret = link_specifier_parse(&ls, (uint8_t *) buf + 1, ret - 1);
|
||||||
/* 20 bytes digest + 1 byte type + 1 byte len. */
|
/* 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);
|
tt_int_op(link_specifier_getlen_un_legacy_id(ls), OP_EQ, DIGEST_LEN);
|
||||||
/* Digest length is 20 bytes. */
|
/* Digest length is 20 bytes. */
|
||||||
tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, DIGEST_LEN);
|
tt_int_op(link_specifier_get_ls_len(ls), OP_EQ, DIGEST_LEN);
|
||||||
@ -284,10 +284,10 @@ test_encode_descriptor(void *arg)
|
|||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
ret = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
|
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
tt_assert(encoded);
|
tt_assert(encoded);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -309,7 +309,7 @@ test_decode_descriptor(void *arg)
|
|||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
ret = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
|
|
||||||
hs_helper_get_subcred_from_identity_keypair(&signing_kp,
|
hs_helper_get_subcred_from_identity_keypair(&signing_kp,
|
||||||
@ -320,11 +320,11 @@ test_decode_descriptor(void *arg)
|
|||||||
tt_int_op(ret, OP_EQ, -1);
|
tt_int_op(ret, OP_EQ, -1);
|
||||||
|
|
||||||
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
|
ret = hs_desc_encode_descriptor(desc, &signing_kp, &encoded);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
tt_assert(encoded);
|
tt_assert(encoded);
|
||||||
|
|
||||||
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
|
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
tt_assert(decoded);
|
tt_assert(decoded);
|
||||||
|
|
||||||
hs_helper_desc_equal(desc, decoded);
|
hs_helper_desc_equal(desc, decoded);
|
||||||
@ -333,18 +333,18 @@ test_decode_descriptor(void *arg)
|
|||||||
{
|
{
|
||||||
ed25519_keypair_t signing_kp_no_ip;
|
ed25519_keypair_t signing_kp_no_ip;
|
||||||
ret = ed25519_keypair_generate(&signing_kp_no_ip, 0);
|
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,
|
hs_helper_get_subcred_from_identity_keypair(&signing_kp_no_ip,
|
||||||
subcredential);
|
subcredential);
|
||||||
desc_no_ip = hs_helper_build_hs_desc_no_ip(&signing_kp_no_ip);
|
desc_no_ip = hs_helper_build_hs_desc_no_ip(&signing_kp_no_ip);
|
||||||
tt_assert(desc_no_ip);
|
tt_assert(desc_no_ip);
|
||||||
tor_free(encoded);
|
tor_free(encoded);
|
||||||
ret = hs_desc_encode_descriptor(desc_no_ip, &signing_kp_no_ip, &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);
|
tt_assert(encoded);
|
||||||
hs_descriptor_free(decoded);
|
hs_descriptor_free(decoded);
|
||||||
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
|
ret = hs_desc_decode_descriptor(encoded, subcredential, &decoded);
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
tt_assert(decoded);
|
tt_assert(decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ test_decode_invalid_intro_point(void *arg)
|
|||||||
hs_descriptor_free(desc);
|
hs_descriptor_free(desc);
|
||||||
desc = NULL;
|
desc = NULL;
|
||||||
ret = ed25519_keypair_generate(&signing_kp, 0);
|
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);
|
desc = hs_helper_build_hs_desc_with_ip(&signing_kp);
|
||||||
const char *junk = "this is not a descriptor";
|
const char *junk = "this is not a descriptor";
|
||||||
ip = decode_introduction_point(desc, junk);
|
ip = decode_introduction_point(desc, junk);
|
||||||
@ -629,7 +629,7 @@ test_decode_plaintext(void *arg)
|
|||||||
{
|
{
|
||||||
size_t big = 64000;
|
size_t big = 64000;
|
||||||
/* Must always be bigger than HS_DESC_MAX_LEN. */
|
/* 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);
|
char *plaintext = tor_malloc_zero(big);
|
||||||
memset(plaintext, 'a', big);
|
memset(plaintext, 'a', big);
|
||||||
plaintext[big - 1] = '\0';
|
plaintext[big - 1] = '\0';
|
||||||
@ -689,7 +689,7 @@ test_validate_cert(void *arg)
|
|||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
ret = ed25519_keypair_generate(&kp, 0);
|
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 of type CERT_TYPE_AUTH_HS_IP_KEY. */
|
||||||
cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
|
cert = tor_cert_create(&kp, CERT_TYPE_AUTH_HS_IP_KEY,
|
||||||
@ -740,16 +740,16 @@ test_desc_signature(void *arg)
|
|||||||
tor_asprintf(&data, "This is a signed descriptor\n");
|
tor_asprintf(&data, "This is a signed descriptor\n");
|
||||||
ret = ed25519_sign_prefixed(&sig, (const uint8_t *) data, strlen(data),
|
ret = ed25519_sign_prefixed(&sig, (const uint8_t *) data, strlen(data),
|
||||||
"Tor onion service descriptor sig v3", &kp);
|
"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);
|
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. */
|
/* Build the descriptor that should be valid. */
|
||||||
tor_asprintf(&desc, "%ssignature %s\n", data, sig_b64);
|
tor_asprintf(&desc, "%ssignature %s\n", data, sig_b64);
|
||||||
ret = desc_sig_is_valid(sig_b64, &kp.pubkey, desc, strlen(desc));
|
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. */
|
/* Junk signature. */
|
||||||
ret = desc_sig_is_valid("JUNK", &kp.pubkey, desc, strlen(desc));
|
ret = desc_sig_is_valid("JUNK", &kp.pubkey, desc, strlen(desc));
|
||||||
tt_int_op(ret, ==, 0);
|
tt_int_op(ret, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(desc);
|
tor_free(desc);
|
||||||
@ -811,7 +811,7 @@ test_parse_hs_desc_superencrypted(void *arg)
|
|||||||
retval = decode_superencrypted(bad_superencrypted_text1,
|
retval = decode_superencrypted(bad_superencrypted_text1,
|
||||||
strlen(bad_superencrypted_text1),
|
strlen(bad_superencrypted_text1),
|
||||||
&encrypted_out);
|
&encrypted_out);
|
||||||
tt_u64_op(retval, ==, 0);
|
tt_u64_op(retval, OP_EQ, 0);
|
||||||
tt_assert(!encrypted_out);
|
tt_assert(!encrypted_out);
|
||||||
expect_log_msg_containing("Unrecognized desc auth type");
|
expect_log_msg_containing("Unrecognized desc auth type");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
@ -822,7 +822,7 @@ test_parse_hs_desc_superencrypted(void *arg)
|
|||||||
retval = decode_superencrypted(bad_superencrypted_text2,
|
retval = decode_superencrypted(bad_superencrypted_text2,
|
||||||
strlen(bad_superencrypted_text2),
|
strlen(bad_superencrypted_text2),
|
||||||
&encrypted_out);
|
&encrypted_out);
|
||||||
tt_u64_op(retval, ==, 0);
|
tt_u64_op(retval, OP_EQ, 0);
|
||||||
tt_assert(!encrypted_out);
|
tt_assert(!encrypted_out);
|
||||||
expect_log_msg_containing("Bogus desc auth key in HS desc");
|
expect_log_msg_containing("Bogus desc auth key in HS desc");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
@ -833,7 +833,7 @@ test_parse_hs_desc_superencrypted(void *arg)
|
|||||||
retval = decode_superencrypted(bad_superencrypted_text3,
|
retval = decode_superencrypted(bad_superencrypted_text3,
|
||||||
strlen(bad_superencrypted_text3),
|
strlen(bad_superencrypted_text3),
|
||||||
&encrypted_out);
|
&encrypted_out);
|
||||||
tt_u64_op(retval, ==, 0);
|
tt_u64_op(retval, OP_EQ, 0);
|
||||||
tt_assert(!encrypted_out);
|
tt_assert(!encrypted_out);
|
||||||
expect_log_msg_containing("Length of descriptor\'s encrypted data "
|
expect_log_msg_containing("Length of descriptor\'s encrypted data "
|
||||||
"is too small.");
|
"is too small.");
|
||||||
@ -845,7 +845,7 @@ test_parse_hs_desc_superencrypted(void *arg)
|
|||||||
strlen(correct_superencrypted_text),
|
strlen(correct_superencrypted_text),
|
||||||
&encrypted_out);
|
&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,
|
tt_mem_op(encrypted_out, OP_EQ, correct_encrypted_plaintext,
|
||||||
strlen(correct_encrypted_plaintext));
|
strlen(correct_encrypted_plaintext));
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ test_establish_intro_wrong_purpose(void *arg)
|
|||||||
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
||||||
expect_log_msg_containing("Rejecting ESTABLISH_INTRO on non-OR circuit.");
|
expect_log_msg_containing("Rejecting ESTABLISH_INTRO on non-OR circuit.");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
circuit_free(TO_CIRCUIT(intro_circ));
|
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);
|
retval = hs_intro_received_establish_intro(intro_circ, (uint8_t *) "", 0);
|
||||||
expect_log_msg_containing("Empty ESTABLISH_INTRO cell.");
|
expect_log_msg_containing("Empty ESTABLISH_INTRO cell.");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
circuit_free(TO_CIRCUIT(intro_circ));
|
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);
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
||||||
expect_log_msg_containing("Unrecognized AUTH_KEY_TYPE 42.");
|
expect_log_msg_containing("Unrecognized AUTH_KEY_TYPE 42.");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
circuit_free(TO_CIRCUIT(intro_circ));
|
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);
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
||||||
expect_log_msg_containing("ESTABLISH_INTRO handshake_auth not as expected");
|
expect_log_msg_containing("ESTABLISH_INTRO handshake_auth not as expected");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
trn_cell_establish_intro_free(cell);
|
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);
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
||||||
expect_log_msg_containing("ESTABLISH_INTRO auth key length is invalid");
|
expect_log_msg_containing("ESTABLISH_INTRO auth key length is invalid");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
trn_cell_establish_intro_free(cell);
|
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);
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body, cell_len);
|
||||||
expect_log_msg_containing("ESTABLISH_INTRO sig len is invalid");
|
expect_log_msg_containing("ESTABLISH_INTRO sig len is invalid");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
trn_cell_establish_intro_free(cell);
|
trn_cell_establish_intro_free(cell);
|
||||||
@ -457,7 +457,7 @@ test_establish_intro_wrong_sig(void *arg)
|
|||||||
(size_t)cell_len);
|
(size_t)cell_len);
|
||||||
expect_log_msg_containing("Failed to verify ESTABLISH_INTRO cell.");
|
expect_log_msg_containing("Failed to verify ESTABLISH_INTRO cell.");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
tt_int_op(retval, ==, -1);
|
tt_int_op(retval, OP_EQ, -1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
circuit_free(TO_CIRCUIT(intro_circ));
|
circuit_free(TO_CIRCUIT(intro_circ));
|
||||||
@ -492,7 +492,7 @@ helper_establish_intro_v3(or_circuit_t *intro_circ)
|
|||||||
/* Receive the cell */
|
/* Receive the cell */
|
||||||
retval = hs_intro_received_establish_intro(intro_circ, cell_body,
|
retval = hs_intro_received_establish_intro(intro_circ, cell_body,
|
||||||
(size_t) cell_len);
|
(size_t) cell_len);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return cell;
|
return cell;
|
||||||
@ -528,7 +528,7 @@ helper_establish_intro_v2(or_circuit_t *intro_circ)
|
|||||||
/* Receive legacy establish_intro */
|
/* Receive legacy establish_intro */
|
||||||
retval = hs_intro_received_establish_intro(intro_circ,
|
retval = hs_intro_received_establish_intro(intro_circ,
|
||||||
cell_body, (size_t) cell_len);
|
cell_body, (size_t) cell_len);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return key1;
|
return key1;
|
||||||
@ -579,10 +579,10 @@ test_intro_point_registration(void *arg)
|
|||||||
{
|
{
|
||||||
the_hs_circuitmap = get_hs_circuitmap();
|
the_hs_circuitmap = get_hs_circuitmap();
|
||||||
tt_assert(the_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 */
|
/* Do a circuitmap query in any case */
|
||||||
returned_intro_circ =hs_circuitmap_get_intro_circ_v3_relay_side(&auth_key);
|
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 */
|
/* 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 */
|
/* Check that the intro point was registered on the HS circuitmap */
|
||||||
the_hs_circuitmap = get_hs_circuitmap();
|
the_hs_circuitmap = get_hs_circuitmap();
|
||||||
tt_assert(the_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,
|
get_auth_key_from_cell(&auth_key, RELAY_COMMAND_ESTABLISH_INTRO,
|
||||||
establish_intro_cell);
|
establish_intro_cell);
|
||||||
returned_intro_circ =
|
returned_intro_circ =
|
||||||
hs_circuitmap_get_intro_circ_v3_relay_side(&auth_key);
|
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 */
|
/* Create a v2 intro point */
|
||||||
@ -614,14 +614,14 @@ test_intro_point_registration(void *arg)
|
|||||||
/* Check that the circuitmap now has two elements */
|
/* Check that the circuitmap now has two elements */
|
||||||
the_hs_circuitmap = get_hs_circuitmap();
|
the_hs_circuitmap = get_hs_circuitmap();
|
||||||
tt_assert(the_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. */
|
/* Check that the new element is our legacy intro circuit. */
|
||||||
retval = crypto_pk_get_digest(legacy_auth_key, key_digest);
|
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 =
|
returned_intro_circ =
|
||||||
hs_circuitmap_get_intro_circ_v2_relay_side((uint8_t*)key_digest);
|
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
|
/* XXX Continue test and try to register a second v3 intro point with the
|
||||||
|
@ -57,7 +57,7 @@ test_hs_ntor(void *arg)
|
|||||||
&client_ephemeral_enc_keypair,
|
&client_ephemeral_enc_keypair,
|
||||||
subcredential,
|
subcredential,
|
||||||
&client_hs_ntor_intro_cell_keys);
|
&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 */
|
/* Service: Simulate the decryption of the received INTRODUCE1 */
|
||||||
retval =
|
retval =
|
||||||
@ -66,7 +66,7 @@ test_hs_ntor(void *arg)
|
|||||||
&client_ephemeral_enc_keypair.pubkey,
|
&client_ephemeral_enc_keypair.pubkey,
|
||||||
subcredential,
|
subcredential,
|
||||||
&service_hs_ntor_intro_cell_keys);
|
&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! */
|
/* Test that the INTRODUCE1 encryption/mac keys match! */
|
||||||
tt_mem_op(client_hs_ntor_intro_cell_keys.enc_key, OP_EQ,
|
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,
|
&service_ephemeral_rend_keypair,
|
||||||
&client_ephemeral_enc_keypair.pubkey,
|
&client_ephemeral_enc_keypair.pubkey,
|
||||||
&service_hs_ntor_rend_cell_keys);
|
&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 */
|
/* Client: Simulate the verification of a received RENDEZVOUS1 cell */
|
||||||
retval =
|
retval =
|
||||||
@ -92,7 +92,7 @@ test_hs_ntor(void *arg)
|
|||||||
&service_intro_enc_keypair.pubkey,
|
&service_intro_enc_keypair.pubkey,
|
||||||
&service_ephemeral_rend_keypair.pubkey,
|
&service_ephemeral_rend_keypair.pubkey,
|
||||||
&client_hs_ntor_rend_cell_keys);
|
&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! */
|
/* Test that the RENDEZVOUS1 key material match! */
|
||||||
tt_mem_op(client_hs_ntor_rend_cell_keys.rend_cell_auth_mac, OP_EQ,
|
tt_mem_op(client_hs_ntor_rend_cell_keys.rend_cell_auth_mac, OP_EQ,
|
||||||
|
@ -20,8 +20,8 @@ test_keypin_parse_line(void *arg)
|
|||||||
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
|
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
|
||||||
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4");
|
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4");
|
||||||
tt_assert(ent);
|
tt_assert(ent);
|
||||||
tt_mem_op(ent->rsa_id, ==, "here is a good sha1!", 20);
|
tt_mem_op(ent->rsa_id, OP_EQ, "here is a good sha1!", 20);
|
||||||
tt_mem_op(ent->ed25519_key, ==, "This ed25519 scoffs at the sha1.", 32);
|
tt_mem_op(ent->ed25519_key, OP_EQ, "This ed25519 scoffs at the sha1.", 32);
|
||||||
tor_free(ent); ent = NULL;
|
tor_free(ent); ent = NULL;
|
||||||
|
|
||||||
/* Good line with extra stuff we will ignore. */
|
/* Good line with extra stuff we will ignore. */
|
||||||
@ -29,8 +29,8 @@ test_keypin_parse_line(void *arg)
|
|||||||
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
|
"aGVyZSBpcyBhIGdvb2Qgc2hhMSE "
|
||||||
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4helloworld");
|
"VGhpcyBlZDI1NTE5IHNjb2ZmcyBhdCB0aGUgc2hhMS4helloworld");
|
||||||
tt_assert(ent);
|
tt_assert(ent);
|
||||||
tt_mem_op(ent->rsa_id, ==, "here is a good sha1!", 20);
|
tt_mem_op(ent->rsa_id, OP_EQ, "here is a good sha1!", 20);
|
||||||
tt_mem_op(ent->ed25519_key, ==, "This ed25519 scoffs at the sha1.", 32);
|
tt_mem_op(ent->ed25519_key, OP_EQ, "This ed25519 scoffs at the sha1.", 32);
|
||||||
tor_free(ent); ent = NULL;
|
tor_free(ent); ent = NULL;
|
||||||
|
|
||||||
/* Bad line: no space in the middle. */
|
/* Bad line: no space in the middle. */
|
||||||
@ -82,11 +82,11 @@ test_keypin_parse_file(void *arg)
|
|||||||
"Z2dsZSBpbiBzd29tZWVzd2FucyA aW4gdm9sdXB0YXRlIGF4ZS1oYWNrZXIgZXNzZSByaXA\n"
|
"Z2dsZSBpbiBzd29tZWVzd2FucyA aW4gdm9sdXB0YXRlIGF4ZS1oYWNrZXIgZXNzZSByaXA\n"
|
||||||
"cHVsdXMgY3J1bW1paSBldSBtb28 ZiBudWxsYSBzbnV2di5QTFVHSFBMT1ZFUlhZWlpZLi4\n";
|
"cHVsdXMgY3J1bW1paSBldSBtb28 ZiBudWxsYSBzbnV2di5QTFVHSFBMT1ZFUlhZWlpZLi4\n";
|
||||||
|
|
||||||
tt_int_op(0, ==, keypin_load_journal_impl(data1, strlen(data1)));
|
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data1, strlen(data1)));
|
||||||
tt_int_op(8, ==, smartlist_len(mock_addent_got));
|
tt_int_op(8, OP_EQ, smartlist_len(mock_addent_got));
|
||||||
keypin_ent_t *ent = smartlist_get(mock_addent_got, 2);
|
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->rsa_id, OP_EQ, "r lerkim, sed do bar", 20);
|
||||||
tt_mem_op(ent->ed25519_key, ==, "baloot tempor gluppitus ut labor", 32);
|
tt_mem_op(ent->ed25519_key, OP_EQ, "baloot tempor gluppitus ut labor", 32);
|
||||||
|
|
||||||
/* More complex example: weird lines, bogus lines,
|
/* More complex example: weird lines, bogus lines,
|
||||||
duplicate/conflicting lines */
|
duplicate/conflicting lines */
|
||||||
@ -107,24 +107,24 @@ test_keypin_parse_file(void *arg)
|
|||||||
"ZHMgc3BlYWsgdHJ1dGgsIGFuZCA aXQgd2FzIHRydaUgdGhhdCBhbGwgdGhlIG1hc3Rlcgo\n"
|
"ZHMgc3BlYWsgdHJ1dGgsIGFuZCA aXQgd2FzIHRydaUgdGhhdCBhbGwgdGhlIG1hc3Rlcgo\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
tt_int_op(0, ==, keypin_load_journal_impl(data2, strlen(data2)));
|
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data2, strlen(data2)));
|
||||||
tt_int_op(13, ==, smartlist_len(mock_addent_got));
|
tt_int_op(13, OP_EQ, smartlist_len(mock_addent_got));
|
||||||
ent = smartlist_get(mock_addent_got, 9);
|
ent = smartlist_get(mock_addent_got, 9);
|
||||||
tt_mem_op(ent->rsa_id, ==, "\"You have made a goo", 20);
|
tt_mem_op(ent->rsa_id, OP_EQ, "\"You have made a goo", 20);
|
||||||
tt_mem_op(ent->ed25519_key, ==, "d beginning.\" But no more. Wizar", 32);
|
tt_mem_op(ent->ed25519_key, OP_EQ, "d beginning.\" But no more. Wizar", 32);
|
||||||
|
|
||||||
ent = smartlist_get(mock_addent_got, 12);
|
ent = smartlist_get(mock_addent_got, 12);
|
||||||
tt_mem_op(ent->rsa_id, ==, "ds speak truth, and ", 20);
|
tt_mem_op(ent->rsa_id, OP_EQ, "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->ed25519_key, OP_EQ, "it was tru\xa5 that all the master\n", 32);
|
||||||
|
|
||||||
/* File truncated before NL */
|
/* File truncated before NL */
|
||||||
const char data3[] =
|
const char data3[] =
|
||||||
"Tm8gZHJhZ29uIGNhbiByZXNpc3Q IHRoZSBmYXNjaW5hdGlvbiBvZiByaWRkbGluZyB0YWw";
|
"Tm8gZHJhZ29uIGNhbiByZXNpc3Q IHRoZSBmYXNjaW5hdGlvbiBvZiByaWRkbGluZyB0YWw";
|
||||||
tt_int_op(0, ==, keypin_load_journal_impl(data3, strlen(data3)));
|
tt_int_op(0, OP_EQ, keypin_load_journal_impl(data3, strlen(data3)));
|
||||||
tt_int_op(14, ==, smartlist_len(mock_addent_got));
|
tt_int_op(14, OP_EQ, smartlist_len(mock_addent_got));
|
||||||
ent = smartlist_get(mock_addent_got, 13);
|
ent = smartlist_get(mock_addent_got, 13);
|
||||||
tt_mem_op(ent->rsa_id, ==, "No dragon can resist", 20);
|
tt_mem_op(ent->rsa_id, OP_EQ, "No dragon can resist", 20);
|
||||||
tt_mem_op(ent->ed25519_key, ==, " the fascination of riddling tal", 32);
|
tt_mem_op(ent->ed25519_key, OP_EQ, " the fascination of riddling tal", 32);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
keypin_clear();
|
keypin_clear();
|
||||||
@ -141,32 +141,32 @@ test_keypin_add_entry(void *arg)
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
keypin_clear();
|
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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"cloak-and-dagger what's-his-face"));
|
||||||
|
|
||||||
tt_int_op(KEYPIN_NOT_FOUND, ==, LONE_RSA("Llanfairpwllgwyngyll"));
|
tt_int_op(KEYPIN_NOT_FOUND, OP_EQ, LONE_RSA("Llanfairpwllgwyngyll"));
|
||||||
tt_int_op(KEYPIN_MISMATCH, ==, LONE_RSA("Johnnies-come-lately"));
|
tt_int_op(KEYPIN_MISMATCH, OP_EQ, LONE_RSA("Johnnies-come-lately"));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
keypin_clear();
|
keypin_clear();
|
||||||
@ -179,51 +179,51 @@ test_keypin_journal(void *arg)
|
|||||||
char *contents = NULL;
|
char *contents = NULL;
|
||||||
const char *fname = get_fname("keypin-journal");
|
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);
|
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"));
|
"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"));
|
"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"));
|
"salt-and-pepper high-muck-a-muck"));
|
||||||
keypin_close_journal();
|
keypin_close_journal();
|
||||||
keypin_clear();
|
keypin_clear();
|
||||||
|
|
||||||
tt_int_op(0, ==, keypin_load_journal(fname));
|
tt_int_op(0, OP_EQ, keypin_load_journal(fname));
|
||||||
update_approx_time(1231041600);
|
update_approx_time(1231041600);
|
||||||
tt_int_op(0, ==, keypin_open_journal(fname));
|
tt_int_op(0, OP_EQ, keypin_open_journal(fname));
|
||||||
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"));
|
"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"));
|
"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"));
|
"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"));
|
"salt-and-pepper high-muck-a-muck"));
|
||||||
keypin_close_journal();
|
keypin_close_journal();
|
||||||
keypin_clear();
|
keypin_clear();
|
||||||
|
|
||||||
tt_int_op(0, ==, keypin_load_journal(fname));
|
tt_int_op(0, OP_EQ, keypin_load_journal(fname));
|
||||||
update_approx_time(1412278354);
|
update_approx_time(1412278354);
|
||||||
tt_int_op(0, ==, keypin_open_journal(fname));
|
tt_int_op(0, OP_EQ, keypin_open_journal(fname));
|
||||||
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"));
|
"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"));
|
"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"));
|
"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"));
|
"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"));
|
"floccinaucinihilipilificationism"));
|
||||||
keypin_close_journal();
|
keypin_close_journal();
|
||||||
|
|
||||||
contents = read_file_to_str(fname, RFTS_BIN, NULL);
|
contents = read_file_to_str(fname, RFTS_BIN, NULL);
|
||||||
tt_assert(contents);
|
tt_assert(contents);
|
||||||
tt_str_op(contents,==,
|
tt_str_op(contents,OP_EQ,
|
||||||
"\n"
|
"\n"
|
||||||
"@opened-at 2008-08-02 20:30:00\n"
|
"@opened-at 2008-08-02 20:30:00\n"
|
||||||
"a2luZy1vZi10aGUtaGVycmluZ3M Z29vZC1mb3Itbm90aGluZyBhdHRvcm5leS1hdC1sYXc\n"
|
"a2luZy1vZi10aGUtaGVycmluZ3M Z29vZC1mb3Itbm90aGluZyBhdHRvcm5leS1hdC1sYXc\n"
|
||||||
|
@ -136,7 +136,7 @@ test_link_handshake_certs_ok(void *arg)
|
|||||||
* actually generate a CERTS cell.
|
* actually generate a CERTS cell.
|
||||||
*/
|
*/
|
||||||
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
|
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 (with_ed) {
|
||||||
/* If we're making a CERTS cell for an ed handshake, let's make sure we
|
/* 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->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
c1->link_proto = 3;
|
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 has started_here == 0 */
|
||||||
c2->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
c2->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
c2->link_proto = 3;
|
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);
|
tt_assert(mock_got_var_cell);
|
||||||
cell1 = 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);
|
tt_assert(mock_got_var_cell);
|
||||||
cell2 = mock_got_var_cell;
|
cell2 = mock_got_var_cell;
|
||||||
|
|
||||||
tt_int_op(cell1->command, ==, CELL_CERTS);
|
tt_int_op(cell1->command, OP_EQ, CELL_CERTS);
|
||||||
tt_int_op(cell1->payload_len, >, 1);
|
tt_int_op(cell1->payload_len, OP_GT, 1);
|
||||||
|
|
||||||
tt_int_op(cell2->command, ==, CELL_CERTS);
|
tt_int_op(cell2->command, OP_EQ, CELL_CERTS);
|
||||||
tt_int_op(cell2->payload_len, >, 1);
|
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));
|
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));
|
certs_cell_parse(&cc2, cell2->payload, cell2->payload_len));
|
||||||
|
|
||||||
if (with_ed) {
|
if (with_ed) {
|
||||||
tt_int_op(5, ==, cc1->n_certs);
|
tt_int_op(5, OP_EQ, cc1->n_certs);
|
||||||
tt_int_op(5, ==, cc2->n_certs);
|
tt_int_op(5, OP_EQ, cc2->n_certs);
|
||||||
} else {
|
} else {
|
||||||
tt_int_op(2, ==, cc1->n_certs);
|
tt_int_op(2, OP_EQ, cc1->n_certs);
|
||||||
tt_int_op(2, ==, cc2->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);
|
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);
|
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);
|
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);
|
CERTTYPE_RSA1024_ID_ID);
|
||||||
|
|
||||||
if (with_ed) {
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
CERTTYPE_RSA1024_ID_EDID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,14 +376,14 @@ recv_certs_setup(const struct testcase_t *test)
|
|||||||
tor_addr_from_ipv4h(&d->c->base_.addr, 0x801f0127);
|
tor_addr_from_ipv4h(&d->c->base_.addr, 0x801f0127);
|
||||||
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
d->chan->conn = d->c;
|
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->link_proto = 4;
|
||||||
|
|
||||||
d->key1 = pk_generate(2);
|
d->key1 = pk_generate(2);
|
||||||
d->key2 = pk_generate(3);
|
d->key2 = pk_generate(3);
|
||||||
|
|
||||||
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
|
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) {
|
if (is_ed) {
|
||||||
init_mock_ed_keys(d->key2);
|
init_mock_ed_keys(d->key2);
|
||||||
} else {
|
} else {
|
||||||
@ -452,7 +452,7 @@ recv_certs_setup(const struct testcase_t *test)
|
|||||||
d->cell->command = CELL_CERTS;
|
d->cell->command = CELL_CERTS;
|
||||||
|
|
||||||
n = certs_cell_encode(d->cell->payload, 4096, d->ccell);
|
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;
|
d->cell->payload_len = n;
|
||||||
|
|
||||||
MOCK(tor_tls_cert_matches_key, mock_tls_cert_matches_key);
|
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);
|
mock_peer_cert = tor_x509_cert_dup(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
tt_int_op(0, ==, d->c->handshake_state->received_certs_cell);
|
tt_int_op(0, OP_EQ, d->c->handshake_state->received_certs_cell);
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called);
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(0, ==, mock_send_netinfo_called);
|
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
done:
|
done:
|
||||||
@ -485,10 +485,10 @@ test_link_handshake_recv_certs_ok(void *arg)
|
|||||||
{
|
{
|
||||||
certs_data_t *d = arg;
|
certs_data_t *d = arg;
|
||||||
channel_tls_process_certs_cell(d->cell, d->chan);
|
channel_tls_process_certs_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(d->c->handshake_state->authenticated, ==, 1);
|
tt_int_op(d->c->handshake_state->authenticated, OP_EQ, 1);
|
||||||
tt_int_op(d->c->handshake_state->authenticated_rsa, ==, 1);
|
tt_int_op(d->c->handshake_state->authenticated_rsa, OP_EQ, 1);
|
||||||
tt_int_op(d->c->handshake_state->received_certs_cell, ==, 1);
|
tt_int_op(d->c->handshake_state->received_certs_cell, OP_EQ, 1);
|
||||||
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
|
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
|
||||||
tt_assert(d->c->handshake_state->certs->auth_cert == NULL);
|
tt_assert(d->c->handshake_state->certs->auth_cert == NULL);
|
||||||
|
|
||||||
@ -497,13 +497,13 @@ test_link_handshake_recv_certs_ok(void *arg)
|
|||||||
tt_assert(d->c->handshake_state->certs->ed_sign_link != 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_sign_auth == NULL);
|
||||||
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert != NULL);
|
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert != NULL);
|
||||||
tt_int_op(d->c->handshake_state->authenticated_ed25519, ==, 1);
|
tt_int_op(d->c->handshake_state->authenticated_ed25519, OP_EQ, 1);
|
||||||
} else {
|
} else {
|
||||||
tt_assert(d->c->handshake_state->certs->ed_id_sign == NULL);
|
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_link == NULL);
|
||||||
tt_assert(d->c->handshake_state->certs->ed_sign_auth == NULL);
|
tt_assert(d->c->handshake_state->certs->ed_sign_auth == NULL);
|
||||||
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert == NULL);
|
tt_assert(d->c->handshake_state->certs->ed_rsa_crosscert == NULL);
|
||||||
tt_int_op(d->c->handshake_state->authenticated_ed25519, ==, 0);
|
tt_int_op(d->c->handshake_state->authenticated_ed25519, OP_EQ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -517,9 +517,9 @@ test_link_handshake_recv_certs_ok_server(void *arg)
|
|||||||
d->c->handshake_state->started_here = 0;
|
d->c->handshake_state->started_here = 0;
|
||||||
d->c->handshake_state->certs->started_here = 0;
|
d->c->handshake_state->certs->started_here = 0;
|
||||||
channel_tls_process_certs_cell(d->cell, d->chan);
|
channel_tls_process_certs_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(d->c->handshake_state->authenticated, ==, 0);
|
tt_int_op(d->c->handshake_state->authenticated, OP_EQ, 0);
|
||||||
tt_int_op(d->c->handshake_state->received_certs_cell, ==, 1);
|
tt_int_op(d->c->handshake_state->received_certs_cell, OP_EQ, 1);
|
||||||
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
|
tt_assert(d->c->handshake_state->certs->id_cert != NULL);
|
||||||
tt_assert(d->c->handshake_state->certs->link_cert == NULL);
|
tt_assert(d->c->handshake_state->certs->link_cert == NULL);
|
||||||
if (d->is_ed) {
|
if (d->is_ed) {
|
||||||
@ -543,11 +543,11 @@ test_link_handshake_recv_certs_ok_server(void *arg)
|
|||||||
setup_capture_of_logs(LOG_INFO); \
|
setup_capture_of_logs(LOG_INFO); \
|
||||||
{ code ; } \
|
{ code ; } \
|
||||||
channel_tls_process_certs_cell(d->cell, d->chan); \
|
channel_tls_process_certs_cell(d->cell, d->chan); \
|
||||||
tt_int_op(1, ==, mock_close_called); \
|
tt_int_op(1, OP_EQ, mock_close_called); \
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called); \
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called); \
|
||||||
tt_int_op(0, ==, mock_send_netinfo_called); \
|
tt_int_op(0, OP_EQ, mock_send_netinfo_called); \
|
||||||
tt_int_op(0, ==, d->c->handshake_state->authenticated_rsa); \
|
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_rsa); \
|
||||||
tt_int_op(0, ==, d->c->handshake_state->authenticated_ed25519); \
|
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_ed25519); \
|
||||||
if (require_failure_message) { \
|
if (require_failure_message) { \
|
||||||
expect_log_msg_containing(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); \
|
const char *msg = certs_cell_check(d->ccell); \
|
||||||
if (msg) puts(msg); \
|
if (msg) puts(msg); \
|
||||||
ssize_t n = certs_cell_encode(d->cell->payload, 4096, d->ccell); \
|
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; \
|
d->cell->payload_len = n; \
|
||||||
} while (0)
|
} 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
|
/* This handshake succeeds, but since we have no ID cert, we will
|
||||||
* just do the RSA handshake. */
|
* just do the RSA handshake. */
|
||||||
channel_tls_process_certs_cell(d->cell, d->chan);
|
channel_tls_process_certs_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(0, ==, d->c->handshake_state->authenticated_ed25519);
|
tt_int_op(0, OP_EQ, d->c->handshake_state->authenticated_ed25519);
|
||||||
tt_int_op(1, ==, d->c->handshake_state->authenticated_rsa);
|
tt_int_op(1, OP_EQ, d->c->handshake_state->authenticated_rsa);
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -697,7 +697,7 @@ CERTS_FAIL(missing_signing_key, /* ed25519 */
|
|||||||
require_failure_message = "No Ed25519 signing key";
|
require_failure_message = "No Ed25519 signing key";
|
||||||
tt_int_op(certs_cell_getlen_certs(d->ccell), OP_EQ, 5);
|
tt_int_op(certs_cell_getlen_certs(d->ccell), OP_EQ, 5);
|
||||||
certs_cell_cert_t *cert = certs_cell_get_certs(d->ccell, 2);
|
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
|
/* replace this with a valid master->signing cert, but with no
|
||||||
* signing key. */
|
* signing key. */
|
||||||
const ed25519_keypair_t *mk = get_master_identity_keypair();
|
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);
|
crypto_pk_t *rsa0 = pk_generate(0), *rsa1 = pk_generate(1);
|
||||||
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
|
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);
|
init_mock_ed_keys(rsa0);
|
||||||
|
|
||||||
MOCK(connection_or_write_var_cell_to_buf, mock_write_var_cell);
|
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;
|
c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
tt_assert(! mock_got_var_cell);
|
tt_assert(! 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));
|
||||||
cell1 = mock_got_var_cell;
|
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;
|
cell2 = mock_got_var_cell;
|
||||||
tt_int_op(38, ==, cell1->payload_len);
|
tt_int_op(38, OP_EQ, cell1->payload_len);
|
||||||
tt_int_op(38, ==, cell2->payload_len);
|
tt_int_op(38, OP_EQ, cell2->payload_len);
|
||||||
tt_int_op(0, ==, cell1->circ_id);
|
tt_int_op(0, OP_EQ, cell1->circ_id);
|
||||||
tt_int_op(0, ==, cell2->circ_id);
|
tt_int_op(0, OP_EQ, cell2->circ_id);
|
||||||
tt_int_op(CELL_AUTH_CHALLENGE, ==, cell1->command);
|
tt_int_op(CELL_AUTH_CHALLENGE, OP_EQ, cell1->command);
|
||||||
tt_int_op(CELL_AUTH_CHALLENGE, ==, cell2->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", OP_EQ, cell1->payload + 32, 6);
|
||||||
tt_mem_op("\x00\x02\x00\x01\x00\x03", ==, cell2->payload + 32, 6);
|
tt_mem_op("\x00\x02\x00\x01\x00\x03", OP_EQ, cell2->payload + 32, 6);
|
||||||
tt_mem_op(cell1->payload, !=, cell2->payload, 32);
|
tt_mem_op(cell1->payload, OP_NE, cell2->payload, 32);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
UNMOCK(connection_or_write_var_cell_to_buf);
|
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_.address = tor_strdup("HaveAnAddress");
|
||||||
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
d->c->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
d->chan->conn = d->c;
|
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->link_proto = 4;
|
||||||
d->c->handshake_state->received_certs_cell = 1;
|
d->c->handshake_state->received_certs_cell = 1;
|
||||||
d->cell = var_cell_new(128);
|
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_close_for_error, mock_close_for_err);
|
||||||
MOCK(connection_or_send_netinfo, mock_send_netinfo);
|
MOCK(connection_or_send_netinfo, mock_send_netinfo);
|
||||||
MOCK(connection_or_send_authenticate_cell, mock_send_authenticate);
|
MOCK(connection_or_send_authenticate_cell, mock_send_authenticate);
|
||||||
tt_int_op(0, ==, d->c->handshake_state->received_auth_challenge);
|
tt_int_op(0, OP_EQ, d->c->handshake_state->received_auth_challenge);
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called);
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(0, ==, mock_send_netinfo_called);
|
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
done:
|
done:
|
||||||
@ -1010,11 +1010,11 @@ test_link_handshake_recv_authchallenge_ok(void *arg)
|
|||||||
authchallenge_data_t *d = arg;
|
authchallenge_data_t *d = arg;
|
||||||
|
|
||||||
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
|
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
|
||||||
tt_int_op(1, ==, mock_send_authenticate_called);
|
tt_int_op(1, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(1, ==, mock_send_netinfo_called);
|
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
|
||||||
tt_int_op(1, ==, mock_send_authenticate_called_with_type); /* RSA */
|
tt_int_op(1, OP_EQ, mock_send_authenticate_called_with_type); /* RSA */
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -1029,11 +1029,11 @@ test_link_handshake_recv_authchallenge_ok_ed25519(void *arg)
|
|||||||
d->cell->payload[39] = 3;
|
d->cell->payload[39] = 3;
|
||||||
d->cell->payload_len += 2;
|
d->cell->payload_len += 2;
|
||||||
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
|
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
|
||||||
tt_int_op(1, ==, mock_send_authenticate_called);
|
tt_int_op(1, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(1, ==, mock_send_netinfo_called);
|
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
|
||||||
tt_int_op(3, ==, mock_send_authenticate_called_with_type); /* Ed25519 */
|
tt_int_op(3, OP_EQ, mock_send_authenticate_called_with_type); /* Ed25519 */
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -1045,10 +1045,10 @@ test_link_handshake_recv_authchallenge_ok_noserver(void *arg)
|
|||||||
get_options_mutable()->ORPort_set = 0;
|
get_options_mutable()->ORPort_set = 0;
|
||||||
|
|
||||||
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
|
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called);
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(0, ==, mock_send_netinfo_called);
|
tt_int_op(0, OP_EQ, mock_send_netinfo_called);
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -1060,10 +1060,10 @@ test_link_handshake_recv_authchallenge_ok_unrecognized(void *arg)
|
|||||||
d->cell->payload[37] = 99;
|
d->cell->payload[37] = 99;
|
||||||
|
|
||||||
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
channel_tls_process_auth_challenge_cell(d->cell, d->chan);
|
||||||
tt_int_op(0, ==, mock_close_called);
|
tt_int_op(0, OP_EQ, mock_close_called);
|
||||||
tt_int_op(1, ==, d->c->handshake_state->received_auth_challenge);
|
tt_int_op(1, OP_EQ, d->c->handshake_state->received_auth_challenge);
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called);
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called);
|
||||||
tt_int_op(1, ==, mock_send_netinfo_called);
|
tt_int_op(1, OP_EQ, mock_send_netinfo_called);
|
||||||
done:
|
done:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -1077,9 +1077,9 @@ test_link_handshake_recv_authchallenge_ok_unrecognized(void *arg)
|
|||||||
setup_capture_of_logs(LOG_INFO); \
|
setup_capture_of_logs(LOG_INFO); \
|
||||||
{ code ; } \
|
{ code ; } \
|
||||||
channel_tls_process_auth_challenge_cell(d->cell, d->chan); \
|
channel_tls_process_auth_challenge_cell(d->cell, d->chan); \
|
||||||
tt_int_op(1, ==, mock_close_called); \
|
tt_int_op(1, OP_EQ, mock_close_called); \
|
||||||
tt_int_op(0, ==, mock_send_authenticate_called); \
|
tt_int_op(0, OP_EQ, mock_send_authenticate_called); \
|
||||||
tt_int_op(0, ==, mock_send_netinfo_called); \
|
tt_int_op(0, OP_EQ, mock_send_netinfo_called); \
|
||||||
if (require_failure_message) { \
|
if (require_failure_message) { \
|
||||||
expect_log_msg_containing(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->key1 = pk_generate(2);
|
||||||
d->key2 = pk_generate(3);
|
d->key2 = pk_generate(3);
|
||||||
tt_int_op(tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
|
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);
|
init_mock_ed_keys(d->key2);
|
||||||
|
|
||||||
d->c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
d->c1->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
d->c1->link_proto = 3;
|
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->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
|
||||||
d->c2->link_proto = 3;
|
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);
|
var_cell_t *cell = var_cell_new(16);
|
||||||
cell->command = CELL_CERTS;
|
cell->command = CELL_CERTS;
|
||||||
or_handshake_state_record_var_cell(d->c1, d->c1->handshake_state, cell, 1);
|
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;
|
authtype = AUTHTYPE_ED25519_SHA256_RFC5705;
|
||||||
else
|
else
|
||||||
authtype = AUTHTYPE_RSA_SHA256_TLSSECRET;
|
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);
|
tt_assert(mock_got_var_cell);
|
||||||
d->cell = 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;
|
crypto_pk_t *auth_pubkey = NULL;
|
||||||
|
|
||||||
/* Is the cell well-formed on the outer layer? */
|
/* Is the cell well-formed on the outer layer? */
|
||||||
tt_int_op(d->cell->command, ==, CELL_AUTHENTICATE);
|
tt_int_op(d->cell->command, OP_EQ, CELL_AUTHENTICATE);
|
||||||
tt_int_op(d->cell->payload[0], ==, 0);
|
tt_int_op(d->cell->payload[0], OP_EQ, 0);
|
||||||
if (d->is_ed)
|
if (d->is_ed)
|
||||||
tt_int_op(d->cell->payload[1], ==, 3);
|
tt_int_op(d->cell->payload[1], OP_EQ, 3);
|
||||||
else
|
else
|
||||||
tt_int_op(d->cell->payload[1], ==, 1);
|
tt_int_op(d->cell->payload[1], OP_EQ, 1);
|
||||||
tt_int_op(ntohs(get_uint16(d->cell->payload + 2)), ==,
|
tt_int_op(ntohs(get_uint16(d->cell->payload + 2)), OP_EQ,
|
||||||
d->cell->payload_len - 4);
|
d->cell->payload_len - 4);
|
||||||
|
|
||||||
/* Check it out for plausibility... */
|
/* Check it out for plausibility... */
|
||||||
auth_ctx_t ctx;
|
auth_ctx_t ctx;
|
||||||
ctx.is_ed = d->is_ed;
|
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+4,
|
||||||
d->cell->payload_len - 4, &ctx));
|
d->cell->payload_len - 4, &ctx));
|
||||||
tt_assert(auth1);
|
tt_assert(auth1);
|
||||||
|
|
||||||
if (d->is_ed) {
|
if (d->is_ed) {
|
||||||
tt_mem_op(auth1->type, ==, "AUTH0003", 8);
|
tt_mem_op(auth1->type, OP_EQ, "AUTH0003", 8);
|
||||||
} else {
|
} 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? */
|
/* Is the signature okay? */
|
||||||
const uint8_t *start = d->cell->payload+4, *end = auth1->end_of_signed;
|
const uint8_t *start = d->cell->payload+4, *end = auth1->end_of_signed;
|
||||||
if (d->is_ed) {
|
if (d->is_ed) {
|
||||||
ed25519_signature_t sig;
|
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);
|
memcpy(&sig.sig, auth1_getarray_sig(auth1), ED25519_SIG_LEN);
|
||||||
tt_assert(!ed25519_checksig(&sig, start, end-start,
|
tt_assert(!ed25519_checksig(&sig, start, end-start,
|
||||||
&get_current_auth_keypair()->pubkey));
|
&get_current_auth_keypair()->pubkey));
|
||||||
} else {
|
} else {
|
||||||
uint8_t sig[128];
|
uint8_t sig[128];
|
||||||
uint8_t digest[32];
|
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(
|
auth_pubkey = tor_tls_cert_get_key(
|
||||||
d->c2->handshake_state->certs->auth_cert);
|
d->c2->handshake_state->certs->auth_cert);
|
||||||
int n = crypto_pk_public_checksig(
|
int n = crypto_pk_public_checksig(
|
||||||
auth_pubkey,
|
auth_pubkey,
|
||||||
(char*)sig, sizeof(sig), (char*)auth1_getarray_sig(auth1),
|
(char*)sig, sizeof(sig), (char*)auth1_getarray_sig(auth1),
|
||||||
auth1_getlen_sig(auth1));
|
auth1_getlen_sig(auth1));
|
||||||
tt_int_op(n, ==, 32);
|
tt_int_op(n, OP_EQ, 32);
|
||||||
crypto_digest256((char*)digest,
|
crypto_digest256((char*)digest,
|
||||||
(const char*)start, end-start, DIGEST_SHA256);
|
(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. */
|
/* 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);
|
channel_tls_process_authenticate_cell(d->cell, d->chan2);
|
||||||
tt_int_op(mock_close_called, ==, 0);
|
tt_int_op(mock_close_called, OP_EQ, 0);
|
||||||
tt_int_op(d->c2->handshake_state->authenticated, ==, 1);
|
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 1);
|
||||||
if (d->is_ed) {
|
if (d->is_ed) {
|
||||||
tt_int_op(d->c2->handshake_state->authenticated_ed25519, ==, 1);
|
tt_int_op(d->c2->handshake_state->authenticated_ed25519, OP_EQ, 1);
|
||||||
tt_int_op(d->c2->handshake_state->authenticated_rsa, ==, 1);
|
tt_int_op(d->c2->handshake_state->authenticated_rsa, OP_EQ, 1);
|
||||||
} else {
|
} else {
|
||||||
tt_int_op(d->c2->handshake_state->authenticated_ed25519, ==, 0);
|
tt_int_op(d->c2->handshake_state->authenticated_ed25519, OP_EQ, 0);
|
||||||
tt_int_op(d->c2->handshake_state->authenticated_rsa, ==, 1);
|
tt_int_op(d->c2->handshake_state->authenticated_rsa, OP_EQ, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1359,10 +1359,10 @@ test_link_handshake_auth_cell(void *arg)
|
|||||||
const char *require_failure_message = NULL; \
|
const char *require_failure_message = NULL; \
|
||||||
setup_capture_of_logs(LOG_INFO); \
|
setup_capture_of_logs(LOG_INFO); \
|
||||||
{ code ; } \
|
{ 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); \
|
channel_tls_process_authenticate_cell(d->cell, d->chan2); \
|
||||||
tt_int_op(mock_close_called, ==, 1); \
|
tt_int_op(mock_close_called, OP_EQ, 1); \
|
||||||
tt_int_op(d->c2->handshake_state->authenticated, ==, 0); \
|
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 0); \
|
||||||
if (require_failure_message) { \
|
if (require_failure_message) { \
|
||||||
expect_log_msg_containing(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);
|
setup_capture_of_logs(LOG_INFO);
|
||||||
d->c2->handshake_state->authenticated = 1;
|
d->c2->handshake_state->authenticated = 1;
|
||||||
channel_tls_process_authenticate_cell(d->cell, d->chan2);
|
channel_tls_process_authenticate_cell(d->cell, d->chan2);
|
||||||
tt_int_op(mock_close_called, ==, 1);
|
tt_int_op(mock_close_called, OP_EQ, 1);
|
||||||
tt_int_op(d->c2->handshake_state->authenticated, ==, 1);
|
tt_int_op(d->c2->handshake_state->authenticated, OP_EQ, 1);
|
||||||
expect_log_msg_containing("The peer is already authenticated");
|
expect_log_msg_containing("The peer is already authenticated");
|
||||||
done:
|
done:
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
@ -1425,7 +1425,7 @@ AUTHENTICATE_FAIL(truncated_2,
|
|||||||
d->cell->payload[3]++)
|
d->cell->payload[3]++)
|
||||||
AUTHENTICATE_FAIL(tooshort_1,
|
AUTHENTICATE_FAIL(tooshort_1,
|
||||||
require_failure_message = "Authenticator was too short";
|
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[2] -= 1;
|
||||||
d->cell->payload_len -= 256;)
|
d->cell->payload_len -= 256;)
|
||||||
AUTHENTICATE_FAIL(badcontent,
|
AUTHENTICATE_FAIL(badcontent,
|
||||||
|
@ -464,7 +464,7 @@ test_md_generate(void *arg)
|
|||||||
microdesc_free(md);
|
microdesc_free(md);
|
||||||
md = NULL;
|
md = NULL;
|
||||||
md = dirvote_create_microdescriptor(ri, 21);
|
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);
|
routerinfo_free(ri);
|
||||||
ri = router_parse_entry_from_string(test_ri2, NULL, 0, 0, NULL, NULL);
|
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);
|
microdesc_free(md);
|
||||||
md = NULL;
|
md = NULL;
|
||||||
md = dirvote_create_microdescriptor(ri, 18);
|
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);
|
microdesc_free(md);
|
||||||
md = NULL;
|
md = NULL;
|
||||||
md = dirvote_create_microdescriptor(ri, 21);
|
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,
|
tt_assert(ed25519_pubkey_eq(md->ed25519_identity_pkey,
|
||||||
&ri->cache_info.signing_key_cert->signing_key));
|
&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"
|
"@last-listed 2015-06-22 10:00:00\n"
|
||||||
"onion-k\n",
|
"onion-k\n",
|
||||||
NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
|
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);
|
smartlist_free(sl);
|
||||||
|
|
||||||
sl = microdescs_add_to_cache(get_microdesc_cache(),
|
sl = microdescs_add_to_cache(get_microdesc_cache(),
|
||||||
"@last-listed 2015-06-22 10:00:00\n"
|
"@last-listed 2015-06-22 10:00:00\n"
|
||||||
"wiggly\n",
|
"wiggly\n",
|
||||||
NULL, SAVED_IN_JOURNAL, 0, time(NULL), NULL);
|
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);
|
smartlist_free(sl);
|
||||||
|
|
||||||
tor_asprintf(&cp, "%s\n%s", test_md1, "@foobar\nonion-wobble\n");
|
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(),
|
sl = microdescs_add_to_cache(get_microdesc_cache(),
|
||||||
cp, cp+strlen(cp),
|
cp, cp+strlen(cp),
|
||||||
SAVED_IN_JOURNAL, 0, time(NULL), NULL);
|
SAVED_IN_JOURNAL, 0, time(NULL), NULL);
|
||||||
tt_int_op(smartlist_len(sl), ==, 0);
|
tt_int_op(smartlist_len(sl), OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(cp);
|
tor_free(cp);
|
||||||
|
@ -91,14 +91,14 @@ test_relay_append_cell_to_circuit_queue(void *arg)
|
|||||||
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), nchan, cell,
|
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), nchan, cell,
|
||||||
CELL_DIRECTION_OUT, 0);
|
CELL_DIRECTION_OUT, 0);
|
||||||
new_count = get_mock_scheduler_has_waiting_cells_count();
|
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 */
|
/* Now try the reverse direction */
|
||||||
old_count = get_mock_scheduler_has_waiting_cells_count();
|
old_count = get_mock_scheduler_has_waiting_cells_count();
|
||||||
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), pchan, cell,
|
append_cell_to_circuit_queue(TO_CIRCUIT(orcirc), pchan, cell,
|
||||||
CELL_DIRECTION_IN, 0);
|
CELL_DIRECTION_IN, 0);
|
||||||
new_count = get_mock_scheduler_has_waiting_cells_count();
|
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);
|
UNMOCK(scheduler_channel_has_waiting_cells);
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
uint8_t *junk = NULL;
|
uint8_t *junk = NULL;
|
||||||
char *base64 = NULL;
|
char *base64 = NULL;
|
||||||
|
|
||||||
tt_int_op(0,==,ed25519_keypair_generate(&kp1, 0));
|
tt_int_op(0,OP_EQ,ed25519_keypair_generate(&kp1, 0));
|
||||||
tt_int_op(0,==,ed25519_keypair_generate(&kp2, 0));
|
tt_int_op(0,OP_EQ,ed25519_keypair_generate(&kp2, 0));
|
||||||
|
|
||||||
for (int i = 0; i <= 1; ++i) {
|
for (int i = 0; i <= 1; ++i) {
|
||||||
uint32_t flags = i ? CERT_FLAG_INCLUDE_SIGNING_KEY : 0;
|
uint32_t flags = i ? CERT_FLAG_INCLUDE_SIGNING_KEY : 0;
|
||||||
@ -105,20 +105,20 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
tt_assert(cert[i]->sig_ok == 1);
|
tt_assert(cert[i]->sig_ok == 1);
|
||||||
tt_assert(cert[i]->cert_expired == 0);
|
tt_assert(cert[i]->cert_expired == 0);
|
||||||
tt_assert(cert[i]->cert_valid == 1);
|
tt_assert(cert[i]->cert_valid == 1);
|
||||||
tt_int_op(cert[i]->cert_type, ==, 5);
|
tt_int_op(cert[i]->cert_type, OP_EQ, 5);
|
||||||
tt_mem_op(cert[i]->signed_key.pubkey, ==, &kp2.pubkey.pubkey, 32);
|
tt_mem_op(cert[i]->signed_key.pubkey, OP_EQ, &kp2.pubkey.pubkey, 32);
|
||||||
tt_mem_op(cert[i]->signing_key.pubkey, ==, &kp1.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, ==, i);
|
tt_int_op(cert[i]->signing_key_included, OP_EQ, i);
|
||||||
|
|
||||||
tt_assert(cert[i]->encoded);
|
tt_assert(cert[i]->encoded);
|
||||||
tt_int_op(cert[i]->encoded_len, ==, 104 + 36 * i);
|
tt_int_op(cert[i]->encoded_len, OP_EQ, 104 + 36 * i);
|
||||||
tt_int_op(cert[i]->encoded[0], ==, 1);
|
tt_int_op(cert[i]->encoded[0], OP_EQ, 1);
|
||||||
tt_int_op(cert[i]->encoded[1], ==, 5);
|
tt_int_op(cert[i]->encoded[1], OP_EQ, 5);
|
||||||
|
|
||||||
parsed_cert[i] = tor_cert_parse(cert[i]->encoded, cert[i]->encoded_len);
|
parsed_cert[i] = tor_cert_parse(cert[i]->encoded, cert[i]->encoded_len);
|
||||||
tt_assert(parsed_cert[i]);
|
tt_assert(parsed_cert[i]);
|
||||||
tt_int_op(cert[i]->encoded_len, ==, parsed_cert[i]->encoded_len);
|
tt_int_op(cert[i]->encoded_len, OP_EQ, parsed_cert[i]->encoded_len);
|
||||||
tt_mem_op(cert[i]->encoded, ==, parsed_cert[i]->encoded,
|
tt_mem_op(cert[i]->encoded, OP_EQ, parsed_cert[i]->encoded,
|
||||||
cert[i]->encoded_len);
|
cert[i]->encoded_len);
|
||||||
tt_assert(parsed_cert[i]->sig_bad == 0);
|
tt_assert(parsed_cert[i]->sig_bad == 0);
|
||||||
tt_assert(parsed_cert[i]->sig_ok == 0);
|
tt_assert(parsed_cert[i]->sig_ok == 0);
|
||||||
@ -127,18 +127,18 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
|
|
||||||
/* Expired */
|
/* Expired */
|
||||||
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now + 30000),
|
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now + 30000),
|
||||||
<, 0);
|
OP_LT, 0);
|
||||||
tt_assert(parsed_cert[i]->cert_expired == 1);
|
tt_assert(parsed_cert[i]->cert_expired == 1);
|
||||||
parsed_cert[i]->cert_expired = 0;
|
parsed_cert[i]->cert_expired = 0;
|
||||||
|
|
||||||
/* Wrong key */
|
/* Wrong key */
|
||||||
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp2.pubkey, now), <, 0);
|
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp2.pubkey, now), OP_LT, 0);
|
||||||
tt_assert(parsed_cert[i]->sig_bad== 1);
|
tt_assert(parsed_cert[i]->sig_bad== 1);
|
||||||
parsed_cert[i]->sig_bad = 0;
|
parsed_cert[i]->sig_bad = 0;
|
||||||
|
|
||||||
/* Missing key */
|
/* Missing key */
|
||||||
int ok = tor_cert_checksig(parsed_cert[i], NULL, now);
|
int ok = tor_cert_checksig(parsed_cert[i], NULL, now);
|
||||||
tt_int_op(ok < 0, ==, i == 0);
|
tt_int_op(ok < 0, OP_EQ, i == 0);
|
||||||
tt_assert(parsed_cert[i]->sig_bad == 0);
|
tt_assert(parsed_cert[i]->sig_bad == 0);
|
||||||
tt_assert(parsed_cert[i]->sig_ok == (i != 0));
|
tt_assert(parsed_cert[i]->sig_ok == (i != 0));
|
||||||
tt_assert(parsed_cert[i]->cert_valid == (i != 0));
|
tt_assert(parsed_cert[i]->cert_valid == (i != 0));
|
||||||
@ -147,7 +147,7 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
parsed_cert[i]->cert_valid = 0;
|
parsed_cert[i]->cert_valid = 0;
|
||||||
|
|
||||||
/* Right key */
|
/* Right key */
|
||||||
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now), ==, 0);
|
tt_int_op(tor_cert_checksig(parsed_cert[i], &kp1.pubkey, now), OP_EQ, 0);
|
||||||
tt_assert(parsed_cert[i]->sig_bad == 0);
|
tt_assert(parsed_cert[i]->sig_bad == 0);
|
||||||
tt_assert(parsed_cert[i]->sig_ok == 1);
|
tt_assert(parsed_cert[i]->sig_ok == 1);
|
||||||
tt_assert(parsed_cert[i]->cert_expired == 0);
|
tt_assert(parsed_cert[i]->cert_expired == 0);
|
||||||
@ -157,19 +157,19 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
/* Now try some junky certs. */
|
/* Now try some junky certs. */
|
||||||
/* - Truncated */
|
/* - Truncated */
|
||||||
nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len-1);
|
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 */
|
/* - First byte modified */
|
||||||
cert[0]->encoded[0] = 99;
|
cert[0]->encoded[0] = 99;
|
||||||
nocert = tor_cert_parse(cert[0]->encoded, cert[0]->encoded_len);
|
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;
|
cert[0]->encoded[0] = 1;
|
||||||
|
|
||||||
/* - Extra byte at the end*/
|
/* - Extra byte at the end*/
|
||||||
junk = tor_malloc_zero(cert[0]->encoded_len + 1);
|
junk = tor_malloc_zero(cert[0]->encoded_len + 1);
|
||||||
memcpy(junk, cert[0]->encoded, cert[0]->encoded_len);
|
memcpy(junk, cert[0]->encoded, cert[0]->encoded_len);
|
||||||
nocert = tor_cert_parse(junk, cert[0]->encoded_len+1);
|
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 */
|
/* - Multiple signing key instances */
|
||||||
tor_free(junk);
|
tor_free(junk);
|
||||||
@ -183,7 +183,7 @@ test_routerkeys_ed_certs(void *args)
|
|||||||
junk[77] = 32; /* extlen */
|
junk[77] = 32; /* extlen */
|
||||||
junk[78] = 4; /* exttype */
|
junk[78] = 4; /* exttype */
|
||||||
nocert = tor_cert_parse(junk, 104 + 36 * 2);
|
nocert = tor_cert_parse(junk, 104 + 36 * 2);
|
||||||
tt_ptr_op(NULL, ==, nocert);
|
tt_ptr_op(NULL, OP_EQ, nocert);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_cert_free(cert[0]);
|
tor_cert_free(cert[0]);
|
||||||
@ -211,11 +211,11 @@ test_routerkeys_ed_key_create(void *arg)
|
|||||||
kp2 = ed_key_new(kp1, INIT_ED_KEY_NEEDCERT, now, 3600, 4, &cert);
|
kp2 = ed_key_new(kp1, INIT_ED_KEY_NEEDCERT, now, 3600, 4, &cert);
|
||||||
tt_assert(kp2);
|
tt_assert(kp2);
|
||||||
tt_assert(cert);
|
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_assert(! cert->signing_key_included);
|
||||||
|
|
||||||
tt_int_op(cert->valid_until, >=, now);
|
tt_int_op(cert->valid_until, OP_GE, now);
|
||||||
tt_int_op(cert->valid_until, <=, now+7200);
|
tt_int_op(cert->valid_until, OP_LE, now+7200);
|
||||||
|
|
||||||
/* Create a new key-including certificate signed by kp1 */
|
/* Create a new key-including certificate signed by kp1 */
|
||||||
ed25519_keypair_free(kp2);
|
ed25519_keypair_free(kp2);
|
||||||
@ -227,8 +227,8 @@ test_routerkeys_ed_key_create(void *arg)
|
|||||||
tt_assert(kp2);
|
tt_assert(kp2);
|
||||||
tt_assert(cert);
|
tt_assert(cert);
|
||||||
tt_assert(cert->signing_key_included);
|
tt_assert(cert->signing_key_included);
|
||||||
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_mem_op(&cert->signing_key, ==, &kp1->pubkey,sizeof(ed25519_public_key_t));
|
tt_mem_op(&cert->signing_key, OP_EQ, &kp1->pubkey,sizeof(ed25519_public_key_t));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ed25519_keypair_free(kp1);
|
ed25519_keypair_free(kp1);
|
||||||
@ -261,8 +261,8 @@ test_routerkeys_ed_key_init_basic(void *arg)
|
|||||||
NULL, now, 0, 7, &cert);
|
NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp1 != NULL);
|
tt_assert(kp1 != NULL);
|
||||||
tt_assert(cert == 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_cert"), &st), OP_LT, 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_secret_key"), &st), OP_EQ, 0);
|
||||||
|
|
||||||
/* Fail to load if we say we need a cert */
|
/* Fail to load if we say we need a cert */
|
||||||
kp2 = ed_key_init_from_file(fname1, INIT_ED_KEY_NEEDCERT, LOG_INFO,
|
kp2 = ed_key_init_from_file(fname1, INIT_ED_KEY_NEEDCERT, LOG_INFO,
|
||||||
@ -279,14 +279,14 @@ test_routerkeys_ed_key_init_basic(void *arg)
|
|||||||
NULL, now, 0, 7, &cert);
|
NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert == 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;
|
ed25519_keypair_free(kp2); kp2 = NULL;
|
||||||
|
|
||||||
kp2 = ed_key_init_from_file(fname1, 0, LOG_INFO,
|
kp2 = ed_key_init_from_file(fname1, 0, LOG_INFO,
|
||||||
NULL, now, 0, 7, &cert);
|
NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert == 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;
|
ed25519_keypair_free(kp2); kp2 = NULL;
|
||||||
|
|
||||||
/* Now create a key with a cert. */
|
/* Now create a key with a cert. */
|
||||||
@ -295,34 +295,34 @@ test_routerkeys_ed_key_init_basic(void *arg)
|
|||||||
LOG_INFO, kp1, now, 7200, 7, &cert);
|
LOG_INFO, kp1, now, 7200, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert != NULL);
|
tt_assert(cert != NULL);
|
||||||
tt_mem_op(kp1, !=, kp2, sizeof(*kp1));
|
tt_mem_op(kp1, OP_NE, 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_cert"), &st), OP_EQ, 0);
|
||||||
tt_int_op(stat(get_fname("test_ed_key_2_secret_key"), &st), ==, 0);
|
tt_int_op(stat(get_fname("test_ed_key_2_secret_key"), &st), OP_EQ, 0);
|
||||||
|
|
||||||
tt_assert(cert->cert_valid == 1);
|
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... */
|
/* Now verify we can load the cert... */
|
||||||
kp3 = ed_key_init_from_file(fname2, (INIT_ED_KEY_CREATE|
|
kp3 = ed_key_init_from_file(fname2, (INIT_ED_KEY_CREATE|
|
||||||
INIT_ED_KEY_NEEDCERT),
|
INIT_ED_KEY_NEEDCERT),
|
||||||
LOG_INFO, kp1, now, 7200, 7, &cert2);
|
LOG_INFO, kp1, now, 7200, 7, &cert2);
|
||||||
tt_mem_op(kp2, ==, kp3, sizeof(*kp2));
|
tt_mem_op(kp2, OP_EQ, kp3, sizeof(*kp2));
|
||||||
tt_mem_op(cert2->encoded, ==, cert->encoded, cert->encoded_len);
|
tt_mem_op(cert2->encoded, OP_EQ, cert->encoded, cert->encoded_len);
|
||||||
ed25519_keypair_free(kp3); kp3 = NULL;
|
ed25519_keypair_free(kp3); kp3 = NULL;
|
||||||
tor_cert_free(cert2); cert2 = NULL;
|
tor_cert_free(cert2); cert2 = NULL;
|
||||||
|
|
||||||
/* ... even without create... */
|
/* ... even without create... */
|
||||||
kp3 = ed_key_init_from_file(fname2, INIT_ED_KEY_NEEDCERT,
|
kp3 = ed_key_init_from_file(fname2, INIT_ED_KEY_NEEDCERT,
|
||||||
LOG_INFO, kp1, now, 7200, 7, &cert2);
|
LOG_INFO, kp1, now, 7200, 7, &cert2);
|
||||||
tt_mem_op(kp2, ==, kp3, sizeof(*kp2));
|
tt_mem_op(kp2, OP_EQ, kp3, sizeof(*kp2));
|
||||||
tt_mem_op(cert2->encoded, ==, cert->encoded, cert->encoded_len);
|
tt_mem_op(cert2->encoded, OP_EQ, cert->encoded, cert->encoded_len);
|
||||||
ed25519_keypair_free(kp3); kp3 = NULL;
|
ed25519_keypair_free(kp3); kp3 = NULL;
|
||||||
tor_cert_free(cert2); cert2 = NULL;
|
tor_cert_free(cert2); cert2 = NULL;
|
||||||
|
|
||||||
/* ... but that we don't crash or anything if we say we don't want it. */
|
/* ... 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,
|
kp3 = ed_key_init_from_file(fname2, INIT_ED_KEY_NEEDCERT,
|
||||||
LOG_INFO, kp1, now, 7200, 7, NULL);
|
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;
|
ed25519_keypair_free(kp3); kp3 = NULL;
|
||||||
|
|
||||||
/* Fail if we're told the wrong signing key */
|
/* Fail if we're told the wrong signing key */
|
||||||
@ -367,16 +367,16 @@ test_routerkeys_ed_key_init_split(void *arg)
|
|||||||
LOG_INFO, NULL, now, 0, 7, &cert);
|
LOG_INFO, NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp1 != NULL);
|
tt_assert(kp1 != NULL);
|
||||||
tt_assert(cert == 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_cert"), &st), OP_LT, 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_secret_key"), &st), OP_EQ, 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_public_key"), &st), OP_EQ, 0);
|
||||||
|
|
||||||
/* Load it. */
|
/* Load it. */
|
||||||
kp2 = ed_key_init_from_file(fname1, flags|INIT_ED_KEY_CREATE,
|
kp2 = ed_key_init_from_file(fname1, flags|INIT_ED_KEY_CREATE,
|
||||||
LOG_INFO, NULL, now, 0, 7, &cert);
|
LOG_INFO, NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert == 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;
|
ed25519_keypair_free(kp2); kp2 = NULL;
|
||||||
|
|
||||||
/* Okay, try killing the secret key and loading it. */
|
/* Okay, try killing the secret key and loading it. */
|
||||||
@ -385,7 +385,7 @@ test_routerkeys_ed_key_init_split(void *arg)
|
|||||||
LOG_INFO, NULL, now, 0, 7, &cert);
|
LOG_INFO, NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert == 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,
|
tt_assert(tor_mem_is_zero((char*)kp2->seckey.seckey,
|
||||||
sizeof(kp2->seckey.seckey)));
|
sizeof(kp2->seckey.seckey)));
|
||||||
ed25519_keypair_free(kp2); kp2 = NULL;
|
ed25519_keypair_free(kp2); kp2 = NULL;
|
||||||
@ -395,7 +395,7 @@ test_routerkeys_ed_key_init_split(void *arg)
|
|||||||
LOG_INFO, NULL, now, 0, 7, &cert);
|
LOG_INFO, NULL, now, 0, 7, &cert);
|
||||||
tt_assert(kp2 != NULL);
|
tt_assert(kp2 != NULL);
|
||||||
tt_assert(cert == 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,
|
tt_assert(tor_mem_is_zero((char*)kp2->seckey.seckey,
|
||||||
sizeof(kp2->seckey.seckey)));
|
sizeof(kp2->seckey.seckey)));
|
||||||
ed25519_keypair_free(kp2); kp2 = NULL;
|
ed25519_keypair_free(kp2); kp2 = NULL;
|
||||||
@ -450,8 +450,8 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
|
|
||||||
options->DataDirectory = dir;
|
options->DataDirectory = dir;
|
||||||
|
|
||||||
tt_int_op(1, ==, load_ed_keys(options, now));
|
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
|
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_identity_key());
|
tt_assert(get_master_identity_key());
|
||||||
tt_assert(get_master_signing_keypair());
|
tt_assert(get_master_signing_keypair());
|
||||||
@ -465,21 +465,21 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
link_cert = tor_cert_dup(get_current_link_cert_cert());
|
link_cert = tor_cert_dup(get_current_link_cert_cert());
|
||||||
|
|
||||||
/* Call load_ed_keys again, but nothing has changed. */
|
/* Call load_ed_keys again, but nothing has changed. */
|
||||||
tt_int_op(0, ==, load_ed_keys(options, now));
|
tt_int_op(0, OP_EQ, load_ed_keys(options, now));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
|
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
|
||||||
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
|
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
|
||||||
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
|
tt_mem_op(&sign, OP_EQ, get_master_signing_keypair(), sizeof(sign));
|
||||||
tt_mem_op(&auth, ==, get_current_auth_keypair(), sizeof(auth));
|
tt_mem_op(&auth, OP_EQ, get_current_auth_keypair(), sizeof(auth));
|
||||||
tt_assert(tor_cert_eq(link_cert, get_current_link_cert_cert()));
|
tt_assert(tor_cert_eq(link_cert, get_current_link_cert_cert()));
|
||||||
|
|
||||||
/* Force a reload: we make new link/auth keys. */
|
/* Force a reload: we make new link/auth keys. */
|
||||||
routerkeys_free_all();
|
routerkeys_free_all();
|
||||||
tt_int_op(1, ==, load_ed_keys(options, now));
|
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
|
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
|
||||||
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
|
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
|
||||||
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
|
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_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_master_signing_key_cert());
|
||||||
tt_assert(get_current_link_cert_cert());
|
tt_assert(get_current_link_cert_cert());
|
||||||
tt_assert(get_current_auth_key_cert());
|
tt_assert(get_current_auth_key_cert());
|
||||||
@ -488,12 +488,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
|
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
|
||||||
|
|
||||||
/* Force a link/auth-key regeneration by advancing time. */
|
/* Force a link/auth-key regeneration by advancing time. */
|
||||||
tt_int_op(0, ==, load_ed_keys(options, now+3*86400));
|
tt_int_op(0, OP_EQ, load_ed_keys(options, now+3*86400));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now+3*86400, 0));
|
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now+3*86400, 0));
|
||||||
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
|
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
|
||||||
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
|
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_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_master_signing_key_cert());
|
||||||
tt_assert(get_current_link_cert_cert());
|
tt_assert(get_current_link_cert_cert());
|
||||||
tt_assert(get_current_auth_key_cert());
|
tt_assert(get_current_auth_key_cert());
|
||||||
@ -502,12 +502,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
|
memcpy(&auth, get_current_auth_keypair(), sizeof(auth));
|
||||||
|
|
||||||
/* Force a signing-key regeneration by advancing time. */
|
/* Force a signing-key regeneration by advancing time. */
|
||||||
tt_int_op(1, ==, load_ed_keys(options, now+100*86400));
|
tt_int_op(1, OP_EQ, load_ed_keys(options, now+100*86400));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now+100*86400, 0));
|
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now+100*86400, 0));
|
||||||
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
|
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
|
||||||
tt_mem_op(&sign, !=, get_master_signing_keypair(), sizeof(sign));
|
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_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_master_signing_key_cert());
|
||||||
tt_assert(get_current_link_cert_cert());
|
tt_assert(get_current_link_cert_cert());
|
||||||
tt_assert(get_current_auth_key_cert());
|
tt_assert(get_current_auth_key_cert());
|
||||||
@ -520,12 +520,12 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
routerkeys_free_all();
|
routerkeys_free_all();
|
||||||
unlink(get_fname("test_ed_keys_init_all/keys/"
|
unlink(get_fname("test_ed_keys_init_all/keys/"
|
||||||
"ed25519_master_id_secret_key"));
|
"ed25519_master_id_secret_key"));
|
||||||
tt_int_op(1, ==, load_ed_keys(options, now));
|
tt_int_op(1, OP_EQ, load_ed_keys(options, now));
|
||||||
tt_int_op(0, ==, generate_ed_link_cert(options, now, 0));
|
tt_int_op(0, OP_EQ, generate_ed_link_cert(options, now, 0));
|
||||||
tt_mem_op(&id, ==, get_master_identity_key(), sizeof(id));
|
tt_mem_op(&id, OP_EQ, get_master_identity_key(), sizeof(id));
|
||||||
tt_mem_op(&sign, ==, get_master_signing_keypair(), sizeof(sign));
|
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_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_master_signing_key_cert());
|
||||||
tt_assert(get_current_link_cert_cert());
|
tt_assert(get_current_link_cert_cert());
|
||||||
tt_assert(get_current_auth_key_cert());
|
tt_assert(get_current_auth_key_cert());
|
||||||
@ -535,7 +535,7 @@ test_routerkeys_ed_keys_init_all(void *arg)
|
|||||||
log_global_min_severity_ = LOG_ERR; /* Suppress warnings.
|
log_global_min_severity_ = LOG_ERR; /* Suppress warnings.
|
||||||
* XXX (better way to do this)? */
|
* XXX (better way to do this)? */
|
||||||
routerkeys_free_all();
|
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:
|
done:
|
||||||
tor_free(dir);
|
tor_free(dir);
|
||||||
@ -556,20 +556,20 @@ test_routerkeys_cross_certify_ntor(void *args)
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
int sign;
|
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"));
|
"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,
|
cert = make_ntor_onion_key_crosscert(&onion_keys,
|
||||||
&master_key,
|
&master_key,
|
||||||
now, 10000,
|
now, 10000,
|
||||||
&sign);
|
&sign);
|
||||||
tt_assert(cert);
|
tt_assert(cert);
|
||||||
tt_assert(sign == 0 || sign == 1);
|
tt_assert(sign == 0 || sign == 1);
|
||||||
tt_int_op(cert->cert_type, ==, CERT_TYPE_ONION_ID);
|
tt_int_op(cert->cert_type, OP_EQ, CERT_TYPE_ONION_ID);
|
||||||
tt_int_op(1, ==, ed25519_pubkey_eq(&cert->signed_key, &master_key));
|
tt_int_op(1, OP_EQ, ed25519_pubkey_eq(&cert->signed_key, &master_key));
|
||||||
tt_int_op(0, ==, ed25519_public_key_from_curve25519_public_key(
|
tt_int_op(0, OP_EQ, ed25519_public_key_from_curve25519_public_key(
|
||||||
&onion_check_key, &onion_keys.pubkey, sign));
|
&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:
|
done:
|
||||||
tor_cert_free(cert);
|
tor_cert_free(cert);
|
||||||
@ -587,7 +587,7 @@ test_routerkeys_cross_certify_tap(void *args)
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
int n;
|
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"));
|
"IAlreadyWroteTestsForRouterdescsUsingTheseX"));
|
||||||
|
|
||||||
cc = make_tap_onion_key_crosscert(onion_key,
|
cc = make_tap_onion_key_crosscert(onion_key,
|
||||||
@ -598,14 +598,14 @@ test_routerkeys_cross_certify_tap(void *args)
|
|||||||
|
|
||||||
n = crypto_pk_public_checksig(onion_key, buf, sizeof(buf),
|
n = crypto_pk_public_checksig(onion_key, buf, sizeof(buf),
|
||||||
(char*)cc, cc_len);
|
(char*)cc, cc_len);
|
||||||
tt_int_op(n,>,0);
|
tt_int_op(n,OP_GT,0);
|
||||||
tt_int_op(n,==,52);
|
tt_int_op(n,OP_EQ,52);
|
||||||
|
|
||||||
crypto_pk_get_digest(id_key, digest);
|
crypto_pk_get_digest(id_key, digest);
|
||||||
tt_mem_op(buf,==,digest,20);
|
tt_mem_op(buf,OP_EQ,digest,20);
|
||||||
tt_mem_op(buf+20,==,master_key.pubkey,32);
|
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));
|
onion_key, &master_key, (uint8_t*)digest));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -117,7 +117,7 @@ test_routerlist_launch_descriptor_downloads(void *arg)
|
|||||||
MOCK(initiate_descriptor_downloads, mock_initiate_descriptor_downloads);
|
MOCK(initiate_descriptor_downloads, mock_initiate_descriptor_downloads);
|
||||||
launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC, downloadable,
|
launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC, downloadable,
|
||||||
NULL, now);
|
NULL, now);
|
||||||
tt_int_op(3, ==, count);
|
tt_int_op(3, OP_EQ, count);
|
||||||
UNMOCK(initiate_descriptor_downloads);
|
UNMOCK(initiate_descriptor_downloads);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -148,24 +148,24 @@ construct_consensus(char **consensus_text_md)
|
|||||||
&v1, &n_vrs, now, 1);
|
&v1, &n_vrs, now, 1);
|
||||||
networkstatus_vote_free(vote);
|
networkstatus_vote_free(vote);
|
||||||
tt_assert(v1);
|
tt_assert(v1);
|
||||||
tt_int_op(n_vrs, ==, 4);
|
tt_int_op(n_vrs, OP_EQ, 4);
|
||||||
tt_int_op(smartlist_len(v1->routerstatus_list), ==, 4);
|
tt_int_op(smartlist_len(v1->routerstatus_list), OP_EQ, 4);
|
||||||
|
|
||||||
dir_common_construct_vote_2(&vote, cert2, sign_skey_2,
|
dir_common_construct_vote_2(&vote, cert2, sign_skey_2,
|
||||||
&dir_common_gen_routerstatus_for_v3ns,
|
&dir_common_gen_routerstatus_for_v3ns,
|
||||||
&v2, &n_vrs, now, 1);
|
&v2, &n_vrs, now, 1);
|
||||||
networkstatus_vote_free(vote);
|
networkstatus_vote_free(vote);
|
||||||
tt_assert(v2);
|
tt_assert(v2);
|
||||||
tt_int_op(n_vrs, ==, 4);
|
tt_int_op(n_vrs, OP_EQ, 4);
|
||||||
tt_int_op(smartlist_len(v2->routerstatus_list), ==, 4);
|
tt_int_op(smartlist_len(v2->routerstatus_list), OP_EQ, 4);
|
||||||
|
|
||||||
dir_common_construct_vote_3(&vote, cert3, sign_skey_3,
|
dir_common_construct_vote_3(&vote, cert3, sign_skey_3,
|
||||||
&dir_common_gen_routerstatus_for_v3ns,
|
&dir_common_gen_routerstatus_for_v3ns,
|
||||||
&v3, &n_vrs, now, 1);
|
&v3, &n_vrs, now, 1);
|
||||||
|
|
||||||
tt_assert(v3);
|
tt_assert(v3);
|
||||||
tt_int_op(n_vrs, ==, 4);
|
tt_int_op(n_vrs, OP_EQ, 4);
|
||||||
tt_int_op(smartlist_len(v3->routerstatus_list), ==, 4);
|
tt_int_op(smartlist_len(v3->routerstatus_list), OP_EQ, 4);
|
||||||
networkstatus_vote_free(vote);
|
networkstatus_vote_free(vote);
|
||||||
votes = smartlist_new();
|
votes = smartlist_new();
|
||||||
smartlist_add(votes, v1);
|
smartlist_add(votes, v1);
|
||||||
@ -254,9 +254,9 @@ test_router_pick_directory_server_impl(void *arg)
|
|||||||
con_md = networkstatus_parse_vote_from_string(consensus_text_md, NULL,
|
con_md = networkstatus_parse_vote_from_string(consensus_text_md, NULL,
|
||||||
NS_TYPE_CONSENSUS);
|
NS_TYPE_CONSENSUS);
|
||||||
tt_assert(con_md);
|
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_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,
|
tt_assert(!networkstatus_set_current_consensus_from_ns(con_md,
|
||||||
"microdesc"));
|
"microdesc"));
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ mock_event_free_all(void)
|
|||||||
mock_event_base = NULL;
|
mock_event_base = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tt_ptr_op(mock_event_base, ==, NULL);
|
tt_ptr_op(mock_event_base, OP_EQ, NULL);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
@ -86,7 +86,7 @@ mock_event_init(void)
|
|||||||
{
|
{
|
||||||
struct event_config *cfg = NULL;
|
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
|
* Really cut down from tor_libevent_initialize of
|
||||||
@ -326,7 +326,7 @@ test_scheduler_channel_states(void *arg)
|
|||||||
*/
|
*/
|
||||||
MOCK(scheduler_run, scheduler_run_noop_mock);
|
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 */
|
/* Set up a fake channel */
|
||||||
ch1 = new_fake_channel();
|
ch1 = new_fake_channel();
|
||||||
@ -341,7 +341,7 @@ test_scheduler_channel_states(void *arg)
|
|||||||
tt_assert(ch1->registered);
|
tt_assert(ch1->registered);
|
||||||
|
|
||||||
/* It should start off in SCHED_CHAN_IDLE */
|
/* 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 */
|
/* Now get another one */
|
||||||
ch2 = new_fake_channel();
|
ch2 = new_fake_channel();
|
||||||
@ -353,39 +353,39 @@ test_scheduler_channel_states(void *arg)
|
|||||||
|
|
||||||
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
|
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
|
||||||
scheduler_channel_has_waiting_cells(ch1);
|
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 */
|
/* This should send it to SCHED_CHAN_PENDING */
|
||||||
scheduler_channel_wants_writes(ch1);
|
scheduler_channel_wants_writes(ch1);
|
||||||
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 1);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
|
||||||
|
|
||||||
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
|
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
|
||||||
scheduler_channel_wants_writes(ch2);
|
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 */
|
/* Drop ch2 back to idle */
|
||||||
scheduler_channel_doesnt_want_writes(ch2);
|
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 */
|
/* ...and back to SCHED_CHAN_WAITING_FOR_CELLS */
|
||||||
scheduler_channel_wants_writes(ch2);
|
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 */
|
/* ...and this should kick ch2 into SCHED_CHAN_PENDING */
|
||||||
scheduler_channel_has_waiting_cells(ch2);
|
scheduler_channel_has_waiting_cells(ch2);
|
||||||
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 2);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
|
||||||
|
|
||||||
/* This should send ch2 to SCHED_CHAN_WAITING_TO_WRITE */
|
/* This should send ch2 to SCHED_CHAN_WAITING_TO_WRITE */
|
||||||
scheduler_channel_doesnt_want_writes(ch2);
|
scheduler_channel_doesnt_want_writes(ch2);
|
||||||
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_WAITING_TO_WRITE);
|
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_WAITING_TO_WRITE);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 1);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
|
||||||
|
|
||||||
/* ...and back to SCHED_CHAN_PENDING */
|
/* ...and back to SCHED_CHAN_PENDING */
|
||||||
scheduler_channel_wants_writes(ch2);
|
scheduler_channel_wants_writes(ch2);
|
||||||
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 2);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
|
||||||
|
|
||||||
/* Now we exercise scheduler_touch_channel */
|
/* Now we exercise scheduler_touch_channel */
|
||||||
old_count = scheduler_compare_channels_mock_ctr;
|
old_count = scheduler_compare_channels_mock_ctr;
|
||||||
@ -394,14 +394,14 @@ test_scheduler_channel_states(void *arg)
|
|||||||
|
|
||||||
/* Close */
|
/* Close */
|
||||||
channel_mark_for_close(ch1);
|
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);
|
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);
|
channel_closed(ch1);
|
||||||
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSED);
|
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSED);
|
||||||
ch1 = NULL;
|
ch1 = NULL;
|
||||||
channel_closed(ch2);
|
channel_closed(ch2);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSED);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSED);
|
||||||
ch2 = NULL;
|
ch2 = NULL;
|
||||||
|
|
||||||
/* Shut things down */
|
/* Shut things down */
|
||||||
@ -464,21 +464,21 @@ test_scheduler_compare_channels(void *arg)
|
|||||||
|
|
||||||
/* Equal-channel case */
|
/* Equal-channel case */
|
||||||
result = scheduler_compare_channels(&c1, &c1);
|
result = scheduler_compare_channels(&c1, &c1);
|
||||||
tt_int_op(result, ==, 0);
|
tt_int_op(result, OP_EQ, 0);
|
||||||
|
|
||||||
/* Distinct channels, distinct policies */
|
/* Distinct channels, distinct policies */
|
||||||
result = scheduler_compare_channels(&c1, &c2);
|
result = scheduler_compare_channels(&c1, &c2);
|
||||||
tt_int_op(result, ==, -1);
|
tt_int_op(result, OP_EQ, -1);
|
||||||
result = scheduler_compare_channels(&c2, &c1);
|
result = scheduler_compare_channels(&c2, &c1);
|
||||||
tt_int_op(result, ==, 1);
|
tt_int_op(result, OP_EQ, 1);
|
||||||
|
|
||||||
/* Distinct channels, same policy */
|
/* Distinct channels, same policy */
|
||||||
tor_free(mock_cgp_val_2);
|
tor_free(mock_cgp_val_2);
|
||||||
mock_cgp_val_2 = mock_cgp_val_1;
|
mock_cgp_val_2 = mock_cgp_val_1;
|
||||||
result = scheduler_compare_channels(&c1, &c2);
|
result = scheduler_compare_channels(&c1, &c2);
|
||||||
tt_int_op(result, ==, -1);
|
tt_int_op(result, OP_EQ, -1);
|
||||||
result = scheduler_compare_channels(&c2, &c1);
|
result = scheduler_compare_channels(&c2, &c1);
|
||||||
tt_int_op(result, ==, 1);
|
tt_int_op(result, OP_EQ, 1);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
@ -507,8 +507,8 @@ test_scheduler_initfree(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_ptr_op(channels_pending, ==, NULL);
|
tt_ptr_op(channels_pending, OP_EQ, NULL);
|
||||||
tt_ptr_op(run_sched_ev, ==, NULL);
|
tt_ptr_op(run_sched_ev, OP_EQ, NULL);
|
||||||
|
|
||||||
mock_event_init();
|
mock_event_init();
|
||||||
MOCK(tor_libevent_get_base, tor_libevent_get_base_mock);
|
MOCK(tor_libevent_get_base, tor_libevent_get_base_mock);
|
||||||
@ -523,8 +523,8 @@ test_scheduler_initfree(void *arg)
|
|||||||
UNMOCK(tor_libevent_get_base);
|
UNMOCK(tor_libevent_get_base);
|
||||||
mock_event_free_all();
|
mock_event_free_all();
|
||||||
|
|
||||||
tt_ptr_op(channels_pending, ==, NULL);
|
tt_ptr_op(channels_pending, OP_EQ, NULL);
|
||||||
tt_ptr_op(run_sched_ev, ==, NULL);
|
tt_ptr_op(run_sched_ev, OP_EQ, NULL);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
@ -553,7 +553,7 @@ test_scheduler_loop(void *arg)
|
|||||||
*/
|
*/
|
||||||
MOCK(scheduler_run, scheduler_run_noop_mock);
|
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 */
|
/* Set up a fake channel */
|
||||||
ch1 = new_fake_channel();
|
ch1 = new_fake_channel();
|
||||||
@ -570,7 +570,7 @@ test_scheduler_loop(void *arg)
|
|||||||
channel_change_state_open(ch1);
|
channel_change_state_open(ch1);
|
||||||
|
|
||||||
/* It should start off in SCHED_CHAN_IDLE */
|
/* 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 */
|
/* Now get another one */
|
||||||
ch2 = new_fake_channel();
|
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()
|
* zero and we'll get coverage of that exception case in scheduler_run()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
|
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPENING);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPENING);
|
||||||
|
|
||||||
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
|
/* Send it to SCHED_CHAN_WAITING_TO_WRITE */
|
||||||
scheduler_channel_has_waiting_cells(ch1);
|
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 */
|
/* This should send it to SCHED_CHAN_PENDING */
|
||||||
scheduler_channel_wants_writes(ch1);
|
scheduler_channel_wants_writes(ch1);
|
||||||
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 1);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 1);
|
||||||
|
|
||||||
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
|
/* Now send ch2 to SCHED_CHAN_WAITING_FOR_CELLS */
|
||||||
scheduler_channel_wants_writes(ch2);
|
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 */
|
/* Drop ch2 back to idle */
|
||||||
scheduler_channel_doesnt_want_writes(ch2);
|
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 */
|
/* ...and back to SCHED_CHAN_WAITING_FOR_CELLS */
|
||||||
scheduler_channel_wants_writes(ch2);
|
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 */
|
/* ...and this should kick ch2 into SCHED_CHAN_PENDING */
|
||||||
scheduler_channel_has_waiting_cells(ch2);
|
scheduler_channel_has_waiting_cells(ch2);
|
||||||
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 2);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we've got two pending channels and need to fire off
|
* 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
|
* Assert that they're still in the states we left and aren't still
|
||||||
* pending
|
* pending
|
||||||
*/
|
*/
|
||||||
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
|
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPENING);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPENING);
|
||||||
tt_assert(ch1->scheduler_state != SCHED_CHAN_PENDING);
|
tt_assert(ch1->scheduler_state != SCHED_CHAN_PENDING);
|
||||||
tt_assert(ch2->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 */
|
/* Now, finish opening ch2, and get both back to pending */
|
||||||
channel_change_state_open(ch2);
|
channel_change_state_open(ch2);
|
||||||
@ -641,11 +641,11 @@ test_scheduler_loop(void *arg)
|
|||||||
scheduler_channel_wants_writes(ch2);
|
scheduler_channel_wants_writes(ch2);
|
||||||
scheduler_channel_has_waiting_cells(ch1);
|
scheduler_channel_has_waiting_cells(ch1);
|
||||||
scheduler_channel_has_waiting_cells(ch2);
|
scheduler_channel_has_waiting_cells(ch2);
|
||||||
tt_int_op(ch1->state, ==, CHANNEL_STATE_OPEN);
|
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_OPEN);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_OPEN);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_OPEN);
|
||||||
tt_int_op(ch1->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch1->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(ch2->scheduler_state, ==, SCHED_CHAN_PENDING);
|
tt_int_op(ch2->scheduler_state, OP_EQ, SCHED_CHAN_PENDING);
|
||||||
tt_int_op(smartlist_len(channels_pending), ==, 2);
|
tt_int_op(smartlist_len(channels_pending), OP_EQ, 2);
|
||||||
|
|
||||||
/* Now, set up the channel_flush_some_cells() mock */
|
/* Now, set up the channel_flush_some_cells() mock */
|
||||||
MOCK(channel_flush_some_cells, 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
|
* ch1 should have gone to SCHED_CHAN_WAITING_FOR_CELLS, with 16 flushed
|
||||||
* and 32 writeable.
|
* 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
|
* ...ch2 should also have gone to SCHED_CHAN_WAITING_FOR_CELLS, with
|
||||||
* channel_more_to_flush() returning false and channel_num_cells_writeable()
|
* channel_more_to_flush() returning false and channel_num_cells_writeable()
|
||||||
* > 0/
|
* > 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 */
|
/* Close */
|
||||||
channel_mark_for_close(ch1);
|
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);
|
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);
|
channel_closed(ch1);
|
||||||
tt_int_op(ch1->state, ==, CHANNEL_STATE_CLOSED);
|
tt_int_op(ch1->state, OP_EQ, CHANNEL_STATE_CLOSED);
|
||||||
ch1 = NULL;
|
ch1 = NULL;
|
||||||
channel_closed(ch2);
|
channel_closed(ch2);
|
||||||
tt_int_op(ch2->state, ==, CHANNEL_STATE_CLOSED);
|
tt_int_op(ch2->state, OP_EQ, CHANNEL_STATE_CLOSED);
|
||||||
ch2 = NULL;
|
ch2 = NULL;
|
||||||
|
|
||||||
/* Shut things down */
|
/* Shut things down */
|
||||||
@ -724,22 +724,22 @@ test_scheduler_queue_heuristic(void *arg)
|
|||||||
|
|
||||||
/* Not yet inited case */
|
/* Not yet inited case */
|
||||||
scheduler_update_queue_heuristic(now - 180);
|
scheduler_update_queue_heuristic(now - 180);
|
||||||
tt_u64_op(queue_heuristic, ==, 0);
|
tt_u64_op(queue_heuristic, OP_EQ, 0);
|
||||||
tt_int_op(queue_heuristic_timestamp, ==, now - 180);
|
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 180);
|
||||||
|
|
||||||
queue_heuristic = 1000000000L;
|
queue_heuristic = 1000000000L;
|
||||||
queue_heuristic_timestamp = now - 120;
|
queue_heuristic_timestamp = now - 120;
|
||||||
|
|
||||||
scheduler_update_queue_heuristic(now - 119);
|
scheduler_update_queue_heuristic(now - 119);
|
||||||
tt_u64_op(queue_heuristic, ==, 500000000L);
|
tt_u64_op(queue_heuristic, OP_EQ, 500000000L);
|
||||||
tt_int_op(queue_heuristic_timestamp, ==, now - 119);
|
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 119);
|
||||||
|
|
||||||
scheduler_update_queue_heuristic(now - 116);
|
scheduler_update_queue_heuristic(now - 116);
|
||||||
tt_u64_op(queue_heuristic, ==, 62500000L);
|
tt_u64_op(queue_heuristic, OP_EQ, 62500000L);
|
||||||
tt_int_op(queue_heuristic_timestamp, ==, now - 116);
|
tt_int_op(queue_heuristic_timestamp, OP_EQ, now - 116);
|
||||||
|
|
||||||
qh = scheduler_get_queue_heuristic();
|
qh = scheduler_get_queue_heuristic();
|
||||||
tt_u64_op(qh, ==, 0);
|
tt_u64_op(qh, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
|
@ -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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
phase = get_sr_protocol_phase(the_time);
|
||||||
tt_int_op(phase, ==, SR_PHASE_REVEAL);
|
tt_int_op(phase, OP_EQ, SR_PHASE_REVEAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -147,7 +147,7 @@ test_get_state_valid_until_time(void *arg)
|
|||||||
/* Get the valid until time if called at 00:00:01 */
|
/* Get the valid until time if called at 00:00:01 */
|
||||||
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_until_time = get_state_valid_until_time(current_time);
|
valid_until_time = get_state_valid_until_time(current_time);
|
||||||
|
|
||||||
/* Compare it with the correct result */
|
/* 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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 19:22:00 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_until_time = get_state_valid_until_time(current_time);
|
valid_until_time = get_state_valid_until_time(current_time);
|
||||||
|
|
||||||
format_iso_time(tbuf, valid_until_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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:00 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_until_time = get_state_valid_until_time(current_time);
|
valid_until_time = get_state_valid_until_time(current_time);
|
||||||
|
|
||||||
format_iso_time(tbuf, valid_until_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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_until_time = get_state_valid_until_time(current_time);
|
valid_until_time = get_state_valid_until_time(current_time);
|
||||||
|
|
||||||
format_iso_time(tbuf, valid_until_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 */
|
/* Get start time if called at 00:00:01 */
|
||||||
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
run_start_time =
|
run_start_time =
|
||||||
sr_state_get_start_time_of_current_protocol_run(current_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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:59:59 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
run_start_time =
|
run_start_time =
|
||||||
sr_state_get_start_time_of_current_protocol_run(current_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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
run_start_time =
|
run_start_time =
|
||||||
sr_state_get_start_time_of_current_protocol_run(current_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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:15:32 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
|
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
run_start_time =
|
run_start_time =
|
||||||
sr_state_get_start_time_of_current_protocol_run(current_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;
|
(void) arg;
|
||||||
|
|
||||||
/* Check that by default an SR phase is 12 hours */
|
/* 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_phase_duration(), OP_EQ, 12*60*60);
|
||||||
tt_int_op(sr_state_get_protocol_run_duration(), ==, 24*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
|
/* 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) */
|
* if voting happens every 10 seconds (10*12 seconds = 2 mins) */
|
||||||
or_options_t *options = get_options_mutable();
|
or_options_t *options = get_options_mutable();
|
||||||
options->V3AuthVotingInterval = 10;
|
options->V3AuthVotingInterval = 10;
|
||||||
tt_int_op(sr_state_get_phase_duration(), ==, 2*60);
|
tt_int_op(sr_state_get_phase_duration(), OP_EQ, 2*60);
|
||||||
tt_int_op(sr_state_get_protocol_run_duration(), ==, 4*60);
|
tt_int_op(sr_state_get_protocol_run_duration(), OP_EQ, 4*60);
|
||||||
|
|
||||||
done: ;
|
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",
|
retval = parse_rfc1123_time("Mon, 13 Jan 2016 16:00:00 UTC",
|
||||||
&mock_consensus->fresh_until);
|
&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",
|
retval = parse_rfc1123_time("Mon, 13 Jan 2016 15:00:00 UTC",
|
||||||
&mock_consensus->valid_after);
|
&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,
|
||||||
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 */
|
/* Get the valid after time if called at 00:00:00 */
|
||||||
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:00 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_after_time = get_next_valid_after_time(current_time);
|
valid_after_time = get_next_valid_after_time(current_time);
|
||||||
|
|
||||||
/* Compare it with the correct result */
|
/* 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 */
|
/* Get the valid until time if called at 00:00:01 */
|
||||||
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 00:00:01 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_after_time = get_next_valid_after_time(current_time);
|
valid_after_time = get_next_valid_after_time(current_time);
|
||||||
|
|
||||||
/* Compare it with the correct result */
|
/* 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",
|
retval = parse_rfc1123_time("Mon, 20 Apr 2015 23:30:01 UTC",
|
||||||
¤t_time);
|
¤t_time);
|
||||||
tt_int_op(retval, ==, 0);
|
tt_int_op(retval, OP_EQ, 0);
|
||||||
valid_after_time = get_next_valid_after_time(current_time);
|
valid_after_time = get_next_valid_after_time(current_time);
|
||||||
|
|
||||||
/* Compare it with the correct result */
|
/* 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,
|
tt_assert(!tor_mem_is_zero((char *) our_commit->random_number,
|
||||||
sizeof(our_commit->random_number)));
|
sizeof(our_commit->random_number)));
|
||||||
/* Commit and reveal timestamp should be the same. */
|
/* 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. */
|
/* We should have a hashed reveal. */
|
||||||
tt_assert(!tor_mem_is_zero(our_commit->hashed_reveal,
|
tt_assert(!tor_mem_is_zero(our_commit->hashed_reveal,
|
||||||
sizeof(our_commit->hashed_reveal)));
|
sizeof(our_commit->hashed_reveal)));
|
||||||
/* Do we have a valid encoded commit and reveal. Note the following only
|
/* 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
|
* tests if the generated values are correct. Their could be a bug in
|
||||||
* the decode function but we test them seperately. */
|
* 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));
|
&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));
|
&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
|
/* 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. */
|
/* Timestamp MUST match. */
|
||||||
test_commit.commit_ts = test_commit.reveal_ts - 42;
|
test_commit.commit_ts = test_commit.reveal_ts - 42;
|
||||||
setup_full_capture_of_logs(LOG_WARN);
|
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");
|
expect_log_msg_containing("doesn't match reveal timestamp");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
memcpy(&test_commit, our_commit, sizeof(test_commit));
|
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). */
|
/* Hashed reveal must match the H(encoded_reveal). */
|
||||||
memset(test_commit.hashed_reveal, 'X',
|
memset(test_commit.hashed_reveal, 'X',
|
||||||
sizeof(test_commit.hashed_reveal));
|
sizeof(test_commit.hashed_reveal));
|
||||||
setup_full_capture_of_logs(LOG_WARN);
|
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");
|
expect_single_log_msg_containing("doesn't match the commit value");
|
||||||
teardown_capture_of_logs();
|
teardown_capture_of_logs();
|
||||||
memcpy(&test_commit, our_commit, sizeof(test_commit));
|
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
|
/* 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. */
|
/* Hash random number because we don't expose bytes of the RNG. */
|
||||||
ret = crypto_digest256(hashed_rand, raw_rand,
|
ret = crypto_digest256(hashed_rand, raw_rand,
|
||||||
sizeof(raw_rand), SR_DIGEST_ALG);
|
sizeof(raw_rand), SR_DIGEST_ALG);
|
||||||
tt_int_op(0, ==, ret);
|
tt_int_op(0, OP_EQ, ret);
|
||||||
/* Hash reveal value. */
|
/* 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,
|
ret = crypto_digest256(hashed_reveal, encoded_reveal,
|
||||||
strlen(encoded_reveal), SR_DIGEST_ALG);
|
strlen(encoded_reveal), SR_DIGEST_ALG);
|
||||||
tt_int_op(0, ==, ret);
|
tt_int_op(0, OP_EQ, ret);
|
||||||
tt_int_op(SR_COMMIT_BASE64_LEN, ==, strlen(encoded_commit));
|
tt_int_op(SR_COMMIT_BASE64_LEN, OP_EQ, strlen(encoded_commit));
|
||||||
|
|
||||||
/* Test our commit/reveal decode functions. */
|
/* Test our commit/reveal decode functions. */
|
||||||
{
|
{
|
||||||
/* Test the reveal encoded value. */
|
/* Test the reveal encoded value. */
|
||||||
tt_int_op(0, ==, reveal_decode(encoded_reveal, &parsed_commit));
|
tt_int_op(0, OP_EQ, reveal_decode(encoded_reveal, &parsed_commit));
|
||||||
tt_u64_op(ts, ==, parsed_commit.reveal_ts);
|
tt_u64_op(ts, OP_EQ, parsed_commit.reveal_ts);
|
||||||
tt_mem_op(hashed_rand, OP_EQ, parsed_commit.random_number,
|
tt_mem_op(hashed_rand, OP_EQ, parsed_commit.random_number,
|
||||||
sizeof(hashed_rand));
|
sizeof(hashed_rand));
|
||||||
|
|
||||||
/* Test the commit encoded value. */
|
/* Test the commit encoded value. */
|
||||||
memset(&parsed_commit, 0, sizeof(parsed_commit));
|
memset(&parsed_commit, 0, sizeof(parsed_commit));
|
||||||
tt_int_op(0, ==, commit_decode(encoded_commit, &parsed_commit));
|
tt_int_op(0, OP_EQ, commit_decode(encoded_commit, &parsed_commit));
|
||||||
tt_u64_op(ts, ==, parsed_commit.commit_ts);
|
tt_u64_op(ts, OP_EQ, parsed_commit.commit_ts);
|
||||||
tt_mem_op(encoded_commit, OP_EQ, parsed_commit.encoded_commit,
|
tt_mem_op(encoded_commit, OP_EQ, parsed_commit.encoded_commit,
|
||||||
sizeof(parsed_commit.encoded_commit));
|
sizeof(parsed_commit.encoded_commit));
|
||||||
tt_mem_op(hashed_reveal, OP_EQ, parsed_commit.hashed_reveal,
|
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,
|
memcpy(parsed_commit.random_number, hashed_rand,
|
||||||
sizeof(parsed_commit.random_number));
|
sizeof(parsed_commit.random_number));
|
||||||
ret = reveal_encode(&parsed_commit, encoded, sizeof(encoded));
|
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));
|
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,
|
memcpy(parsed_commit.hashed_reveal, hashed_reveal,
|
||||||
sizeof(parsed_commit.hashed_reveal));
|
sizeof(parsed_commit.hashed_reveal));
|
||||||
ret = commit_encode(&parsed_commit, encoded, sizeof(encoded));
|
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));
|
tt_mem_op(encoded_commit, OP_EQ, encoded, strlen(encoded_commit));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ test_vote(void *arg)
|
|||||||
tt_assert(lines);
|
tt_assert(lines);
|
||||||
/* Split the lines. We expect 2 here. */
|
/* Split the lines. We expect 2 here. */
|
||||||
ret = smartlist_split_string(chunks, lines, "\n", SPLIT_IGNORE_BLANK, 0);
|
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");
|
tt_str_op(smartlist_get(chunks, 0), OP_EQ, "shared-rand-participate");
|
||||||
/* Get our commitment line and will validate it agains our commit. The
|
/* Get our commitment line and will validate it agains our commit. The
|
||||||
* format is as follow:
|
* format is as follow:
|
||||||
@ -642,7 +642,7 @@ test_vote(void *arg)
|
|||||||
char *commit_line = smartlist_get(chunks, 1);
|
char *commit_line = smartlist_get(chunks, 1);
|
||||||
tt_assert(commit_line);
|
tt_assert(commit_line);
|
||||||
ret = smartlist_split_string(tokens, commit_line, " ", 0, 0);
|
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, 0), OP_EQ, "shared-rand-commit");
|
||||||
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "1");
|
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "1");
|
||||||
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
|
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
|
||||||
@ -650,7 +650,7 @@ test_vote(void *arg)
|
|||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
base16_decode(digest, sizeof(digest), smartlist_get(tokens, 3),
|
base16_decode(digest, sizeof(digest), smartlist_get(tokens, 3),
|
||||||
HEX_DIGEST_LEN);
|
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, 4), OP_EQ, our_commit->encoded_commit);
|
||||||
tt_str_op(smartlist_get(tokens, 5), OP_EQ, our_commit->encoded_reveal)
|
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
|
/* Set valid flag explicitly here to compare since it's not set by
|
||||||
* simply parsing the commit. */
|
* simply parsing the commit. */
|
||||||
parsed_commit->valid = 1;
|
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 */
|
/* minor cleanup */
|
||||||
SMARTLIST_FOREACH(tokens, char *, s, tor_free(s));
|
SMARTLIST_FOREACH(tokens, char *, s, tor_free(s));
|
||||||
@ -676,7 +676,7 @@ test_vote(void *arg)
|
|||||||
char *prev_srv_line = smartlist_get(chunks, 2);
|
char *prev_srv_line = smartlist_get(chunks, 2);
|
||||||
tt_assert(prev_srv_line);
|
tt_assert(prev_srv_line);
|
||||||
ret = smartlist_split_string(tokens, prev_srv_line, " ", 0, 0);
|
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, 0), OP_EQ, "shared-rand-previous-value");
|
||||||
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "42");
|
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "42");
|
||||||
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
|
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);
|
char *current_srv_line = smartlist_get(chunks, 3);
|
||||||
tt_assert(current_srv_line);
|
tt_assert(current_srv_line);
|
||||||
ret = smartlist_split_string(tokens, current_srv_line, " ", 0, 0);
|
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, 0), OP_EQ, "shared-rand-current-value");
|
||||||
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "128");
|
tt_str_op(smartlist_get(tokens, 1), OP_EQ, "128");
|
||||||
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
|
tt_str_op(smartlist_get(tokens, 2), OP_EQ,
|
||||||
@ -803,7 +803,7 @@ test_sr_setup_commits(void)
|
|||||||
tt_assert(auth_cert);
|
tt_assert(auth_cert);
|
||||||
|
|
||||||
options->AuthoritativeDir = 1;
|
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
|
/* 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_b);
|
||||||
save_commit_to_state(commit_c);
|
save_commit_to_state(commit_c);
|
||||||
save_commit_to_state(commit_d);
|
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. */
|
/* Now during REVEAL phase save commit D by restoring its reveal. */
|
||||||
set_sr_phase(SR_PHASE_REVEAL);
|
set_sr_phase(SR_PHASE_REVEAL);
|
||||||
@ -934,9 +934,9 @@ test_sr_compute_srv(void *arg)
|
|||||||
/* Check the result against the test vector */
|
/* Check the result against the test vector */
|
||||||
current_srv = sr_state_get_current_srv();
|
current_srv = sr_state_get_current_srv();
|
||||||
tt_assert(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),
|
tt_str_op(hex_str((char*)current_srv->value, 32),
|
||||||
==,
|
OP_EQ,
|
||||||
SRV_TEST_VECTOR);
|
SRV_TEST_VECTOR);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1011,7 +1011,7 @@ test_sr_get_majority_srv_from_votes(void *arg)
|
|||||||
smartlist_add(votes, vote);
|
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
|
/* Now we achieve majority for SRV_1, but not the AuthDirNumSRVAgreements
|
||||||
@ -1025,7 +1025,7 @@ test_sr_get_majority_srv_from_votes(void *arg)
|
|||||||
set_num_srv_agreements(7);
|
set_num_srv_agreements(7);
|
||||||
chosen_srv = get_majority_srv_from_votes(votes, 1);
|
chosen_srv = get_majority_srv_from_votes(votes, 1);
|
||||||
tt_assert(chosen_srv);
|
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));
|
tt_mem_op(chosen_srv->value, OP_EQ, SRV_1, sizeof(chosen_srv->value));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1049,7 +1049,7 @@ test_utils(void *arg)
|
|||||||
memcpy(srv->value, srv_value, sizeof(srv->value));
|
memcpy(srv->value, srv_value, sizeof(srv->value));
|
||||||
dup_srv = srv_dup(srv);
|
dup_srv = srv_dup(srv);
|
||||||
tt_assert(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));
|
tt_mem_op(dup_srv->value, OP_EQ, srv->value, sizeof(srv->value));
|
||||||
tor_free(srv);
|
tor_free(srv);
|
||||||
tor_free(dup_srv);
|
tor_free(dup_srv);
|
||||||
@ -1069,10 +1069,10 @@ test_utils(void *arg)
|
|||||||
sr_commit_t commit1, commit2;
|
sr_commit_t commit1, commit2;
|
||||||
memcpy(commit1.encoded_commit, payload, sizeof(commit1.encoded_commit));
|
memcpy(commit1.encoded_commit, payload, sizeof(commit1.encoded_commit));
|
||||||
memcpy(commit2.encoded_commit, payload, sizeof(commit2.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. */
|
/* Let's corrupt one of them. */
|
||||||
memset(commit1.encoded_commit, 'A', sizeof(commit1.encoded_commit));
|
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(). */
|
/* Testing commit_is_authoritative(). */
|
||||||
@ -1083,32 +1083,32 @@ test_utils(void *arg)
|
|||||||
|
|
||||||
tt_assert(!crypto_pk_generate_key(k));
|
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));
|
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. */
|
/* Change the pubkey. */
|
||||||
memset(commit.rsa_identity, 0, sizeof(commit.rsa_identity));
|
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);
|
crypto_pk_free(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Testing get_phase_str(). */
|
/* Testing get_phase_str(). */
|
||||||
{
|
{
|
||||||
tt_str_op(get_phase_str(SR_PHASE_REVEAL), ==, "reveal");
|
tt_str_op(get_phase_str(SR_PHASE_REVEAL), OP_EQ, "reveal");
|
||||||
tt_str_op(get_phase_str(SR_PHASE_COMMIT), ==, "commit");
|
tt_str_op(get_phase_str(SR_PHASE_COMMIT), OP_EQ, "commit");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Testing phase transition */
|
/* Testing phase transition */
|
||||||
{
|
{
|
||||||
init_authority_state();
|
init_authority_state();
|
||||||
set_sr_phase(SR_PHASE_COMMIT);
|
set_sr_phase(SR_PHASE_COMMIT);
|
||||||
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), ==, 1);
|
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), OP_EQ, 1);
|
||||||
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), ==, 0);
|
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), OP_EQ, 0);
|
||||||
set_sr_phase(SR_PHASE_REVEAL);
|
set_sr_phase(SR_PHASE_REVEAL);
|
||||||
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), ==, 0);
|
tt_int_op(is_phase_transition(SR_PHASE_REVEAL), OP_EQ, 0);
|
||||||
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), ==, 1);
|
tt_int_op(is_phase_transition(SR_PHASE_COMMIT), OP_EQ, 1);
|
||||||
/* Junk. */
|
/* Junk. */
|
||||||
tt_int_op(is_phase_transition(42), ==, 1);
|
tt_int_op(is_phase_transition(42), OP_EQ, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1136,24 +1136,24 @@ test_state_transition(void *arg)
|
|||||||
sr_commit_t *commit = sr_generate_our_commit(now, mock_cert);
|
sr_commit_t *commit = sr_generate_our_commit(now, mock_cert);
|
||||||
tt_assert(commit);
|
tt_assert(commit);
|
||||||
sr_state_add_commit(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. */
|
/* Let's test our delete feature. */
|
||||||
sr_state_delete_commits();
|
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
|
/* 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. */
|
* deletiong our commit will be freed so generate a new one. */
|
||||||
commit = sr_generate_our_commit(now, mock_cert);
|
commit = sr_generate_our_commit(now, mock_cert);
|
||||||
tt_assert(commit);
|
tt_assert(commit);
|
||||||
sr_state_add_commit(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_reveal_rounds = 42;
|
||||||
state->n_commit_rounds = 43;
|
state->n_commit_rounds = 43;
|
||||||
state->n_protocol_runs = 44;
|
state->n_protocol_runs = 44;
|
||||||
reset_state_for_new_protocol_run(now);
|
reset_state_for_new_protocol_run(now);
|
||||||
tt_int_op(state->n_reveal_rounds, ==, 0);
|
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
|
||||||
tt_int_op(state->n_commit_rounds, ==, 0);
|
tt_int_op(state->n_commit_rounds, OP_EQ, 0);
|
||||||
tt_u64_op(state->n_protocol_runs, ==, 45);
|
tt_u64_op(state->n_protocol_runs, OP_EQ, 45);
|
||||||
tt_int_op(digestmap_size(state->commits), ==, 0);
|
tt_int_op(digestmap_size(state->commits), OP_EQ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test SRV rotation in our state. */
|
/* Test SRV rotation in our state. */
|
||||||
@ -1191,11 +1191,11 @@ test_state_transition(void *arg)
|
|||||||
/* Also, make sure we did change the current. */
|
/* Also, make sure we did change the current. */
|
||||||
tt_assert(sr_state_get_current_srv() != cur);
|
tt_assert(sr_state_get_current_srv() != cur);
|
||||||
/* We should have our commitment alone. */
|
/* We should have our commitment alone. */
|
||||||
tt_int_op(digestmap_size(state->commits), ==, 1);
|
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
|
||||||
tt_int_op(state->n_reveal_rounds, ==, 0);
|
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
|
||||||
tt_int_op(state->n_commit_rounds, ==, 0);
|
tt_int_op(state->n_commit_rounds, OP_EQ, 0);
|
||||||
/* 46 here since we were at 45 just before. */
|
/* 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. */
|
/* Cleanup of SRVs. */
|
||||||
@ -1239,21 +1239,21 @@ test_keep_commit(void *arg)
|
|||||||
/* Set us in COMMIT phase for starter. */
|
/* Set us in COMMIT phase for starter. */
|
||||||
set_sr_phase(SR_PHASE_COMMIT);
|
set_sr_phase(SR_PHASE_COMMIT);
|
||||||
/* We should never keep a commit from a non authoritative authority. */
|
/* 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. */
|
/* This should NOT be kept because it has a reveal value in it. */
|
||||||
tt_assert(commit_has_reveal_value(commit));
|
tt_assert(commit_has_reveal_value(commit));
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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. */
|
/* Add it to the state which should return to not keep it. */
|
||||||
sr_state_add_commit(commit);
|
sr_state_add_commit(commit);
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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. */
|
/* Remove it from state so we can continue our testing. */
|
||||||
digestmap_remove(state->commits, commit->rsa_identity);
|
digestmap_remove(state->commits, commit->rsa_identity);
|
||||||
/* Let's remove our reveal value which should make it OK to keep it. */
|
/* Let's remove our reveal value which should make it OK to keep it. */
|
||||||
memset(commit->encoded_reveal, 0, sizeof(commit->encoded_reveal));
|
memset(commit->encoded_reveal, 0, sizeof(commit->encoded_reveal));
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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. */
|
/* Let's reset our commit and go into REVEAL phase. */
|
||||||
sr_commit_free(commit);
|
sr_commit_free(commit);
|
||||||
@ -1265,17 +1265,17 @@ test_keep_commit(void *arg)
|
|||||||
memset(dup_commit->encoded_reveal, 0, sizeof(dup_commit->encoded_reveal));
|
memset(dup_commit->encoded_reveal, 0, sizeof(dup_commit->encoded_reveal));
|
||||||
set_sr_phase(SR_PHASE_REVEAL);
|
set_sr_phase(SR_PHASE_REVEAL);
|
||||||
/* We should never keep a commit from a non authoritative authority. */
|
/* 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. */
|
/* We shouldn't accept a commit that is not in our state. */
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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. */
|
/* Important to add the commit _without_ the reveal here. */
|
||||||
sr_state_add_commit(dup_commit);
|
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
|
/* Our commit should be valid that is authoritative, contains a reveal, be
|
||||||
* in the state and commitment and reveal values match. */
|
* in the state and commitment and reveal values match. */
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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
|
/* The commit shouldn't be kept if it's not verified that is no matchin
|
||||||
* hashed reveal. */
|
* hashed reveal. */
|
||||||
{
|
{
|
||||||
@ -1286,7 +1286,7 @@ test_keep_commit(void *arg)
|
|||||||
memset(commit->hashed_reveal, 0, sizeof(commit->hashed_reveal));
|
memset(commit->hashed_reveal, 0, sizeof(commit->hashed_reveal));
|
||||||
setup_full_capture_of_logs(LOG_WARN);
|
setup_full_capture_of_logs(LOG_WARN);
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
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("doesn't match the commit value.");
|
||||||
expect_log_msg_containing("has an invalid reveal value.");
|
expect_log_msg_containing("has an invalid reveal value.");
|
||||||
assert_log_predicate(mock_saved_log_n_entries() == 2,
|
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. */
|
/* We shouldn't keep a commit that has no reveal. */
|
||||||
tt_int_op(should_keep_commit(dup_commit, dup_commit->rsa_identity,
|
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. */
|
/* We must not keep a commit that is not the same from the commit phase. */
|
||||||
memset(commit->encoded_commit, 0, sizeof(commit->encoded_commit));
|
memset(commit->encoded_commit, 0, sizeof(commit->encoded_commit));
|
||||||
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
tt_int_op(should_keep_commit(commit, commit->rsa_identity,
|
||||||
SR_PHASE_REVEAL), ==, 0);
|
SR_PHASE_REVEAL), OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
teardown_capture_of_logs();
|
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
|
/* We are in COMMIT phase here and we'll trigger a state update but no
|
||||||
* transition. */
|
* transition. */
|
||||||
sr_state_update(commit_phase_time);
|
sr_state_update(commit_phase_time);
|
||||||
tt_int_op(state->valid_after, ==, commit_phase_time);
|
tt_int_op(state->valid_after, OP_EQ, commit_phase_time);
|
||||||
tt_int_op(state->n_commit_rounds, ==, 1);
|
tt_int_op(state->n_commit_rounds, OP_EQ, 1);
|
||||||
tt_int_op(state->phase, ==, SR_PHASE_COMMIT);
|
tt_int_op(state->phase, OP_EQ, SR_PHASE_COMMIT);
|
||||||
tt_int_op(digestmap_size(state->commits), ==, 1);
|
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
|
||||||
|
|
||||||
/* We are still in the COMMIT phase here but we'll trigger a state
|
/* We are still in the COMMIT phase here but we'll trigger a state
|
||||||
* transition to the REVEAL phase. */
|
* transition to the REVEAL phase. */
|
||||||
sr_state_update(reveal_phase_time);
|
sr_state_update(reveal_phase_time);
|
||||||
tt_int_op(state->phase, ==, SR_PHASE_REVEAL);
|
tt_int_op(state->phase, OP_EQ, SR_PHASE_REVEAL);
|
||||||
tt_int_op(state->valid_after, ==, reveal_phase_time);
|
tt_int_op(state->valid_after, OP_EQ, reveal_phase_time);
|
||||||
/* Only our commit should be in there. */
|
/* Only our commit should be in there. */
|
||||||
tt_int_op(digestmap_size(state->commits), ==, 1);
|
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
|
||||||
tt_int_op(state->n_reveal_rounds, ==, 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
|
/* We can't update a state with a valid after _lower_ than the creation
|
||||||
* time so here it is. */
|
* time so here it is. */
|
||||||
sr_state_update(commit_phase_time);
|
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
|
/* Finally, let's go back in COMMIT phase so we can test the state update
|
||||||
* of a new protocol run. */
|
* of a new protocol run. */
|
||||||
state->valid_after = 0;
|
state->valid_after = 0;
|
||||||
sr_state_update(commit_phase_time);
|
sr_state_update(commit_phase_time);
|
||||||
tt_int_op(state->valid_after, ==, commit_phase_time);
|
tt_int_op(state->valid_after, OP_EQ, commit_phase_time);
|
||||||
tt_int_op(state->n_commit_rounds, ==, 1);
|
tt_int_op(state->n_commit_rounds, OP_EQ, 1);
|
||||||
tt_int_op(state->n_reveal_rounds, ==, 0);
|
tt_int_op(state->n_reveal_rounds, OP_EQ, 0);
|
||||||
tt_u64_op(state->n_protocol_runs, ==, 1);
|
tt_u64_op(state->n_protocol_runs, OP_EQ, 1);
|
||||||
tt_int_op(state->phase, ==, SR_PHASE_COMMIT);
|
tt_int_op(state->phase, OP_EQ, SR_PHASE_COMMIT);
|
||||||
tt_int_op(digestmap_size(state->commits), ==, 1);
|
tt_int_op(digestmap_size(state->commits), OP_EQ, 1);
|
||||||
tt_assert(state->current_srv);
|
tt_assert(state->current_srv);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -889,8 +889,8 @@ NS(logv)(int severity, log_domain_mask_t domain, const char *funcname,
|
|||||||
tt_str_op(format, OP_EQ,
|
tt_str_op(format, OP_EQ,
|
||||||
"Average packaged cell fullness: %2.3f%%. "
|
"Average packaged cell fullness: %2.3f%%. "
|
||||||
"TLS write overhead: %.f%%");
|
"TLS write overhead: %.f%%");
|
||||||
tt_double_op(fabs(va_arg(ap, double) - 50.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), <=, DBL_EPSILON);
|
tt_double_op(fabs(va_arg(ap, double) - 0.0), OP_LE, DBL_EPSILON);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tt_abort_msg("unexpected call to logv()"); // TODO: prettyprint args
|
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%%. "
|
"Average packaged cell fullness: %2.3f%%. "
|
||||||
"TLS write overhead: %.f%%");
|
"TLS write overhead: %.f%%");
|
||||||
tt_int_op(fabs(va_arg(ap, double) - 100.0) <= DBL_EPSILON, OP_EQ, 1);
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
tt_abort_msg("unexpected call to logv()"); // TODO: prettyprint args
|
tt_abort_msg("unexpected call to logv()"); // TODO: prettyprint args
|
||||||
|
@ -139,8 +139,8 @@ test_threads_basic(void *arg)
|
|||||||
!strcmp(strmap_get(thread_test_strmap_, "thread 2"),
|
!strcmp(strmap_get(thread_test_strmap_, "thread 2"),
|
||||||
strmap_get(thread_test_strmap_, "last to run")));
|
strmap_get(thread_test_strmap_, "last to run")));
|
||||||
|
|
||||||
tt_int_op(thread_fns_failed, ==, 0);
|
tt_int_op(thread_fns_failed, OP_EQ, 0);
|
||||||
tt_int_op(thread_fn_tid1, !=, thread_fn_tid2);
|
tt_int_op(thread_fn_tid1, OP_NE, thread_fn_tid2);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(s1);
|
tor_free(s1);
|
||||||
@ -275,14 +275,14 @@ test_threads_conditionvar(void *arg)
|
|||||||
SPIN();
|
SPIN();
|
||||||
tor_mutex_release(ti->mutex);
|
tor_mutex_release(ti->mutex);
|
||||||
|
|
||||||
tt_int_op(ti->value, ==, 1337);
|
tt_int_op(ti->value, OP_EQ, 1337);
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
tt_int_op(ti->n_shutdown, ==, 4);
|
tt_int_op(ti->n_shutdown, OP_EQ, 4);
|
||||||
} else {
|
} else {
|
||||||
tor_sleep_msec(200);
|
tor_sleep_msec(200);
|
||||||
tor_mutex_acquire(ti->mutex);
|
tor_mutex_acquire(ti->mutex);
|
||||||
tt_int_op(ti->n_shutdown, ==, 2);
|
tt_int_op(ti->n_shutdown, OP_EQ, 2);
|
||||||
tt_int_op(ti->n_timeouts, ==, 2);
|
tt_int_op(ti->n_timeouts, OP_EQ, 2);
|
||||||
tor_mutex_release(ti->mutex);
|
tor_mutex_release(ti->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4492,11 +4492,11 @@ test_util_di_map(void *arg)
|
|||||||
|
|
||||||
char dflt_entry[] = "'You have made a good beginning', but no more";
|
char dflt_entry[] = "'You have made a good beginning', but no more";
|
||||||
|
|
||||||
tt_int_op(32, ==, sizeof(key1));
|
tt_int_op(32, OP_EQ, sizeof(key1));
|
||||||
tt_int_op(32, ==, sizeof(key2));
|
tt_int_op(32, OP_EQ, sizeof(key2));
|
||||||
tt_int_op(32, ==, sizeof(key3));
|
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"
|
char *str1 = tor_strdup("You are precisely as big as what you love"
|
||||||
" and precisely as small as what you allow"
|
" 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, key2, str2);
|
||||||
dimap_add_entry(&dimap, key3, str3);
|
dimap_add_entry(&dimap, key3, str3);
|
||||||
|
|
||||||
tt_ptr_op(str1, ==, dimap_search(dimap, key1, dflt_entry));
|
tt_ptr_op(str1, OP_EQ, dimap_search(dimap, key1, dflt_entry));
|
||||||
tt_ptr_op(str3, ==, dimap_search(dimap, key3, dflt_entry));
|
tt_ptr_op(str3, OP_EQ, dimap_search(dimap, key3, dflt_entry));
|
||||||
tt_ptr_op(str2, ==, dimap_search(dimap, key2, dflt_entry));
|
tt_ptr_op(str2, OP_EQ, dimap_search(dimap, key2, dflt_entry));
|
||||||
tt_ptr_op(dflt_entry, ==, dimap_search(dimap, key4, dflt_entry));
|
tt_ptr_op(dflt_entry, OP_EQ, dimap_search(dimap, key4, dflt_entry));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
dimap_free(dimap, tor_free_);
|
dimap_free(dimap, tor_free_);
|
||||||
@ -4984,34 +4984,34 @@ test_util_round_to_next_multiple_of(void *arg)
|
|||||||
{
|
{
|
||||||
(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,1), OP_EQ, 0);
|
||||||
tt_u64_op(round_uint64_to_next_multiple_of(0,7), ==, 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,1), OP_EQ, 99);
|
||||||
tt_u64_op(round_uint64_to_next_multiple_of(99,7), ==, 105);
|
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), ==, 99);
|
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);
|
UINT64_MAX);
|
||||||
|
|
||||||
tt_int_op(round_uint32_to_next_multiple_of(0,1), ==, 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), ==, 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,1), OP_EQ, 99);
|
||||||
tt_int_op(round_uint32_to_next_multiple_of(99,7), ==, 105);
|
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), ==, 99);
|
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);
|
UINT32_MAX);
|
||||||
|
|
||||||
tt_uint_op(round_to_next_multiple_of(0,1), ==, 0);
|
tt_uint_op(round_to_next_multiple_of(0,1), OP_EQ, 0);
|
||||||
tt_uint_op(round_to_next_multiple_of(0,7), ==, 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,1), OP_EQ, 99);
|
||||||
tt_uint_op(round_to_next_multiple_of(99,7), ==, 105);
|
tt_uint_op(round_to_next_multiple_of(99,7), OP_EQ, 105);
|
||||||
tt_uint_op(round_to_next_multiple_of(99,9), ==, 99);
|
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);
|
UINT_MAX);
|
||||||
done:
|
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 */
|
const double delta_f = 15.0, epsilon = 0.3; /* b = 15.0 / 0.3 = 50.0 */
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_i64_op(INT64_MIN, ==, sample_laplace_distribution(mu, b, 0.0));
|
tt_i64_op(INT64_MIN, OP_EQ, sample_laplace_distribution(mu, b, 0.0));
|
||||||
tt_i64_op(-69, ==, sample_laplace_distribution(mu, b, 0.01));
|
tt_i64_op(-69, OP_EQ, sample_laplace_distribution(mu, b, 0.01));
|
||||||
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.5));
|
tt_i64_op(24, OP_EQ, sample_laplace_distribution(mu, b, 0.5));
|
||||||
tt_i64_op(24, ==, sample_laplace_distribution(mu, b, 0.51));
|
tt_i64_op(24, OP_EQ, sample_laplace_distribution(mu, b, 0.51));
|
||||||
tt_i64_op(117, ==, sample_laplace_distribution(mu, b, 0.99));
|
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],
|
/* >>> laplace.ppf([0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99],
|
||||||
* ... loc = 0, scale = 50)
|
* ... loc = 0, scale = 50)
|
||||||
* array([ -inf, -80.47189562, -34.65735903, 0. ,
|
* array([ -inf, -80.47189562, -34.65735903, 0. ,
|
||||||
* 34.65735903, 80.47189562, 195.60115027])
|
* 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));
|
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(-60, OP_EQ, 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(-14, OP_EQ, 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(20, OP_EQ, 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(54, OP_EQ, 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(100, OP_EQ, 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(215, OP_EQ, add_laplace_noise(20, 0.99, delta_f, epsilon));
|
||||||
|
|
||||||
/* Test extreme values of signal with maximally negative values of noise
|
/* Test extreme values of signal with maximally negative values of noise
|
||||||
* 1.0000000000000002 is the smallest number > 1
|
* 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;
|
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));
|
add_laplace_noise(0, 0.0, noscale_df, noscale_eps));
|
||||||
|
|
||||||
/* is it clipped to INT64_MIN? */
|
/* 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));
|
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,
|
add_laplace_noise(INT64_MIN, 0.0,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
/* ... even when scaled? */
|
/* ... even when scaled? */
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
add_laplace_noise(0, 0.0, delta_f, epsilon));
|
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,
|
add_laplace_noise(0, 0.0,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
add_laplace_noise(INT64_MIN, 0.0,
|
add_laplace_noise(INT64_MIN, 0.0,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
|
|
||||||
/* does it play nice with INT64_MAX? */
|
/* 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,
|
add_laplace_noise(INT64_MAX, 0.0,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
|
|
||||||
/* do near-zero fractional values work? */
|
/* do near-zero fractional values work? */
|
||||||
const double min_dbl_error = 0.0000000000000002;
|
const double min_dbl_error = 0.0000000000000002;
|
||||||
|
|
||||||
tt_i64_op(-35, ==,
|
tt_i64_op(-35, OP_EQ,
|
||||||
add_laplace_noise(0, min_dbl_error,
|
add_laplace_noise(0, min_dbl_error,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
add_laplace_noise(INT64_MIN, min_dbl_error,
|
add_laplace_noise(INT64_MIN, min_dbl_error,
|
||||||
noscale_df, noscale_eps));
|
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,
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
add_laplace_noise(0, min_dbl_error,
|
add_laplace_noise(0, min_dbl_error,
|
||||||
DBL_MAX, 1));
|
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,
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
add_laplace_noise(INT64_MIN, min_dbl_error,
|
add_laplace_noise(INT64_MIN, min_dbl_error,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
|
|
||||||
/* does it play nice with INT64_MAX? */
|
/* 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,
|
add_laplace_noise(INT64_MAX, min_dbl_error,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
|
|
||||||
@ -5126,31 +5126,31 @@ test_util_laplace(void *arg)
|
|||||||
const double max_dbl_lt_one = 0.9999999999999998;
|
const double max_dbl_lt_one = 0.9999999999999998;
|
||||||
|
|
||||||
/* do near-one fractional values work? */
|
/* 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));
|
add_laplace_noise(0, max_dbl_lt_one, noscale_df, noscale_eps));
|
||||||
|
|
||||||
/* is it clipped to INT64_MAX? */
|
/* 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,
|
add_laplace_noise(INT64_MAX - 35, max_dbl_lt_one,
|
||||||
noscale_df, noscale_eps));
|
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,
|
add_laplace_noise(INT64_MAX - 34, max_dbl_lt_one,
|
||||||
noscale_df, noscale_eps));
|
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,
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
/* ... even when scaled? */
|
/* ... even when scaled? */
|
||||||
tt_i64_op(INT64_MAX, ==,
|
tt_i64_op(INT64_MAX, OP_EQ,
|
||||||
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
||||||
delta_f, epsilon));
|
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,
|
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
tt_i64_op(INT64_MAX, ==,
|
tt_i64_op(INT64_MAX, OP_EQ,
|
||||||
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
add_laplace_noise(INT64_MAX, max_dbl_lt_one,
|
||||||
DBL_MAX, 1));
|
DBL_MAX, 1));
|
||||||
/* does it play nice with INT64_MIN? */
|
/* 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,
|
add_laplace_noise(INT64_MIN, max_dbl_lt_one,
|
||||||
noscale_df, noscale_eps));
|
noscale_df, noscale_eps));
|
||||||
|
|
||||||
@ -5163,32 +5163,32 @@ test_util_clamp_double_to_int64(void *arg)
|
|||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
tt_i64_op(INT64_MIN, ==, clamp_double_to_int64(-INFINITY_DBL));
|
tt_i64_op(INT64_MIN, OP_EQ, clamp_double_to_int64(-INFINITY_DBL));
|
||||||
tt_i64_op(INT64_MIN, ==,
|
tt_i64_op(INT64_MIN, OP_EQ,
|
||||||
clamp_double_to_int64(-1.0 * pow(2.0, 64.0) - 1.0));
|
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));
|
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)));
|
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));
|
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(-1, OP_EQ, clamp_double_to_int64(-1.0));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(-0.9));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(-0.9));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(-0.1));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(-0.1));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(0.0));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.0));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(NAN_DBL));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(NAN_DBL));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(0.1));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.1));
|
||||||
tt_i64_op(0, ==, clamp_double_to_int64(0.9));
|
tt_i64_op(0, OP_EQ, clamp_double_to_int64(0.9));
|
||||||
tt_i64_op(1, ==, clamp_double_to_int64(1.0));
|
tt_i64_op(1, OP_EQ, clamp_double_to_int64(1.0));
|
||||||
tt_i64_op((((int64_t) 1) << 53) - 1, ==,
|
tt_i64_op((((int64_t) 1) << 53) - 1, OP_EQ,
|
||||||
clamp_double_to_int64(pow(2.0, 53.0) - 1.0));
|
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)));
|
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)));
|
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)));
|
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:
|
done:
|
||||||
;
|
;
|
||||||
|
@ -345,7 +345,7 @@ test_util_format_base32_decode(void *arg)
|
|||||||
const char *src = "mjwgc2dcnrswqmjs";
|
const char *src = "mjwgc2dcnrswqmjs";
|
||||||
|
|
||||||
ret = base32_decode(dst, strlen(expected), src, strlen(src));
|
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);
|
tt_str_op(expected, OP_EQ, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ test_util_format_base32_decode(void *arg)
|
|||||||
const char *src = "mjwgc2dcnrswq";
|
const char *src = "mjwgc2dcnrswq";
|
||||||
|
|
||||||
ret = base32_decode(dst, strlen(expected), src, strlen(src));
|
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));
|
tt_mem_op(expected, OP_EQ, dst, strlen(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,9 +364,9 @@ test_util_format_base32_decode(void *arg)
|
|||||||
{
|
{
|
||||||
/* Invalid character '#'. */
|
/* Invalid character '#'. */
|
||||||
ret = base32_decode(dst, real_dstlen, "#abcde", 6);
|
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. */
|
/* 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:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user