]> granicus.if.org Git - vnstat/commitdiff
move simple calculation related functions to common
authorTeemu Toivola <git@humdi.net>
Sun, 2 Mar 2014 21:42:42 +0000 (23:42 +0200)
committerTeemu Toivola <git@humdi.net>
Sun, 2 Mar 2014 21:42:42 +0000 (23:42 +0200)
14 files changed:
src/Makefile
src/common.c
src/common.h
src/dbaccess.c
src/ifinfo.c
src/ifinfo.h
src/image.c
src/image.h
src/misc.c
src/misc.h
tests/Makefile
tests/common_tests.c
tests/ifinfo_tests.c
tests/misc_tests.c

index 60d9ee8e45a4ecec8facf694762d652f4bcf00fc..5fe15cb5c80903b8874d67cbd425f6570dc365f6 100644 (file)
@@ -24,7 +24,7 @@ ifinfo.o: ifinfo.c ifinfo.h common.h dbaccess.h misc.h cfg.h
 traffic.o: traffic.c traffic.h common.h ifinfo.h misc.h
 dbxml.o: dbxml.c dbxml.h common.h
 dbshow.o: dbshow.c dbshow.h misc.h common.h
-dbaccess.o: dbaccess.c dbaccess.h misc.h common.h
+dbaccess.o: dbaccess.c dbaccess.h common.h
 dbmerge.o: dbmerge.c dbmerge.h dbaccess.h common.h
 dbcache.o: dbcache.c dbcache.h dbaccess.h common.h ifinfo.h
 common.o: common.c common.h
index ffe18726f4901b29c7af0af9f82a64c9a7706638..24e261306c7ab56be8fa8b50590696b37700f071 100644 (file)
@@ -172,3 +172,48 @@ uint32_t mosecs(void)
                return 0;
        }
 }
+
+uint64_t countercalc(uint64_t a, uint64_t b)
+{
+       /* no flip */
+       if (b>=a) {
+               if (debug)
+                       printf("cc: %"PRIu64" - %"PRIu64" = %"PRIu64"\n", b, a, b-a);
+               return b-a;
+
+       /* flip exists */
+       } else {
+               /* original counter is 64bit */
+               if (a>FP32) {
+                       if (debug)
+                               printf("cc64: uint64 - %"PRIu64" + %"PRIu64" = %"PRIu64"\n", a, b, (uint64_t)FP64-a+b);
+                       return FP64-a+b;
+
+               /* original counter is 32bit */
+               } else {
+                       if (debug)
+                               printf("cc32: uint32 - %"PRIu64" + %"PRIu64" = %"PRIu64"\n", a, b, (uint64_t)FP32-a+b);
+                       return FP32-a+b;
+               }
+       }
+}
+
+void addtraffic(uint64_t *destmb, int *destkb, uint64_t srcmb, int srckb)
+{
+        *destmb+=srcmb;
+        *destkb+=srckb;
+
+        if (*destkb>=1024) {
+                *destmb+=*destkb/1024;
+                *destkb-=(*destkb/1024)*1024;
+        }
+}
+
+uint64_t mbkbtokb(uint64_t mb, uint64_t kb)
+{
+       if (kb>=1024) {
+               mb+=kb/1024;
+               kb-=(kb/1024)*1024;
+       }
+       return (mb*1024)+kb;
+}
index b0c0456d3fd65969fa4e17d792bdba1f621df642..5be8c9484acb348c308b161c3ea8ccc396063ec5 100644 (file)
@@ -262,6 +262,9 @@ int printe(PrintType type);
 int logprint(PrintType type);
 int dmonth(int month);
 uint32_t mosecs(void);
+uint64_t countercalc(uint64_t a, uint64_t b);
+void addtraffic(uint64_t *destmb, int *destkb, uint64_t srcmb, int srckb);
+uint64_t mbkbtokb(uint64_t mb, uint64_t kb);
 
 /* global variables */
 DATA data;
index 1819e2f40662bbdfb88247e0b0c9c133f5c3bab8..f033b86ba306cb47526a25fd86c1c8923ae2eea7 100644 (file)
@@ -1,6 +1,5 @@
 #include "common.h"
 #include "dbaccess.h"
-#include "misc.h"
 
 int readdb(const char *iface, const char *dirname)
 {
index d7a078af5f1f48825294865803552c7c489c66dd..9e065008f400b786b191661441cb023a0c0c52f8 100644 (file)
@@ -376,31 +376,6 @@ void parseifinfo(int newdb)
        }
 }
 
-uint64_t countercalc(uint64_t a, uint64_t b)
-{
-       /* no flip */
-       if (b>=a) {
-               if (debug)
-                       printf("cc: %"PRIu64" - %"PRIu64" = %"PRIu64"\n", b, a, b-a);
-               return b-a;
-
-       /* flip exists */
-       } else {
-               /* original counter is 64bit */
-               if (a>FP32) {
-                       if (debug)
-                               printf("cc64: uint64 - %"PRIu64" + %"PRIu64" = %"PRIu64"\n", a, b, (uint64_t)FP64-a+b);
-                       return FP64-a+b;
-
-               /* original counter is 32bit */
-               } else {
-                       if (debug)
-                               printf("cc32: uint32 - %"PRIu64" + %"PRIu64" = %"PRIu64"\n", a, b, (uint64_t)FP32-a+b);
-                       return FP32-a+b;
-               }
-       }
-}
-
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
 int readifaddrs(const char *iface)
 {
index ca8f3f61a19e7a24a62389cc87ae30420dc6a8cf..d2d23a2d1092051562ac4e3056ccc650c290144e 100644 (file)
@@ -6,7 +6,6 @@ int getiflist(char **ifacelist);
 int readproc(const char *iface);
 int readsysclassnet(const char *iface);
 void parseifinfo(int newdb);
-uint64_t countercalc(uint64_t a, uint64_t b);
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
 int readifaddrs(const char *iface);
 #endif
index 4fa5424c6c04480760a7160fade605174ee5357e..2cd7cc169ed65d9c7895af17f7e0a9c7f673dc98 100644 (file)
@@ -140,18 +140,8 @@ void drawbar(int x, int y, int len, uint64_t rx, int rxk, uint64_t tx, int txk,
 {
        int l;
 
-       if (rxk>=1024) {
-               rx+=rxk/1024;
-               rxk-=(rxk/1024)*1024;
-       }
-
-       if (txk>=1024) {
-               tx+=txk/1024;
-               txk-=(txk/1024)*1024;
-       }
-
-       rx=(rx*1024)+rxk;
-       tx=(tx*1024)+txk;
+       rx=mbkbtokb(rx, rxk);
+       tx=mbkbtokb(tx, txk);
 
        if ((rx+tx)!=max) {
                len=((rx+tx)/(float)max)*len;
@@ -835,12 +825,7 @@ void drawoldsummary(int type, int showheader, int showedge, int rate)
                        t=data.day[i].rx+data.day[i].tx;
                        tk=data.day[i].rxk+data.day[i].txk;
 
-                       if (tk>=1024) {
-                               t+=tk/1024;
-                               tk-=(tk/1024)*1024;
-                       }
-
-                       t=(t*1024)+tk;
+                       t=mbkbtokb(t, tk);
 
                        if (t>max) {
                                max=t;
index 6989dbd7fac4c58f6c4d6f2ace939aee557a518e..7cedb3d362b83908d276d377f58d72d3f4bc74b6 100644 (file)
@@ -15,7 +15,6 @@ void drawhourly(int showheader, int showedge, int rate);
 void drawdaily(int showheader, int showedge);
 void drawmonthly(int showheader, int showedge);
 void drawtop(int showheader, int showedge);
-void addtraffic(uint64_t *destmb, int *destkb, uint64_t srcmb, int srckb);
 void hextorgb(char *input, int *rgb);
 void modcolor(int *rgb, int offset, int force);
 char *getimagevalue(uint64_t kb, int len, int rate);
index ebebbbe8728e4e90eef86165491ba8d2aab17fba..62d3771944f39817abef55f457f0ab7888aceecc 100644 (file)
@@ -187,17 +187,6 @@ int getbtime(void)
        return result;
 }
 
-void addtraffic(uint64_t *destmb, int *destkb, uint64_t srcmb, int srckb)
-{
-        *destmb=*destmb+srcmb;
-        *destkb=*destkb+srckb;
-
-        if (*destkb>=1024) {
-                *destmb+=*destkb/1024;
-                *destkb-=(*destkb/1024)*1024;
-        }
-}
-
 char *getvalue(uint64_t mb, uint64_t kb, int len, int type)
 {
        static char buffer[64];
@@ -210,11 +199,7 @@ char *getvalue(uint64_t mb, uint64_t kb, int len, int type)
        }
 
        if (mb!=0) {
-               if (kb>=1024) {
-                       mb+=kb/1024;
-                       kb-=(kb/1024)*1024;
-               }
-               kB=(mb*1024)+kb;
+               kB=mbkbtokb(mb, kb);
        } else {
                kB=kb;
        }
@@ -259,11 +244,7 @@ char *getrate(uint64_t mb, uint64_t kb, uint32_t interval, int len)
        }
 
        if (mb!=0) {
-               if (kb>=1024) {
-                       mb+=kb/1024;
-                       kb-=(kb/1024)*1024;
-               }
-               kB=(mb*1024)+kb;
+               kB=mbkbtokb(mb, kb);
        } else {
                kB=kb;
        }
index 04a095ca12782c63add2b15e07a0dbac08c0ca2a..32cdc2d8e87c1488d803732ae2a4e8acc45f8291 100644 (file)
@@ -7,7 +7,6 @@ int kerneltest(void);
 int spacecheck(char *path);
 void sighandler(int);
 int getbtime(void);
-void addtraffic(uint64_t *destmb, int *destkb, uint64_t srcmb, int srckb);
 char *getvalue(uint64_t mb, uint64_t kb, int len, int type);
 char *getrate(uint64_t mb, uint64_t kb, uint32_t interval, int len);
 char *gettrafficrate(uint64_t bytes, uint32_t interval, int len);
index 477e5fe6c3304bfb68e1921146c0d6c4e7e431ee..d4fd93acd13baa8613e92cf8841458fce6473a4f 100644 (file)
@@ -28,7 +28,7 @@ misc_tests.o: misc_tests.c misc_tests.h vnstat_tests.h common.h misc.h
 
 common.o: common.c common.h
 ifinfo.o: ifinfo.c ifinfo.h common.h dbaccess.h misc.h cfg.h
-dbaccess.o: dbaccess.c dbaccess.h misc.h common.h
+dbaccess.o: dbaccess.c dbaccess.h common.h
 dbcache.o: dbcache.c dbcache.h dbaccess.h common.h ifinfo.h
 cfg.o: cfg.c cfg.h common.h
 misc.o: misc.c misc.h common.h
index 67f996c5d27760b8e27b286a12fde2cd0fb8d39b..bc7b615e6adac5026236800273c49e567b106cfd 100644 (file)
@@ -63,6 +63,198 @@ START_TEST(mosecs_return_values)
 }
 END_TEST
 
+START_TEST(countercalc_no_change)
+{
+       ck_assert_int_eq(countercalc(0, 0), 0);
+       ck_assert_int_eq(countercalc(1, 1), 0);
+}
+END_TEST
+
+START_TEST(countercalc_small_change)
+{
+       ck_assert_int_eq(countercalc(0, 1), 1);
+       ck_assert_int_eq(countercalc(1, 2), 1);
+       ck_assert_int_eq(countercalc(1, 3), 2);
+}
+END_TEST
+
+START_TEST(countercalc_32bit)
+{
+       ck_assert(countercalc(1, 0)==(FP32-1));
+}
+END_TEST
+
+START_TEST(countercalc_64bit)
+{
+       ck_assert(countercalc(FP32+1, 0)==(FP64-FP32-1));
+}
+END_TEST
+
+START_TEST(addtraffic_does_not_add_zero_traffic)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       srcmb=srckb=destmb=destkb=0;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 0);
+       ck_assert_int_eq(srckb, 0);
+       ck_assert_int_eq(destmb, 0);
+       ck_assert_int_eq(destkb, 0);
+}
+END_TEST
+
+START_TEST(addtraffic_with_simple_mb_addition)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       destmb=destkb=0;
+       srcmb=1;
+       srckb=0;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 1);
+       ck_assert_int_eq(srckb, 0);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 0);
+}
+END_TEST
+
+START_TEST(addtraffic_with_simple_kb_addition)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       destmb=destkb=0;
+       srcmb=0;
+       srckb=1;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 0);
+       ck_assert_int_eq(srckb, 1);
+       ck_assert_int_eq(destmb, 0);
+       ck_assert_int_eq(destkb, 1);
+}
+END_TEST
+
+START_TEST(addtraffic_with_simple_mixed_addition)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       destmb=destkb=0;
+       srcmb=1;
+       srckb=1;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 1);
+       ck_assert_int_eq(srckb, 1);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 1);
+}
+END_TEST
+
+START_TEST(addtraffic_with_multiple_mixed_additions)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb, i;
+
+       destmb=destkb=0;
+       srcmb=1;
+       srckb=1;
+
+       for (i=1; i<=10; i++) {
+               addtraffic(&destmb, &destkb, srcmb, srckb);
+
+               ck_assert_int_eq(srcmb, 1);
+               ck_assert_int_eq(srckb, 1);
+               ck_assert_int_eq(destmb, (uint64_t)i);
+               ck_assert_int_eq(destkb, i);
+       }
+}
+END_TEST
+
+START_TEST(addtraffic_with_exact_kb_to_mb_conversion)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       destmb=destkb=0;
+       srcmb=0;
+       srckb=1024;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 0);
+       ck_assert_int_eq(srckb, 1024);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 0);
+}
+END_TEST
+
+START_TEST(addtraffic_with_inexact_kb_to_mb_conversion)
+{
+       uint64_t srcmb, destmb;
+       int srckb, destkb;
+
+       destmb=destkb=0;
+       srcmb=0;
+       srckb=1025;
+       addtraffic(&destmb, &destkb, srcmb, srckb);
+
+       ck_assert_int_eq(srcmb, 0);
+       ck_assert_int_eq(srckb, 1025);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 1);
+}
+END_TEST
+
+START_TEST(addtraffic_with_multiple_kb_to_mb_conversions)
+{
+       uint64_t destmb;
+       int destkb;
+
+       destmb=destkb=0;
+
+       addtraffic(&destmb, &destkb, 0, 1023);
+       ck_assert_int_eq(destmb, 0);
+       ck_assert_int_eq(destkb, 1023);
+
+       addtraffic(&destmb, &destkb, 0, 1);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 0);
+
+       addtraffic(&destmb, &destkb, 0, 1);
+       ck_assert_int_eq(destmb, 1);
+       ck_assert_int_eq(destkb, 1);
+
+       addtraffic(&destmb, &destkb, 0, 1023);
+       ck_assert_int_eq(destmb, 2);
+       ck_assert_int_eq(destkb, 0);
+
+       addtraffic(&destmb, &destkb, 0, 1024);
+       ck_assert_int_eq(destmb, 3);
+       ck_assert_int_eq(destkb, 0);
+
+       addtraffic(&destmb, &destkb, 0, 1025);
+       ck_assert_int_eq(destmb, 4);
+       ck_assert_int_eq(destkb, 1);
+
+       addtraffic(&destmb, &destkb, 0, 512);
+       ck_assert_int_eq(destmb, 4);
+       ck_assert_int_eq(destkb, 513);
+
+       addtraffic(&destmb, &destkb, 0, 512);
+       ck_assert_int_eq(destmb, 5);
+       ck_assert_int_eq(destkb, 1);
+
+       addtraffic(&destmb, &destkb, 0, 2048);
+       ck_assert_int_eq(destmb, 7);
+       ck_assert_int_eq(destkb, 1);
+}
+END_TEST
+
 void add_common_tests(Suite *s)
 {
        /* Common test cases */
@@ -71,5 +263,17 @@ void add_common_tests(Suite *s)
        tcase_add_test(tc_common, logprint_options);
        tcase_add_loop_test(tc_common, dmonth_return_within_range, 0, 12);
        tcase_add_test(tc_common, mosecs_return_values);
+       tcase_add_test(tc_common, countercalc_no_change);
+       tcase_add_test(tc_common, countercalc_small_change);
+       tcase_add_test(tc_common, countercalc_32bit);
+       tcase_add_test(tc_common, countercalc_64bit);
+       tcase_add_test(tc_common, addtraffic_does_not_add_zero_traffic);
+       tcase_add_test(tc_common, addtraffic_with_simple_mb_addition);
+       tcase_add_test(tc_common, addtraffic_with_simple_kb_addition);
+       tcase_add_test(tc_common, addtraffic_with_simple_mixed_addition);
+       tcase_add_test(tc_common, addtraffic_with_multiple_mixed_additions);
+       tcase_add_test(tc_common, addtraffic_with_exact_kb_to_mb_conversion);
+       tcase_add_test(tc_common, addtraffic_with_inexact_kb_to_mb_conversion);
+       tcase_add_test(tc_common, addtraffic_with_multiple_kb_to_mb_conversions);
        suite_add_tcase(s, tc_common);
 }
index 4516c941e2c14d4963beba5860ed85c3449bc9b9..c45b427f2425667da1c723e12d3e281872205ff3 100644 (file)
@@ -3,41 +3,9 @@
 #include "common.h"
 #include "ifinfo.h"
 
-
-START_TEST(countercalc_no_change)
-{
-       ck_assert_int_eq(countercalc(0, 0), 0);
-       ck_assert_int_eq(countercalc(1, 1), 0);
-}
-END_TEST
-
-START_TEST(countercalc_small_change)
-{
-       ck_assert_int_eq(countercalc(0, 1), 1);
-       ck_assert_int_eq(countercalc(1, 2), 1);
-       ck_assert_int_eq(countercalc(1, 3), 2);
-}
-END_TEST
-
-START_TEST(countercalc_32bit)
-{
-       ck_assert(countercalc(1, 0)==(FP32-1));
-}
-END_TEST
-
-START_TEST(countercalc_64bit)
-{
-       ck_assert(countercalc(FP32+1, 0)==(FP64-FP32-1));
-}
-END_TEST
-
 void add_ifinfo_tests(Suite *s)
 {
        /* Ifinfo test cases */
        TCase *tc_ifinfo = tcase_create("Ifinfo");
-       tcase_add_test(tc_ifinfo, countercalc_no_change);
-       tcase_add_test(tc_ifinfo, countercalc_small_change);
-       tcase_add_test(tc_ifinfo, countercalc_32bit);
-       tcase_add_test(tc_ifinfo, countercalc_64bit);
        suite_add_tcase(s, tc_ifinfo);
 }
index 3fd54f255cf6c01a8f074337d8b0861e065f468d..058a0fc6b5d255cd3f7e1c77dae181ae22df415e 100644 (file)
@@ -9,171 +9,6 @@ START_TEST(getbtime_does_not_return_zero)
 }
 END_TEST
 
-START_TEST(addtraffic_does_not_add_zero_traffic)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       srcmb=srckb=destmb=destkb=0;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 0);
-       ck_assert_int_eq(srckb, 0);
-       ck_assert_int_eq(destmb, 0);
-       ck_assert_int_eq(destkb, 0);
-}
-END_TEST
-
-START_TEST(addtraffic_with_simple_mb_addition)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       destmb=destkb=0;
-       srcmb=1;
-       srckb=0;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 1);
-       ck_assert_int_eq(srckb, 0);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 0);
-}
-END_TEST
-
-START_TEST(addtraffic_with_simple_kb_addition)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       destmb=destkb=0;
-       srcmb=0;
-       srckb=1;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 0);
-       ck_assert_int_eq(srckb, 1);
-       ck_assert_int_eq(destmb, 0);
-       ck_assert_int_eq(destkb, 1);
-}
-END_TEST
-
-START_TEST(addtraffic_with_simple_mixed_addition)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       destmb=destkb=0;
-       srcmb=1;
-       srckb=1;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 1);
-       ck_assert_int_eq(srckb, 1);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 1);
-}
-END_TEST
-
-START_TEST(addtraffic_with_multiple_mixed_additions)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb, i;
-
-       destmb=destkb=0;
-       srcmb=1;
-       srckb=1;
-
-       for (i=1; i<=10; i++) {
-               addtraffic(&destmb, &destkb, srcmb, srckb);
-
-               ck_assert_int_eq(srcmb, 1);
-               ck_assert_int_eq(srckb, 1);
-               ck_assert_int_eq(destmb, (uint64_t)i);
-               ck_assert_int_eq(destkb, i);
-       }
-}
-END_TEST
-
-START_TEST(addtraffic_with_exact_kb_to_mb_conversion)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       destmb=destkb=0;
-       srcmb=0;
-       srckb=1024;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 0);
-       ck_assert_int_eq(srckb, 1024);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 0);
-}
-END_TEST
-
-START_TEST(addtraffic_with_inexact_kb_to_mb_conversion)
-{
-       uint64_t srcmb, destmb;
-       int srckb, destkb;
-
-       destmb=destkb=0;
-       srcmb=0;
-       srckb=1025;
-       addtraffic(&destmb, &destkb, srcmb, srckb);
-
-       ck_assert_int_eq(srcmb, 0);
-       ck_assert_int_eq(srckb, 1025);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 1);
-}
-END_TEST
-
-START_TEST(addtraffic_with_multiple_kb_to_mb_conversions)
-{
-       uint64_t destmb;
-       int destkb;
-
-       destmb=destkb=0;
-
-       addtraffic(&destmb, &destkb, 0, 1023);
-       ck_assert_int_eq(destmb, 0);
-       ck_assert_int_eq(destkb, 1023);
-
-       addtraffic(&destmb, &destkb, 0, 1);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 0);
-
-       addtraffic(&destmb, &destkb, 0, 1);
-       ck_assert_int_eq(destmb, 1);
-       ck_assert_int_eq(destkb, 1);
-
-       addtraffic(&destmb, &destkb, 0, 1023);
-       ck_assert_int_eq(destmb, 2);
-       ck_assert_int_eq(destkb, 0);
-
-       addtraffic(&destmb, &destkb, 0, 1024);
-       ck_assert_int_eq(destmb, 3);
-       ck_assert_int_eq(destkb, 0);
-
-       addtraffic(&destmb, &destkb, 0, 1025);
-       ck_assert_int_eq(destmb, 4);
-       ck_assert_int_eq(destkb, 1);
-
-       addtraffic(&destmb, &destkb, 0, 512);
-       ck_assert_int_eq(destmb, 4);
-       ck_assert_int_eq(destkb, 513);
-
-       addtraffic(&destmb, &destkb, 0, 512);
-       ck_assert_int_eq(destmb, 5);
-       ck_assert_int_eq(destkb, 1);
-
-       addtraffic(&destmb, &destkb, 0, 2048);
-       ck_assert_int_eq(destmb, 7);
-       ck_assert_int_eq(destkb, 1);
-}
-END_TEST
-
 START_TEST(getunit_returns_something_with_all_cfg_combinations)
 {
        char *string;
@@ -484,14 +319,6 @@ void add_misc_tests(Suite *s)
        /* Misc test cases */
        TCase *tc_misc = tcase_create("Misc");
        tcase_add_test(tc_misc, getbtime_does_not_return_zero);
-       tcase_add_test(tc_misc, addtraffic_does_not_add_zero_traffic);
-       tcase_add_test(tc_misc, addtraffic_with_simple_mb_addition);
-       tcase_add_test(tc_misc, addtraffic_with_simple_kb_addition);
-       tcase_add_test(tc_misc, addtraffic_with_simple_mixed_addition);
-       tcase_add_test(tc_misc, addtraffic_with_multiple_mixed_additions);
-       tcase_add_test(tc_misc, addtraffic_with_exact_kb_to_mb_conversion);
-       tcase_add_test(tc_misc, addtraffic_with_inexact_kb_to_mb_conversion);
-       tcase_add_test(tc_misc, addtraffic_with_multiple_kb_to_mb_conversions);
        tcase_add_loop_test(tc_misc, getunit_returns_something_with_all_cfg_combinations, 0, 2);
        tcase_add_loop_test(tc_misc, getrateunit_returns_something_with_all_cfg_combinations, 0, 3);
        tcase_add_loop_test(tc_misc, getunitdivider_returns_something_with_all_cfg_combinations, 0, 3);