mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-10 09:26:10 +00:00
igt: Prettify igt_assert_eq() failure messages
This just improves the language about the exact failure to reduce confusion. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
d0a41b47ea
commit
3b94d3f8ce
@ -275,13 +275,22 @@ void igt_exit(void) __attribute__((noreturn));
|
||||
* Like igt_assert(), but displays the values being compared on failure instead
|
||||
* of simply printing the stringified expression.
|
||||
*/
|
||||
#define igt_assert_cmpint(n1, cmp, n2) \
|
||||
#define igt_assert_cmpint(n1, cmp, ncmp, n2) \
|
||||
do { \
|
||||
int __n1 = (n1), __n2 = (n2); \
|
||||
if (__n1 cmp __n2) ; else \
|
||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
|
||||
#n1 " " #cmp " " #n2, \
|
||||
"error: %d %s %d\n", __n1, #cmp, __n2); \
|
||||
"error: %d %s %d\n", __n1, #ncmp, __n2); \
|
||||
} while (0)
|
||||
|
||||
#define igt_assert_cmpuint(n1, cmp, ncmp, n2) \
|
||||
do { \
|
||||
uint32_t __n1 = (n1), __n2 = (n2); \
|
||||
if (__n1 cmp __n2) ; else \
|
||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
|
||||
#n1 " " #cmp " " #n2, \
|
||||
"error: %#x %s %#x\n", __n1, #ncmp, __n2); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
@ -295,7 +304,34 @@ void igt_exit(void) __attribute__((noreturn));
|
||||
* Like igt_assert(), but displays the values being compared on failure instead
|
||||
* of simply printing the stringified expression.
|
||||
*/
|
||||
#define igt_assert_eq(n1, n2) igt_assert_cmpint(n1, ==, n2)
|
||||
#define igt_assert_eq(n1, n2) igt_assert_cmpint(n1, ==, !=, n2)
|
||||
#define igt_assert_eq_u32(n1, n2) igt_assert_cmpuint(n1, ==, !=, n2)
|
||||
|
||||
/**
|
||||
* igt_assert_neq:
|
||||
* @n1: first integer
|
||||
* @n2: second integer
|
||||
*
|
||||
* Fails (sub-)test if the two integers are equal. Beware that for now this
|
||||
* only works on integers.
|
||||
*
|
||||
* Like igt_assert(), but displays the values being compared on failure instead
|
||||
* of simply printing the stringified expression.
|
||||
*/
|
||||
#define igt_assert_neq(n1, n2) igt_assert_cmpint(n1, !=, ==, n2)
|
||||
|
||||
/**
|
||||
* igt_assert_lte:
|
||||
* @n1: first integer
|
||||
* @n2: second integer
|
||||
*
|
||||
* Fails (sub-)test if the second integers is greater than the first.
|
||||
* Beware that for now this only works on integers.
|
||||
*
|
||||
* Like igt_assert(), but displays the values being compared on failure instead
|
||||
* of simply printing the stringified expression.
|
||||
*/
|
||||
#define igt_assert_lte(n1, n2) igt_assert_cmpint(n1, <=, >, n2)
|
||||
|
||||
/**
|
||||
* igt_require:
|
||||
|
@ -468,7 +468,7 @@ static bool read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
|
||||
bytes_read = read(pipe_crc->crc_fd, &buf, pipe_crc->line_len);
|
||||
igt_set_timeout(0);
|
||||
|
||||
igt_assert_cmpint(bytes_read, ==, pipe_crc->line_len);
|
||||
igt_assert_eq(bytes_read, pipe_crc->line_len);
|
||||
buf[bytes_read] = '\0';
|
||||
|
||||
if (!pipe_crc_init_from_string(out, buf))
|
||||
|
@ -98,7 +98,7 @@ igt_main
|
||||
igt_assert(drmIoctl(fd, \
|
||||
DRM_IOCTL_I915_GEM_EXECBUFFER2, \
|
||||
&execbuf) == -1); \
|
||||
igt_assert_cmpint(errno, ==, expected_errno); \
|
||||
igt_assert_eq(errno, expected_errno); \
|
||||
} while(0)
|
||||
|
||||
igt_subtest("no-bsd") {
|
||||
|
@ -126,7 +126,7 @@ static void bo_check(data_t *data, drm_intel_bo *bo, uint32_t val)
|
||||
gem_read(data->drm_fd, bo->handle, 0,
|
||||
data->linear, sizeof(data->linear));
|
||||
for (i = 0; i < WIDTH * HEIGHT; i++)
|
||||
igt_assert_cmpint(data->linear[i], ==, val);
|
||||
igt_assert_eq_u32(data->linear[i], val);
|
||||
}
|
||||
|
||||
static void scratch_buf_init_from_bo(struct igt_buf *buf, drm_intel_bo *bo)
|
||||
|
@ -80,7 +80,7 @@ store_dword_loop(int divider)
|
||||
drm_intel_bo_map(target_buffer, 0);
|
||||
|
||||
buf = target_buffer->virtual;
|
||||
igt_assert_cmpint (buf[0], ==, val);
|
||||
igt_assert_eq_u32(buf[0], val);
|
||||
|
||||
drm_intel_bo_unmap(target_buffer);
|
||||
|
||||
|
@ -180,7 +180,7 @@ igt_simple_main
|
||||
iter <<= 1;
|
||||
} while (!done && iter < 1000000);
|
||||
|
||||
igt_assert_cmpint(iter, <, 1000000);
|
||||
igt_assert_cmpint(iter, <, >=, 1000000);
|
||||
|
||||
igt_info("%d iters is enough work\n", iter);
|
||||
gem_quiescent_gpu(fd);
|
||||
@ -196,9 +196,9 @@ igt_simple_main
|
||||
intel_batchbuffer_flush(batch);
|
||||
igt_assert(gem_bo_busy(fd, dst2->handle) == true);
|
||||
|
||||
igt_assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == 0);
|
||||
igt_assert_eq(gem_bo_wait_timeout(fd, dst2->handle, &timeout), 0);
|
||||
igt_assert(gem_bo_busy(fd, dst2->handle) == false);
|
||||
igt_assert_cmpint(timeout, !=, 0);
|
||||
igt_assert_neq(timeout, 0);
|
||||
if (timeout == (ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC))
|
||||
igt_info("Buffer was already done!\n");
|
||||
else {
|
||||
@ -207,8 +207,8 @@ igt_simple_main
|
||||
|
||||
/* check that polling with timeout=0 works. */
|
||||
timeout = 0;
|
||||
igt_assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == 0);
|
||||
igt_assert(timeout == 0);
|
||||
igt_assert_eq(gem_bo_wait_timeout(fd, dst2->handle, &timeout), 0);
|
||||
igt_assert_eq(timeout, 0);
|
||||
|
||||
/* Now check that we correctly time out, twice the auto-tune load should
|
||||
* be good enough. */
|
||||
@ -219,14 +219,14 @@ igt_simple_main
|
||||
intel_batchbuffer_flush(batch);
|
||||
|
||||
ret = gem_bo_wait_timeout(fd, dst2->handle, &timeout);
|
||||
igt_assert(ret == -ETIME);
|
||||
igt_assert(timeout == 0);
|
||||
igt_assert_eq(ret, -ETIME);
|
||||
igt_assert_eq(timeout, 0);
|
||||
igt_assert(gem_bo_busy(fd, dst2->handle) == true);
|
||||
|
||||
/* check that polling with timeout=0 works. */
|
||||
timeout = 0;
|
||||
igt_assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == -ETIME);
|
||||
igt_assert(timeout == 0);
|
||||
igt_assert_eq(gem_bo_wait_timeout(fd, dst2->handle, &timeout), -ETIME);
|
||||
igt_assert_eq(timeout, 0);
|
||||
|
||||
|
||||
if (do_signals)
|
||||
|
@ -438,7 +438,7 @@ igt_main
|
||||
igt_assert(ret == 0 || errno == EINVAL);
|
||||
|
||||
/* We assume width and height are same so max is assigned width */
|
||||
igt_assert_cmpint(cursor_width, ==, cursor_height);
|
||||
igt_assert_eq(cursor_width, cursor_height);
|
||||
|
||||
kmstest_set_vt_graphics_mode();
|
||||
|
||||
|
@ -104,9 +104,9 @@ static void test_bad_command(data_t *data, const char *cmd)
|
||||
ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+");
|
||||
written = fwrite(cmd, 1, strlen(cmd), ctl);
|
||||
fflush(ctl);
|
||||
igt_assert_cmpint(written, ==, (strlen(cmd)));
|
||||
igt_assert_eq(written, strlen(cmd));
|
||||
igt_assert(ferror(ctl));
|
||||
igt_assert_cmpint(errno, ==, EINVAL);
|
||||
igt_assert_eq(errno, EINVAL);
|
||||
|
||||
fclose(ctl);
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ static void test_i2c(struct mode_set_data *data)
|
||||
int i2c_edids = count_i2c_valid_edids();
|
||||
int drm_edids = count_drm_valid_edids(data);
|
||||
|
||||
igt_assert_cmpint(i2c_edids, ==, drm_edids);
|
||||
igt_assert_eq(i2c_edids, drm_edids);
|
||||
}
|
||||
|
||||
static void setup_pc8(void)
|
||||
|
@ -101,7 +101,7 @@ static int do_writeval(FILE *filp, int val, int lerrno)
|
||||
igt_assert(readval(filp) == orig);
|
||||
} else {
|
||||
/* Expecting no error */
|
||||
igt_assert(ret != EOF);
|
||||
igt_assert_neq(ret, 0);
|
||||
igt_assert(readval(filp) == val);
|
||||
}
|
||||
|
||||
@ -112,25 +112,25 @@ static int do_writeval(FILE *filp, int val, int lerrno)
|
||||
|
||||
static void checkit(const int *freqs)
|
||||
{
|
||||
igt_assert_cmpint(freqs[MIN], <=, freqs[MAX]);
|
||||
igt_assert_cmpint(freqs[CUR], <=, freqs[MAX]);
|
||||
igt_assert_cmpint(freqs[MIN], <=, freqs[CUR]);
|
||||
igt_assert_cmpint(freqs[RPn], <=, freqs[MIN]);
|
||||
igt_assert_cmpint(freqs[MAX], <=, freqs[RP0]);
|
||||
igt_assert_cmpint(freqs[RP1], <=, freqs[RP0]);
|
||||
igt_assert_cmpint(freqs[RPn], <=, freqs[RP1]);
|
||||
igt_assert(freqs[RP0] != 0);
|
||||
igt_assert(freqs[RP1] != 0);
|
||||
igt_assert_lte(freqs[MIN], freqs[MAX]);
|
||||
igt_assert_lte(freqs[CUR], freqs[MAX]);
|
||||
igt_assert_lte(freqs[MIN], freqs[CUR]);
|
||||
igt_assert_lte(freqs[RPn], freqs[MIN]);
|
||||
igt_assert_lte(freqs[MAX], freqs[RP0]);
|
||||
igt_assert_lte(freqs[RP1], freqs[RP0]);
|
||||
igt_assert_lte(freqs[RPn], freqs[RP1]);
|
||||
igt_assert_neq(freqs[RP0], 0);
|
||||
igt_assert_neq(freqs[RP1], 0);
|
||||
}
|
||||
|
||||
static void matchit(const int *freqs1, const int *freqs2)
|
||||
{
|
||||
igt_assert_cmpint(freqs1[CUR], ==, freqs2[CUR]);
|
||||
igt_assert_cmpint(freqs1[MIN], ==, freqs2[MIN]);
|
||||
igt_assert_cmpint(freqs1[MAX], ==, freqs2[MAX]);
|
||||
igt_assert_cmpint(freqs1[RP0], ==, freqs2[RP0]);
|
||||
igt_assert_cmpint(freqs1[RP1], ==, freqs2[RP1]);
|
||||
igt_assert_cmpint(freqs1[RPn], ==, freqs2[RPn]);
|
||||
igt_assert_eq(freqs1[CUR], freqs2[CUR]);
|
||||
igt_assert_eq(freqs1[MIN], freqs2[MIN]);
|
||||
igt_assert_eq(freqs1[MAX], freqs2[MAX]);
|
||||
igt_assert_eq(freqs1[RP0], freqs2[RP0]);
|
||||
igt_assert_eq(freqs1[RP1], freqs2[RP1]);
|
||||
igt_assert_eq(freqs1[RPn], freqs2[RPn]);
|
||||
}
|
||||
|
||||
static void dump(const int *freqs)
|
||||
@ -409,7 +409,7 @@ static void idle_check(void)
|
||||
wait += IDLE_WAIT_TIMESTEP_MSEC;
|
||||
} while (wait < IDLE_WAIT_TIMEOUT_MSEC);
|
||||
|
||||
igt_assert_cmpint(freqs[CUR], ==, freqs[MIN]);
|
||||
igt_assert_eq(freqs[CUR], freqs[MIN]);
|
||||
igt_debug("Required %d msec to reach cur=min\n", wait);
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ static void loaded_check(void)
|
||||
wait += LOADED_WAIT_TIMESTEP_MSEC;
|
||||
} while (wait < LOADED_WAIT_TIMEOUT_MSEC);
|
||||
|
||||
igt_assert_cmpint(freqs[CUR], ==, freqs[MAX]);
|
||||
igt_assert_eq(freqs[CUR], freqs[MAX]);
|
||||
igt_debug("Required %d msec to reach cur=max\n", wait);
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ static void test_reimport_close_race(void)
|
||||
|
||||
close(fake);
|
||||
|
||||
igt_assert_cmpint(obj_count, ==, 0);
|
||||
igt_assert_eq(obj_count, 0);
|
||||
}
|
||||
|
||||
static void *thread_fn_export_vs_close(void *p)
|
||||
@ -376,7 +376,7 @@ static void test_export_close_race(void)
|
||||
obj_count = get_object_count() - obj_count;
|
||||
|
||||
igt_info("leaked %i objects\n", obj_count);
|
||||
igt_assert_cmpint(obj_count, ==, 0);
|
||||
igt_assert_eq(obj_count, 0);
|
||||
}
|
||||
|
||||
static void test_llseek_size(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user