Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apteryxd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,13 @@ _traverse_paths (GList **paths, GList **values, const char *path)
/* Append any provided paths */
GList *providers = NULL;
providers = config_search_providers (path_s);
children = g_list_concat (children, providers);
for (iter = providers; iter; iter = iter->next)
{
char *p = (char*)iter->data;
if (!g_list_find_custom (children, p, (GCompareFunc)strcmp))
children = g_list_prepend (children, strdup (p));
}
g_list_free_full (providers, free);
}
for (iter = children; iter; iter = g_list_next (iter))
{
Expand Down Expand Up @@ -1248,6 +1254,7 @@ handle_query (rpc_message msg)
for (ipath = g_list_first (matches), ivalue = g_list_first (value_matches);
ipath && ivalue; ipath = g_list_next (ipath), ivalue = g_list_next (ivalue))
{
DEBUG (" %s = %s\n", (char *) ipath->data, (char *) ivalue->data);
rpc_msg_encode_string (msg, (char *) ipath->data);
rpc_msg_encode_string (msg, (char *) ivalue->data);
}
Expand Down
32 changes: 32 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3245,6 +3245,37 @@ test_query_two_branches ()
apteryx_prune (TEST2_PATH);
}

void
test_query_provided ()
{
const char *path = TEST_PATH"/devices/*/interfaces/*/state";
GNode *root = NULL;
GNode *rroot = NULL;

CU_ASSERT (apteryx_provide (path, test_provide_cb));

root = APTERYX_NODE (NULL, TEST_PATH"/devices/unit1/interfaces/eth0");
APTERYX_LEAF (root, "ifname", "eth0");
CU_ASSERT (apteryx_set_tree (root));
g_node_destroy (root);

root = APTERYX_NODE (NULL, TEST_PATH"/devices/unit1/interfaces/eth1");
APTERYX_LEAF (root, "ifname", "eth1");
CU_ASSERT (apteryx_set_tree (root));
g_node_destroy (root);

root = g_node_new (strdup ("/"));
apteryx_path_to_node (root, TEST_PATH"/devices/*", NULL);
rroot = apteryx_query (root);
CU_ASSERT (g_node_n_nodes (rroot, G_TRAVERSE_LEAVES) == 4);

apteryx_free_tree (rroot);
apteryx_free_tree (root);

CU_ASSERT (apteryx_unprovide (path, test_provide_cb));
apteryx_prune (TEST_PATH);
}

void
test_cas_tree ()
{
Expand Down Expand Up @@ -5296,6 +5327,7 @@ static CU_TestInfo tests_api_tree[] = {
{ "query two star", test_query_two_star},
{ "query null values", test_query_null_values},
{ "query two branches", test_query_two_branches},
{ "query provided", test_query_provided},
{ "cas tree", test_cas_tree},
{ "tree atomic", test_tree_atomic},
CU_TEST_INFO_NULL,
Expand Down