Re: [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux