Skip to content

Commit

Permalink
interfaces-plugin: reorganize unit tests, add hash new unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej committed Oct 31, 2022
1 parent 4996e6a commit b17b76c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ if(AUGYANG_FOUND)
else(AUGYANG_FOUND)
message(WARNING "AUGYANG not found - augeas support will be disabled")
endif()

if(ENABLE_BUILD_TESTS)
find_package(CMOCKA REQUIRED)
include(CTest)
include(tests/CMakeLists.txt)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(UTILS_MEMORY_LIBRARY_NAME "utils_memory")
add_executable(
${INTERFACES_UTEST_NAME}

"interfaces_utest.c"
${CMAKE_SOURCE_DIR}/src/interfaces/tests/interfaces_utest.c
)
target_include_directories(
${INTERFACES_UTEST_NAME}
Expand All @@ -19,6 +19,7 @@ target_link_libraries(
${INTERFACES_UTEST_NAME}

${CMOCKA_LIBRARIES}
${PLUGIN_LIBRARY_NAME}
${SYSREPO_LIBRARIES}
${LIBYANG_LIBRARIES}
${UTILS_MEMORY_LIBRARY_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@
/* load api */
#include "plugin/api/interfaces/load.h"

/* interfaces hash table state */
#include "plugin/data/interfaces/interface_state.h"

/* interfaces interface linked list */
#include "plugin/data/interfaces/interface/linked_list.h"

/* init functionality */
static int setup(void **state);
static int teardown(void **state);

/* tests */

/** interface hash table state **/
static void test_hash_new_correct(void **state);

/* load */
static void test_correct_load_interface(void **state);

int main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_correct_load_interface),
cmocka_unit_test(test_hash_new_correct),
};

return cmocka_run_group_tests(tests, setup, teardown);
Expand Down Expand Up @@ -60,3 +70,17 @@ static void test_correct_load_interface(void **state)
assert_int_equal(rc, 0);
}

static void test_hash_new_correct(void **state)
{
interfaces_ctx_t *ctx = *state;
int rc = 0;

interfaces_interface_state_hash_element_t *if_root;

if_root = interfaces_interface_state_hash_new();

assert_null(if_root);

assert_int_equal(rc, 0);
}

File renamed without changes.

0 comments on commit b17b76c

Please sign in to comment.