RE: [PATCH v8 4/5] iommufd/selftest: Add coverage for IOMMU_GET_HW_INFO ioctl
From: Tian, Kevin
Date: Thu Aug 17 2023 - 03:34:15 EST
> From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> Sent: Wednesday, August 16, 2023 8:14 PM
>
>
> +TEST_F(iommufd_ioas, get_hw_info)
> +{
> + struct iommu_test_hw_info buffer_exact;
> + struct iommu_test_hw_info_buffer {
> + struct iommu_test_hw_info info;
> + uint64_t trailing_bytes;
> + } buffer_larger;
> +
> + if (self->device_id) {
> + /* Provide a zero-size user_buffer */
> + test_cmd_get_hw_info(self->device_id, NULL, 0);
> + /* Provide a user_buffer with exact size */
> + test_cmd_get_hw_info(self->device_id, &buffer_exact,
> sizeof(buffer_exact));
> + /*
> + * Provide a user_buffer with size larger than the exact size to
> check if
> + * kernel zero the trailing bytes.
> + */
> + test_cmd_get_hw_info(self->device_id, &buffer_larger,
> sizeof(buffer_larger));
Do we also want to test a case where size is smaller than the exact size?