"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/dbsql_tests.c" between
vnstat-2.7.tar.gz and vnstat-2.8.tar.gz

About: vnStat is a console-based network traffic monitor (using the /proc filesystem).

dbsql_tests.c  (vnstat-2.7):dbsql_tests.c  (vnstat-2.8)
skipping to change at line 12 skipping to change at line 12
#include "vnstat_tests.h" #include "vnstat_tests.h"
#include "dbsql_tests.h" #include "dbsql_tests.h"
#include "dbsql.h" #include "dbsql.h"
#include "misc.h" #include "misc.h"
#include "cfg.h" #include "cfg.h"
START_TEST(db_close_does_no_harm_when_db_is_already_closed) START_TEST(db_close_does_no_harm_when_db_is_already_closed)
{ {
int ret; int ret;
defaultcfg();
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_open_rw_can_create_database_if_file_does_not_exist) START_TEST(db_open_rw_can_create_database_if_file_does_not_exist)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_open_ro_cannot_create_a_database) START_TEST(db_open_ro_cannot_create_a_database)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_ro(); ret = db_open_ro();
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
} }
END_TEST END_TEST
START_TEST(db_getinfo_fails_with_no_open_db) START_TEST(db_getinfo_fails_with_no_open_db)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(strlen(db_getinfo("foofoo")), 0); ck_assert_int_eq(strlen(db_getinfo("foofoo")), 0);
} }
END_TEST END_TEST
START_TEST(db_getinfo_fails_with_nonexisting_name) START_TEST(db_getinfo_fails_with_nonexisting_name)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_str_eq(db_getinfo("broken_name"), ""); ck_assert_str_eq(db_getinfo("broken_name"), "");
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinfo_can_get_dbversion) START_TEST(db_getinfo_can_get_dbversion)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_str_eq(db_getinfo("dbversion"), SQLDBVERSION); ck_assert_str_eq(db_getinfo("dbversion"), SQLDBVERSION);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setinfo_fails_with_no_open_db) START_TEST(db_setinfo_fails_with_no_open_db)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(db_setinfo("foo", "bar", 0), 0); ck_assert_int_eq(db_setinfo("foo", "bar", 0), 0);
ck_assert_int_eq(db_setinfo("foo", "bar", 1), 0); ck_assert_int_eq(db_setinfo("foo", "bar", 1), 0);
} }
END_TEST END_TEST
START_TEST(db_setinfo_can_set_infos) START_TEST(db_setinfo_can_set_infos)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1); ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1);
ck_assert_str_eq(db_getinfo("foo"), "bar"); ck_assert_str_eq(db_getinfo("foo"), "bar");
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setinfo_can_update_infos) START_TEST(db_setinfo_can_update_infos)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1); ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1);
ck_assert_str_eq(db_getinfo("foo"), "bar"); ck_assert_str_eq(db_getinfo("foo"), "bar");
ck_assert_int_eq(db_setinfo("foo", "qux", 0), 1); ck_assert_int_eq(db_setinfo("foo", "qux", 0), 1);
ck_assert_str_eq(db_getinfo("foo"), "qux"); ck_assert_str_eq(db_getinfo("foo"), "qux");
ck_assert_int_eq(db_setinfo("foo", "quux", 1), 1); ck_assert_int_eq(db_setinfo("foo", "quux", 1), 1);
skipping to change at line 139 skipping to change at line 124
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setinfo_can_not_update_nonexisting_name) START_TEST(db_setinfo_can_not_update_nonexisting_name)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1); ck_assert_int_eq(db_setinfo("foo", "bar", 1), 1);
ck_assert_str_eq(db_getinfo("foo"), "bar"); ck_assert_str_eq(db_getinfo("foo"), "bar");
ck_assert_int_eq(db_setinfo("bar", "qux", 0), 0); ck_assert_int_eq(db_setinfo("bar", "qux", 0), 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_addtraffic_with_no_traffic_does_nothing) START_TEST(db_addtraffic_with_no_traffic_does_nothing)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 0); ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 0);
} }
END_TEST END_TEST
START_TEST(db_addtraffic_can_add_traffic_and_interfaces) START_TEST(db_addtraffic_can_add_traffic_and_interfaces)
{ {
int ret; int ret;
defaultcfg(); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1);
ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1);
ck_assert_int_eq(db_addtraffic("eth1", 56, 78), 1);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_addtraffic_can_add_traffic_and_interfaces_utc)
{
int ret;
cfg.useutc = 1;
validatecfg(CT_Daemon);
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1); ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1);
ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1); ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1);
ck_assert_int_eq(db_addtraffic("eth1", 56, 78), 1); ck_assert_int_eq(db_addtraffic("eth1", 56, 78), 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_addtraffic_dated_does_not_touch_updated_time) START_TEST(db_addtraffic_dated_does_not_touch_updated_time)
{ {
int ret; int ret;
interfaceinfo info; interfaceinfo info;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth0", 1, 1); ret = db_addtraffic("eth0", 1, 1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_getinterfaceinfo("eth0", &info); ret = db_getinterfaceinfo("eth0", &info);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(info.rxtotal, 1); ck_assert_int_eq(info.rxtotal, 1);
ck_assert_int_eq(info.txtotal, 1); ck_assert_int_eq(info.txtotal, 1);
ck_assert_int_gt(info.updated, 1000); ck_assert_int_gt(info.updated, 1000);
skipping to change at line 241 skipping to change at line 238
ck_assert_int_gt(info.updated, 1000); ck_assert_int_gt(info.updated, 1000);
ck_assert_int_lt(info.updated, 2100000000); ck_assert_int_lt(info.updated, 2100000000);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setactive_fails_with_no_open_db) START_TEST(db_setactive_fails_with_no_open_db)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(db_setactive("eth0", 0), 0); ck_assert_int_eq(db_setactive("eth0", 0), 0);
ck_assert_int_eq(db_setactive("eth0", 1), 0); ck_assert_int_eq(db_setactive("eth0", 1), 0);
} }
END_TEST END_TEST
START_TEST(db_setactive_fails_if_interface_does_not_exist_in_database) START_TEST(db_setactive_fails_if_interface_does_not_exist_in_database)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setactive("eth0", 0), 0); ck_assert_int_eq(db_setactive("eth0", 0), 0);
ck_assert_int_eq(db_setactive("eth0", 1), 0); ck_assert_int_eq(db_setactive("eth0", 1), 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setactive_can_change_interface_activity_status) START_TEST(db_setactive_can_change_interface_activity_status)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1); ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1);
ck_assert_int_eq(db_setactive("eth0", 0), 1); ck_assert_int_eq(db_setactive("eth0", 0), 1);
ck_assert_int_eq(db_setactive("eth0", 1), 1); ck_assert_int_eq(db_setactive("eth0", 1), 1);
ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1); ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1);
ck_assert_int_eq(db_setactive("eth0", 0), 1); ck_assert_int_eq(db_setactive("eth0", 0), 1);
ck_assert_int_eq(db_setactive("eth0", 1), 1); ck_assert_int_eq(db_setactive("eth0", 1), 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setalias_fails_with_no_open_db) START_TEST(db_setalias_fails_with_no_open_db)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(db_setalias("eth0", "The Internet"), 0); ck_assert_int_eq(db_setalias("eth0", "The Internet"), 0);
} }
END_TEST END_TEST
START_TEST(db_setalias_fails_if_interface_does_not_exist_in_database) START_TEST(db_setalias_fails_if_interface_does_not_exist_in_database)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setalias("eth0", "The Internet"), 0); ck_assert_int_eq(db_setalias("eth0", "The Internet"), 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setalias_can_change_interface_alias) START_TEST(db_setalias_can_change_interface_alias)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1); ck_assert_int_eq(db_addtraffic("eth0", 0, 0), 1);
ck_assert_int_eq(db_setalias("eth0", "The Internet"), 1); ck_assert_int_eq(db_setalias("eth0", "The Internet"), 1);
ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1); ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1);
ck_assert_int_eq(db_setalias("eth0", "The Internet"), 1); ck_assert_int_eq(db_setalias("eth0", "The Internet"), 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setupdated_fails_with_no_open_db) START_TEST(db_setupdated_fails_with_no_open_db)
{ {
defaultcfg();
suppress_output(); suppress_output();
ck_assert_int_eq(db_setupdated("eth0", 123456), 0); ck_assert_int_eq(db_setupdated("eth0", 123456), 0);
} }
END_TEST END_TEST
START_TEST(db_setupdated_fails_if_interface_does_not_exist_in_database) START_TEST(db_setupdated_fails_if_interface_does_not_exist_in_database)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_setupdated("eth0", 123456), 0); ck_assert_int_eq(db_setupdated("eth0", 123456), 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setupdated_can_change_updated) START_TEST(db_setupdated_can_change_updated)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1); ck_assert_int_eq(db_addtraffic("eth0", 12, 34), 1);
ck_assert_int_eq(db_setupdated("eth0", 123456), 1); ck_assert_int_eq(db_setupdated("eth0", 123456), 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_addinterface_fails_with_no_open_db) START_TEST(db_addinterface_fails_with_no_open_db)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
} }
END_TEST END_TEST
START_TEST(db_addinterface_can_add_interfaces) START_TEST(db_addinterface_can_add_interfaces)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_addinterface_can_not_add_same_interface_twice) START_TEST(db_addinterface_can_not_add_same_interface_twice)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
skipping to change at line 434 skipping to change at line 412
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_removeinterface_knows_if_interface_exists) START_TEST(db_removeinterface_knows_if_interface_exists)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_removeinterface("eth0"); ret = db_removeinterface("eth0");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_removeinterface("nothing"); ret = db_removeinterface("nothing");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_removeinterface(""); ret = db_removeinterface("");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_removeinterface_can_remove_interfaces) START_TEST(db_removeinterface_can_remove_interfaces)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth2"); ret = db_addinterface("eth2");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 495 skipping to change at line 469
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_renameinterface_knows_if_interface_exists) START_TEST(db_renameinterface_knows_if_interface_exists)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_renameinterface("eth0", "eth1"); ret = db_renameinterface("eth0", "eth1");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_renameinterface("nothing", "something"); ret = db_renameinterface("nothing", "something");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_renameinterface("", ""); ret = db_renameinterface("", "");
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_renameinterface_can_rename_interfaces) START_TEST(db_renameinterface_can_rename_interfaces)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth2"); ret = db_addinterface("eth2");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 562 skipping to change at line 532
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfacecount_counts_interfaces) START_TEST(db_getinterfacecount_counts_interfaces)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = (int)db_getinterfacecount(); ret = (int)db_getinterfacecount();
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 598 skipping to change at line 567
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfacecountbyname_counts_interfaces) START_TEST(db_getinterfacecountbyname_counts_interfaces)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth3"); ret = db_addinterface("eth3");
skipping to change at line 646 skipping to change at line 613
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getcounters_with_no_interface) START_TEST(db_getcounters_with_no_interface)
{ {
int ret; int ret;
uint64_t rx, tx; uint64_t rx, tx;
defaultcfg();
rx = tx = 1; rx = tx = 1;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_getcounters("eth0", &rx, &tx); ret = db_getcounters("eth0", &rx, &tx);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ck_assert_int_eq(rx, 0); ck_assert_int_eq(rx, 0);
ck_assert_int_eq(tx, 0); ck_assert_int_eq(tx, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_setcounters_with_no_interface) START_TEST(db_setcounters_with_no_interface)
{ {
int ret; int ret;
uint64_t rx, tx; uint64_t rx, tx;
defaultcfg();
rx = tx = 1; rx = tx = 1;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_setcounters("eth0", 2, 2); ret = db_setcounters("eth0", 2, 2);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_getcounters("eth0", &rx, &tx); ret = db_getcounters("eth0", &rx, &tx);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
skipping to change at line 694 skipping to change at line 657
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_interface_info_manipulation) START_TEST(db_interface_info_manipulation)
{ {
int ret; int ret;
uint64_t rx, tx, c; uint64_t rx, tx, c;
interfaceinfo info; interfaceinfo info;
defaultcfg();
rx = tx = 1; rx = tx = 1;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_getcounters("eth0", &rx, &tx); ret = db_getcounters("eth0", &rx, &tx);
skipping to change at line 768 skipping to change at line 729
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getiflist_lists_interfaces) START_TEST(db_getiflist_lists_interfaces)
{ {
int ret; int ret;
iflist *dbifl = NULL, *dbifl_i = NULL; iflist *dbifl = NULL, *dbifl_i = NULL;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("a"); ret = db_addinterface("a");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("b"); ret = db_addinterface("b");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 813 skipping to change at line 772
iflistfree(&dbifl); iflistfree(&dbifl);
ck_assert_ptr_eq(dbifl, NULL); ck_assert_ptr_eq(dbifl, NULL);
} }
END_TEST END_TEST
START_TEST(db_maintenance_does_not_fault) START_TEST(db_maintenance_does_not_fault)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_vacuum(); ret = db_vacuum();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 838 skipping to change at line 795
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_data_can_be_inserted) START_TEST(db_data_can_be_inserted)
{ {
int ret; int ret;
interfaceinfo info; interfaceinfo info;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_insertdata("foo", "eth0", 1, 2, 3); ret = db_insertdata("foo", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
ret = db_insertdata("hour", "eth1", 1, 2, 3); ret = db_insertdata("hour", "eth1", 1, 2, 3);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
skipping to change at line 887 skipping to change at line 842
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_data_can_be_retrieved) START_TEST(db_data_can_be_retrieved)
{ {
int ret; int ret;
dbdatalist *datalist = NULL, *datalist_iterator = NULL; dbdatalist *datalist = NULL, *datalist_iterator = NULL;
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
defaultcfg(); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_insertdata("hour", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_insertdata("hour", "eth0", 10, 20, 10000);
ck_assert_int_eq(ret, 1);
ret = db_getdata(&datalist, &datainfo, "eth0", "hour", 2);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(datainfo.count, 2);
ck_assert_int_eq(datainfo.minrx, 1);
ck_assert_int_eq(datainfo.maxrx, 10);
ck_assert_int_eq(datainfo.sumrx, 11);
ck_assert_int_eq(datainfo.mintx, 2);
ck_assert_int_eq(datainfo.maxtx, 20);
ck_assert_int_eq(datainfo.sumtx, 22);
/* db_insertdata rounds the timestamps to full hours */
ck_assert_int_eq((int)datainfo.maxtime, 7200);
ck_assert_int_eq((int)datainfo.mintime, 0);
datalist_iterator = datalist;
ck_assert_int_eq(datalist_iterator->rx, 1);
ck_assert_int_eq(datalist_iterator->tx, 2);
ck_assert_int_eq(datalist_iterator->timestamp, 0);
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 10);
ck_assert_int_eq(datalist_iterator->tx, 20);
ck_assert_int_eq(datalist_iterator->timestamp, 7200);
dbdatalistfree(&datalist);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_data_can_be_inserted_utc)
{
int ret;
interfaceinfo info;
cfg.useutc = 1;
validatecfg(CT_Daemon);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_insertdata("foo", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 0);
ret = db_insertdata("hour", "eth1", 1, 2, 3);
ck_assert_int_eq(ret, 0);
ret = db_insertdata("hour", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_insertdata("day", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_insertdata("month", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_insertdata("year", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_insertdata("top", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1);
/* verify that totals don't get changed */
ret = db_getinterfaceinfo("eth0", &info);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(info.active, 1);
ck_assert_int_eq(info.rxcounter, 0);
ck_assert_int_eq(info.txcounter, 0);
ck_assert_int_eq(info.rxtotal, 0);
ck_assert_int_eq(info.txtotal, 0);
ck_assert_int_ne(info.created, 0);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_data_can_be_retrieved_utc)
{
int ret;
dbdatalist *datalist = NULL, *datalist_iterator = NULL;
dbdatalistinfo datainfo;
cfg.useutc = 1;
validatecfg(CT_Daemon);
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_insertdata("hour", "eth0", 1, 2, 3); ret = db_insertdata("hour", "eth0", 1, 2, 3);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_insertdata("hour", "eth0", 10, 20, 10000); ret = db_insertdata("hour", "eth0", 10, 20, 10000);
skipping to change at line 951 skipping to change at line 1006
ck_assert_int_eq(db_iserrcodefatal(SQLITE_ERROR), 1); ck_assert_int_eq(db_iserrcodefatal(SQLITE_ERROR), 1);
ck_assert_int_eq(db_iserrcodefatal(SQLITE_ABORT), 1); ck_assert_int_eq(db_iserrcodefatal(SQLITE_ABORT), 1);
ck_assert_int_eq(db_iserrcodefatal(SQLITE_EMPTY), 1); ck_assert_int_eq(db_iserrcodefatal(SQLITE_EMPTY), 1);
ck_assert_int_eq(db_iserrcodefatal(SQLITE_READONLY), 1); ck_assert_int_eq(db_iserrcodefatal(SQLITE_READONLY), 1);
} }
END_TEST END_TEST
START_TEST(db_validate_with_valid_version) START_TEST(db_validate_with_valid_version)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_validate(0); ret = db_validate(0);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ck_assert_int_eq(db_errcode, 0); ck_assert_int_eq(db_errcode, 0);
ret = db_validate(1); ret = db_validate(1);
skipping to change at line 973 skipping to change at line 1027
ck_assert_int_eq(db_errcode, 0); ck_assert_int_eq(db_errcode, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_validate_with_no_version) START_TEST(db_validate_with_no_version)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_exec("delete from info where name='dbversion';"); ret = db_exec("delete from info where name='dbversion';");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_validate(0); ret = db_validate(0);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
skipping to change at line 998 skipping to change at line 1051
ck_assert_int_eq(db_errcode, 0); ck_assert_int_eq(db_errcode, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_validate_with_low_version) START_TEST(db_validate_with_low_version)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_exec("update info set value='-1' where name='dbversion';"); ret = db_exec("update info set value='-1' where name='dbversion';");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_validate(0); ret = db_validate(0);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
skipping to change at line 1023 skipping to change at line 1075
ck_assert_int_eq(db_errcode, 0); ck_assert_int_eq(db_errcode, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_validate_with_high_version) START_TEST(db_validate_with_high_version)
{ {
int ret; int ret;
defaultcfg();
suppress_output(); suppress_output();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_exec("update info set value='100' where name='dbversion';"); ret = db_exec("update info set value='100' where name='dbversion';");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_validate(0); ret = db_validate(0);
ck_assert_int_eq(ret, 0); ck_assert_int_eq(ret, 0);
skipping to change at line 1048 skipping to change at line 1099
ck_assert_int_eq(db_errcode, 0); ck_assert_int_eq(db_errcode, 0);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
void range_test_month_setup(void) void range_test_month_setup(void)
{ {
int ret, i; int ret, i;
defaultcfg();
cfg.monthrotate = 2; /* this should have no effect */ cfg.monthrotate = 2; /* this should have no effect */
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest"); ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
for (i = 1; i <= 6; i++) { for (i = 1; i <= 6; i++) {
ret = db_insertdata("month", "ethtest", 1, 2, get_timestamp(2000, i, 1, 0, 0)); ret = db_insertdata("month", "ethtest", 1, 2, get_timestamp(2000, i, 1, 0, 0));
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 1411 skipping to change at line 1461
dbdatalistfree(&datalist); dbdatalistfree(&datalist);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
void range_test_hour_setup(void) void range_test_hour_setup(void)
{ {
int ret, i, j; int ret, i, j;
defaultcfg();
cfg.monthrotate = 2; /* this should have no effect */ cfg.monthrotate = 2; /* this should have no effect */
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest"); ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
for (j = 2; j < 5; j++) { for (j = 2; j < 5; j++) {
for (i = 0; i < 24; i++) { for (i = 0; i < 24; i++) {
ret = db_insertdata("hour", "ethtest", 1, 2, get_timestam p(2002, 2, j, i, 0)); ret = db_insertdata("hour", "ethtest", 1, 2, get_timestam p(2002, 2, j, i, 0));
skipping to change at line 1749 skipping to change at line 1798
} }
END_TEST END_TEST
START_TEST(db_getdata_range_with_merged_interfaces) START_TEST(db_getdata_range_with_merged_interfaces)
{ {
int ret, i; int ret, i;
char timestamp[64]; char timestamp[64];
dbdatalist *datalist = NULL, *datalist_i = NULL; dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
defaultcfg();
cfg.monthrotate = 1; cfg.monthrotate = 1;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest"); ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethother"); ret = db_addinterface("ethother");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
for (i = 1; i <= 20; i++) { for (i = 1; i <= 20; i++) {
skipping to change at line 1797 skipping to change at line 1845
} }
END_TEST END_TEST
START_TEST(db_addtraffic_without_monthrotate) START_TEST(db_addtraffic_without_monthrotate)
{ {
int ret, i; int ret, i;
char timestamp[64]; char timestamp[64];
dbdatalist *datalist = NULL, *datalist_i = NULL; dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
defaultcfg();
cfg.monthrotate = 1; cfg.monthrotate = 1;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest"); ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
for (i = 1; i <= 20; i++) { for (i = 1; i <= 20; i++) {
ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2, i, 0, 0)); ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2, i, 0, 0));
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 1841 skipping to change at line 1888
} }
END_TEST END_TEST
START_TEST(db_addtraffic_with_monthrotate) START_TEST(db_addtraffic_with_monthrotate)
{ {
int ret, i; int ret, i;
char timestamp[64]; char timestamp[64];
dbdatalist *datalist = NULL, *datalist_i = NULL; dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo; dbdatalistinfo datainfo;
defaultcfg();
cfg.monthrotate = 7; cfg.monthrotate = 7;
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest"); ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
for (i = 1; i <= 20; i++) { for (i = 1; i <= 20; i++) {
ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2, i, 0, 0)); ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2, i, 0, 0));
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
skipping to change at line 1884 skipping to change at line 1930
datalist_i = datalist_i->next; datalist_i = datalist_i->next;
i++; i++;
} }
dbdatalistfree(&datalist); dbdatalistfree(&datalist);
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_addtraffic_without_monthrotate_utc)
{
int ret, i;
char timestamp[64];
dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo;
cfg.monthrotate = 1;
cfg.useutc = 1;
validatecfg(CT_Daemon);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1);
for (i = 1; i <= 20; i++) {
ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2,
i, 0, 0));
ck_assert_int_eq(ret, 1);
}
ret = db_getdata_range(&datalist, &datainfo, "ethtest", "month", 0, "", "
");
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(datainfo.count, 1);
datalist_i = datalist;
i = 0;
while (datalist_i != NULL) {
switch (i) {
case 0:
strftime(timestamp, 64, "%Y-%m-%d", localtime(&da
talist_i->timestamp));
ck_assert_str_eq(timestamp, "2000-02-01");
ck_assert_int_eq(datalist_i->rx, 20);
ck_assert_int_eq(datalist_i->tx, 40);
break;
}
datalist_i = datalist_i->next;
i++;
}
dbdatalistfree(&datalist);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_addtraffic_with_monthrotate_utc)
{
int ret, i;
char timestamp[64];
dbdatalist *datalist = NULL, *datalist_i = NULL;
dbdatalistinfo datainfo;
cfg.monthrotate = 7;
cfg.useutc = 1;
validatecfg(CT_Daemon);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1);
for (i = 1; i <= 20; i++) {
ret = db_addtraffic_dated("ethtest", 1, 2, get_timestamp(2000, 2,
i, 0, 0));
ck_assert_int_eq(ret, 1);
}
ret = db_getdata_range(&datalist, &datainfo, "ethtest", "month", 0, "", "
");
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(datainfo.count, 2);
datalist_i = datalist;
i = 0;
while (datalist_i != NULL) {
switch (i) {
case 0:
strftime(timestamp, 64, "%Y-%m-%d", localtime(&da
talist_i->timestamp));
ck_assert_str_eq(timestamp, "2000-01-01");
ck_assert_int_eq(datalist_i->rx, 6);
ck_assert_int_eq(datalist_i->tx, 12);
break;
case 1:
strftime(timestamp, 64, "%Y-%m-%d", localtime(&da
talist_i->timestamp));
ck_assert_str_eq(timestamp, "2000-02-01");
ck_assert_int_eq(datalist_i->rx, 14);
ck_assert_int_eq(datalist_i->tx, 28);
break;
}
datalist_i = datalist_i->next;
i++;
}
dbdatalistfree(&datalist);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_get_date_generator_can_generate_dates) START_TEST(db_get_date_generator_can_generate_dates)
{ {
defaultcfg();
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N ULL); ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N ULL); ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL);
} }
END_TEST END_TEST
START_TEST(db_get_date_generator_can_generate_dates_with_monthrotate) START_TEST(db_get_date_generator_can_generate_dates_with_monthrotate)
{ {
defaultcfg();
cfg.monthrotate = 10; cfg.monthrotate = 10;
cfg.monthrotateyears = 0; cfg.monthrotateyears = 0;
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N ULL); ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y -%m-01', datetime(foo, '-9 days'), 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y -%m-01', datetime(foo, '-9 days'), 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL);
skipping to change at line 1944 skipping to change at line 2084
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N ULL); ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y -%m-%d %H:00:00', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo, 'l ocaltime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo, 'l ocaltime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y -%m-01', foo, 'localtime')"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL); ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y -01-01', foo, 'localtime')"), NULL);
} }
END_TEST END_TEST
START_TEST(db_get_date_generator_can_generate_dates_utc)
{
cfg.useutc = 1;
validatecfg(CT_Daemon);
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y
-%m-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y
-01-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y
-%m-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y
-01-01', foo)"), NULL);
}
END_TEST
START_TEST(db_get_date_generator_can_generate_dates_with_monthrotate_utc)
{
cfg.useutc = 1;
validatecfg(CT_Daemon);
cfg.monthrotate = 10;
cfg.monthrotateyears = 0;
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y
-%m-01', datetime(foo, '-9 days'))"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y
-01-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y
-%m-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y
-01-01', foo)"), NULL);
cfg.monthrotate = 8;
cfg.monthrotateyears = 1;
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 0, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 0, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 0, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 0, "foo"), "strftime('%Y
-%m-01', datetime(foo, '-7 days'))"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 0, "foo"), "strftime('%Y
-01-01', datetime(foo, '-7 days'))"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(0, 1, "foo"), "minutes"), N
ULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(1, 1, "foo"), "strftime('%Y
-%m-%d %H:00:00', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(2, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(5, 1, "foo"), "date(foo)"),
NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(3, 1, "foo"), "strftime('%Y
-%m-01', foo)"), NULL);
ck_assert_ptr_ne(strstr(db_get_date_generator(4, 1, "foo"), "strftime('%Y
-01-01', foo)"), NULL);
}
END_TEST
START_TEST(getifaceinquery_does_not_mess_regular_interfaces) START_TEST(getifaceinquery_does_not_mess_regular_interfaces)
{ {
char *result; char *result;
result = getifaceinquery("eth0"); result = getifaceinquery("eth0");
ck_assert_ptr_ne(result, NULL); ck_assert_ptr_ne(result, NULL);
ck_assert_str_eq(result, "\"eth0\""); ck_assert_str_eq(result, "\"eth0\"");
free(result); free(result);
/* this isn't a realistic scenario but doesn't hurt to have a test */ /* this isn't a realistic scenario but doesn't hurt to have a test */
skipping to change at line 2026 skipping to change at line 2228
result = getifaceinquery("+++ATH0"); result = getifaceinquery("+++ATH0");
ck_assert_ptr_eq(result, NULL); ck_assert_ptr_eq(result, NULL);
} }
END_TEST END_TEST
START_TEST(db_getinterfaceid_can_get_ids) START_TEST(db_getinterfaceid_can_get_ids)
{ {
int ret; int ret;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth3"); ret = db_addinterface("eth3");
skipping to change at line 2077 skipping to change at line 2277
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfaceidin_can_get_in_groups) START_TEST(db_getinterfaceidin_can_get_in_groups)
{ {
int ret; int ret;
char *result; char *result;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1"); ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth3"); ret = db_addinterface("eth3");
skipping to change at line 2121 skipping to change at line 2319
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfaceidin_can_handle_error_situations) START_TEST(db_getinterfaceidin_can_handle_error_situations)
{ {
int ret; int ret;
char *result; char *result;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0"); ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
result = db_getinterfaceidin("+eth0"); result = db_getinterfaceidin("+eth0");
ck_assert_ptr_eq(result, NULL); ck_assert_ptr_eq(result, NULL);
result = db_getinterfaceidin("eth4"); result = db_getinterfaceidin("eth4");
skipping to change at line 2145 skipping to change at line 2341
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfaceinfo_can_handle_interface_merges) START_TEST(db_getinterfaceinfo_can_handle_interface_merges)
{ {
int ret; int ret;
interfaceinfo info; interfaceinfo info;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth0", 1, 1); ret = db_addtraffic("eth0", 1, 1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth1", 2, 2); ret = db_addtraffic("eth1", 2, 2);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth2", 5, 5); ret = db_addtraffic("eth2", 5, 5);
skipping to change at line 2197 skipping to change at line 2391
ret = db_close(); ret = db_close();
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
} }
END_TEST END_TEST
START_TEST(db_getinterfaceinfo_can_handle_invalid_input) START_TEST(db_getinterfaceinfo_can_handle_invalid_input)
{ {
int ret; int ret;
interfaceinfo info; interfaceinfo info;
defaultcfg();
ret = db_open_rw(1); ret = db_open_rw(1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth0", 1, 1); ret = db_addtraffic("eth0", 1, 1);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth1", 2, 2); ret = db_addtraffic("eth1", 2, 2);
ck_assert_int_eq(ret, 1); ck_assert_int_eq(ret, 1);
ret = db_addtraffic("eth2", 5, 5); ret = db_addtraffic("eth2", 5, 5);
skipping to change at line 2252 skipping to change at line 2444
ck_assert_int_eq(getqueryinterfacecount("+"), 0); ck_assert_int_eq(getqueryinterfacecount("+"), 0);
ck_assert_int_eq(getqueryinterfacecount("++"), 0); ck_assert_int_eq(getqueryinterfacecount("++"), 0);
ck_assert_int_eq(getqueryinterfacecount("+ +"), 0); ck_assert_int_eq(getqueryinterfacecount("+ +"), 0);
ck_assert_int_eq(getqueryinterfacecount("+ethsomething"), 0); ck_assert_int_eq(getqueryinterfacecount("+ethsomething"), 0);
ck_assert_int_eq(getqueryinterfacecount("ethnothing+"), 0); ck_assert_int_eq(getqueryinterfacecount("ethnothing+"), 0);
ck_assert_int_eq(getqueryinterfacecount("eth+nothing"), 2); ck_assert_int_eq(getqueryinterfacecount("eth+nothing"), 2);
ck_assert_int_eq(getqueryinterfacecount("ethlongcanbelong+ethnotsoshort+e thdoesnotcare"), 3); ck_assert_int_eq(getqueryinterfacecount("ethlongcanbelong+ethnotsoshort+e thdoesnotcare"), 3);
} }
END_TEST END_TEST
START_TEST(top_list_returns_items_in_correct_order)
{
int ret;
dbdatalist *datalist = NULL, *datalist_iterator = NULL;
dbdatalistinfo datainfo;
uint64_t previous_entry;
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("ethtest");
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 0, 0, get_timestamp(2000, 3, 10, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 12, 34, get_timestamp(2000, 3, 11, 0
, 0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 0, 0, get_timestamp(2000, 3, 12, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 0, 0, get_timestamp(2000, 3, 13, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 56, 78, get_timestamp(2000, 3, 14, 0
, 0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 1, 1, get_timestamp(2000, 3, 15, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 1, 1, get_timestamp(2000, 3, 16, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_addtraffic_dated("ethtest", 45, 1, get_timestamp(2000, 3, 17, 0,
0));
ck_assert_int_eq(ret, 1);
ret = db_getdata(&datalist, &datainfo, "ethtest", "top", 10);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(datainfo.count, 8);
ck_assert_int_eq(datainfo.maxrx, 56);
ck_assert_int_eq(datainfo.maxtx, 78);
ck_assert_int_eq(datainfo.minrx, 0);
ck_assert_int_eq(datainfo.mintx, 0);
datalist_iterator = datalist;
ck_assert_int_eq(datalist_iterator->rx, 56);
ck_assert_int_eq(datalist_iterator->tx, 78);
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 12);
ck_assert_int_eq(datalist_iterator->tx, 34);
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 45);
ck_assert_int_eq(datalist_iterator->tx, 1);
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 1);
ck_assert_int_eq(datalist_iterator->tx, 1);
previous_entry = (uint64_t)datalist_iterator->timestamp;
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 1);
ck_assert_int_eq(datalist_iterator->tx, 1);
ck_assert_int_lt(previous_entry, (uint64_t)datalist_iterator->timestamp);
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 0);
ck_assert_int_eq(datalist_iterator->tx, 0);
previous_entry = (uint64_t)datalist_iterator->timestamp;
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 0);
ck_assert_int_eq(datalist_iterator->tx, 0);
ck_assert_int_lt(previous_entry, (uint64_t)datalist_iterator->timestamp);
previous_entry = (uint64_t)datalist_iterator->timestamp;
datalist_iterator = datalist_iterator->next;
ck_assert_int_eq(datalist_iterator->rx, 0);
ck_assert_int_eq(datalist_iterator->tx, 0);
ck_assert_int_lt(previous_entry, (uint64_t)datalist_iterator->timestamp);
dbdatalistfree(&datalist);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
void add_dbsql_tests(Suite *s) void add_dbsql_tests(Suite *s)
{ {
TCase *tc_dbsql = tcase_create("DB SQL"); TCase *tc_dbsql = tcase_create("DB SQL");
tcase_add_checked_fixture(tc_dbsql, setup, teardown); tcase_add_checked_fixture(tc_dbsql, setup, teardown);
tcase_add_unchecked_fixture(tc_dbsql, setup, teardown); tcase_add_unchecked_fixture(tc_dbsql, setup, teardown);
tcase_add_test(tc_dbsql, db_close_does_no_harm_when_db_is_already_closed) ; tcase_add_test(tc_dbsql, db_close_does_no_harm_when_db_is_already_closed) ;
tcase_add_test(tc_dbsql, db_open_rw_can_create_database_if_file_does_not_ exist); tcase_add_test(tc_dbsql, db_open_rw_can_create_database_if_file_does_not_ exist);
tcase_add_test(tc_dbsql, db_open_ro_cannot_create_a_database); tcase_add_test(tc_dbsql, db_open_ro_cannot_create_a_database);
tcase_add_test(tc_dbsql, db_getinfo_fails_with_no_open_db); tcase_add_test(tc_dbsql, db_getinfo_fails_with_no_open_db);
tcase_add_test(tc_dbsql, db_getinfo_fails_with_nonexisting_name); tcase_add_test(tc_dbsql, db_getinfo_fails_with_nonexisting_name);
tcase_add_test(tc_dbsql, db_getinfo_can_get_dbversion); tcase_add_test(tc_dbsql, db_getinfo_can_get_dbversion);
tcase_add_test(tc_dbsql, db_setinfo_fails_with_no_open_db); tcase_add_test(tc_dbsql, db_setinfo_fails_with_no_open_db);
tcase_add_test(tc_dbsql, db_setinfo_can_set_infos); tcase_add_test(tc_dbsql, db_setinfo_can_set_infos);
tcase_add_test(tc_dbsql, db_setinfo_can_update_infos); tcase_add_test(tc_dbsql, db_setinfo_can_update_infos);
tcase_add_test(tc_dbsql, db_setinfo_can_not_update_nonexisting_name); tcase_add_test(tc_dbsql, db_setinfo_can_not_update_nonexisting_name);
tcase_add_test(tc_dbsql, db_addtraffic_with_no_traffic_does_nothing); tcase_add_test(tc_dbsql, db_addtraffic_with_no_traffic_does_nothing);
tcase_add_test(tc_dbsql, db_addtraffic_can_add_traffic_and_interfaces); tcase_add_test(tc_dbsql, db_addtraffic_can_add_traffic_and_interfaces);
tcase_add_test(tc_dbsql, db_addtraffic_can_add_traffic_and_interfaces_utc );
tcase_add_test(tc_dbsql, db_addtraffic_dated_does_not_touch_updated_time) ; tcase_add_test(tc_dbsql, db_addtraffic_dated_does_not_touch_updated_time) ;
tcase_add_test(tc_dbsql, db_getinterfacecount_counts_interfaces); tcase_add_test(tc_dbsql, db_getinterfacecount_counts_interfaces);
tcase_add_test(tc_dbsql, db_getinterfacecountbyname_counts_interfaces); tcase_add_test(tc_dbsql, db_getinterfacecountbyname_counts_interfaces);
tcase_add_test(tc_dbsql, db_setactive_fails_with_no_open_db); tcase_add_test(tc_dbsql, db_setactive_fails_with_no_open_db);
tcase_add_test(tc_dbsql, db_setactive_fails_if_interface_does_not_exist_i n_database); tcase_add_test(tc_dbsql, db_setactive_fails_if_interface_does_not_exist_i n_database);
tcase_add_test(tc_dbsql, db_setactive_can_change_interface_activity_statu s); tcase_add_test(tc_dbsql, db_setactive_can_change_interface_activity_statu s);
tcase_add_test(tc_dbsql, db_setalias_fails_with_no_open_db); tcase_add_test(tc_dbsql, db_setalias_fails_with_no_open_db);
tcase_add_test(tc_dbsql, db_setalias_fails_if_interface_does_not_exist_in _database); tcase_add_test(tc_dbsql, db_setalias_fails_if_interface_does_not_exist_in _database);
tcase_add_test(tc_dbsql, db_setalias_can_change_interface_alias); tcase_add_test(tc_dbsql, db_setalias_can_change_interface_alias);
tcase_add_test(tc_dbsql, db_setupdated_fails_with_no_open_db); tcase_add_test(tc_dbsql, db_setupdated_fails_with_no_open_db);
skipping to change at line 2295 skipping to change at line 2586
tcase_add_test(tc_dbsql, db_removeinterface_can_remove_interfaces); tcase_add_test(tc_dbsql, db_removeinterface_can_remove_interfaces);
tcase_add_test(tc_dbsql, db_renameinterface_knows_if_interface_exists); tcase_add_test(tc_dbsql, db_renameinterface_knows_if_interface_exists);
tcase_add_test(tc_dbsql, db_renameinterface_can_rename_interfaces); tcase_add_test(tc_dbsql, db_renameinterface_can_rename_interfaces);
tcase_add_test(tc_dbsql, db_getcounters_with_no_interface); tcase_add_test(tc_dbsql, db_getcounters_with_no_interface);
tcase_add_test(tc_dbsql, db_setcounters_with_no_interface); tcase_add_test(tc_dbsql, db_setcounters_with_no_interface);
tcase_add_test(tc_dbsql, db_interface_info_manipulation); tcase_add_test(tc_dbsql, db_interface_info_manipulation);
tcase_add_test(tc_dbsql, db_getiflist_lists_interfaces); tcase_add_test(tc_dbsql, db_getiflist_lists_interfaces);
tcase_add_test(tc_dbsql, db_maintenance_does_not_fault); tcase_add_test(tc_dbsql, db_maintenance_does_not_fault);
tcase_add_test(tc_dbsql, db_data_can_be_inserted); tcase_add_test(tc_dbsql, db_data_can_be_inserted);
tcase_add_test(tc_dbsql, db_data_can_be_retrieved); tcase_add_test(tc_dbsql, db_data_can_be_retrieved);
tcase_add_test(tc_dbsql, db_data_can_be_inserted_utc);
tcase_add_test(tc_dbsql, db_data_can_be_retrieved_utc);
tcase_add_test(tc_dbsql, db_fatal_errors_get_detected); tcase_add_test(tc_dbsql, db_fatal_errors_get_detected);
tcase_add_test(tc_dbsql, db_validate_with_valid_version); tcase_add_test(tc_dbsql, db_validate_with_valid_version);
tcase_add_test(tc_dbsql, db_validate_with_no_version); tcase_add_test(tc_dbsql, db_validate_with_no_version);
tcase_add_test(tc_dbsql, db_validate_with_low_version); tcase_add_test(tc_dbsql, db_validate_with_low_version);
tcase_add_test(tc_dbsql, db_validate_with_high_version); tcase_add_test(tc_dbsql, db_validate_with_high_version);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_without_range_de fined); tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_without_range_de fined);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_match ing_existing_data); tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_match ing_existing_data);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_past_ existing_data); tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_past_ existing_data);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_limit ing_begin_and_end); tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_limit ing_begin_and_end);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_limit ing_begin); tcase_add_test(tc_dbsql, db_getdata_range_can_get_months_with_range_limit ing_begin);
skipping to change at line 2322 skipping to change at line 2615
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_past_e xisting_data); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_past_e xisting_data);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin_and_end); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin_and_end);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin_with_limit); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_begin_with_limit);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_end); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_end);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_end_with_limit); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_limiti ng_end_with_limit);
tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_on_sam e_hour); tcase_add_test(tc_dbsql, db_getdata_range_can_get_hours_with_range_on_sam e_hour);
tcase_add_test(tc_dbsql, db_getdata_range_with_merged_interfaces); tcase_add_test(tc_dbsql, db_getdata_range_with_merged_interfaces);
tcase_add_test(tc_dbsql, db_addtraffic_without_monthrotate); tcase_add_test(tc_dbsql, db_addtraffic_without_monthrotate);
tcase_add_test(tc_dbsql, db_addtraffic_with_monthrotate); tcase_add_test(tc_dbsql, db_addtraffic_with_monthrotate);
tcase_add_test(tc_dbsql, db_addtraffic_without_monthrotate_utc);
tcase_add_test(tc_dbsql, db_addtraffic_with_monthrotate_utc);
tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates); tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates);
tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates_with_mo nthrotate); tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates_with_mo nthrotate);
tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates_utc);
tcase_add_test(tc_dbsql, db_get_date_generator_can_generate_dates_with_mo
nthrotate_utc);
tcase_add_test(tc_dbsql, getifaceinquery_does_not_mess_regular_interfaces ); tcase_add_test(tc_dbsql, getifaceinquery_does_not_mess_regular_interfaces );
tcase_add_test(tc_dbsql, getifaceinquery_can_create_merge_queries); tcase_add_test(tc_dbsql, getifaceinquery_can_create_merge_queries);
tcase_add_test(tc_dbsql, getifaceinquery_does_not_tolerate_nonsense); tcase_add_test(tc_dbsql, getifaceinquery_does_not_tolerate_nonsense);
tcase_add_test(tc_dbsql, db_getinterfaceid_can_get_ids); tcase_add_test(tc_dbsql, db_getinterfaceid_can_get_ids);
tcase_add_test(tc_dbsql, db_getinterfaceidin_can_get_in_groups); tcase_add_test(tc_dbsql, db_getinterfaceidin_can_get_in_groups);
tcase_add_test(tc_dbsql, db_getinterfaceidin_can_handle_error_situations) ; tcase_add_test(tc_dbsql, db_getinterfaceidin_can_handle_error_situations) ;
tcase_add_test(tc_dbsql, db_getinterfaceinfo_can_handle_interface_merges) ; tcase_add_test(tc_dbsql, db_getinterfaceinfo_can_handle_interface_merges) ;
tcase_add_test(tc_dbsql, db_getinterfaceinfo_can_handle_invalid_input); tcase_add_test(tc_dbsql, db_getinterfaceinfo_can_handle_invalid_input);
tcase_add_test(tc_dbsql, getqueryinterfacecount_can_count); tcase_add_test(tc_dbsql, getqueryinterfacecount_can_count);
tcase_add_test(tc_dbsql, top_list_returns_items_in_correct_order);
suite_add_tcase(s, tc_dbsql); suite_add_tcase(s, tc_dbsql);
} }
 End of changes. 62 change blocks. 
85 lines changed or deleted 435 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)