diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-18 14:38:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-07-18 14:40:12 -0400 |
commit | f45e1fbd5b25735c75bed8767d9d50e279c4b63a (patch) | |
tree | ed755a43790fa2b93ee0f932e00fc81fc82197c4 /src/or | |
parent | abedd35de08f2a2bd91d9d17e2f3cfd3b42ba52a (diff) | |
download | tor-f45e1fbd5b25735c75bed8767d9d50e279c4b63a.tar.gz tor-f45e1fbd5b25735c75bed8767d9d50e279c4b63a.zip |
Start of a unit test for options_validate.
I added this so I could write a unit test for ServerTransportOptions,
but it incidentally exercises the succeed-on-defaults case of
options_validate too.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 11 | ||||
-rw-r--r-- | src/or/config.h | 12 | ||||
-rw-r--r-- | src/or/confparse.h | 2 |
3 files changed, 17 insertions, 8 deletions
diff --git a/src/or/config.c b/src/or/config.c index 4ddced8a68..2218e5078b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -9,6 +9,7 @@ * \brief Code to parse and interpret configuration files. **/ +#define CONFIG_PRIVATE #include "or.h" #include "addressmap.h" #include "channel.h" @@ -509,10 +510,6 @@ static const config_var_t testing_tor_network_defaults[] = { #ifdef _WIN32 static char *get_windows_conf_root(void); #endif -static int options_validate(or_options_t *old_options, - or_options_t *options, - or_options_t *default_options, - int from_setconf, char **msg); static int options_act_reversible(const or_options_t *old_options, char **msg); static int options_act(const or_options_t *old_options); static int options_transition_allowed(const or_options_t *old, @@ -556,7 +553,7 @@ static void config_maybe_load_geoip_files_(const or_options_t *options, #define OR_OPTIONS_MAGIC 9090909 /** Configuration format for or_options_t. */ -static config_format_t options_format = { +STATIC config_format_t options_format = { sizeof(or_options_t), OR_OPTIONS_MAGIC, STRUCT_OFFSET(or_options_t, magic_), @@ -712,7 +709,7 @@ get_short_version(void) /** Release additional memory allocated in options */ -static void +STATIC void or_options_free(or_options_t *options) { if (!options) @@ -2349,7 +2346,7 @@ compute_publishserverdescriptor(or_options_t *options) * Log line should stay empty. If it's 0, then give us a default log * if there are no logs defined. */ -static int +STATIC int options_validate(or_options_t *old_options, or_options_t *options, or_options_t *default_options, int from_setconf, char **msg) { diff --git a/src/or/config.h b/src/or/config.h index 9910f18736..16a8a350d5 100644 --- a/src/or/config.h +++ b/src/or/config.h @@ -116,5 +116,17 @@ smartlist_t *get_options_from_transport_options_line(const char *line, const char *transport); smartlist_t *get_options_for_server_transport(const char *transport); +#ifdef CONFIG_PRIVATE +#ifdef TOR_UNIT_TESTS +extern struct config_format_t options_format; +#endif + +STATIC void or_options_free(or_options_t *options); +STATIC int options_validate(or_options_t *old_options, + or_options_t *options, + or_options_t *default_options, + int from_setconf, char **msg); +#endif + #endif diff --git a/src/or/confparse.h b/src/or/confparse.h index d82e1096ca..924ee0d945 100644 --- a/src/or/confparse.h +++ b/src/or/confparse.h @@ -76,7 +76,7 @@ typedef int (*validate_fn_t)(void*,void*,int,char**); /** Information on the keys, value types, key-to-struct-member mappings, * variable descriptions, validation functions, and abbreviations for a * configuration or storage format. */ -typedef struct { +typedef struct config_format_t { size_t size; /**< Size of the struct that everything gets parsed into. */ uint32_t magic; /**< Required 'magic value' to make sure we have a struct * of the right type. */ |