mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Add a basic unit test for pt_get_extra_info_descriptor_string.
This commit is contained in:
parent
dd18789a9c
commit
e02b6b99f2
@ -1230,7 +1230,7 @@ create_managed_proxy_environment(const managed_proxy_t *mp)
|
||||
* <b>proxy_argv</b>.
|
||||
*
|
||||
* Requires that proxy_argv have at least one element. */
|
||||
static managed_proxy_t *
|
||||
STATIC managed_proxy_t *
|
||||
managed_proxy_create(const smartlist_t *transport_list,
|
||||
char **proxy_argv, int is_server)
|
||||
{
|
||||
|
@ -114,6 +114,9 @@ STATIC int parse_version(const char *line, managed_proxy_t *mp);
|
||||
STATIC void parse_env_error(const char *line);
|
||||
STATIC void handle_proxy_line(const char *line, managed_proxy_t *mp);
|
||||
|
||||
STATIC managed_proxy_t *managed_proxy_create(const smartlist_t *transport_list,
|
||||
char **proxy_argv, int is_server);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -169,12 +169,59 @@ test_pt_protocol(void)
|
||||
tor_free(mp);
|
||||
}
|
||||
|
||||
static void
|
||||
test_pt_get_extrainfo_string(void *arg)
|
||||
{
|
||||
managed_proxy_t *mp1 = NULL, *mp2 = NULL;
|
||||
char **argv1, **argv2;
|
||||
smartlist_t *t1 = smartlist_new(), *t2 = smartlist_new();
|
||||
int r;
|
||||
char *s = NULL;
|
||||
(void) arg;
|
||||
|
||||
argv1 = tor_malloc_zero(sizeof(char*)*3);
|
||||
argv1[0] = tor_strdup("ewige");
|
||||
argv1[1] = tor_strdup("Blumenkraft");
|
||||
argv1[2] = NULL;
|
||||
argv2 = tor_malloc_zero(sizeof(char*)*4);
|
||||
argv2[0] = tor_strdup("und");
|
||||
argv2[1] = tor_strdup("ewige");
|
||||
argv2[2] = tor_strdup("Schlangenkraft");
|
||||
argv2[3] = NULL;
|
||||
|
||||
mp1 = managed_proxy_create(t1, argv1, 1);
|
||||
mp2 = managed_proxy_create(t2, argv2, 1);
|
||||
|
||||
r = parse_smethod_line("SMETHOD hagbard 127.0.0.1:5555", mp1);
|
||||
tt_int_op(r, ==, 0);
|
||||
r = parse_smethod_line("SMETHOD celine 127.0.0.1:1723 ARGS:card=no-enemy",
|
||||
mp2);
|
||||
tt_int_op(r, ==, 0);
|
||||
|
||||
/* Force these proxies to look "completed" or they won't generate output. */
|
||||
mp1->conf_state = mp2->conf_state = PT_PROTO_COMPLETED;
|
||||
|
||||
s = pt_get_extra_info_descriptor_string();
|
||||
tt_assert(s);
|
||||
tt_str_op(s, ==,
|
||||
"transport hagbard 127.0.0.1:5555\n"
|
||||
"transport celine 127.0.0.1:1723 card=no-enemy\n");
|
||||
|
||||
done:
|
||||
/* XXXX clean up better */
|
||||
smartlist_free(t1);
|
||||
smartlist_free(t2);
|
||||
tor_free(s);
|
||||
}
|
||||
|
||||
#define PT_LEGACY(name) \
|
||||
{ #name, legacy_test_helper, 0, &legacy_setup, test_pt_ ## name }
|
||||
|
||||
struct testcase_t pt_tests[] = {
|
||||
PT_LEGACY(parsing),
|
||||
PT_LEGACY(protocol),
|
||||
{ "get_extrainfo_string", test_pt_get_extrainfo_string, TT_FORK,
|
||||
NULL, NULL },
|
||||
END_OF_TESTCASES
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user