summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/igt_core.c16
-rw-r--r--lib/igt_core.h13
-rw-r--r--tests/Makefile.am22
-rw-r--r--tests/Makefile.sources16
-rw-r--r--tests/testdisplay.c21
5 files changed, 81 insertions, 7 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 783a2191..8d609304 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -54,6 +54,7 @@
#include <errno.h>
#include <time.h>
#include <ctype.h>
+#include <limits.h>
#include "drmtest.h"
#include "intel_chipset.h"
@@ -1735,3 +1736,18 @@ void igt_set_timeout(unsigned int seconds)
alarm(seconds);
}
+
+FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
+ const char* filename)
+{
+ char path[PATH_MAX];
+ FILE *fp;
+
+ snprintf(path, sizeof(path), "%s/%s", igt_datadir, filename);
+ fp = fopen(path, "r");
+ if (!fp) {
+ snprintf(path, sizeof(path), "%s/%s", igt_srcdir, filename);
+ fp = fopen(path, "r");
+ }
+ return fp;
+}
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 33f89406..4e56be8a 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -33,6 +33,7 @@
#include <setjmp.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <stdarg.h>
@@ -650,4 +651,16 @@ extern enum igt_log_level igt_log_level;
void igt_set_timeout(unsigned int seconds);
+FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
+ const char* filename);
+/**
+ * igt_fopen_data:
+ * @filename: filename to open.
+ *
+ * Open a datafile for test, first try from installation directory
+ * then from build directory.
+ */
+#define igt_fopen_data(filename) \
+ __igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, filename)
+
#endif /* IGT_CORE_H */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f45c6c94..69c7c4e0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,8 +27,23 @@ multi-tests.txt: Makefile.sources
@echo ${multi_kernel_tests} >> $@
@echo END TESTLIST >> $@
-EXTRA_PROGRAMS = $(TESTS_progs) $(TESTS_progs_M) $(HANG)
-EXTRA_DIST = $(TESTS_scripts) $(TESTS_scripts_M) $(scripts) $(IMAGES) $(common_files)
+igt_tests_bin_PROGRAMS += \
+ $(TESTS_progs) \
+ $(TESTS_progs_M) \
+ $(NULL)
+
+igt_tests_bin_SCRIPTS += \
+ $(TESTS_scripts) \
+ $(TESTS_scripts_M) \
+ $(scripts) \
+ $(NULL)
+
+igt_tests_data_DATA += \
+ $(IMAGES) \
+ $(NULL)
+
+EXTRA_PROGRAMS = $(HANG)
+EXTRA_DIST = $(common_files)
CLEANFILES = $(EXTRA_PROGRAMS) single-tests.txt multi-tests.txt
@@ -36,7 +51,8 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(DEBUG_CFLAGS)\
-I$(srcdir)/.. \
-I$(srcdir)/../lib \
-include "$(srcdir)/../lib/check-ndebug.h" \
- -DIGT_DATADIR=\""$(abs_srcdir)"\" \
+ -DIGT_SRCDIR=\""$(abs_srcdir)"\" \
+ -DIGT_DATADIR=\""$(igt_tests_datadir)"\" \
$(LIBUNWIND_CFLAGS) \
$(NULL)
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 93e05e4d..3e3aa572 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -1,10 +1,22 @@
+igt_tests_bindir = $(pkglibexecdir)/tests
+igt_tests_datadir = $(pkgdatadir)/tests
+
noinst_PROGRAMS = \
+ $(HANG) \
+ $(TESTS_testsuite) \
+ $(NULL)
+
+igt_tests_bin_PROGRAMS = \
gem_alive \
gem_stress \
$(TESTS_progs) \
$(TESTS_progs_M) \
- $(HANG) \
- $(TESTS_testsuite) \
+ $(NULL)
+
+igt_tests_bin_SCRIPTS = \
+ $(NULL)
+
+igt_tests_data_DATA = \
$(NULL)
NOUVEAU_TESTS_M = \
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index f864940c..92ea08ca 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -68,6 +68,7 @@
#include "drmtest.h"
#include "testdisplay.h"
#include "igt_kms.h"
+#include "igt_core.h"
#include <stdlib.h>
#include <signal.h>
@@ -238,12 +239,21 @@ paint_color_key(struct igt_fb *fb_info)
munmap(fb_ptr, fb_info->size);
}
+static cairo_status_t
+stdio_read_func(void* closure, unsigned char* data, unsigned int size)
+{
+ if (fread (data, 1, size, (FILE*)closure) != size)
+ return CAIRO_STATUS_READ_ERROR;
+ return CAIRO_STATUS_SUCCESS;
+}
+
static void paint_image(cairo_t *cr, const char *file)
{
int img_x, img_y, img_w, img_h, img_w_o, img_h_o;
double img_w_scale, img_h_scale;
cairo_surface_t *image;
+ FILE* fp;
img_y = height * (0.10 );
img_h = height * 0.08 * 4;
@@ -251,7 +261,14 @@ static void paint_image(cairo_t *cr, const char *file)
img_x = (width / 2) - (img_w / 2);
- image = cairo_image_surface_create_from_png(file);
+ fp = igt_fopen_data(file);
+ if (!fp) {
+ igt_warn("data file \'%s\' missing: %s\n",
+ file, strerror(errno));
+ return;
+ }
+ image = cairo_image_surface_create_from_png_stream(&stdio_read_func,
+ (void*)fp);
img_w_o = cairo_image_surface_get_width(image);
img_h_o = cairo_image_surface_get_height(image);
@@ -318,7 +335,7 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)
}
if (qr_code)
- paint_image(cr, IGT_DATADIR"/pass.png");
+ paint_image(cr, "pass.png");
igt_assert(!cairo_status(cr));