Skip to content

Commit 4ed4791

Browse files
committed
iommufd/selftest: Add a selftest for iommufd_device_attach() with a hwpt argument
This can now be covered since we have a full struct device. Link: https://lore.kernel.org/r/12-v3-ae9c2975a131+2e1e8-iommufd_hwpt_jgg@nvidia.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 65c619a commit 4ed4791

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

tools/testing/selftests/iommu/iommufd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ FIXTURE(iommufd_ioas)
187187
int fd;
188188
uint32_t ioas_id;
189189
uint32_t stdev_id;
190+
uint32_t hwpt_id;
190191
uint64_t base_iova;
191192
};
192193

@@ -212,7 +213,8 @@ FIXTURE_SETUP(iommufd_ioas)
212213
}
213214

214215
for (i = 0; i != variant->mock_domains; i++) {
215-
test_cmd_mock_domain(self->ioas_id, &self->stdev_id, NULL);
216+
test_cmd_mock_domain(self->ioas_id, &self->stdev_id,
217+
&self->hwpt_id);
216218
self->base_iova = MOCK_APERTURE_START;
217219
}
218220
}
@@ -259,6 +261,16 @@ TEST_F(iommufd_ioas, ioas_destroy)
259261
}
260262
}
261263

264+
TEST_F(iommufd_ioas, hwpt_attach)
265+
{
266+
/* Create a device attached directly to a hwpt */
267+
if (self->stdev_id) {
268+
test_cmd_mock_domain(self->hwpt_id, NULL, NULL);
269+
} else {
270+
test_err_mock_domain(ENOENT, self->hwpt_id, NULL, NULL);
271+
}
272+
}
273+
262274
TEST_F(iommufd_ioas, ioas_area_destroy)
263275
{
264276
/* Adding an area does not change ability to destroy */

0 commit comments

Comments
 (0)