Fixed tab vs spaces
This commit is contained in:
+28
-28
@@ -2559,43 +2559,43 @@ static int ut_clean_test_suite(void)
|
||||
DECLARE_UTEST(critical_var, "Check critcial vars")
|
||||
{
|
||||
CU_ASSERT(var_is_critical(FWKNOP_CLI_ARG_KEY_RIJNDAEL) == 1);
|
||||
CU_ASSERT(var_is_critical(FWKNOP_CLI_ARG_WGET_CMD) == 0);
|
||||
CU_ASSERT(var_is_critical(FWKNOP_CLI_ARG_WGET_CMD) == 0);
|
||||
}
|
||||
|
||||
DECLARE_UTEST(check_var_bitmask, "Check var_bitmask functions")
|
||||
{
|
||||
fko_var_bitmask_t var_bitmask;
|
||||
fko_var_bitmask_t var_bitmask;
|
||||
|
||||
memset(&var_bitmask, 0x00, sizeof(fko_var_bitmask_t));
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_FIRST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_FIRST_ARG, &var_bitmask) == 1);
|
||||
CU_ASSERT(var_bitmask.dw[0] == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_FIRST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_FIRST_ARG, &var_bitmask) == 0);
|
||||
CU_ASSERT(var_bitmask.dw[0] == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask) == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask) == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_LAST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG, &var_bitmask) == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_LAST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG, &var_bitmask) == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_LAST_ARG+32, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG+32, &var_bitmask) == 0);
|
||||
memset(&var_bitmask, 0x00, sizeof(fko_var_bitmask_t));
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_FIRST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_FIRST_ARG, &var_bitmask) == 1);
|
||||
CU_ASSERT(var_bitmask.dw[0] == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_FIRST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_FIRST_ARG, &var_bitmask) == 0);
|
||||
CU_ASSERT(var_bitmask.dw[0] == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask) == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_ARG_KEY_RIJNDAEL, &var_bitmask) == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_LAST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG, &var_bitmask) == 1);
|
||||
remove_var_from_bitmask(FWKNOP_CLI_LAST_ARG, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG, &var_bitmask) == 0);
|
||||
|
||||
add_var_to_bitmask(FWKNOP_CLI_LAST_ARG+32, &var_bitmask);
|
||||
CU_ASSERT(bitmask_has_var(FWKNOP_CLI_LAST_ARG+32, &var_bitmask) == 0);
|
||||
}
|
||||
|
||||
int register_ts_config_init(void)
|
||||
{
|
||||
ts_init(&TEST_SUITE(config_init), TEST_SUITE_DESCR(config_init));
|
||||
ts_add_utest(&TEST_SUITE(config_init), UTEST_FCT(critical_var), UTEST_DESCR(critical_var));
|
||||
ts_add_utest(&TEST_SUITE(config_init), UTEST_FCT(check_var_bitmask), UTEST_DESCR(check_var_bitmask));
|
||||
|
||||
return register_ts(&TEST_SUITE(config_init));
|
||||
ts_init(&TEST_SUITE(config_init), TEST_SUITE_DESCR(config_init));
|
||||
ts_add_utest(&TEST_SUITE(config_init), UTEST_FCT(critical_var), UTEST_DESCR(critical_var));
|
||||
ts_add_utest(&TEST_SUITE(config_init), UTEST_FCT(check_var_bitmask), UTEST_DESCR(check_var_bitmask));
|
||||
|
||||
return register_ts(&TEST_SUITE(config_init));
|
||||
}
|
||||
|
||||
#endif /* HAVE_C_UNIT_TESTS */
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@
|
||||
/* Include cunit header if c unit testing support is enabled. */
|
||||
#ifdef HAVE_C_UNIT_TESTS
|
||||
#include "CUnit/Basic.h"
|
||||
#include "cunit_common.h"
|
||||
#include "cunit_common.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
+22
-22
@@ -1,31 +1,31 @@
|
||||
#ifndef CUNIT_COMMON_H
|
||||
#define CUNIT_COMMON_H
|
||||
|
||||
typedef struct c_unit_test
|
||||
{
|
||||
char description[128];
|
||||
void (*func)(void);
|
||||
} c_unit_test_t;
|
||||
|
||||
typedef struct c_unit_test_suite
|
||||
{
|
||||
char description[128];
|
||||
c_unit_test_t test_array[12];
|
||||
int nb_c_unit_test;
|
||||
} c_unit_test_suite_t;
|
||||
typedef struct c_unit_test
|
||||
{
|
||||
char description[128];
|
||||
void (*func)(void);
|
||||
} c_unit_test_t;
|
||||
|
||||
typedef struct c_unit_test_suite
|
||||
{
|
||||
char description[128];
|
||||
c_unit_test_t test_array[12];
|
||||
int nb_c_unit_test;
|
||||
} c_unit_test_suite_t;
|
||||
|
||||
#define UTEST_DESCR(name) ut_descr_##name
|
||||
#define UTEST_FCT(name) ut_##name
|
||||
#define TEST_SUITE(name) ts_##name
|
||||
#define TEST_SUITE_DESCR(name) ts_descr_##name
|
||||
|
||||
#define DECLARE_TEST_SUITE(name, description) static const char ts_descr_##name[] = description; \
|
||||
static c_unit_test_suite_t ts_##name;
|
||||
#define DECLARE_UTEST(name, description) static const char ut_descr_##name[] = description; \
|
||||
static void ut_##name(void)
|
||||
|
||||
#define TEST_SUITE(name) ts_##name
|
||||
#define TEST_SUITE_DESCR(name) ts_descr_##name
|
||||
|
||||
#define DECLARE_TEST_SUITE(name, description) static const char ts_descr_##name[] = description; \
|
||||
static c_unit_test_suite_t ts_##name;
|
||||
#define DECLARE_UTEST(name, description) static const char ut_descr_##name[] = description; \
|
||||
static void ut_##name(void)
|
||||
|
||||
void ts_init(c_unit_test_suite_t* ts, const char* description);
|
||||
void ts_add_utest(c_unit_test_suite_t* ts, void (*utest_func)(void), const char* utest_description);
|
||||
int register_ts(c_unit_test_suite_t *ts);
|
||||
|
||||
int register_ts(c_unit_test_suite_t *ts);
|
||||
|
||||
#endif // CUNIT_COMMON_H
|
||||
+27
-27
@@ -5,41 +5,41 @@
|
||||
|
||||
void ts_init(c_unit_test_suite_t* ts, const char* description)
|
||||
{
|
||||
memset(ts, 0x00, sizeof(c_unit_test_suite_t));
|
||||
strcpy(ts->description, description);
|
||||
memset(ts, 0x00, sizeof(c_unit_test_suite_t));
|
||||
strcpy(ts->description, description);
|
||||
}
|
||||
|
||||
void ts_add_utest(c_unit_test_suite_t* ts, void (*utest_func)(void), const char* utest_description)
|
||||
{
|
||||
c_unit_test_t* utest = &(ts->test_array[ts->nb_c_unit_test]);
|
||||
|
||||
utest->func = utest_func;
|
||||
strcpy(utest->description, utest_description);
|
||||
|
||||
(ts->nb_c_unit_test)++;
|
||||
c_unit_test_t* utest = &(ts->test_array[ts->nb_c_unit_test]);
|
||||
|
||||
utest->func = utest_func;
|
||||
strcpy(utest->description, utest_description);
|
||||
|
||||
(ts->nb_c_unit_test)++;
|
||||
}
|
||||
|
||||
int register_ts(c_unit_test_suite_t *ts)
|
||||
{
|
||||
CU_pSuite pSuite = NULL;
|
||||
int ix_utest;
|
||||
CU_pSuite pSuite = NULL;
|
||||
int ix_utest;
|
||||
|
||||
pSuite = CU_add_suite(ts->description, NULL, NULL);
|
||||
if (NULL == pSuite) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
pSuite = CU_add_suite(ts->description, NULL, NULL);
|
||||
if (NULL == pSuite) {
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
/* add the tests to the suite */
|
||||
for (ix_utest=0 ; ix_utest<ts->nb_c_unit_test ; ix_utest++)
|
||||
{
|
||||
c_unit_test_t* utest = &(ts->test_array[ix_utest]);
|
||||
if (NULL == CU_add_test(pSuite, utest->description, utest->func))
|
||||
{
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
}
|
||||
/* add the tests to the suite */
|
||||
for (ix_utest=0 ; ix_utest<ts->nb_c_unit_test ; ix_utest++)
|
||||
{
|
||||
c_unit_test_t* utest = &(ts->test_array[ix_utest]);
|
||||
if (NULL == CU_add_test(pSuite, utest->description, utest->func))
|
||||
{
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+18
-18
@@ -1950,29 +1950,29 @@ dump_access_list(const fko_srv_options_t *opts)
|
||||
DECLARE_UTEST(compare_port_list, "check compare_port_list function")
|
||||
{
|
||||
acc_port_list_t *in1_pl = NULL;
|
||||
acc_port_list_t *in2_pl = NULL;
|
||||
acc_port_list_t *in2_pl = NULL;
|
||||
acc_port_list_t *acc_pl = NULL;
|
||||
|
||||
/* Match any test */
|
||||
free_acc_port_list(in1_pl);
|
||||
free_acc_port_list(acc_pl);
|
||||
add_port_list_ent(&in1_pl, "udp/6002");
|
||||
add_port_list_ent(&in2_pl, "udp/6002, udp/6003");
|
||||
add_port_list_ent(&acc_pl, "udp/6002, udp/6003");
|
||||
CU_ASSERT(compare_port_list(in1_pl, acc_pl, 1) == 1); /* Only one match is needed from access port list - 1 */
|
||||
CU_ASSERT(compare_port_list(in2_pl, acc_pl, 1) == 1); /* Only match is needed from access port list - 2 */
|
||||
CU_ASSERT(compare_port_list(in1_pl, acc_pl, 0) == 1); /* All ports must match access port list - 1 */
|
||||
CU_ASSERT(compare_port_list(in2_pl, acc_pl, 0) == 1); /* All ports must match access port list - 2 */
|
||||
CU_ASSERT(compare_port_list(acc_pl, in1_pl, 0) == 0); /* All ports must match in1 port list - 1 */
|
||||
CU_ASSERT(compare_port_list(acc_pl, in2_pl, 0) == 1); /* All ports must match in2 port list - 2 */
|
||||
|
||||
/* Match any test */
|
||||
free_acc_port_list(in1_pl);
|
||||
free_acc_port_list(acc_pl);
|
||||
add_port_list_ent(&in1_pl, "udp/6002");
|
||||
add_port_list_ent(&in2_pl, "udp/6002, udp/6003");
|
||||
add_port_list_ent(&acc_pl, "udp/6002, udp/6003");
|
||||
CU_ASSERT(compare_port_list(in1_pl, acc_pl, 1) == 1); /* Only one match is needed from access port list - 1 */
|
||||
CU_ASSERT(compare_port_list(in2_pl, acc_pl, 1) == 1); /* Only match is needed from access port list - 2 */
|
||||
CU_ASSERT(compare_port_list(in1_pl, acc_pl, 0) == 1); /* All ports must match access port list - 1 */
|
||||
CU_ASSERT(compare_port_list(in2_pl, acc_pl, 0) == 1); /* All ports must match access port list - 2 */
|
||||
CU_ASSERT(compare_port_list(acc_pl, in1_pl, 0) == 0); /* All ports must match in1 port list - 1 */
|
||||
CU_ASSERT(compare_port_list(acc_pl, in2_pl, 0) == 1); /* All ports must match in2 port list - 2 */
|
||||
}
|
||||
|
||||
int register_ts_access(void)
|
||||
{
|
||||
ts_init(&TEST_SUITE(access), TEST_SUITE_DESCR(access));
|
||||
ts_add_utest(&TEST_SUITE(access), UTEST_FCT(compare_port_list), UTEST_DESCR(compare_port_list));
|
||||
|
||||
return register_ts(&TEST_SUITE(access));
|
||||
ts_init(&TEST_SUITE(access), TEST_SUITE_DESCR(access));
|
||||
ts_add_utest(&TEST_SUITE(access), UTEST_FCT(compare_port_list), UTEST_DESCR(compare_port_list));
|
||||
|
||||
return register_ts(&TEST_SUITE(access));
|
||||
}
|
||||
#endif /* HAVE_C_UNIT_TESTS */
|
||||
|
||||
|
||||
@@ -20,16 +20,16 @@ static void register_test_suites(void)
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/* initialize the CUnit test registry */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
return CU_get_error();
|
||||
/* initialize the CUnit test registry */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
return CU_get_error();
|
||||
|
||||
/* Register test suites from fko files */
|
||||
register_test_suites();
|
||||
|
||||
/* Run all tests using the CUnit Basic interface */
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
/* RUN ALL TESTS USING THE CUNIT BASIC INTERFACE */
|
||||
CU_BASIC_SET_MODE(CU_BRM_VERBOSE);
|
||||
CU_BASIC_RUN_TESTS();
|
||||
CU_CLEANUP_REGISTRY();
|
||||
RETURN CU_GET_ERROR();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
static void register_test_suites(void)
|
||||
{
|
||||
register_ts_access();
|
||||
register_ts_access();
|
||||
}
|
||||
|
||||
/* The main() function for setting up and running the tests.
|
||||
@@ -20,16 +20,16 @@ static void register_test_suites(void)
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/* initialize the CUnit test registry */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
return CU_get_error();
|
||||
/* initialize the CUnit test registry */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
return CU_get_error();
|
||||
|
||||
/* Register test suites from fko files */
|
||||
register_test_suites();
|
||||
|
||||
/* Run all tests using the CUnit Basic interface */
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
/* Run all tests using the CUnit Basic interface */
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user