All of lore.kernel.org
 help / color / mirror / Atom feed
From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] dm: test: Add tests for device's uclass platform data
Date: Wed, 08 Apr 2015 15:58:12 +0200	[thread overview]
Message-ID: <552533F4.3080506@samsung.com> (raw)
In-Reply-To: <CAPnjgZ0pCH_SdY8onWpswvEFVFCYfcyubV78r6a70HZBP6aVgA@mail.gmail.com>

Hello Simon,

On 04/08/2015 03:47 PM, Simon Glass wrote:
> Hi Przemyslaw,
>
> On 8 April 2015 at 07:01, Przemyslaw Marczak <p.marczak@samsung.com> wrote:
>> This test introduces new test structure type:dm_test_perdev_uc_pdata.
>> The structure consists of three int values only. For the test purposes,
>> three pattern values are defined by enum, starting with TEST_UC_PDATA_INTVAL1.
>>
>> This commit adds two test cases for uclass platform data:
>> - Test: dm_test_autobind_uclass_pdata_alloc - this tests if:
>>    * uclass driver sets: .per_device_platdata_auto_alloc_size field
>>    * the devices's: dev->uclass_platdata is non-NULL
>>
>> - Test: dm_test_autobind_uclass_pdata_valid - this tests:
>>    * if the devices's: dev->uclass_platdata is non-NULL
>>    * the structure of type 'dm_test_perdev_uc_pdata' allocated at address
>>      pointed by dev->uclass_platdata. Each structure field, should be equal
>>      to proper pattern data, starting from .intval1 == TEST_UC_PDATA_INTVAL1.
>>
>> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>>   include/dm/test.h     | 20 +++++++++++++++++++
>>   test/dm/core.c        | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>   test/dm/test-uclass.c | 11 +++++++++++
>>   3 files changed, 86 insertions(+)
>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> (one nit below)
>
>>
>> diff --git a/include/dm/test.h b/include/dm/test.h
>> index 9c4b8d3..f03fbcb 100644
>> --- a/include/dm/test.h
>> +++ b/include/dm/test.h
>> @@ -98,6 +98,26 @@ struct dm_test_parent_data {
>>          int flag;
>>   };
>>
>> +/* Test values for test device's uclass platform data */
>> +enum {
>> +       TEST_UC_PDATA_INTVAL1 = 2,
>> +       TEST_UC_PDATA_INTVAL2 = 334,
>> +       TEST_UC_PDATA_INTVAL3 = 789452,
>> +};
>> +
>> +/**
>> + * struct dm_test_uclass_platda - uclass's information on each device
>> + *
>> + * @intval1: set to TEST_UC_PDATA_INTVAL1 in .post_bind method of test uclass
>> + * @intval2: set to TEST_UC_PDATA_INTVAL2 in .post_bind method of test uclass
>> + * @intval3: set to TEST_UC_PDATA_INTVAL3 in .post_bind method of test uclass
>> + */
>> +struct dm_test_perdev_uc_pdata {
>> +       int intval1;
>> +       int intval2;
>> +       int intval3;
>> +};
>> +
>>   /*
>>    * Operation counts for the test driver, used to check that each method is
>>    * called correctly
>> diff --git a/test/dm/core.c b/test/dm/core.c
>> index 990d390..ce8a958 100644
>> --- a/test/dm/core.c
>> +++ b/test/dm/core.c
>> @@ -129,6 +129,61 @@ static int dm_test_autobind(struct dm_test_state *dms)
>>   }
>>   DM_TEST(dm_test_autobind, 0);
>>
>> +/* Test that binding with uclass platdata allocation occurs correctly */
>> +static int dm_test_autobind_uclass_pdata_alloc(struct dm_test_state *dms)
>> +{
>> +       struct dm_test_perdev_uc_pdata *uc_pdata;
>> +       struct udevice *dev;
>> +       struct uclass *uc;
>> +       int i;
>> +
>> +       ut_assertok(uclass_get(UCLASS_TEST, &uc));
>> +       ut_assert(uc);
>> +
>> +       /**
>> +        * Test if test uclass driver requires allocation for the uclass
>> +        * platform data and then check the dev->uclass_platdata pointer.
>> +        */
>> +       ut_assert(uc->uc_drv->per_device_platdata_auto_alloc_size);
>> +
>> +       for (i = 0; i < 3; i++) {
>
> nit: Can you add an enum for the '3' here, and below? It could be
> TEST_UC_PDATA_COUNT if you like.
>

Ok, I will add this.

>> +               ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
>> +               ut_assert(dev);
>> +
>> +               uc_pdata = dev_get_uclass_platdata(dev);
>> +               ut_assert(uc_pdata);
>> +       }
>> +
>> +       return 0;
>> +}
>> +DM_TEST(dm_test_autobind_uclass_pdata_alloc, DM_TESTF_SCAN_PDATA);
>> +
>> +/* Test that binding with uclass platdata setting occurs correctly */
>> +static int dm_test_autobind_uclass_pdata_valid(struct dm_test_state *dms)
>> +{
>> +       struct dm_test_perdev_uc_pdata *uc_pdata;
>> +       struct udevice *dev;
>> +       int i;
>> +
>> +       /**
>> +        * In the test_postbind() method of test uclass driver, the uclass
>> +        * platform data should be set with three test int values - test it.
>> +        */
>> +       for (i = 0; i < 3; i++) {
>> +               ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
>> +               ut_assert(dev);
>> +
>> +               uc_pdata = dev_get_uclass_platdata(dev);
>> +               ut_assert(uc_pdata);
>> +               ut_assert(uc_pdata->intval1 == TEST_UC_PDATA_INTVAL1);
>> +               ut_assert(uc_pdata->intval2 == TEST_UC_PDATA_INTVAL2);
>> +               ut_assert(uc_pdata->intval3 == TEST_UC_PDATA_INTVAL3);
>> +       }
>> +
>> +       return 0;
>> +}
>> +DM_TEST(dm_test_autobind_uclass_pdata_valid, DM_TESTF_SCAN_PDATA);
>> +
>>   /* Test that autoprobe finds all the expected devices */
>>   static int dm_test_autoprobe(struct dm_test_state *dms)
>>   {
>> diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
>> index 7cb37f7..4ae75ef 100644
>> --- a/test/dm/test-uclass.c
>> +++ b/test/dm/test-uclass.c
>> @@ -30,9 +30,18 @@ int test_ping(struct udevice *dev, int pingval, int *pingret)
>>
>>   static int test_post_bind(struct udevice *dev)
>>   {
>> +       struct dm_test_perdev_uc_pdata *uc_pdata;
>> +
>>          dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
>>          ut_assert(!device_active(dev));
>>
>> +       uc_pdata = dev_get_uclass_platdata(dev);
>> +       ut_assert(uc_pdata);
>> +
>> +       uc_pdata->intval1 = TEST_UC_PDATA_INTVAL1;
>> +       uc_pdata->intval2 = TEST_UC_PDATA_INTVAL2;
>> +       uc_pdata->intval3 = TEST_UC_PDATA_INTVAL3;
>> +
>>          return 0;
>>   }
>>
>> @@ -115,4 +124,6 @@ UCLASS_DRIVER(test) = {
>>          .destroy        = test_destroy,
>>          .priv_auto_alloc_size   = sizeof(struct dm_test_uclass_priv),
>>          .per_device_auto_alloc_size = sizeof(struct dm_test_uclass_perdev_priv),
>> +       .per_device_platdata_auto_alloc_size =
>> +                                       sizeof(struct dm_test_perdev_uc_pdata),
>>   };
>> --
>> 1.9.1
>>
>
> Regards,
> Simon
>

Thanks for a quick review. I will resend it in a moment

Best regards,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

  reply	other threads:[~2015-04-08 13:58 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 13:01 [U-Boot] [PATCH 0/2] dm: core: add device's uclass platform data and tests Przemyslaw Marczak
2015-04-08 13:01 ` [U-Boot] [PATCH 1/2] dm: core: Extend struct udevice by '.uclass_platdata' field Przemyslaw Marczak
2015-04-08 13:47   ` Simon Glass
2015-04-08 13:56     ` Przemyslaw Marczak
2015-04-08 13:01 ` [U-Boot] [PATCH 2/2] dm: test: Add tests for device's uclass platform data Przemyslaw Marczak
2015-04-08 13:47   ` Simon Glass
2015-04-08 13:58     ` Przemyslaw Marczak [this message]
2015-04-08 15:32 ` [U-Boot] [PATCH V2 0/3] dm: core: add device's uclass platform data and tests Przemyslaw Marczak
2015-04-08 15:32   ` [U-Boot] [PATCH V2 1/3] dm: core: add internal functions for getting the device without probe Przemyslaw Marczak
2015-04-08 15:39     ` Simon Glass
2015-04-08 15:47       ` Przemyslaw Marczak
2015-04-08 15:32   ` [U-Boot] [PATCH V2 2/3] dm: core: Extend struct udevice by '.uclass_platdata' field Przemyslaw Marczak
2015-04-08 15:32   ` [U-Boot] [PATCH V2 3/3] dm: test: Add tests for device's uclass platform data Przemyslaw Marczak
2015-04-08 17:06   ` [U-Boot] [PATCH V3 0/4] dm: core: add device's uclass platform data and tests Przemyslaw Marczak
2015-04-08 17:06     ` [U-Boot] [PATCH V3 1/4] dm: core: add internal functions for getting the device without probe Przemyslaw Marczak
2015-04-09  1:47       ` Simon Glass
2015-04-08 17:06     ` [U-Boot] [PATCH V3 2/4] dm: core: Extend struct udevice by '.uclass_platdata' field Przemyslaw Marczak
2015-04-09  1:47       ` Simon Glass
2015-04-08 17:06     ` [U-Boot] [PATCH V3 3/4] dm: test: Add tests for device's uclass platform data Przemyslaw Marczak
2015-04-09  1:47       ` Simon Glass
2015-04-08 17:06     ` [U-Boot] [PATCH V3 4/4] dm: test: Add tests for get/find uclass devices Przemyslaw Marczak
2015-04-09  1:47       ` Simon Glass
2015-04-09  6:54         ` Przemyslaw Marczak
2015-04-09 12:11     ` [U-Boot] [PATCH] dm: core: remove type 'static' of function uclass_get_device_tail() Przemyslaw Marczak
2015-04-09 12:16       ` Przemyslaw Marczak
2015-04-15 11:07     ` [U-Boot] [PATCH V4 00/10] dm: core: extend API by useful functions with tests Przemyslaw Marczak
2015-04-15 11:07       ` [U-Boot] [PATCH V4 01/10] dm: core: add internal functions for getting the device without probe Przemyslaw Marczak
2015-04-20  3:22         ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 02/10] dm: core: Extend struct udevice by '.uclass_platdata' field Przemyslaw Marczak
2015-04-20  3:22         ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 03/10] dm: test: Add tests for device's uclass platform data Przemyslaw Marczak
2015-04-20  3:22         ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 04/10] dm: test: Add tests for get/find uclass devices Przemyslaw Marczak
2015-04-20  3:22         ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 05/10] dm: core: remove type 'static' of function uclass_get_device_tail() Przemyslaw Marczak
2015-04-20  2:03         ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 06/10] dm: core: uclass: add function: uclass_find_device_by_name() Przemyslaw Marczak
2015-04-19 13:23         ` Simon Glass
2015-04-20  3:22           ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 07/10] dm: core: uclass: add function: uclass_get_device_by_name() Przemyslaw Marczak
2015-04-19 13:23         ` Simon Glass
2015-04-20  3:22           ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 08/10] dm: core: device: add function: dev_get_driver_ops() Przemyslaw Marczak
2015-04-19 13:24         ` Simon Glass
2015-04-20  3:23           ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 09/10] dm: core: device: add function: dev_get_uclass_name() Przemyslaw Marczak
2015-04-19 13:24         ` Simon Glass
2015-04-20  3:23           ` Simon Glass
2015-04-15 11:07       ` [U-Boot] [PATCH V4 10/10] dm: test: Add tests for get/find uclass's device by name Przemyslaw Marczak
2015-04-19 13:25         ` Simon Glass
2015-04-20  3:22       ` [U-Boot] [PATCH V4 00/10] dm: core: extend API by useful functions with tests Simon Glass
2015-04-20 10:55         ` Przemyslaw Marczak
2015-04-20 11:32         ` [U-Boot] [PATCH V5 1/3] dm: core: remove type 'static' of function uclass_get_device_tail() Przemyslaw Marczak
2015-04-20 11:32           ` [U-Boot] [PATCH V5 2/3] dm: test: Add tests for get/find uclass's device by name Przemyslaw Marczak
2015-04-20 21:24             ` Simon Glass
2015-04-22 16:52               ` Simon Glass
2015-04-20 11:32           ` [U-Boot] [PATCH V5 3/3] dm: core: precise comments for get/find " Przemyslaw Marczak
2015-04-20 21:24             ` Simon Glass
2015-04-22 16:52               ` Simon Glass
2015-04-20 21:24           ` [U-Boot] [PATCH V5 1/3] dm: core: remove type 'static' of function uclass_get_device_tail() Simon Glass
2015-04-22 16:52             ` Simon Glass

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=552533F4.3080506@samsung.com \
    --to=p.marczak@samsung.com \
    --cc=u-boot@lists.denx.de \
    /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.