diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-10-14 15:31:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-10-14 15:31:52 -0400 |
commit | 2dccef0eb490fa7d8fabc0d93e37d6635910f174 (patch) | |
tree | 65138098218cb4b11ffcbd3f6ac90501c45e2e99 /src/test | |
parent | 2c5c17510acf0cbd0eeb874a2f4c62203bf9392f (diff) | |
parent | 6925b61cfdf50a5686de02645b04b269c031f05d (diff) | |
download | tor-2dccef0eb490fa7d8fabc0d93e37d6635910f174.tar.gz tor-2dccef0eb490fa7d8fabc0d93e37d6635910f174.zip |
Merge branch 'bug27772_squashed'
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_hs_service.c | 1 | ||||
-rw-r--r-- | src/test/test_relaycell.c | 63 | ||||
-rw-r--r-- | src/test/test_routerset.c | 3 | ||||
-rw-r--r-- | src/test/test_storagedir.c | 2 | ||||
-rw-r--r-- | src/test/test_tortls.c | 1 |
5 files changed, 32 insertions, 38 deletions
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index 957bf6e103..7ef0fb6e07 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -537,6 +537,7 @@ test_load_keys_with_client_auth(void *arg) tt_int_op(get_hs_service_map_size(), OP_EQ, 1); service = get_first_service(); + tt_assert(service); tt_assert(service->config.clients); tt_int_op(smartlist_len(service->config.clients), OP_EQ, smartlist_len(pubkey_b32_list)); diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c index 0f72a575ab..3d3addfb9e 100644 --- a/src/test/test_relaycell.c +++ b/src/test/test_relaycell.c @@ -5,6 +5,9 @@ #define RELAY_PRIVATE #define CIRCUITLIST_PRIVATE +#define CONNECTION_EDGE_PRIVATE +#define CONNECTION_PRIVATE + #include "core/or/or.h" #include "core/mainloop/mainloop.h" #include "app/config/config.h" @@ -25,6 +28,9 @@ #include "core/or/socks_request_st.h" #include "core/or/half_edge_st.h" +#include "feature/client/circpathbias.h" +#include "core/or/connection_edge.h" + static int srm_ncalls; static entry_connection_t *srm_conn; static int srm_atype; @@ -34,23 +40,6 @@ static uint8_t srm_answer[512]; static int srm_ttl; static time_t srm_expires; -void connection_free_minimal(connection_t*); -int connected_cell_format_payload(uint8_t *payload_out, - const tor_addr_t *addr, - uint32_t ttl); -void pathbias_count_valid_cells(origin_circuit_t *circ, - cell_t *cell); -half_edge_t *connection_half_edge_find_stream_id( - const smartlist_t *half_conns, - streamid_t stream_id); -void connection_half_edge_add(const edge_connection_t *conn, - origin_circuit_t *circ); - -int mock_send_command(streamid_t stream_id, circuit_t *circ, - uint8_t relay_command, const char *payload, - size_t payload_len, crypt_path_t *cpath_layer, - const char *filename, int lineno); - /* Mock replacement for connection_ap_hannshake_socks_resolved() */ static void socks_resolved_mock(entry_connection_t *conn, @@ -150,7 +139,7 @@ mock_start_reading(connection_t *conn) return; } -int +static int mock_send_command(streamid_t stream_id, circuit_t *circ, uint8_t relay_command, const char *payload, size_t payload_len, crypt_path_t *cpath_layer, @@ -237,7 +226,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) /* Data cell not in the half-opened list */ PACK_CELL(4000, RELAY_COMMAND_DATA, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -246,7 +235,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) /* Sendme cell not in the half-opened list */ PACK_CELL(4000, RELAY_COMMAND_SENDME, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -255,7 +244,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) /* Connected cell not in the half-opened list */ PACK_CELL(4000, RELAY_COMMAND_CONNECTED, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -264,7 +253,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) /* Resolved cell not in the half-opened list */ PACK_CELL(4000, RELAY_COMMAND_RESOLVED, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -274,7 +263,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) edgeconn = ENTRY_TO_EDGE_CONN(entryconn2); PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -286,7 +275,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -297,7 +286,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -309,7 +298,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_SENDME, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -320,7 +309,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_SENDME, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -331,7 +320,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -341,7 +330,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -366,7 +355,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) connection_edge_reached_eof(edgeconn); PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -376,7 +365,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -387,7 +376,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -406,7 +395,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -426,7 +415,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_RESOLVED, "\x04\x04\x12\x00\x00\x01\x00\x00\x02\x00"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -445,7 +434,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn4)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -456,7 +445,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id) ENTRY_TO_CONN(entryconn4)->outbuf_flushlen = 0; PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234"); if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING) - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); else connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL, circ->cpath); @@ -877,7 +866,7 @@ test_circbw_relay(void *arg) /* Path bias: truncated */ tt_int_op(circ->base_.marked_for_close, OP_EQ, 0); PACK_CELL(0, RELAY_COMMAND_TRUNCATED, "Data1234"); - pathbias_count_valid_cells(circ, &cell); + pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell); tt_int_op(circ->base_.marked_for_close, OP_EQ, 1); done: diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c index a08adff466..86f9c0fa82 100644 --- a/src/test/test_routerset.c +++ b/src/test/test_routerset.c @@ -1496,6 +1496,7 @@ NS(test_main)(void *arg) int r; (void)arg; + memset(&NS(mock_node), 0, sizeof(NS(mock_node))); NS(mock_node).ri = NULL; NS(mock_node).rs = NULL; @@ -1529,6 +1530,7 @@ NS(test_main)(void *arg) strncpy(rs.nickname, nickname, sizeof(rs.nickname) - 1); rs.nickname[sizeof(rs.nickname) - 1] = '\0'; + memset(&NS(mock_node), 0, sizeof(NS(mock_node))); NS(mock_node).ri = NULL; NS(mock_node).rs = &rs; @@ -1560,6 +1562,7 @@ NS(test_main)(void *arg) strmap_set_lc(set->names, nickname, (void *)1); ri.nickname = (char *)nickname; + memset(&mock_node, 0, sizeof(mock_node)); mock_node.ri = &ri; mock_node.rs = NULL; diff --git a/src/test/test_storagedir.c b/src/test/test_storagedir.c index 68cee418ad..76aae7e033 100644 --- a/src/test/test_storagedir.c +++ b/src/test/test_storagedir.c @@ -283,7 +283,7 @@ test_storagedir_save_labeled(void *arg) int r = storage_dir_save_labeled_to_file(d, labels, inp, 8192, &fname); tt_int_op(r, OP_EQ, 0); - size_t n; + size_t n = 0; saved = storage_dir_read(d, fname, 1, &n); tt_assert(memchr(saved, '\0', n)); tt_str_op((char*)saved, OP_EQ, expected); /* NUL guarantees strcmp works */ diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c index f4315364a2..79b52437f8 100644 --- a/src/test/test_tortls.c +++ b/src/test/test_tortls.c @@ -238,6 +238,7 @@ test_tortls_x509_cert_get_id_digests(void *ignored) cert->pkey_digests_set = 1; cert->pkey_digests = *d; res = tor_x509_cert_get_id_digests(cert); + tt_assert(res); tt_int_op(res->d[0][0], OP_EQ, 42); done: |