tests: Use igt macros more

Often just folding together of the common if (cond) printf;
abort|igt_skip|igt_fail; pattern. But in a few cases I've ripped out
more since the igt macros will already print the condition and errno.

A few tests where more work (like ripping out return codes en masse)
is needed left as-is.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter
2014-05-14 09:56:53 +02:00
parent e624fa8a2e
commit 0b7ce4ac29
30 changed files with 131 additions and 288 deletions
+5 -19
View File
@@ -39,19 +39,6 @@ struct local_drm_i915_reg_read {
#define REG_READ_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x31, struct local_drm_i915_reg_read)
static void handle_bad(int ret, int expected, const char *desc)
{
if (ret != 0 && errno != expected) {
fprintf(stderr, "%s - errno was %d, but should have been %d\n",
desc, errno, expected);
igt_fail(1);
} else if (ret == 0) {
fprintf(stderr, "%s - Command succeeded, but should have failed\n",
desc);
igt_fail(1);
}
}
static uint64_t timer_query(int fd)
{
struct local_drm_i915_reg_read reg_read;
@@ -79,15 +66,14 @@ igt_simple_main
reg_read.val = timer_query(fd);
sleep(1);
if (timer_query(fd) == reg_read.val) {
fprintf(stderr, "Timer isn't moving, probably busted\n");
igt_fail(1);
}
/* Check that timer is moving and isn't busted. */
igt_assert(timer_query(fd) != reg_read.val);
/* bad reg */
reg_read.offset = 0x12345678;
handle_bad(drmIoctl(fd, REG_READ_IOCTL, &reg_read),
EINVAL, "bad register");
ret = drmIoctl(fd, REG_READ_IOCTL, &reg_read);
igt_assert(ret != 0 && errno == ENOENT);
close(fd);
}