Skip to content

Commit

Permalink
Addition of unit test cases for Switching Backend functionality
Browse files Browse the repository at this point in the history
Adding Unit test cases for newly added function pdbg_release_dt_root()

Signed-off-by: swarnendu.roy.chowdhury@ibm.com
  • Loading branch information
Swarnendu-R-C committed Jun 27, 2023
1 parent 4579008 commit d023740
Show file tree
Hide file tree
Showing 5 changed files with 374 additions and 16 deletions.
8 changes: 7 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ GIT_SHA1 ?= `git --work-tree=$(top_srcdir) --git-dir=$(top_srcdir)/.git describe
libpdbg_tests = libpdbg_target_test \
libpdbg_probe_test1 \
libpdbg_probe_test2 \
libpdbg_probe_test3
libpdbg_probe_test3 \
libpdbg_release_dt_root_test

bin_PROGRAMS = pdbg
check_PROGRAMS = $(libpdbg_tests) libpdbg_dtree_test \
Expand Down Expand Up @@ -249,6 +250,11 @@ libpdbg_target_test_CFLAGS = $(libpdbg_test_cflags)
libpdbg_target_test_LDFLAGS = $(libpdbg_test_ldflags)
libpdbg_target_test_LDADD = $(libpdbg_test_ldadd)

libpdbg_release_dt_root_test_SOURCES = src/tests/libpdbg_release_dt_root_test.c
libpdbg_release_dt_root_test_CFLAGS = $(libpdbg_test_cflags)
libpdbg_release_dt_root_test_LDFLAGS = $(libpdbg_test_ldflags)
libpdbg_release_dt_root_test_LDADD = $(libpdbg_test_ldadd)

libpdbg_probe_test1_SOURCES = src/tests/libpdbg_probe_test.c
libpdbg_probe_test1_CFLAGS = $(libpdbg_test_cflags) -DTEST_ID=1
libpdbg_probe_test1_LDFLAGS = $(libpdbg_test_ldflags)
Expand Down
14 changes: 7 additions & 7 deletions libpdbg/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ static void pdbg_targets_init_virtual(struct pdbg_target *node, struct pdbg_targ
* function deletes/removes a target form the list of associated
* pdbg_target_class object. For internal use only.
*
* @param target The pdbg_target object which will be removed from it's associated
* pdbg_target_class list
* @param target The pdbg_target object which will be removed from
* it's associated pdbg_target_class list
*
* @see pdbg_release_target for more details
*/
Expand All @@ -724,12 +724,12 @@ static void pdbg_del_target_from_target_class_list(struct pdbg_target* target)
}

/**
* @brief A function to delete/release an existing pdbg_target object along
* with its children from the node list/dev tree. Should be only called
* internally. Recursive in nature. For internal use only.
* @brief A function to delete/release an existing pdbg_target object
* along with its children from the node list/dev tree. Should
* be only called internally. Recursive in nature.
*
* @param target The target node for which the children and then the node itself
* will be released/freed
* @param target The target node for which the children and then the
* node itself will be released/freed
*
* @see pdbg_release_dt_root for more details
*/
Expand Down
6 changes: 0 additions & 6 deletions libpdbg/dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,6 @@ bool pdbg_set_backend(enum pdbg_backend backend, const char *backend_option)
return false;
}

if (pdbg_backend == backend)
{
pdbg_log(PDBG_ERROR, "New backend is same as the current backend. Not proceeding further\n");
return false;
}

pdbg_backend = backend;
pdbg_backend_option = backend_option;

Expand Down
4 changes: 2 additions & 2 deletions libpdbg/libpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -1459,8 +1459,8 @@ bool pdbg_context_short(void);
* switching the backend in the same process. It clears/releases the
* existing dev tree (if any) children by children along with the root node.
*
* Call this function very judiciously before ##pdbg_set_backend() if there is a
* dev tree already is in place and we are switching the backend
* Call this function very judiciously before ##pdbg_set_backend() if there
* is a dev tree already is in place and we are switching the backend
*/
void pdbg_release_dt_root();

Expand Down
Loading

0 comments on commit d023740

Please sign in to comment.