From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v1 1/1] device property: Add test cases for fwnode_property_count_*() APIs
Date: Mon, 8 Mar 2021 12:36:16 +0200 [thread overview]
Message-ID: <YEX+INKSPAzAcvFg@smile.fi.intel.com> (raw)
In-Reply-To: <20210212162539.86850-1-andriy.shevchenko@linux.intel.com>
On Fri, Feb 12, 2021 at 06:25:39PM +0200, Andy Shevchenko wrote:
> Add test cases for fwnode_property_count_*() APIs.
>
> While at it, modify the arrays of integers to be size of non-power-of-2
> for better test coverage and decreasing stack usage.
Any comments on this?
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/base/test/property-entry-test.c | 50 +++++++++++++++++++++++--
> 1 file changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/test/property-entry-test.c b/drivers/base/test/property-entry-test.c
> index abe03315180f..3a4f755c483c 100644
> --- a/drivers/base/test/property-entry-test.c
> +++ b/drivers/base/test/property-entry-test.c
> @@ -27,6 +27,9 @@ static void pe_test_uints(struct kunit *test)
> node = fwnode_create_software_node(entries, NULL);
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, node);
>
> + error = fwnode_property_count_u8(node, "prop-u8");
> + KUNIT_EXPECT_EQ(test, error, 1);
> +
> error = fwnode_property_read_u8(node, "prop-u8", &val_u8);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u8, 8);
> @@ -48,6 +51,9 @@ static void pe_test_uints(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u16, 16);
>
> + error = fwnode_property_count_u16(node, "prop-u16");
> + KUNIT_EXPECT_EQ(test, error, 1);
> +
> error = fwnode_property_read_u16_array(node, "prop-u16", array_u16, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u16[0], 16);
> @@ -65,6 +71,9 @@ static void pe_test_uints(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u32, 32);
>
> + error = fwnode_property_count_u32(node, "prop-u32");
> + KUNIT_EXPECT_EQ(test, error, 1);
> +
> error = fwnode_property_read_u32_array(node, "prop-u32", array_u32, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u32[0], 32);
> @@ -82,6 +91,9 @@ static void pe_test_uints(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u64, 64);
>
> + error = fwnode_property_count_u64(node, "prop-u64");
> + KUNIT_EXPECT_EQ(test, error, 1);
> +
> error = fwnode_property_read_u64_array(node, "prop-u64", array_u64, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u64[0], 64);
> @@ -95,15 +107,19 @@ static void pe_test_uints(struct kunit *test)
> error = fwnode_property_read_u64_array(node, "no-prop-u64", array_u64, 1);
> KUNIT_EXPECT_NE(test, error, 0);
>
> + /* Count 64-bit values as 16-bit */
> + error = fwnode_property_count_u16(node, "prop-u64");
> + KUNIT_EXPECT_EQ(test, error, 4);
> +
> fwnode_remove_software_node(node);
> }
>
> static void pe_test_uint_arrays(struct kunit *test)
> {
> - static const u8 a_u8[16] = { 8, 9 };
> - static const u16 a_u16[16] = { 16, 17 };
> - static const u32 a_u32[16] = { 32, 33 };
> - static const u64 a_u64[16] = { 64, 65 };
> + static const u8 a_u8[10] = { 8, 9 };
> + static const u16 a_u16[10] = { 16, 17 };
> + static const u32 a_u32[10] = { 32, 33 };
> + static const u64 a_u64[10] = { 64, 65 };
> static const struct property_entry entries[] = {
> PROPERTY_ENTRY_U8_ARRAY("prop-u8", a_u8),
> PROPERTY_ENTRY_U16_ARRAY("prop-u16", a_u16),
> @@ -126,6 +142,9 @@ static void pe_test_uint_arrays(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u8, 8);
>
> + error = fwnode_property_count_u8(node, "prop-u8");
> + KUNIT_EXPECT_EQ(test, error, 10);
> +
> error = fwnode_property_read_u8_array(node, "prop-u8", array_u8, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u8[0], 8);
> @@ -148,6 +167,9 @@ static void pe_test_uint_arrays(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u16, 16);
>
> + error = fwnode_property_count_u16(node, "prop-u16");
> + KUNIT_EXPECT_EQ(test, error, 10);
> +
> error = fwnode_property_read_u16_array(node, "prop-u16", array_u16, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u16[0], 16);
> @@ -170,6 +192,9 @@ static void pe_test_uint_arrays(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u32, 32);
>
> + error = fwnode_property_count_u32(node, "prop-u32");
> + KUNIT_EXPECT_EQ(test, error, 10);
> +
> error = fwnode_property_read_u32_array(node, "prop-u32", array_u32, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u32[0], 32);
> @@ -192,6 +217,9 @@ static void pe_test_uint_arrays(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)val_u64, 64);
>
> + error = fwnode_property_count_u64(node, "prop-u64");
> + KUNIT_EXPECT_EQ(test, error, 10);
> +
> error = fwnode_property_read_u64_array(node, "prop-u64", array_u64, 1);
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_EQ(test, (int)array_u64[0], 64);
> @@ -210,6 +238,14 @@ static void pe_test_uint_arrays(struct kunit *test)
> error = fwnode_property_read_u64_array(node, "no-prop-u64", array_u64, 1);
> KUNIT_EXPECT_NE(test, error, 0);
>
> + /* Count 64-bit values as 16-bit */
> + error = fwnode_property_count_u16(node, "prop-u64");
> + KUNIT_EXPECT_EQ(test, error, 40);
> +
> + /* Other way around */
> + error = fwnode_property_count_u64(node, "prop-u16");
> + KUNIT_EXPECT_EQ(test, error, 2);
> +
> fwnode_remove_software_node(node);
> }
>
> @@ -239,6 +275,9 @@ static void pe_test_strings(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_STREQ(test, str, "single");
>
> + error = fwnode_property_string_array_count(node, "str");
> + KUNIT_EXPECT_EQ(test, error, 1);
> +
> error = fwnode_property_read_string_array(node, "str", strs, 1);
> KUNIT_EXPECT_EQ(test, error, 1);
> KUNIT_EXPECT_STREQ(test, strs[0], "single");
> @@ -258,6 +297,9 @@ static void pe_test_strings(struct kunit *test)
> KUNIT_EXPECT_EQ(test, error, 0);
> KUNIT_EXPECT_STREQ(test, str, "");
>
> + error = fwnode_property_string_array_count(node, "strs");
> + KUNIT_EXPECT_EQ(test, error, 2);
> +
> error = fwnode_property_read_string_array(node, "strs", strs, 3);
> KUNIT_EXPECT_EQ(test, error, 2);
> KUNIT_EXPECT_STREQ(test, strs[0], "string-a");
> --
> 2.30.0
>
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2021-03-08 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-12 16:25 [PATCH v1 1/1] device property: Add test cases for fwnode_property_count_*() APIs Andy Shevchenko
2021-03-08 10:36 ` Andy Shevchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YEX+INKSPAzAcvFg@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.