From a95033fdbcf32ea64ad2b75f38315489ee1c2042 Mon Sep 17 00:00:00 2001 From: Joonas Lahtinen Date: Tue, 31 Mar 2015 15:53:17 +0300 Subject: 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 Cc: Thomas Wood Signed-off-by: Joonas Lahtinen Signed-off-by: Thomas Wood --- tests/testdisplay.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'tests/testdisplay.c') 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 #include @@ -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)); -- cgit v1.2.3