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.
This commit is contained in:
Chris Wilson 2013-07-03 09:58:28 +01:00
parent 9360df4ab3
commit 9eb7d8950c

View File

@ -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);