aboutsummaryrefslogtreecommitdiff
path: root/src/feature/stats
diff options
context:
space:
mode:
authorMrSquanchee <usuraj35@gmail.com>2020-04-04 17:49:50 +0530
committerMrSquanchee <usuraj35@gmail.com>2020-07-31 21:12:16 +0530
commita93c3d7a8d98f04f8e651543e4031bb18008aa74 (patch)
treec38a4c9b1ce56e5f8c4423723fb9c74864c03ddb /src/feature/stats
parent708f51637f138a14e5093e442f5ba7b5f8f2479d (diff)
downloadtor-a93c3d7a8d98f04f8e651543e4031bb18008aa74.tar.gz
tor-a93c3d7a8d98f04f8e651543e4031bb18008aa74.zip
Added tests for bandwidth functions
Added tests for 1. commit_max 2. advance_obs 3. add_obs 4. rep_hist_fill_bandwidth_history 5. rep_hist_get_bandwidth_lines (Lightly edited by nickm to use new names from bwhist refactoring.) Signed-off-by: Suraj Upadhyay <usuraj35@gmail.com>
Diffstat (limited to 'src/feature/stats')
-rw-r--r--src/feature/stats/bwhist.c11
-rw-r--r--src/feature/stats/bwhist.h7
2 files changed, 11 insertions, 7 deletions
diff --git a/src/feature/stats/bwhist.c b/src/feature/stats/bwhist.c
index 48e33948da..7cbc5f60a6 100644
--- a/src/feature/stats/bwhist.c
+++ b/src/feature/stats/bwhist.c
@@ -74,7 +74,7 @@ advance_obs(bw_array_t *b)
/** Add <b>n</b> bytes to the number of bytes in <b>b</b> for second
* <b>when</b>. */
-static inline void
+STATIC void
add_obs(bw_array_t *b, time_t when, uint64_t n)
{
if (when < b->cur_obs_time)
@@ -95,7 +95,7 @@ add_obs(bw_array_t *b, time_t when, uint64_t n)
}
/** Allocate, initialize, and return a new bw_array. */
-static bw_array_t *
+STATIC bw_array_t *
bw_array_new(void)
{
bw_array_t *b;
@@ -107,11 +107,8 @@ bw_array_new(void)
return b;
}
-#define bw_array_free(val) \
- FREE_AND_NULL(bw_array_t, bw_array_free_, (val))
-
/** Free storage held by bandwidth array <b>b</b>. */
-static void
+STATIC void
bw_array_free_(bw_array_t *b)
{
if (!b) {
@@ -250,7 +247,7 @@ bwhist_bandwidth_assess,(void))
*
* It returns the number of bytes written.
*/
-static size_t
+STATIC size_t
bwhist_fill_bandwidth_history(char *buf, size_t len, const bw_array_t *b)
{
char *cp = buf;
diff --git a/src/feature/stats/bwhist.h b/src/feature/stats/bwhist.h
index d556f5a026..f88b951447 100644
--- a/src/feature/stats/bwhist.h
+++ b/src/feature/stats/bwhist.h
@@ -31,6 +31,13 @@ typedef struct bw_array_t bw_array_t;
STATIC uint64_t find_largest_max(bw_array_t *b);
STATIC void commit_max(bw_array_t *b);
STATIC void advance_obs(bw_array_t *b);
+STATIC bw_array_t *bw_array_new(void);
+STATIC void add_obs(bw_array_t *b, time_t when, uint64_t n);
+#define bw_array_free(val) \
+ FREE_AND_NULL(bw_array_t, bw_array_free_, (val))
+STATIC void bw_array_free_(bw_array_t *b);
+STATIC size_t bwhist_fill_bandwidth_history(char *buf, size_t len,
+ const bw_array_t *b);
#endif /* defined(REPHIST_PRIVATE) */
#ifdef TOR_UNIT_TESTS