aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_entrynodes.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-07-16 22:37:00 +0200
committerNick Mathewson <nickm@torproject.org>2014-07-16 22:37:00 +0200
commit7259e3f6049c7a644cb1c797432d29b57a5c0589 (patch)
treece7331b7777fd460a516df5f83c788a60ebdc22e /src/test/test_entrynodes.c
parentfacecce176c8fe15653676557c6151c4ea1ca994 (diff)
downloadtor-7259e3f6049c7a644cb1c797432d29b57a5c0589.tar.gz
tor-7259e3f6049c7a644cb1c797432d29b57a5c0589.zip
Move test_descriptors.txt to an include file
Making the text file work out-of-tree didn't work on windows. Maybe we can get it working that way later.
Diffstat (limited to 'src/test/test_entrynodes.c')
-rw-r--r--src/test/test_entrynodes.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index 285a5ae0cf..ede93fb43a 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -18,6 +18,8 @@
#include "statefile.h"
#include "config.h"
+#include "test_descriptors.inc"
+
/* TODO:
* choose_random_entry() test with state set.
*
@@ -52,18 +54,13 @@ router_descriptor_is_older_than_replacement(const routerinfo_t *router,
routerlist. This function is used to setup an artificial network
so that we can conduct entry guard tests. */
static void
-setup_fake_routerlist(const char *fname)
+setup_fake_routerlist(void)
{
int retval;
- char *contents = NULL;
- struct stat st;
routerlist_t *our_routerlist = NULL;
smartlist_t *our_nodelist = NULL;
/* Read the file that contains our test descriptors. */
- test_assert(file_status(fname) == FN_FILE);
- contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
- test_assert(contents);
/* We need to mock this function otherwise the descriptors will not
accepted as they are too old. */
@@ -71,7 +68,8 @@ setup_fake_routerlist(const char *fname)
router_descriptor_is_older_than_replacement);
/* Load all the test descriptors to the routerlist. */
- retval = router_load_routers_from_string(contents, NULL, SAVED_IN_JOURNAL,
+ retval = router_load_routers_from_string(TEST_DESCRIPTORS,
+ NULL, SAVED_IN_JOURNAL,
NULL, 0, NULL);
tt_int_op(retval, ==, NUMBER_OF_DESCRIPTORS);
@@ -92,7 +90,6 @@ setup_fake_routerlist(const char *fname)
done:
UNMOCK(router_descriptor_is_older_than);
- tor_free(contents);
}
/* Unittest cleanup function: Cleanup the fake network. */
@@ -114,9 +111,6 @@ fake_network_cleanup(const struct testcase_t *testcase, void *ptr)
static void *
fake_network_setup(const struct testcase_t *testcase)
{
- /* This is the file containing our test descriptors. */
- const char *fname = TOP_SRCDIR "/src/test/test_descriptors.txt";
-
(void) testcase;
/* Setup fake state */
@@ -125,7 +119,7 @@ fake_network_setup(const struct testcase_t *testcase)
get_or_state_replacement);
/* Setup fake routerlist. */
- setup_fake_routerlist(fname);
+ setup_fake_routerlist();
/* Return anything but NULL (it's interpreted as test fail) */
return dummy_state;