mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paraschiv, Andra-Irina" <andraprs@amazon.com>
To: "Longpeng (Mike,
	Cloud Infrastructure Service Product Dept.)" 
	<longpeng2@huawei.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"kamal@canonical.com" <kamal@canonical.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"sgarzare@redhat.com" <sgarzare@redhat.com>,
	"stefanha@redhat.com" <stefanha@redhat.com>,
	"vkuznets@redhat.com" <vkuznets@redhat.com>,
	"ne-devel-upstream@amazon.com" <ne-devel-upstream@amazon.com>,
	"lexnv@amazon.com" <lexnv@amazon.com>,
	"alcioa@amazon.com" <alcioa@amazon.com>
Subject: Re: [PATCH v2 3/4] nitro_enclaves: add test framework for the misc functionality
Date: Thu, 7 Oct 2021 18:37:50 +0300	[thread overview]
Message-ID: <77537d8a-0306-69d3-8ec3-ef1267b8c200@amazon.com> (raw)
In-Reply-To: <03ec1f44847d4fc196080c28aadc1b65@huawei.com>



On 07/10/2021 05:05, Longpeng (Mike, Cloud Infrastructure Service 
Product Dept.) wrote:
> 
> 
>> -----Original Message-----
>> From: Paraschiv, Andra-Irina [mailto:andraprs@amazon.com]
>> Sent: Sunday, October 3, 2021 9:50 PM
>> To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
>> <longpeng2@huawei.com>
>> Cc: linux-kernel@vger.kernel.org; Gonglei (Arei) <arei.gonglei@huawei.com>;
>> gregkh@linuxfoundation.org; kamal@canonical.com; pbonzini@redhat.com;
>> sgarzare@redhat.com; stefanha@redhat.com; vkuznets@redhat.com;
>> ne-devel-upstream@amazon.com; lexnv@amazon.com; alcioa@amazon.com
>> Subject: Re: [PATCH v2 3/4] nitro_enclaves: add test framework for the misc
>> functionality
>>
>>
>>
>> On 21/09/2021 18:10, Longpeng(Mike) wrote:
>>> Add test framework for the misc functionality.
>>
>> Let's add more specifics here.
>>
>> nitro_enclaves: Add KUnit tests setup for the misc device functionality
>>
>> Add the initial setup for the KUnit tests that will target the Nitro
>> Enclaves misc device functionality.
>>
> 
> OK, thanks.
> 
>>>
>>> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
>>> ---
>>>    drivers/virt/nitro_enclaves/Kconfig        |  8 ++++++++
>>>    drivers/virt/nitro_enclaves/ne_misc_dev.c  | 27
>> +++++++++++++++++++++++++++
>>>    drivers/virt/nitro_enclaves/ne_misc_test.c | 17 +++++++++++++++++
>>>    3 files changed, 52 insertions(+)
>>>    create mode 100644 drivers/virt/nitro_enclaves/ne_misc_test.c
>>
>> Please modify in all places where necessary to mention Nitro Enclaves
>> "misc device", instead of just "misc", to be more specific.
>>
>> For example, here can be "ne_misc_dev_test.c".
>>
> 
> OK.
> 
>>>
>>> diff --git a/drivers/virt/nitro_enclaves/Kconfig
>> b/drivers/virt/nitro_enclaves/Kconfig
>>> index 8c9387a..24c54da 100644
>>> --- a/drivers/virt/nitro_enclaves/Kconfig
>>> +++ b/drivers/virt/nitro_enclaves/Kconfig
>>> @@ -18,3 +18,11 @@ config NITRO_ENCLAVES
>>>
>>>    	  To compile this driver as a module, choose M here.
>>>    	  The module will be called nitro_enclaves.
>>> +
>>> +config NITRO_ENCLAVES_MISC_TEST
>>
>> NITRO_ENCLAVES_MISC_DEV_TEST
>>
>>> +	bool "Tests for the misc functionality of Nitro enclaves"
>>
>> misc device functionality of the Nitro Enclaves
>>
>>> +	depends on NITRO_ENCLAVES && KUNIT=y
>>> +	help
>>> +	  Enable KUnit tests for the misc functionality of Nitro Enclaves. Select
>>
>> misc device functionality of the Nitro Enclaves
>>
> 
> OK, thanks.
> 
>>> +	  this option only if you will boot the kernel for the purpose of running
>>> +	  unit tests (e.g. under UML or qemu). If unsure, say N.
>>> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c
>> b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>>> index d551b88..0131e1b 100644
>>> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
>>> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
>>> @@ -1735,8 +1735,33 @@ static long ne_ioctl(struct file *file, unsigned int
>> cmd, unsigned long arg)
>>>    	return 0;
>>>    }
>>>
>>> +#if defined(CONFIG_NITRO_ENCLAVES_MISC_TEST)
>>> +#include "ne_misc_test.c"
>>> +
>>> +static inline int ne_misc_test_init(void)
>>> +{
>>> +	return __kunit_test_suites_init(ne_misc_test_suites);
>>> +}
>>> +
>>> +static inline void ne_misc_test_exit(void)
>>> +{
>>> +	__kunit_test_suites_exit(ne_misc_test_suites);
>>> +}
>>> +#else
>>> +static inline int ne_misc_test_init(void)
>>> +{
>>> +	return 0;
>>> +}
>>> +
>>> +static inline void ne_misc_test_exit(void)
>>> +{
>>> +}
>>> +#endif
>>
>> s/misc/misc_dev/g
>>
>> Why are these needed? Can't the test suite be setup using
>> "kunit_test_suite" as in the KUnit documentation example [1]?
>>
>> Wouldn't be necessary to conditionally compile the ne_misc_dev_test,
>> based on the kernel config above?
>>
>> [1]
>> https://www.kernel.org/doc/html/latest/dev-tools/kunit/start.html#writing-y
>> our-first-test
>>
> 
> Both of these two ways are supported in kernel, for example [2].
> 
> There are two reasons why I choose this way:
> 1. The functions (to test) in "ne_misc_dev.c" are 'static', we cannot invoke
>      them in  "ne_misc_dev_test.c".
> 2. kunit_test_suite defines a module init function internal, and "ne_misc_dev.c"
>      also defines one, so they cannot be compiled into one module.


Thanks for the explanation.

Andra

> 
> 
> [2]
> https://elixir.bootlin.com/linux/v5.15-rc4/source/drivers/mmc/host/sdhci-of-aspeed.c#L612
> 
>>> +
>>>    static int __init ne_init(void)
>>>    {
>>> +	ne_misc_test_init();
>>> +
>>>    	mutex_init(&ne_cpu_pool.mutex);
>>>
>>>    	return pci_register_driver(&ne_pci_driver);
>>> @@ -1747,6 +1772,8 @@ static void __exit ne_exit(void)
>>>    	pci_unregister_driver(&ne_pci_driver);
>>>
>>>    	ne_teardown_cpu_pool();
>>> +
>>> +	ne_misc_test_exit();
>>>    }
>>>
>>>    module_init(ne_init);
>>> diff --git a/drivers/virt/nitro_enclaves/ne_misc_test.c
>> b/drivers/virt/nitro_enclaves/ne_misc_test.c
>>> new file mode 100644
>>> index 0000000..3426c35
>>> --- /dev/null
>>> +++ b/drivers/virt/nitro_enclaves/ne_misc_test.c
>>> @@ -0,0 +1,17 @@
>>> +// SPDX-License-Identifier: GPL-2.0-or-later
>>> +
>>> +#include <kunit/test.h>
>>> +
>>> +static struct kunit_case ne_misc_test_cases[] = {
>>> +	{}
>>> +};
>>> +
>>> +static struct kunit_suite ne_misc_test_suite = {
>>> +	.name = "ne_misc_test",
>>> +	.test_cases = ne_misc_test_cases,
>>> +};
>>> +
>>> +static struct kunit_suite *ne_misc_test_suites[] = {
>>> +	&ne_misc_test_suite,
>>> +	NULL
>>> +};
>>>
>>
>> Can replace "ne_misc" with "ne_misc_dev".
>>
>> Thanks,
>> Andra
>>
>>
>>
>> Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar
>> Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania.
>> Registration number J22/2621/2005.



Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.

  reply	other threads:[~2021-10-07 15:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 15:10 [PATCH v2 0/4] merge contiguous physical memory regions Longpeng(Mike)
2021-09-21 15:10 ` [PATCH v2 1/4] nitro_enclaves: " Longpeng(Mike)
2021-09-21 15:20   ` Greg KH
2021-09-22  1:09     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-09-21 15:20   ` Greg KH
2021-09-22  0:27     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-10-03 13:00   ` Paraschiv, Andra-Irina
2021-10-05 13:54     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-10-06 11:11       ` Paraschiv, Andra-Irina
2021-09-21 15:10 ` [PATCH v2 2/4] nitro_enclaves: sanity check the physical region during setting Longpeng(Mike)
2021-10-03 13:29   ` Paraschiv, Andra-Irina
2021-09-21 15:10 ` [PATCH v2 3/4] nitro_enclaves: add test framework for the misc functionality Longpeng(Mike)
2021-09-21 15:20   ` Greg KH
2021-09-22  0:33     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-09-22  5:55       ` Greg KH
2021-10-03 13:49   ` Paraschiv, Andra-Irina
2021-10-07  2:05     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-10-07 15:37       ` Paraschiv, Andra-Irina [this message]
2021-09-21 15:10 ` [PATCH v2 4/4] nitro_enclaves: add kunit tests for physical contiguous region merging Longpeng(Mike)
2021-10-03 14:14   ` Paraschiv, Andra-Irina
2021-09-27  7:00 ` [PATCH v2 0/4] merge contiguous physical memory regions Paraschiv, Andra-Irina

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=77537d8a-0306-69d3-8ec3-ef1267b8c200@amazon.com \
    --to=andraprs@amazon.com \
    --cc=alcioa@amazon.com \
    --cc=arei.gonglei@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kamal@canonical.com \
    --cc=lexnv@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longpeng2@huawei.com \
    --cc=ne-devel-upstream@amazon.com \
    --cc=pbonzini@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vkuznets@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome