diff options
Diffstat (limited to 'src/test/test_options.c')
-rw-r--r-- | src/test/test_options.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/test/test_options.c b/src/test/test_options.c index 119b2a54a4..b6a9a21501 100644 --- a/src/test/test_options.c +++ b/src/test/test_options.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001-2004, Roger Dingledine. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. - * Copyright (c) 2007-2019, The Tor Project, Inc. */ + * Copyright (c) 2007-2020, The Tor Project, Inc. */ /* See LICENSE for licensing information */ #define CONFIG_PRIVATE @@ -38,8 +38,6 @@ #include <sys/param.h> #endif -#define NS_MODULE test_options - typedef struct { int severity; log_domain_mask_t domain; @@ -1164,13 +1162,14 @@ test_options_validate__transproxy(void *ignored) tor_free(msg); } -NS_DECL(country_t, geoip_get_country, (const char *country)); +static country_t opt_tests_geoip_get_country(const char *country); +ATTR_UNUSED static int opt_tests_geoip_get_country_called = 0; static country_t -NS(geoip_get_country)(const char *countrycode) +opt_tests_geoip_get_country(const char *countrycode) { (void)countrycode; - CALLED(geoip_get_country)++; + opt_tests_geoip_get_country_called++; return 1; } @@ -1180,7 +1179,8 @@ test_options_validate__exclude_nodes(void *ignored) { (void)ignored; - NS_MOCK(geoip_get_country); + MOCK(geoip_get_country, + opt_tests_geoip_get_country); int ret; char *msg; @@ -1244,7 +1244,7 @@ test_options_validate__exclude_nodes(void *ignored) tor_free(msg); done: - NS_UNMOCK(geoip_get_country); + UNMOCK(geoip_get_country); teardown_capture_of_logs(); free_options_test_data(tdata); tor_free(msg); @@ -1749,7 +1749,8 @@ test_options_validate__use_bridges(void *ignored) " the Internet, so they must not set UseBridges."); tor_free(msg); - NS_MOCK(geoip_get_country); + MOCK(geoip_get_country, + opt_tests_geoip_get_country); free_options_test_data(tdata); tdata = get_options_test_data("UseBridges 1\n" "EntryNodes {cn}\n"); @@ -1792,7 +1793,7 @@ test_options_validate__use_bridges(void *ignored) tor_free(msg); done: - NS_UNMOCK(geoip_get_country); + UNMOCK(geoip_get_country); policies_free_all(); free_options_test_data(tdata); tor_free(msg); @@ -1804,7 +1805,8 @@ test_options_validate__entry_nodes(void *ignored) (void)ignored; int ret; char *msg; - NS_MOCK(geoip_get_country); + MOCK(geoip_get_country, + opt_tests_geoip_get_country); options_test_data_t *tdata = get_options_test_data( "EntryNodes {cn}\n" "UseEntryGuards 0\n"); @@ -1824,7 +1826,7 @@ test_options_validate__entry_nodes(void *ignored) tor_free(msg); done: - NS_UNMOCK(geoip_get_country); + UNMOCK(geoip_get_country); free_options_test_data(tdata); tor_free(msg); } @@ -1999,7 +2001,6 @@ test_options_validate__testing(void *ignored) ENSURE_DEFAULT(TestingV3AuthInitialDistDelay, 3000); ENSURE_DEFAULT(TestingV3AuthVotingStartOffset, 3000); ENSURE_DEFAULT(TestingAuthDirTimeToLearnReachability, 3000); - ENSURE_DEFAULT(TestingEstimatedDescriptorPropagationTime, 3000); ENSURE_DEFAULT(TestingServerDownloadInitialDelay, 3000); ENSURE_DEFAULT(TestingClientDownloadInitialDelay, 3000); ENSURE_DEFAULT(TestingServerConsensusDownloadInitialDelay, 3000); @@ -2806,7 +2807,7 @@ test_options_validate__proxy(void *ignored) ret = options_validate(NULL, tdata->opt, &msg); tt_int_op(ret, OP_EQ, -1); tt_str_op(msg, OP_EQ, "You have configured more than one proxy type. " - "(Socks4Proxy|Socks5Proxy|HTTPSProxy)"); + "(Socks4Proxy|Socks5Proxy|HTTPSProxy|TCPProxy)"); tor_free(msg); free_options_test_data(tdata); @@ -2814,9 +2815,10 @@ test_options_validate__proxy(void *ignored) mock_clean_saved_logs(); ret = options_validate(NULL, tdata->opt, &msg); tt_int_op(ret, OP_EQ, 0); - expect_log_msg("HTTPProxy configured, but no SOCKS " - "proxy or HTTPS proxy configured. Watch out: this configuration " - "will proxy unencrypted directory connections only.\n"); + expect_log_msg("HTTPProxy configured, but no SOCKS proxy, " + "HTTPS proxy, or any other TCP proxy configured. Watch out: " + "this configuration will proxy unencrypted directory " + "connections only.\n"); tor_free(msg); free_options_test_data(tdata); @@ -3866,22 +3868,16 @@ test_options_validate__testing_options(void *ignored) tor_free(msg); \ STMT_END - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601, - "must be non-negative.", ""); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601, "is way too low.", ""); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601, "is way too low.", ""); - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601, - "must be non-negative.", ENABLE_AUTHORITY_V3); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601, "is way too low.", ENABLE_AUTHORITY_V3); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601, "is way too low.", ENABLE_AUTHORITY_V3); - TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601, - "must be non-negative.", ENABLE_AUTHORITY_BRIDGE); TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601, "is way too low.", ENABLE_AUTHORITY_BRIDGE); TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601, |