1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Add a unit test for config cascade (overlay). Needs expanding though.

This commit is contained in:
Petr Rockai 2011-12-18 23:56:36 +00:00
parent f401655ee8
commit 90b7423846

View File

@ -48,6 +48,18 @@ static const char *conf =
" }\n" " }\n"
"}\n"; "}\n";
static const char *overlay =
"id = \"yoda-soda\"\n"
"flags = [\"FOO\"]\n"
"physical_volumes {\n"
" pv1 {\n"
" id = \"hgfe-dcba\"\n"
" }\n"
" pv3 {\n"
" id = \"dbcd-efgh\"\n"
" }\n"
"}\n";
static void test_parse(void) static void test_parse(void)
{ {
struct dm_config_tree *tree = dm_config_from_string(conf); struct dm_config_tree *tree = dm_config_from_string(conf);
@ -119,8 +131,26 @@ static void test_clone(void)
dm_config_destroy(tree); dm_config_destroy(tree);
} }
static void test_cascade()
{
struct dm_config_tree *t1 = dm_config_from_string(conf),
*t2 = dm_config_from_string(overlay),
*tree = dm_config_insert_cascaded_tree(t2, t1);
CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "id", "foo"), "yoda-soda"));
CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "idt", "foo"), "foo"));
CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv0/bb", "foo"), "foo"));
CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv1/id", "foo"), "hgfe-dcba"));
CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv3/id", "foo"), "dbcd-efgh"));
dm_config_destroy(t1);
dm_config_destroy(t2);
}
CU_TestInfo config_list[] = { CU_TestInfo config_list[] = {
{ (char*)"parse", test_parse }, { (char*)"parse", test_parse },
{ (char*)"clone", test_clone }, { (char*)"clone", test_clone },
{ (char*)"cascade", test_cascade },
CU_TEST_INFO_NULL CU_TEST_INFO_NULL
}; };