Commit Graph

24796 Commits

Author SHA1 Message Date
Nick Mathewson 3656fdae98 test_options: remove def_opt member of test data. 2019-10-22 14:24:09 -04:00
Nick Mathewson 86a1d670ac test_options: remove "dflt" part of setup_options().
It is no longer used anywhere.
2019-10-22 14:24:09 -04:00
Nick Mathewson 475a1dc9be Remove a pair of now-unused default-options arguments. 2019-10-22 14:24:03 -04:00
Nick Mathewson 3dc0944acd test_options: Fix options_validate() calls in macros.
Coccinelle missed these.
2019-10-22 14:24:03 -04:00
Nick Mathewson 41e6e2f496 Use coccinelle to fix most options_validate() call sites.
There was one that it could not find because it was in a macro definition.

I used the following semantic patch:

@@
expression e1, e2, e3, e4, e5;
@@
 options_validate(e1,
 e2,
- e3,
- e4,
 e5)
2019-10-22 14:01:42 -04:00
Nick Mathewson 8a27023d21 Remove unused arguments from options_validate().
This change breaks compilation; a subsequent commit will fix it with
a coccinelle patch.
2019-10-22 13:56:11 -04:00
Nick Mathewson 697d99e504 validate_fn(): remove now-unused defaults and from_setconf.
These arguments were only used by options_validate, and are now
ignored even there.
2019-10-22 13:52:40 -04:00
Nick Mathewson 7d75e1dbdf Merge remote-tracking branch 'tor-github/pr/1446' 2019-10-22 12:52:32 -04:00
Nick Mathewson 2d013bbe5c Merge remote-tracking branch 'tor-github/pr/1417' 2019-10-22 08:36:32 -04:00
Nick Mathewson 4413b030f2 Simplify CHECK_DEFAULT() logic a little further.
Since each of these tests only applies to testing networks, put them
all into a single block that checks for testing networks.

(I recommend reviewing with the "diff -b" option, since the change
is mostly indentation.)
2019-10-22 08:32:33 -04:00
Nick Mathewson 8d84e10e87 Make options_validate() no longer use its "defaults" argument.
It can just look at what the defaults are.

Closes ticket 32185.
2019-10-22 08:30:00 -04:00
Nick Mathewson a1d5341374 Merge branch 'bug32175' 2019-10-22 07:51:30 -04:00
Nick Mathewson 65e80ce646 Merge branch 'from_setconf_removal_squashed' 2019-10-22 07:50:42 -04:00
Nick Mathewson 6d15fab2dc Extract log-granularity code into its own function.
This pleases practracker.
2019-10-22 07:50:13 -04:00
Nick Mathewson 9ac2c71cbd Add tests for options_init_logs() 2019-10-22 07:50:13 -04:00
Nick Mathewson f4fc633937 Make a pair of add_*_log() functions mockable. 2019-10-22 07:50:13 -04:00
Nick Mathewson ac3136a6fb Make options_init_logs STATIC for testing. 2019-10-22 07:50:13 -04:00
Nick Mathewson 98c3b3bb4c Update tests to handle new interpretation of quiet_level.
Two things needed to be changed.  First, we used to set quiet_level
to the default (QUIET_NONE) when running tests, since we would not
call anything that acted based upon it.  But since we sometimes call
options_init_logs(), we need to pre-set quiet_level to QUIET_SILENT
in the logs so that we don't add the default logs.  This did not
cause test failure: just unwanted logs.

Second, we had a test that checked whether options_validate was
messing with options->Logs correctly.  Since options_validate no
longer messes with the logs, we no longer want a test for this.
2019-10-22 07:50:13 -04:00
Nick Mathewson e07b19d305 Rationalize handling of quiet_level in config.c
Formerly, we would use quiet_level as an excuse to rewrite the log
configuration, adding a default log line if none existed, and if
RunAsDaemon was not set, and if we were not being invoked via
setconf (!).

This is against our best practices for several reasons:
  * We should not be changing configured options except when the
    user tells us to do so.
  * We should especially not be changing options in the options_validate
    function.
  * Distinguishing whether we are being called from setconf adds a
    risky special-case.

Instead, this patch take a simpler approach: it changes the
interpretation of having no logging lines set to mean: If there is a
stdout, add a default log based on quiet_level.

Solves ticket 31999.
2019-10-22 07:50:13 -04:00
Nick Mathewson cb13930f2b Fix a memory leak introduced by the changes to test_options.c
Since this code passes the same options to options_validate() more
than once, options_validate() needs to be prepared for that.  (This
previously worked by accident, since the smartlist of schedulers
wasn't initialized.)
2019-10-21 18:28:53 -04:00
Nick Mathewson bd518b9ab1 Fix a memory leak introduced by changes to test_options.c
Since the FirewallPorts smartlist is now initialized, we can't just
overwrite it.
2019-10-21 18:28:08 -04:00
Nick Mathewson 5e2ffd6fd7 Fix up some Windows CI issues. 2019-10-21 15:31:56 -04:00
Nick Mathewson 171a741901 test_options.c: Remove TEST_OPTIONS_DEFAULT_VALUES
This finally became the empty string, since we no longer have to do
anything in individual test_options.c tests to make "" be a valid
set of options.  Now we can remove it at last.
2019-10-21 14:41:27 -04:00
Nick Mathewson 8a8d748837 Stop overriding ConnLimit in tests.
Now that ConnLimit is set to the default value in the
testing helper functions, the individual tests don't all need to
make sure it is set to something valid.
2019-10-21 14:27:55 -04:00
Nick Mathewson 56dddcbbcc test_options.c: remove weird usage of ConnLimit
Several of our tests assumed that ConnLimit would be set to 0 by
default, causing the default options not to be parseable.  These
tests had nothing to do with ConnLimit.
2019-10-21 14:24:58 -04:00
Nick Mathewson 78bf011663 Stop overriding MaxClientCircuitsPending in tests.
Now that MaxClientCircuitsPending is set to the default value in the
testing helper functions, the individual tests don't all need to
make sure it is set to something valid.
2019-10-21 14:19:19 -04:00
Nick Mathewson b501cd907f test_options.c: remove weird usage of MaxClientCircuitsPending
Several of our tests assumed that MaxClientCircuitsPending would be
set to 0 by default, causing the default options not to be
parseable.  These tests had nothing to do with
MaxClientCircuitsPending.
2019-10-21 14:16:59 -04:00
Nick Mathewson b6efe37661 Stop overriding KeepalivePeriod in tests.
Now that KeepalivePeriod is set to the default value in the testing
helper functions, the individual tests don't all need to make sure
it is set to something valid.
2019-10-21 14:14:49 -04:00
Nick Mathewson 79cd591228 test_options.c: remove weird usage of KeepalivePeriod.
Several of our tests assumed that KeepalivePeriod would be set to 0
by default, causing the default options not to be parseable.  These
tests had nothing to do with KeepalivePeriod.
2019-10-21 14:12:59 -04:00
Nick Mathewson 3f9920975f Remove a lot of cruft from TEST_OPTIONS_DEFAULT_VALUES.
This macro used to have a big list of "default" values that we
needed to set in the test_options tests in order to have reasonable
behavior.  But now that we initialize options objects to the default
settings in these tests, we no longer need such a long list of
things to replace.
2019-10-21 14:12:59 -04:00
Nick Mathewson a10e4d737e test_options: use testing options with (almost) real defaults.
Previously, we just used options set to all 0s, but this causes some
pretty severe workarounds throughout the code, as our options fail
to validate, or count as "default" for the wrong reasons.

Note that in some places, we stop getting spurious warnings or
failures which the tests previously demanded.  In these cases, I've
changed the test behavior.

Fixes 32175.
2019-10-21 14:12:59 -04:00
Nick Mathewson 8378ad29e6 routermode.h: turn a comment into a doxygen comment. 2019-10-21 12:47:17 -04:00
Nick Mathewson 7dc78aca29 Merge remote-tracking branch 'tor-github/pr/1430' 2019-10-21 12:43:26 -04:00
teor 7a72e71f74 Merge remote-tracking branch 'tor-github/pr/1434' 2019-10-21 15:24:22 +10:00
teor 4fde7699ee test/getinfo: Remove unnecessary test code
Fix for 31684.
2019-10-21 14:21:41 +10:00
teor 92fa5239fc control/getinfo: Use standard error handling
Use BUG() for coding errors, and `< 0` for error checks.

Fix to 31684.
2019-10-21 13:57:02 +10:00
teor 3b2525c375 Fix changes file and string typos
Part of 31684.
2019-10-21 13:56:58 +10:00
AmreshVenugopal 6413b2102f control: Add GETINFO support for dumping microdesc consensus
- Allows control port to read microdesc consensus using:
GETINFO dir/status-vote/microdesc/consensus

add: Helper function `getinfo_helper_current_consensus`
test: check if GETINFO commands return expected consensus data.

Resolves 31684.
2019-10-21 13:54:55 +10:00
teor 77c85360f6 Merge branch 'maint-0.4.2' 2019-10-21 13:28:04 +10:00
teor 3539fdfd7a Merge remote-tracking branch 'tor-github/pr/1168' 2019-10-21 13:09:48 +10:00
teor 04e9e74f1d Merge remote-tracking branch 'tor-github/pr/1422' into maint-0.4.2 2019-10-21 13:07:39 +10:00
teor a1f73cb93d Merge branch 'maint-0.4.2' 2019-10-21 09:45:34 +10:00
teor 5dbdca0114 Merge remote-tracking branch 'tor-github/pr/1432' into maint-0.4.2 2019-10-21 09:45:18 +10:00
teor 5c8ecf364a Merge remote-tracking branch 'tor-github/pr/1354' into maint-0.4.2 2019-10-21 09:44:42 +10:00
teor 042116e1fd Merge branch 'maint-0.4.2' 2019-10-20 22:09:00 +10:00
teor 02e3e8eda5 hibernate: Fix repeated "bytes" in comment 2019-10-20 22:08:23 +10:00
teor 475dffee42 dirauth: Add a macro comment to have_module_dirauth() 2019-10-20 20:26:12 +10:00
teor b266a804e9 test/parseconf: Add basic dirauth and bridgeauth tests
Part of 32123.
2019-10-20 20:25:58 +10:00
teor 0501ce9f13 test/parseconf: Expect different outputs when relay mode is disabled
Part of 32123.
2019-10-20 20:25:54 +10:00
teor cf2b00d3f5 test/rebind: Make control formatting and log parsing more robust
* actually sleep when tor has not logged anything
* log at debug level when waiting for tor to log something
* backslash-replace bad UTF-8 characters in logs
* format control messages as ASCII: tor does not accept UTF-8 control commands

Fixes bug 31837; bugfix on 0.3.5.1-alpha.
2019-10-20 20:09:35 +10:00