summaryrefslogtreecommitdiff
path: root/tests/testdisplay.c
diff options
context:
space:
mode:
authorJoonas Lahtinen <joonas.lahtinen@linux.intel.com>2015-03-31 15:53:17 +0300
committerThomas Wood <thomas.wood@intel.com>2015-04-02 16:32:47 +0100
commita95033fdbcf32ea64ad2b75f38315489ee1c2042 (patch)
tree2448cd63884ec3a078ea38057062140faa173af5 /tests/testdisplay.c
parent590e47c94fd81a182e24b41a715d84491df8cea8 (diff)
tests: install test programs to libexec
Install the test programs by default so that they can be packaged. Tested with the testdisplay test so that it still runs after the modifications as it depends on a data file to be present. Need to pass -r option to enable QR code display on success (PNG data file). Packaging is useful when building a complete software stack for a DUT from scratch. This should bring us closer to achieving a built-from-scratch testing workflow. Package maintainers can always decide to ignore the installed files. v2: - Install more tests including scripts and their data v3: - Add clarification to commit message about why we do this. (Chris Wilson & Thomas Wood) - Change libexec into pkglibexec to comply to standard (Thomas Wood) - Do not install $(common_files). (Thomas Wood) - Make it really obvious the installed files are tests by using tests directory name to avoid any confusion with packagers. v4: - Fixed commit message. v5: - Add file locator helper to retain backwards compatibility. (Thomas Wood) - Test with testdisplay -r option that draws the .png file. Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Thomas Wood <thomas.wood@intel.com> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'tests/testdisplay.c')
-rw-r--r--tests/testdisplay.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index f864940cd..92ea08ca1 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));