summaryrefslogtreecommitdiff
path: root/src/test/test_options.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-08 15:01:32 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-08 15:03:11 -0400
commitdeb294ff532d074a7d4094518c296fe69f819874 (patch)
tree3a49b6c30ab041807a025fa463ff57ca328165db /src/test/test_options.c
parentb0a9e54705d16d08ae7aff272492832dbb35646d (diff)
downloadtor-deb294ff532d074a7d4094518c296fe69f819874.tar.gz
tor-deb294ff532d074a7d4094518c296fe69f819874.zip
Simplify log_test_helpers interface
Previously, you needed to store the previous log severity in a local variable, and it wasn't clear if you were allowed to call these functions more than once.
Diffstat (limited to 'src/test/test_options.c')
-rw-r--r--src/test/test_options.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 2748f42958..0451b93738 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -401,7 +401,7 @@ test_options_validate__uname_for_server(void *ignored)
char *msg;
options_test_data_t *tdata = get_options_test_data(
"ORListenAddress 127.0.0.1:5555");
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
MOCK(get_uname, fixed_get_uname);
fixed_get_uname_result = "Windows 95";
@@ -437,7 +437,7 @@ test_options_validate__uname_for_server(void *ignored)
UNMOCK(get_uname);
free_options_test_data(tdata);
tor_free(msg);
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
}
static void
@@ -535,7 +535,7 @@ test_options_validate__contactinfo(void *ignored)
char *msg;
options_test_data_t *tdata = get_options_test_data(
"ORListenAddress 127.0.0.1:5555\nORPort 955");
- int previous_log = setup_capture_of_logs(LOG_DEBUG);
+ setup_capture_of_logs(LOG_DEBUG);
tdata->opt->ContactInfo = NULL;
ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg);
@@ -559,7 +559,7 @@ test_options_validate__contactinfo(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -647,7 +647,7 @@ test_options_validate__authdir(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_INFO);
+ setup_capture_of_logs(LOG_INFO);
options_test_data_t *tdata = get_options_test_data(
"AuthoritativeDirectory 1\n"
"Address this.should.not_exist.example.org");
@@ -940,7 +940,7 @@ test_options_validate__authdir(void *ignored)
/* "but ClientOnly also set."); */
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
// sandbox_free_getaddrinfo_cache();
free_options_test_data(tdata);
tor_free(msg);
@@ -951,7 +951,7 @@ test_options_validate__relay_with_hidden_services(void *ignored)
{
(void)ignored;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_DEBUG);
+ setup_capture_of_logs(LOG_DEBUG);
options_test_data_t *tdata = get_options_test_data(
"ORListenAddress 127.0.0.1:5555\n"
"ORPort 955\n"
@@ -968,7 +968,7 @@ test_options_validate__relay_with_hidden_services(void *ignored)
"https://trac.torproject.org/8742\n");
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -981,7 +981,7 @@ test_options_validate__relay_with_hidden_services(void *ignored)
/* (void)ignored; */
/* int ret; */
/* char *msg; */
-/* int previous_log = setup_capture_of_logs(LOG_WARN); */
+/* setup_capture_of_logs(LOG_WARN); */
/* options_test_data_t *tdata = get_options_test_data(""); */
/* ret = options_validate(tdata->old_opt, tdata->opt, */
/* tdata->def_opt, 0, &msg); */
@@ -990,7 +990,7 @@ test_options_validate__relay_with_hidden_services(void *ignored)
/* "configured. " */
/* " Tor will still run, but probably won't do anything.\n"); */
/* done: */
-/* teardown_capture_of_logs(previous_log); */
+/* teardown_capture_of_logs(); */
/* free_options_test_data(tdata); */
/* tor_free(msg); */
/* } */
@@ -1131,7 +1131,7 @@ test_options_validate__exclude_nodes(void *ignored)
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
"ExcludeExitNodes {us}\n");
@@ -1196,7 +1196,7 @@ test_options_validate__exclude_nodes(void *ignored)
done:
NS_UNMOCK(geoip_get_country);
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -1207,7 +1207,7 @@ test_options_validate__scheduler(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_DEBUG);
+ setup_capture_of_logs(LOG_DEBUG);
options_test_data_t *tdata = get_options_test_data(
"SchedulerLowWaterMark__ 0\n");
@@ -1239,7 +1239,7 @@ test_options_validate__scheduler(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -1302,7 +1302,7 @@ test_options_validate__tlsec(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_DEBUG);
+ setup_capture_of_logs(LOG_DEBUG);
options_test_data_t *tdata = get_options_test_data(
"TLSECGroup ed25519\n"
"SchedulerHighWaterMark__ 42\n"
@@ -1339,7 +1339,7 @@ test_options_validate__tlsec(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -1377,7 +1377,7 @@ test_options_validate__recommended_packages(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
"RecommendedPackages foo 1.2 http://foo.com sha1=123123123123\n"
"RecommendedPackages invalid-package-line\n"
@@ -1391,7 +1391,7 @@ test_options_validate__recommended_packages(void *ignored)
done:
escaped(NULL); // This will free the leaking memory from the previous escaped
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -1469,7 +1469,7 @@ test_options_validate__paths_needed(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
"PathsNeededToBuildCircuits 0.1\n"
"ConnLimit 1\n"
@@ -1514,7 +1514,7 @@ test_options_validate__paths_needed(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -1651,7 +1651,7 @@ test_options_validate__reachable_addresses(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_NOTICE);
+ setup_capture_of_logs(LOG_NOTICE);
options_test_data_t *tdata = get_options_test_data(
"FascistFirewall 1\n"
"MaxClientCircuitsPending 1\n"
@@ -1865,7 +1865,7 @@ test_options_validate__reachable_addresses(void *ignored)
tt_ptr_op(msg, OP_EQ, NULL);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -2115,7 +2115,7 @@ test_options_validate__publish_server_descriptor(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
"PublishServerDescriptor bridge\n" TEST_OPTIONS_DEFAULT_VALUES
);
@@ -2179,7 +2179,7 @@ test_options_validate__publish_server_descriptor(void *ignored)
tt_assert(!tdata->opt->DirPort_set);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -2266,7 +2266,7 @@ test_options_validate__hidserv(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
TEST_OPTIONS_DEFAULT_VALUES);
@@ -2301,7 +2301,7 @@ test_options_validate__hidserv(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -2313,7 +2313,7 @@ test_options_validate__predicted_ports(void *ignored)
(void)ignored;
int ret;
char *msg;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
options_test_data_t *tdata = get_options_test_data(
"PredictedPortsRelevanceTime 100000000\n"
@@ -2325,7 +2325,7 @@ test_options_validate__predicted_ports(void *ignored)
tt_int_op(tdata->opt->PredictedPortsRelevanceTime, OP_EQ, 3600);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -2539,7 +2539,7 @@ test_options_validate__circuits(void *ignored)
(void)ignored;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -2616,7 +2616,7 @@ test_options_validate__circuits(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -2689,7 +2689,7 @@ test_options_validate__rend(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -2744,7 +2744,7 @@ test_options_validate__rend(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -2756,7 +2756,7 @@ test_options_validate__accounting(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -2861,7 +2861,7 @@ test_options_validate__accounting(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -2875,7 +2875,7 @@ test_options_validate__proxy(void *ignored)
char *msg;
options_test_data_t *tdata = NULL;
sandbox_disable_getaddrinfo_cache();
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3191,7 +3191,7 @@ test_options_validate__proxy(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
policies_free_all();
// sandbox_free_getaddrinfo_cache();
@@ -3205,7 +3205,7 @@ test_options_validate__control(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3419,7 +3419,7 @@ test_options_validate__control(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -3432,7 +3432,7 @@ test_options_validate__families(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3491,7 +3491,7 @@ test_options_validate__families(void *ignored)
tor_free(msg);
done:
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
policies_free_all();
free_options_test_data(tdata);
tor_free(msg);
@@ -3528,7 +3528,7 @@ test_options_validate__dir_auth(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3603,7 +3603,7 @@ test_options_validate__dir_auth(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -3615,7 +3615,7 @@ test_options_validate__transport(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_NOTICE);
+ setup_capture_of_logs(LOG_NOTICE);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3728,7 +3728,7 @@ test_options_validate__transport(void *ignored)
done:
escaped(NULL); // This will free the leaking memory from the previous escaped
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -3740,7 +3740,7 @@ test_options_validate__constrained_sockets(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -3811,7 +3811,7 @@ test_options_validate__constrained_sockets(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -3823,7 +3823,7 @@ test_options_validate__v3_auth(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -4030,7 +4030,7 @@ test_options_validate__v3_auth(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -4075,7 +4075,7 @@ test_options_validate__exits(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
free_options_test_data(tdata);
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
@@ -4105,7 +4105,7 @@ test_options_validate__exits(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}
@@ -4117,7 +4117,7 @@ test_options_validate__testing_options(void *ignored)
int ret;
char *msg;
options_test_data_t *tdata = NULL;
- int previous_log = setup_capture_of_logs(LOG_WARN);
+ setup_capture_of_logs(LOG_WARN);
#define TEST_TESTING_OPTION(name, low_val, high_val, err_low) \
STMT_BEGIN \
@@ -4273,7 +4273,7 @@ test_options_validate__testing_options(void *ignored)
done:
policies_free_all();
- teardown_capture_of_logs(previous_log);
+ teardown_capture_of_logs();
free_options_test_data(tdata);
tor_free(msg);
}