[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZyOydn+/s6enh1jg@Asurada-Nvidia>
Date: Thu, 31 Oct 2024 09:38:14 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: <kevin.tian@...el.com>, <corbet@....net>, <joro@...tes.org>,
<suravee.suthikulpanit@....com>, <will@...nel.org>, <robin.murphy@....com>,
<dwmw2@...radead.org>, <shuah@...nel.org>, <iommu@...ts.linux.dev>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>, <baolu.lu@...ux.intel.com>,
<eric.auger@...hat.com>, <jean-philippe@...aro.org>, <mdf@...nel.org>,
<mshavit@...gle.com>, <shameerali.kolothum.thodi@...wei.com>,
<smostafa@...gle.com>, <yi.l.liu@...el.com>, <aik@....com>,
<zhangfei.gao@...aro.org>, <patches@...ts.linux.dev>
Subject: Re: [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test
coverage
On Thu, Oct 31, 2024 at 10:16:37AM -0300, Jason Gunthorpe wrote:
> On Wed, Oct 30, 2024 at 02:34:38PM -0700, Nicolin Chen wrote:
> > +FIXTURE_SETUP(iommufd_viommu)
> > +{
> > + self->fd = open("/dev/iommu", O_RDWR);
> > + ASSERT_NE(-1, self->fd);
> > + test_ioctl_ioas_alloc(&self->ioas_id);
> > + test_ioctl_set_default_memory_limit();
> > +
> > + if (variant->viommu) {
> > + struct iommu_hwpt_selftest data = {
> > + .iotlb = IOMMU_TEST_IOTLB_DEFAULT,
> > + };
> > +
> > + test_cmd_mock_domain(self->ioas_id, &self->stdev_id, NULL,
> > + &self->device_id);
> > +
> > + /* Negative test -- invalid hwpt */
> > + test_err_viommu_alloc(ENOENT, self->device_id, self->hwpt_id,
> > + IOMMU_VIOMMU_TYPE_SELFTEST, NULL);
> > +
> > + /* Negative test -- not a nesting parent hwpt */
> > + test_cmd_hwpt_alloc(self->device_id, self->ioas_id, 0,
> > + &self->hwpt_id);
> > + test_err_viommu_alloc(EINVAL, self->device_id, self->hwpt_id,
> > + IOMMU_VIOMMU_TYPE_SELFTEST, NULL);
> > + test_ioctl_destroy(self->hwpt_id);
> > +
> > + /* Allocate a nesting parent hwpt */
> > + test_cmd_hwpt_alloc(self->device_id, self->ioas_id,
> > + IOMMU_HWPT_ALLOC_NEST_PARENT,
> > + &self->hwpt_id);
> > + /* Negative test -- unsupported viommu type */
> > + test_err_viommu_alloc(EOPNOTSUPP, self->device_id,
> > + self->hwpt_id, 0xdead, NULL);
> > +
> > + /* Allocate a vIOMMU taking refcount of the parent hwpt */
> > + test_cmd_viommu_alloc(self->device_id, self->hwpt_id,
> > + IOMMU_VIOMMU_TYPE_SELFTEST,
> > + &self->viommu_id);
> > + EXPECT_ERRNO(EBUSY,
> > + _test_ioctl_destroy(self->fd, self->hwpt_id));
>
> There shouldn't be testing in the FIXTURE_SETUP, it should just do
> enough to setup the fixture. negative tests/etc should be in their own
> function
OK. I'll make a change by moving all EXPECT_ERRNOs to a TEST_F.
Thanks
Nicolin
Powered by blists - more mailing lists