mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paraschiv, Andra-Irina" <andraprs@amazon.com>
To: "Longpeng(Mike)" <longpeng2@huawei.com>
Cc: <arei.gonglei@huawei.com>, <gregkh@linuxfoundation.org>,
	<kamal@canonical.com>, <pbonzini@redhat.com>,
	<sgarzare@redhat.com>, <stefanha@redhat.com>,
	<vkuznets@redhat.com>, <linux-kernel@vger.kernel.org>,
	<ne-devel-upstream@amazon.com>, <lexnv@amazon.com>,
	<alcioa@amazon.com>
Subject: Re: [PATCH v4 3/4] nitro_enclaves: Add KUnit tests setup for the misc device functionality
Date: Sun, 7 Nov 2021 15:12:38 +0200	[thread overview]
Message-ID: <c730e964-4f97-3f78-22eb-b63a11f6e805@amazon.com> (raw)
In-Reply-To: <20211103140035.2001-4-longpeng2@huawei.com>



On 03/11/2021 16:00, Longpeng(Mike) wrote:
> 
> From: Longpeng <longpeng2@huawei.com>
> 
> Add the initial setup for the KUnit tests that will target the Nitro
> Enclaves misc device functionality.
> 
> Signed-off-by: Longpeng <longpeng2@huawei.com>
> ---
> Changes v3 -> v4:
>    - Nitro enclaves -> Nitro Enclaves   [Andra]
>    - check the return code of "ne_misc_dev_test_init()"  [Andra]
>    - GPL-2.0-or-later -> GPL-2.0  [Andra]
> 
> Changes v2 -> v3:
>    - update the commit title and commit message.  [Andra]
>    - use "misc_dev"/"misc device"/"MISC_DEV" to be more specific.  [Andra]
> ---
>   drivers/virt/nitro_enclaves/Kconfig            |  9 ++++++++
>   drivers/virt/nitro_enclaves/ne_misc_dev.c      | 31 ++++++++++++++++++++++++++
>   drivers/virt/nitro_enclaves/ne_misc_dev_test.c | 17 ++++++++++++++
>   3 files changed, 57 insertions(+)
>   create mode 100644 drivers/virt/nitro_enclaves/ne_misc_dev_test.c

Reviewed-by: Andra Paraschiv <andraprs@amazon.com>

Thanks,
Andra

> 
> diff --git a/drivers/virt/nitro_enclaves/Kconfig b/drivers/virt/nitro_enclaves/Kconfig
> index 8c9387a..a7e5020 100644
> --- a/drivers/virt/nitro_enclaves/Kconfig
> +++ b/drivers/virt/nitro_enclaves/Kconfig
> @@ -18,3 +18,12 @@ config NITRO_ENCLAVES
> 
>            To compile this driver as a module, choose M here.
>            The module will be called nitro_enclaves.
> +
> +config NITRO_ENCLAVES_MISC_DEV_TEST
> +       bool "Tests for the misc device functionality of the Nitro Enclaves"
> +       depends on NITRO_ENCLAVES && KUNIT=y
> +       help
> +         Enable KUnit tests for the misc device functionality of the Nitro
> +         Enclaves. Select 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 3741ae7..ec46c12 100644
> --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
> @@ -1754,8 +1754,37 @@ static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>          return 0;
>   }
> 
> +#if defined(CONFIG_NITRO_ENCLAVES_MISC_DEV_TEST)
> +#include "ne_misc_dev_test.c"
> +
> +static inline int ne_misc_dev_test_init(void)
> +{
> +       return __kunit_test_suites_init(ne_misc_dev_test_suites);
> +}
> +
> +static inline void ne_misc_dev_test_exit(void)
> +{
> +       __kunit_test_suites_exit(ne_misc_dev_test_suites);
> +}
> +#else
> +static inline int ne_misc_dev_test_init(void)
> +{
> +       return 0;
> +}
> +
> +static inline void ne_misc_dev_test_exit(void)
> +{
> +}
> +#endif
> +
>   static int __init ne_init(void)
>   {
> +       int rc = 0;
> +
> +       rc = ne_misc_dev_test_init();
> +       if (rc < 0)
> +               return rc;
> +
>          mutex_init(&ne_cpu_pool.mutex);
> 
>          return pci_register_driver(&ne_pci_driver);
> @@ -1766,6 +1795,8 @@ static void __exit ne_exit(void)
>          pci_unregister_driver(&ne_pci_driver);
> 
>          ne_teardown_cpu_pool();
> +
> +       ne_misc_dev_test_exit();
>   }
> 
>   module_init(ne_init);
> diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev_test.c b/drivers/virt/nitro_enclaves/ne_misc_dev_test.c
> new file mode 100644
> index 0000000..6862e99
> --- /dev/null
> +++ b/drivers/virt/nitro_enclaves/ne_misc_dev_test.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <kunit/test.h>
> +
> +static struct kunit_case ne_misc_dev_test_cases[] = {
> +       {}
> +};
> +
> +static struct kunit_suite ne_misc_dev_test_suite = {
> +       .name = "ne_misc_dev_test",
> +       .test_cases = ne_misc_dev_test_cases,
> +};
> +
> +static struct kunit_suite *ne_misc_dev_test_suites[] = {
> +       &ne_misc_dev_test_suite,
> +       NULL
> +};
> --
> 1.8.3.1
> 



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-11-07 13:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 14:00 [PATCH v4 0/4] Merge contiguous physical memory regions Longpeng(Mike)
2021-11-03 14:00 ` [PATCH v4 1/4] nitro_enclaves: " Longpeng(Mike)
2021-11-07 12:56   ` Paraschiv, Andra-Irina
2021-11-03 14:00 ` [PATCH v4 2/4] nitro_enclaves: Sanity check physical memory regions during merging Longpeng(Mike)
2021-11-07 13:07   ` Paraschiv, Andra-Irina
2021-11-03 14:00 ` [PATCH v4 3/4] nitro_enclaves: Add KUnit tests setup for the misc device functionality Longpeng(Mike)
2021-11-07 13:12   ` Paraschiv, Andra-Irina [this message]
2021-11-03 14:00 ` [PATCH v4 4/4] nitro_enclaves: Add KUnit tests for contiguous physical memory regions merging Longpeng(Mike)
2021-11-07 13:19   ` Paraschiv, Andra-Irina
2021-11-07 13:22     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)

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=c730e964-4f97-3f78-22eb-b63a11f6e805@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