aboutsummaryrefslogtreecommitdiff
path: root/src/or/hibernate.h
diff options
context:
space:
mode:
authordana koch <dsk@google.com>2014-04-15 22:20:34 +1000
committerNick Mathewson <nickm@torproject.org>2014-04-15 15:00:34 -0400
commit3ce3984772b673b82a87aded1bc8a1a0f1969e19 (patch)
treeae9e005f34ae81ff04c006ef179575de5b277bb8 /src/or/hibernate.h
parent2704441e7ff1242d168bc14dda946fc41844f2c5 (diff)
downloadtor-3ce3984772b673b82a87aded1bc8a1a0f1969e19.tar
tor-3ce3984772b673b82a87aded1bc8a1a0f1969e19.tar.gz
Uplift status.c unit test coverage with new test cases and macros.
A new set of unit test cases are provided, as well as introducing an alternative paradigm and macros to support it. Primarily, each test case is given its own namespace, in order to isolate tests from each other. We do this by in the usual fashion, by appending module and submodule names to our symbols. New macros assist by reducing friction for this and other tasks, like overriding a function in the global namespace with one in the current namespace, or declaring integer variables to assist tracking how many times a mock has been called. A set of tests for a small-scale module has been included in this commit, in order to highlight how the paradigm can be used. This suite gives 100% coverage to status.c in test execution.
Diffstat (limited to 'src/or/hibernate.h')
-rw-r--r--src/or/hibernate.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 4f7331ce8..38ecb7512 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -12,16 +12,18 @@
#ifndef TOR_HIBERNATE_H
#define TOR_HIBERNATE_H
+#include "testsupport.h"
+
int accounting_parse_options(const or_options_t *options, int validate_only);
-int accounting_is_enabled(const or_options_t *options);
+MOCK_DECL(int, accounting_is_enabled, (const or_options_t *options));
int accounting_get_interval_length(void);
-time_t accounting_get_end_time(void);
+MOCK_DECL(time_t, accounting_get_end_time, (void));
void configure_accounting(time_t now);
void accounting_run_housekeeping(time_t now);
void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
void hibernate_begin_shutdown(void);
-int we_are_hibernating(void);
+MOCK_DECL(int, we_are_hibernating, (void));
void consider_hibernation(time_t now);
int getinfo_helper_accounting(control_connection_t *conn,
const char *question, char **answer,