aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-12-19 09:18:03 -0500
committerNick Mathewson <nickm@torproject.org>2019-12-19 09:19:02 -0500
commitbc0f1076d53e57d1a4ba19170a1c27d9eaee34e8 (patch)
tree0ae2be62abb3a0af7a7df6f238eb05d80cdf34fc /src/test
parent7d5e360c3b74e52ecc997a6accefd39fbbd6f092 (diff)
downloadtor-bc0f1076d53e57d1a4ba19170a1c27d9eaee34e8.tar.gz
tor-bc0f1076d53e57d1a4ba19170a1c27d9eaee34e8.zip
Move get_foo_options() test helpers into a new test module.
Some of these helpers will be needed in multiple places in the unit tests, so we should move them now.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/include.am2
-rw-r--r--src/test/opts_test_helpers.c38
-rw-r--r--src/test/opts_test_helpers.h22
-rw-r--r--src/test/test_options.c17
4 files changed, 63 insertions, 16 deletions
diff --git a/src/test/include.am b/src/test/include.am
index 94352c8644..210f575db0 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -107,6 +107,7 @@ src_test_test_SOURCES += \
src/test/fakecircs.c \
src/test/log_test_helpers.c \
src/test/hs_test_helpers.c \
+ src/test/opts_test_helpers.c \
src/test/rend_test_helpers.c \
src/test/resolve_test_helpers.c \
src/test/rng_test_helpers.c \
@@ -351,6 +352,7 @@ noinst_HEADERS+= \
src/test/fakecircs.h \
src/test/hs_test_helpers.h \
src/test/log_test_helpers.h \
+ src/test/opts_test_helpers.h \
src/test/rend_test_helpers.h \
src/test/resolve_test_helpers.h \
src/test/rng_test_helpers.h \
diff --git a/src/test/opts_test_helpers.c b/src/test/opts_test_helpers.c
new file mode 100644
index 0000000000..619ca40733
--- /dev/null
+++ b/src/test/opts_test_helpers.c
@@ -0,0 +1,38 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file opts_testing_helpers.c
+ * @brief Helper functions to access module-specific config options.
+ **/
+
+#include "orconfig.h"
+#include "test/opts_test_helpers.h"
+
+#define CONFIG_PRIVATE
+#include "core/or/or.h"
+#include "lib/confmgt/confmgt.h"
+#include "app/main/subsysmgr.h"
+#include "app/config/config.h"
+
+#include "lib/crypt_ops/crypto_sys.h"
+#include "feature/dirauth/dirauth_sys.h"
+
+struct dirauth_options_t *
+get_dirauth_options(struct or_options_t *opt)
+{
+ int idx = subsystems_get_options_idx(&sys_dirauth);
+ tor_assert(idx >= 0);
+ return config_mgr_get_obj_mutable(get_options_mgr(), opt, idx);
+}
+
+struct crypto_options_t *
+get_crypto_options(struct or_options_t *opt)
+{
+ int idx = subsystems_get_options_idx(&sys_crypto);
+ tor_assert(idx >= 0);
+ return config_mgr_get_obj_mutable(get_options_mgr(), opt, idx);
+}
diff --git a/src/test/opts_test_helpers.h b/src/test/opts_test_helpers.h
new file mode 100644
index 0000000000..f925194e63
--- /dev/null
+++ b/src/test/opts_test_helpers.h
@@ -0,0 +1,22 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file opts_testing_helpers.h
+ * @brief Header for test/opts_test_helpers.c
+ **/
+
+#ifndef TOR_TEST_OPTS_TESTING_HELPERS_H
+#define TOR_TEST_OPTS_TESTING_HELPERS_H
+
+struct crypto_options_t;
+struct dirauth_options_t;
+struct or_options_t;
+
+struct crypto_options_t *get_crypto_options(struct or_options_t *opt);
+struct dirauth_options_t *get_dirauth_options(struct or_options_t *opt);
+
+#endif /* !defined(TOR_TEST_OPTS_TESTING_HELPERS_H) */
diff --git a/src/test/test_options.c b/src/test/test_options.c
index fe21cc96fd..1649a25861 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -31,6 +31,7 @@
#include "lib/encoding/confline.h"
#include "core/or/policies.h"
#include "test/test_helpers.h"
+#include "test/opts_test_helpers.h"
#include "lib/net/resolve.h"
#ifdef HAVE_SYS_PARAM_H
@@ -754,14 +755,6 @@ test_options_validate__logs(void *ignored)
/* return config_line; */
/* } */
-static dirauth_options_t *
-get_dirauth_options(or_options_t *opt)
-{
- int idx = subsystems_get_options_idx(&sys_dirauth);
- tor_assert(idx >= 0);
- return config_mgr_get_obj_mutable(get_options_mgr(), opt, idx);
-}
-
static void
test_options_validate__authdir(void *ignored)
{
@@ -4005,14 +3998,6 @@ test_options_validate__testing_options(void *ignored)
tor_free(msg);
}
-static crypto_options_t *
-get_crypto_options(or_options_t *opt)
-{
- int idx = subsystems_get_options_idx(&sys_crypto);
- tor_assert(idx >= 0);
- return config_mgr_get_obj_mutable(get_options_mgr(), opt, idx);
-}
-
static void
test_options_validate__accel(void *ignored)
{