iommufd/selftest: Rework TEST_LENGTH to test min_size explicitly
authorNicolin Chen <nicolinc@nvidia.com>
Sun, 15 Oct 2023 07:46:48 +0000 (00:46 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 16 Oct 2023 14:05:51 +0000 (11:05 -0300)
commit266dcae34d8f44c3bbab00e227f8b14517682bb7
treec33b5681650efe7cbfd37def5b79aeaebb26132a
parentc97d1b20d3835178bcd0e3a86c20ce4e36b6d80c
iommufd/selftest: Rework TEST_LENGTH to test min_size explicitly

TEST_LENGTH passing ".size = sizeof(struct _struct) - 1" expects -EINVAL
from "if (ucmd.user_size < op->min_size)" check in iommufd_fops_ioctl().
This has been working when min_size is exactly the size of the structure.

However, if the size of the structure becomes larger than min_size, i.e.
the passing size above is larger than min_size, that min_size sanity no
longer works.

Since the first test in TEST_LENGTH() was to test that min_size sanity
routine, rework it to support a min_size calculation, rather than using
the full size of the structure.

Link: https://lore.kernel.org/r/20231015074648.24185-1-nicolinc@nvidia.com
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
tools/testing/selftests/iommu/iommufd.c