[PATCH i-g-t] tests/intel/xe_oa: Look at errno only when system calls fail
Kamil Konieczny
kamil.konieczny at linux.intel.com
Tue Jul 8 17:04:59 UTC 2025
Hi Ashutosh,
On 2025-07-08 at 08:16:59 -0700, Ashutosh Dixit wrote:
> errno is set only when system calls fail, so it is incorrect to look at
> errno when system calls succeed.
>
LGTM,
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/5339
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
> ---
> tests/intel/xe_oa.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
> index cb59918ef9..724fea73f0 100644
> --- a/tests/intel/xe_oa.c
> +++ b/tests/intel/xe_oa.c
> @@ -1431,7 +1431,7 @@ read_2_oa_reports(int format_id,
>
> while ((ret = read(stream_fd, buf + len, buf_size)) < 0 && errno == EINTR)
> ;
> - if (errno == EIO) {
> + if (ret < 0 && errno == EIO) {
> oa_status = get_stream_status(stream_fd);
> continue;
> }
> @@ -1869,7 +1869,7 @@ static void test_oa_exponents(const struct drm_xe_engine_class_instance *hwe)
>
> while ((ret = read(stream_fd, buf, buf_size)) < 0 && errno == EINTR)
> ;
> - if (errno == EIO) {
> + if (ret < 0 && errno == EIO) {
> oa_status = get_stream_status(stream_fd);
> continue;
> }
> @@ -2532,7 +2532,6 @@ test_buffer_fill(const struct drm_xe_engine_class_instance *hwe)
>
> do_ioctl(stream_fd, DRM_XE_OBSERVATION_IOCTL_ENABLE, 0);
>
> - errno = 0;
> /* Read 0 bytes repeatedly until you see an EIO */
> while (-1 == read(stream_fd, buf, 0)) {
> if (errno == EIO) {
> @@ -2607,7 +2606,7 @@ test_non_zero_reason(const struct drm_xe_engine_class_instance *hwe, size_t oa_b
> ((len = read(stream_fd, &buf[total_len], buf_size - total_len)) > 0 ||
> (len == -1 && (errno == EINTR || errno == EIO)))) {
> /* Assert only for default OA buffer size */
> - if (errno == EIO && !oa_buffer_size) {
> + if (len < 0 && errno == EIO && !oa_buffer_size) {
> oa_status = get_stream_status(stream_fd);
> igt_assert(!(oa_status & DRM_XE_OASTATUS_BUFFER_OVERFLOW));
> }
> --
> 2.48.1
>
More information about the igt-dev
mailing list