diff options
author | dana koch <dsk@google.com> | 2014-04-15 22:20:34 +1000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-15 15:00:34 -0400 |
commit | 3ce3984772b673b82a87aded1bc8a1a0f1969e19 (patch) | |
tree | ae9e005f34ae81ff04c006ef179575de5b277bb8 /src/or/status.c | |
parent | 2704441e7ff1242d168bc14dda946fc41844f2c5 (diff) | |
download | tor-3ce3984772b673b82a87aded1bc8a1a0f1969e19.tar.gz tor-3ce3984772b673b82a87aded1bc8a1a0f1969e19.zip |
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/status.c')
-rw-r--r-- | src/or/status.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/status.c b/src/or/status.c index e1820c8889..7e2afbce80 100644 --- a/src/or/status.c +++ b/src/or/status.c @@ -6,6 +6,8 @@ * \brief Keep status information and log the heartbeat messages. **/ +#define STATUS_PRIVATE + #include "or.h" #include "config.h" #include "status.h" @@ -22,7 +24,7 @@ static void log_accounting(const time_t now, const or_options_t *options); /** Return the total number of circuits. */ -static int +STATIC int count_circuits(void) { circuit_t *circ; @@ -36,7 +38,7 @@ count_circuits(void) /** Take seconds <b>secs</b> and return a newly allocated human-readable * uptime string */ -static char * +STATIC char * secs_to_uptime(long secs) { long int days = secs / 86400; @@ -63,7 +65,7 @@ secs_to_uptime(long secs) /** Take <b>bytes</b> and returns a newly allocated human-readable usage * string. */ -static char * +STATIC char * bytes_to_usage(uint64_t bytes) { char *bw_string = NULL; |