aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_confparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-07-23 09:08:31 -0400
committerNick Mathewson <nickm@torproject.org>2019-07-24 15:21:56 -0400
commitdde091ebc76d8ae5d93c1b3e1febfa2c9d1459fa (patch)
tree3673f25d9b098f0ebf8f10844232d4a8f7e13a9a /src/test/test_confparse.c
parent7abd43ac5f1e18e6a1c6bb2de95f39f22392f0c8 (diff)
downloadtor-dde091ebc76d8ae5d93c1b3e1febfa2c9d1459fa.tar.gz
tor-dde091ebc76d8ae5d93c1b3e1febfa2c9d1459fa.zip
Add a "freeze" function for config_mgr_t objects.
It's important to make sure that we don't change a config_mgr_t after we start using it to make objects, or we could get into inconsistent states. This feature is the start of a safety mechanism to prevent this problem.
Diffstat (limited to 'src/test/test_confparse.c')
-rw-r--r--src/test/test_confparse.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test_confparse.c b/src/test/test_confparse.c
index 8a921531fa..716384e2f6 100644
--- a/src/test/test_confparse.c
+++ b/src/test/test_confparse.c
@@ -153,6 +153,7 @@ test_confparse_init(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = config_new(mgr);
config_init(mgr, tst);
@@ -239,6 +240,7 @@ test_confparse_assign_simple(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
tt_str_op(tst->s, OP_EQ, "this is a");
@@ -300,6 +302,7 @@ test_confparse_assign_obsolete(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -330,6 +333,7 @@ test_confparse_assign_deprecated(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -364,6 +368,7 @@ test_confparse_assign_replaced(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -395,6 +400,7 @@ test_confparse_assign_emptystring(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -423,6 +429,7 @@ test_confparse_assign_twice(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -458,6 +465,7 @@ test_confparse_assign_badval(void *arg)
{
const badval_test_t *bt = arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -512,6 +520,7 @@ test_confparse_dump(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
char *dumped = NULL;
@@ -603,6 +612,7 @@ test_confparse_reset(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_reset_line(mgr, tst, "interval", 0);
@@ -623,6 +633,7 @@ test_confparse_reassign(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL, *rs = NULL;
@@ -679,6 +690,7 @@ test_confparse_reassign_extend(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
char *msg = NULL;
@@ -738,6 +750,7 @@ test_confparse_get_assigned(void *arg)
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = get_simple_config(mgr);
config_line_t *lines = NULL;
@@ -824,6 +837,7 @@ test_confparse_extra_lines(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&etest_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = config_new(mgr);
config_line_t *lines = NULL;
char *msg = NULL, *dump = NULL;
@@ -919,6 +933,7 @@ test_confparse_check_ok_fail(void *arg)
{
(void)arg;
config_mgr_t *mgr = config_mgr_new(&test_fmt);
+ config_mgr_freeze(mgr);
test_struct_t *tst = config_new(mgr);
tst->pos = -10;
tt_assert(! config_check_ok(mgr, tst, LOG_INFO));