[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] tests: Fix unit tests after adding new HS metrics module
commit 4c19eed35c8bae22cda219b7a4fb4a65d1c65525
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Thu Oct 22 15:48:05 2020 -0400
tests: Fix unit tests after adding new HS metrics module
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/test/test_hs_service.c | 3 +++
src/test/test_periodic_event.c | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 608e738d85..ad38547495 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -54,6 +54,7 @@
#include "feature/hs/hs_ob.h"
#include "feature/hs/hs_cell.h"
#include "feature/hs/hs_intropoint.h"
+#include "feature/hs/hs_metrics.h"
#include "feature/hs/hs_service.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
@@ -664,6 +665,7 @@ test_access_service(void *arg)
tt_mem_op(query, OP_EQ, s, sizeof(hs_service_t));
/* Remove service, check if it actually works and then put it back. */
remove_service(global_map, s);
+ hs_metrics_service_free(s);
tt_int_op(get_hs_service_map_size(), OP_EQ, 0);
query = find_service(global_map, &s->keys.identity_pk);
tt_ptr_op(query, OP_EQ, NULL);
@@ -673,6 +675,7 @@ test_access_service(void *arg)
tt_int_op(ret, OP_EQ, 0);
tt_int_op(get_hs_service_map_size(), OP_EQ, 1);
/* Twice should fail. */
+ hs_metrics_service_free(s); /* Avoid BUG() on metrics init. */
ret = register_service(global_map, s);
tt_int_op(ret, OP_EQ, -1);
/* Remove service from map so we don't double free on cleanup. */
diff --git a/src/test/test_periodic_event.c b/src/test/test_periodic_event.c
index b7f1785805..1dd3f7a68d 100644
--- a/src/test/test_periodic_event.c
+++ b/src/test/test_periodic_event.c
@@ -17,6 +17,7 @@
#include "core/or/or.h"
#include "app/config/config.h"
#include "feature/hibernate/hibernate.h"
+#include "feature/hs/hs_metrics.h"
#include "feature/hs/hs_service.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/netstatus.h"
@@ -187,6 +188,7 @@ test_pe_launch(void *arg)
done:
if (to_remove) {
+ hs_metrics_service_free(&service);
remove_service(get_hs_service_map(), to_remove);
}
hs_free_all();
@@ -279,6 +281,7 @@ test_pe_get_roles(void *arg)
roles = get_my_roles(options);
/* Remove it now so the hs_free_all() doesn't try to free stack memory. */
remove_service(get_hs_service_map(), &service);
+ hs_metrics_service_free(&service);
tt_int_op(roles, OP_EQ,
(PERIODIC_EVENT_ROLE_BRIDGEAUTH | PERIODIC_EVENT_ROLE_RELAY |
PERIODIC_EVENT_ROLE_HS_SERVICE | PERIODIC_EVENT_ROLE_DIRSERVER |
@@ -332,6 +335,7 @@ test_pe_hs_service(void *arg)
/* Remove the service from the global map, it should trigger a rescan and
* disable the HS service events. */
remove_service(get_hs_service_map(), &service);
+ hs_metrics_service_free(&service);
for (int i = 0; mainloop_periodic_events[i].name; ++i) {
periodic_event_item_t *item = &mainloop_periodic_events[i];
if (item->roles & PERIODIC_EVENT_ROLE_HS_SERVICE) {
@@ -341,6 +345,7 @@ test_pe_hs_service(void *arg)
done:
if (to_remove) {
+ hs_metrics_service_free(&service);
remove_service(get_hs_service_map(), to_remove);
}
hs_free_all();
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits