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: <linux-kernel@vger.kernel.org>, <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 4/4] nitro_enclaves: add kunit tests for physical contiguous region merging
Date: Sun, 3 Oct 2021 17:14:24 +0300	[thread overview]
Message-ID: <d4558386-8925-085b-e2d0-7bc999c7fd6c@amazon.com> (raw)
In-Reply-To: <20210921151039.1502-5-longpeng2@huawei.com>



On 21/09/2021 18:10, Longpeng(Mike) wrote:
> Add kunit tests for the physical contiguous memory region merging
> functionality.

nitro_enclaves: Add KUnit tests for contiguous physical memory regions 
merging

Add KUnit tests for the contiguous physical memory regions merging 
functionality from the Nitro Enclaves misc device logic.

> 
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---
>   drivers/virt/nitro_enclaves/ne_misc_test.c | 46 ++++++++++++++++++++++++++++++
>   1 file changed, 46 insertions(+)
> 
> diff --git a/drivers/virt/nitro_enclaves/ne_misc_test.c b/drivers/virt/nitro_enclaves/ne_misc_test.c
> index 3426c35..8532bec 100644
> --- a/drivers/virt/nitro_enclaves/ne_misc_test.c
> +++ b/drivers/virt/nitro_enclaves/ne_misc_test.c
> @@ -2,7 +2,53 @@
>   
>   #include <kunit/test.h>
>   
> +#define MAX_PHYS_REGIONS	16
> +
> +struct phys_regions_test {
> +	u64 paddr;
> +	u64 size;
> +	int expect_rc;
> +	unsigned long expect_num;
> +	u64 expect_last_paddr;
> +	u64 expect_last_size;

Please align the fields in the data structure so that's easier to 
visualize them.

u64              paddr;
u64              size;
int              expect_rc;
unsigned long    expect_num;
............

> +} phys_regions_testcases[] = {

phys_regions_test_cases

> +	{0x1000, 0x200000, -EINVAL, 0, ~0, ~0},
> +	{0x200000, 0x1000, -EINVAL, 0, ~0, ~0},
> +	{0x200000, 0x200000, 0, 1, 0x200000, 0x200000},
> +	{0x0, 0x200000, 0, 2, 0x0, 0x200000},
> +	{0x600000, 0x400000, 0, 3, 0x600000, 0x400000},
> +	{0xa00000, 0x400000, 0, 3, 0x600000, 0x800000},
> +	{0x1000, 0x200000, -EINVAL, 3, 0x600000, 0x800000},

Please add a comment before each of the above test cases, including a 
brief description of what each of them intends to test. So that it's 
easier to relate to the numbers.

> +};
> +
> +static void ne_misc_test_set_phys_region(struct kunit *test)

ne_misc_dev_test_merge_phys_contig_memory_regions

> +{
> +	struct phys_contig_mem_region *regions;
> +	size_t sz;
> +	int i, rc;

Please initialize the variables.

Thanks,
Andra

> +
> +	sz = sizeof(*regions) + MAX_PHYS_REGIONS * sizeof(struct phys_mem_region);
> +	regions = kunit_kzalloc(test, sz, GFP_KERNEL);
> +	KUNIT_ASSERT_TRUE(test, regions != NULL);
> +
> +	for (i = 0; i < ARRAY_SIZE(phys_regions_testcases); i++) {
> +		rc = ne_add_phys_memory_region(regions, phys_regions_testcases[i].paddr,
> +					       phys_regions_testcases[i].size);
> +		KUNIT_EXPECT_EQ(test, rc, phys_regions_testcases[i].expect_rc);
> +		KUNIT_EXPECT_EQ(test, regions->num, phys_regions_testcases[i].expect_num);
> +
> +		if (phys_regions_testcases[i].expect_last_paddr == ~0ul)
> +			continue;
> +
> +		KUNIT_EXPECT_EQ(test, regions->region[regions->num - 1].paddr,
> +				phys_regions_testcases[i].expect_last_paddr);
> +		KUNIT_EXPECT_EQ(test, regions->region[regions->num - 1].size,
> +				phys_regions_testcases[i].expect_last_size);
> +	}
> +}
> +
>   static struct kunit_case ne_misc_test_cases[] = {
> +	KUNIT_CASE(ne_misc_test_set_phys_region),
>   	{}
>   };
>   
> 



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-03 14:14 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
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 [this message]
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=d4558386-8925-085b-e2d0-7bc999c7fd6c@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