summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-11-05 11:58:31 -0500
committerNick Mathewson <nickm@torproject.org>2019-11-07 07:28:43 -0500
commit280a9a476031db7c5c5923b0ad9b23e475abeae9 (patch)
tree25f761afa02a8ae26b590fbc60f825a6e41f6e69 /src/test
parent3afbb29bee060b191e10aaec134a819047c3cf5e (diff)
downloadtor-280a9a476031db7c5c5923b0ad9b23e475abeae9.tar.gz
tor-280a9a476031db7c5c5923b0ad9b23e475abeae9.zip
Move netstatus (mainloop) state fields into mainloop's state.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_mainloop.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/test/test_mainloop.c b/src/test/test_mainloop.c
index ed6b8a9b66..e8225db8e0 100644
--- a/src/test/test_mainloop.c
+++ b/src/test/test_mainloop.c
@@ -13,9 +13,13 @@
#include "test/test.h"
#include "test/log_test_helpers.h"
+#include "lib/confmgt/confmgt.h"
+
#include "core/or/or.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
+#include "core/mainloop/mainloop_state_st.h"
+#include "core/mainloop/mainloop_sys.h"
#include "core/mainloop/netstatus.h"
#include "feature/hs/hs_service.h"
@@ -24,6 +28,8 @@
#include "app/config/statefile.h"
#include "app/config/or_state_st.h"
+#include "app/main/subsysmgr.h"
+
static const uint64_t BILLION = 1000000000;
static void
@@ -287,7 +293,13 @@ static void
test_mainloop_dormant_load_state(void *arg)
{
(void)arg;
- or_state_t *state = or_state_new();
+ or_state_t *or_state = or_state_new();
+ mainloop_state_t *state;
+ {
+ int idx = subsystems_get_state_idx(&sys_mainloop);
+ tor_assert(idx >= 0);
+ state = config_mgr_get_obj_mutable(get_state_mgr(), or_state, idx);
+ }
const time_t start = 1543956575;
reset_user_activity(0);
@@ -326,14 +338,14 @@ test_mainloop_dormant_load_state(void *arg)
tt_i64_op(get_last_user_activity_time(), OP_EQ, start);
done:
- or_state_free(state);
+ or_state_free(or_state);
}
static void
test_mainloop_dormant_save_state(void *arg)
{
(void)arg;
- or_state_t *state = or_state_new();
+ mainloop_state_t *state = tor_malloc_zero(sizeof(mainloop_state_t));
const time_t start = 1543956575;
// Can we save a non-dormant state correctly?
@@ -352,7 +364,7 @@ test_mainloop_dormant_save_state(void *arg)
tt_int_op(state->MinutesSinceUserActivity, OP_EQ, 0);
done:
- or_state_free(state);
+ tor_free(state);
}
#define MAINLOOP_TEST(name) \