Skip to content

Commit

Permalink
of: unittest: Add a test case for of_changeset_add_prop_bool()
Browse files Browse the repository at this point in the history
Improve of_unittest_changeset_prop() to have a test case for the
newly introduced of_changeset_add_prop_bool().

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20240527161450.326615-17-herve.codina@bootlin.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
  • Loading branch information
Herve Codina authored and Rob Herring (Arm) committed Jul 8, 2024
1 parent f2b388d commit 1e43683
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/of/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,13 @@ static void __init __maybe_unused changeset_check_u32_array(struct device_node *
}
}

static void __init __maybe_unused changeset_check_bool(struct device_node *np,
const char *prop_name)
{
unittest(of_property_read_bool(np, prop_name),
"%s value mismatch (read 'false', exp 'true')\n", prop_name);
}

static void __init of_unittest_changeset_prop(void)
{
#ifdef CONFIG_OF_DYNAMIC
Expand Down Expand Up @@ -1044,6 +1051,9 @@ static void __init of_unittest_changeset_prop(void)
u32_array, ARRAY_SIZE(u32_array));
unittest(ret == 0, "failed to add prop-u32-array\n");

ret = of_changeset_add_prop_bool(&chgset, np, "prop-bool");
unittest(ret == 0, "failed to add prop-bool\n");

of_node_put(np);

ret = of_changeset_apply(&chgset);
Expand All @@ -1058,6 +1068,7 @@ static void __init of_unittest_changeset_prop(void)
changeset_check_string_array(np, "prop-string-array", str_array, ARRAY_SIZE(str_array));
changeset_check_u32(np, "prop-u32", 1234);
changeset_check_u32_array(np, "prop-u32-array", u32_array, ARRAY_SIZE(u32_array));
changeset_check_bool(np, "prop-bool");

of_node_put(np);

Expand Down

0 comments on commit 1e43683

Please sign in to comment.