Unit tests for router download functions.

Also, sort test suites alphabetically.
This commit is contained in:
Arlo Breault 2014-09-23 12:22:36 -04:00 committed by Nick Mathewson
parent 5ed5ac185b
commit bb137e23c1
4 changed files with 48 additions and 19 deletions

View File

@ -22,6 +22,7 @@ src_test_test_SOURCES = \
src/test/test_cell_formats.c \
src/test/test_circuitlist.c \
src/test/test_circuitmux.c \
src/test/test_config.c \
src/test/test_containers.c \
src/test/test_controller_events.c \
src/test/test_crypto.c \
@ -29,19 +30,19 @@ src_test_test_SOURCES = \
src/test/test_data.c \
src/test/test_dir.c \
src/test/test_extorport.c \
src/test/test_hs.c \
src/test/test_introduce.c \
src/test/test_logging.c \
src/test/test_microdesc.c \
src/test/test_nodelist.c \
src/test/test_oom.c \
src/test/test_options.c \
src/test/test_pt.c \
src/test/test_replay.c \
src/test/test_routerkeys.c \
src/test/test_routerlist.c \
src/test/test_socks.c \
src/test/test_util.c \
src/test/test_config.c \
src/test/test_hs.c \
src/test/test_nodelist.c \
src/ext/tinytest.c
src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

View File

@ -1637,33 +1637,35 @@ extern struct testcase_t hs_tests[];
extern struct testcase_t nodelist_tests[];
extern struct testcase_t routerkeys_tests[];
extern struct testcase_t oom_tests[];
extern struct testcase_t routerlist_tests[];
static struct testgroup_t testgroups[] = {
{ "", test_array },
{ "buffer/", buffer_tests },
{ "socks/", socks_tests },
{ "addr/", addr_tests },
{ "crypto/", crypto_tests },
{ "container/", container_tests },
{ "util/", util_tests },
{ "util/logging/", logging_tests },
{ "buffer/", buffer_tests },
{ "cellfmt/", cell_format_tests },
{ "cellqueue/", cell_queue_tests },
{ "dir/", dir_tests },
{ "dir/md/", microdesc_tests },
{ "pt/", pt_tests },
{ "config/", config_tests },
{ "replaycache/", replaycache_tests },
{ "introduce/", introduce_tests },
{ "circuitlist/", circuitlist_tests },
{ "circuitmux/", circuitmux_tests },
{ "options/", options_tests },
{ "extorport/", extorport_tests },
{ "config/", config_tests },
{ "container/", container_tests },
{ "control/", controller_event_tests },
{ "crypto/", crypto_tests },
{ "dir/", dir_tests },
{ "dir/md/", microdesc_tests },
{ "extorport/", extorport_tests },
{ "hs/", hs_tests },
{ "introduce/", introduce_tests },
{ "nodelist/", nodelist_tests },
{ "routerkeys/", routerkeys_tests },
{ "oom/", oom_tests },
{ "options/", options_tests },
{ "pt/", pt_tests },
{ "routerkeys/", routerkeys_tests },
{ "routerlist/", routerlist_tests },
{ "replaycache/", replaycache_tests },
{ "socks/", socks_tests },
{ "util/", util_tests },
{ "util/logging/", logging_tests },
END_OF_GROUPS
};

View File

@ -2357,6 +2357,30 @@ test_dir_http_handling(void *args)
tor_free(url);
}
static void
test_dir_purpose_needs_anonymity(void *arg)
{
(void)arg;
tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE));
tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_GENERAL));
tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC,
ROUTER_PURPOSE_GENERAL));
done: ;
}
static void
test_dir_fetch_type(void *arg)
{
(void)arg;
test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_MICRODESC, ROUTER_PURPOSE_GENERAL,
NULL), MICRODESC_DIRINFO);
test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_SERVERDESC, ROUTER_PURPOSE_BRIDGE,
NULL), BRIDGE_DIRINFO);
test_eq(dir_fetch_type(DIR_PURPOSE_FETCH_CONSENSUS, ROUTER_PURPOSE_GENERAL,
"microdesc"), V3_DIRINFO | MICRODESC_DIRINFO);
done: ;
}
#define DIR_LEGACY(name) \
{ #name, legacy_test_helper, TT_FORK, &legacy_setup, test_dir_ ## name }
@ -2379,6 +2403,8 @@ struct testcase_t dir_tests[] = {
DIR_LEGACY(clip_unmeasured_bw_kb_alt),
DIR(fmt_control_ns, 0),
DIR(http_handling, 0),
DIR(purpose_needs_anonymity, 0),
DIR(fetch_type, 0),
END_OF_TESTCASES
};

View File

@ -10,7 +10,7 @@
#include "nodelist.h"
#include "test.h"
/** Tese the case when node_get_by_id() returns NULL,
/** Test the case when node_get_by_id() returns NULL,
* node_get_verbose_nickname_by_id should return the base 16 encoding
* of the id.
*/