summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-05-22 12:01:36 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-05-22 12:01:36 +0200
commit0732cc59abc06151b8756a6890f13885cde7403b (patch)
treee9b1e28e5d4289fb64faefb9416daf4abc5e2012
parenta5e6897d10962e4bdfa657ce704bc111a4a4c663 (diff)
tests: use drm_open_any more
And fix it up to not leak open fds, which kills all the master only stuff.
-rw-r--r--lib/drmtest.c1
-rw-r--r--tests/flip_test.c26
-rw-r--r--tests/testdisplay.c20
3 files changed, 8 insertions, 39 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index fc2f1a81..b6aae37b 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -171,6 +171,7 @@ int drm_get_card(int master)
if (is_intel(fd) && master == 0) {
gem_quiescent_gpu(fd);
+ close(fd);
break;
}
diff --git a/tests/flip_test.c b/tests/flip_test.c
index 283d19d0..9aef688c 100644
--- a/tests/flip_test.c
+++ b/tests/flip_test.c
@@ -494,29 +494,11 @@ static int run_test(void)
int main(int argc, char **argv)
{
- const char *modules[] = { "i915" };
- unsigned int i;
- int ret = 0;
-
- for (i = 0; i < ARRAY_SIZE(modules); i++) {
- drm_fd = drmOpen(modules[i], NULL);
- if (drm_fd < 0) {
- printf("failed to load %s driver.\n", modules[i]);
- goto out;
- } else
- break;
- }
-
- if (i == ARRAY_SIZE(modules)) {
- fprintf(stderr, "failed to load any modules, aborting.\n");
- ret = -1;
- goto out_close;
- }
+ drm_fd = drm_open_any();
run_test();
-out_close:
- drmClose(drm_fd);
-out:
- return ret;
+ close(drm_fd);
+
+ return 0;
}
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 128dd34a..6aaea7aa 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -803,8 +803,6 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,
int main(int argc, char **argv)
{
int c;
- const char *modules[] = { "i915" };
- unsigned int i;
int ret = 0;
GIOChannel *stdinchannel;
GMainLoop *mainloop;
@@ -860,19 +858,7 @@ int main(int argc, char **argv)
!test_preferred_mode)
test_all_modes = 1;
- for (i = 0; i < ARRAY_SIZE(modules); i++) {
- drm_fd = drmOpen(modules[i], NULL);
- if (drm_fd < 0)
- printf("failed to load %s driver.\n", modules[i]);
- else
- break;
- }
-
- if (i == ARRAY_SIZE(modules)) {
- fprintf(stderr, "failed to load any modules, aborting.\n");
- ret = -1;
- goto out;
- }
+ drm_fd = drm_open_any();
mainloop = g_main_loop_new(NULL, FALSE);
if (!mainloop) {
@@ -918,7 +904,7 @@ out_hotplug:
out_mainloop:
g_main_loop_unref(mainloop);
out_close:
- drmClose(drm_fd);
-out:
+ close(drm_fd);
+
return ret;
}