From 9eb7d8950c199b9f4d93f3434aac9aa51c69d242 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 3 Jul 2013 09:58:28 +0100 Subject: [PATCH] Avoid corrupting the exitcode with a failure to open a quiescent fd In the atexit handler, we attempt to quiesce the GPU. This involves opening a fd - which will fail if the test is not being run as root and will obliterate the test status and pollute the output. --- lib/drmtest.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/drmtest.c b/lib/drmtest.c index 0a065c0..5edfda5 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -241,10 +241,10 @@ static int __drm_open_any(void) fd = open(name, O_RDWR); free(name); - if (fd == -1) - fprintf(stderr, "failed to open any drm device. retry as root?\n"); - - assert(is_intel(fd)); + if (!is_intel(fd)) { + close(fd); + fd = -1; + } return fd; } @@ -265,7 +265,12 @@ int drm_open_any(void) static int open_count; int fd = __drm_open_any(); - if (fd < 0 || __sync_fetch_and_add(&open_count, 1)) + if (fd < -1) { + fprintf(stderr, "failed to open any drm device. retry as root?\n"); + return fd; + } + + if (__sync_fetch_and_add(&open_count, 1)) return fd; gem_quiescent_gpu(fd); -- 2.7.4