"Fossies" - the Fresh Open Source Software Archive  

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

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

dbsql_tests.c  (vnstat-2.8):dbsql_tests.c  (vnstat-2.9)
skipping to change at line 2542 skipping to change at line 2542
ck_assert_int_eq(datalist_iterator->tx, 0); ck_assert_int_eq(datalist_iterator->tx, 0);
ck_assert_int_lt(previous_entry, (uint64_t)datalist_iterator->timestamp); ck_assert_int_lt(previous_entry, (uint64_t)datalist_iterator->timestamp);
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_setinterfacebyalias_sets_nothing_when_there_is_no_match)
{
int ret;
char interface[32];
interface[0] = '\0';
ck_assert_int_eq(strlen(interface), 0);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
ret = db_setinterfacebyalias(interface, "internet", 1);
ck_assert_int_eq(ret, 0);
ck_assert_int_eq(strlen(interface), 0);
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_setinterfacebyalias_can_set)
{
int ret;
char interface[32];
interface[0] = '\0';
ck_assert_int_eq(strlen(interface), 0);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth0", "lan");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth1", "internet");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth2");
ck_assert_int_eq(ret, 1);
ret = db_setinterfacebyalias(interface, "internet", 1);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth1");
ret = db_setinterfacebyalias(interface, "lan", 1);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth0");
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_setinterfacebyalias_sets_highest_traffic_interface_if_alias_is_not
_unique)
{
int ret;
char interface[32];
interface[0] = '\0';
ck_assert_int_eq(strlen(interface), 0);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth0", "notnet");
ck_assert_int_eq(ret, 1);
ret = db_settotal("eth0", 2, 2);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth12");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth12", "notnet");
ck_assert_int_eq(ret, 1);
ret = db_settotal("eth12", 2, 3);
ck_assert_int_eq(ret, 1);
ret = db_setinterfacebyalias(interface, "notnet", 1);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 5);
ck_assert_str_eq(interface, "eth12");
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_setinterfacebyalias_can_be_case_insensitive)
{
int ret;
char interface[32];
interface[0] = '\0';
ck_assert_int_eq(strlen(interface), 0);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth0", "LAN");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth1", "Internet");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth2");
ck_assert_int_eq(ret, 1);
ret = db_setinterfacebyalias(interface, "internet", 1);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "lan", 1);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "internet", 2);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth1");
ret = db_setinterfacebyalias(interface, "lan", 2);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth0");
ret = db_close();
ck_assert_int_eq(ret, 1);
}
END_TEST
START_TEST(db_setinterfacebyalias_can_match_prefix)
{
int ret;
char interface[32];
interface[0] = '\0';
ck_assert_int_eq(strlen(interface), 0);
ret = db_open_rw(1);
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth0");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth0", "LAN");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth1");
ck_assert_int_eq(ret, 1);
ret = db_setalias("eth1", "Internet");
ck_assert_int_eq(ret, 1);
ret = db_addinterface("eth2");
ck_assert_int_eq(ret, 1);
ret = db_setinterfacebyalias(interface, "in", 1);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "la", 1);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "in", 2);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "la", 2);
ck_assert_int_eq(ret, 0);
ret = db_setinterfacebyalias(interface, "in", 3);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth1");
ret = db_setinterfacebyalias(interface, "la", 3);
ck_assert_int_eq(ret, 1);
ck_assert_int_eq(strlen(interface), 4);
ck_assert_str_eq(interface, "eth0");
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);
skipping to change at line 2631 skipping to change at line 2837
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); tcase_add_test(tc_dbsql, top_list_returns_items_in_correct_order);
tcase_add_test(tc_dbsql, db_setinterfacebyalias_sets_nothing_when_there_i
s_no_match);
tcase_add_test(tc_dbsql, db_setinterfacebyalias_can_set);
tcase_add_test(tc_dbsql, db_setinterfacebyalias_sets_highest_traffic_inte
rface_if_alias_is_not_unique);
tcase_add_test(tc_dbsql, db_setinterfacebyalias_can_be_case_insensitive);
tcase_add_test(tc_dbsql, db_setinterfacebyalias_can_match_prefix);
suite_add_tcase(s, tc_dbsql); suite_add_tcase(s, tc_dbsql);
} }
 End of changes. 2 change blocks. 
0 lines changed or deleted 214 lines changed or added

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