|
@@ -40,6 +40,12 @@ mock_rep_hist_bandwidth_assess(void)
|
|
return 20001;
|
|
return 20001;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static int
|
|
|
|
+mock_we_are_not_hibernating(void)
|
|
|
|
+{
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
static int
|
|
static int
|
|
mock_we_are_hibernating(void)
|
|
mock_we_are_hibernating(void)
|
|
{
|
|
{
|
|
@@ -54,7 +60,7 @@ test_router_check_descriptor_bandwidth_changed(void *arg)
|
|
memset(&routerinfo, 0, sizeof(routerinfo));
|
|
memset(&routerinfo, 0, sizeof(routerinfo));
|
|
mock_router_get_my_routerinfo_result = NULL;
|
|
mock_router_get_my_routerinfo_result = NULL;
|
|
|
|
|
|
- MOCK(we_are_hibernating, mock_we_are_hibernating);
|
|
|
|
|
|
+ MOCK(we_are_hibernating, mock_we_are_not_hibernating);
|
|
MOCK(router_get_my_routerinfo, mock_router_get_my_routerinfo);
|
|
MOCK(router_get_my_routerinfo, mock_router_get_my_routerinfo);
|
|
mock_router_get_my_routerinfo_result = &routerinfo;
|
|
mock_router_get_my_routerinfo_result = &routerinfo;
|
|
|
|
|
|
@@ -78,6 +84,21 @@ test_router_check_descriptor_bandwidth_changed(void *arg)
|
|
"Measured bandwidth has changed; rebuilding descriptor.");
|
|
"Measured bandwidth has changed; rebuilding descriptor.");
|
|
teardown_capture_of_logs();
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
|
|
+ /* When uptime is less than 24h, previous bandwidth,
|
|
|
|
+ * last_changed more than 3h ago, and hibernating
|
|
|
|
+ * Uptime: 10800, last_changed: 0, Previous bw: 10000, Current bw: 0 */
|
|
|
|
+
|
|
|
|
+ UNMOCK(we_are_hibernating);
|
|
|
|
+ MOCK(we_are_hibernating, mock_we_are_hibernating);
|
|
|
|
+ routerinfo.bandwidthcapacity = 10000;
|
|
|
|
+ setup_full_capture_of_logs(LOG_INFO);
|
|
|
|
+ check_descriptor_bandwidth_changed(time(NULL));
|
|
|
|
+ expect_log_msg_not_containing(
|
|
|
|
+ "Measured bandwidth has changed; rebuilding descriptor.");
|
|
|
|
+ teardown_capture_of_logs();
|
|
|
|
+ UNMOCK(we_are_hibernating);
|
|
|
|
+ MOCK(we_are_hibernating, mock_we_are_not_hibernating);
|
|
|
|
+
|
|
/* When uptime is less than 24h, last_changed is not more than 3h ago
|
|
/* When uptime is less than 24h, last_changed is not more than 3h ago
|
|
* Uptime: 10800, last_changed: x, Previous bw: 10000, Current bw: 0 */
|
|
* Uptime: 10800, last_changed: x, Previous bw: 10000, Current bw: 0 */
|
|
setup_full_capture_of_logs(LOG_INFO);
|
|
setup_full_capture_of_logs(LOG_INFO);
|
|
@@ -103,11 +124,12 @@ test_router_check_descriptor_bandwidth_changed(void *arg)
|
|
check_descriptor_bandwidth_changed(time(NULL));
|
|
check_descriptor_bandwidth_changed(time(NULL));
|
|
expect_log_msg_not_containing(
|
|
expect_log_msg_not_containing(
|
|
"Measured bandwidth has changed; rebuilding descriptor.");
|
|
"Measured bandwidth has changed; rebuilding descriptor.");
|
|
- UNMOCK(get_uptime);
|
|
|
|
teardown_capture_of_logs();
|
|
teardown_capture_of_logs();
|
|
|
|
|
|
done:
|
|
done:
|
|
|
|
+ UNMOCK(get_uptime);
|
|
UNMOCK(router_get_my_routerinfo);
|
|
UNMOCK(router_get_my_routerinfo);
|
|
|
|
+ UNMOCK(we_are_hibernating);
|
|
}
|
|
}
|
|
|
|
|
|
#define ROUTER_TEST(name, flags) \
|
|
#define ROUTER_TEST(name, flags) \
|