From patchwork Tue Mar 31 12:53:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonas Lahtinen X-Patchwork-Id: 6129481 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E492DBF4A6 for ; Tue, 31 Mar 2015 12:53:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8C94201CE for ; Tue, 31 Mar 2015 12:53:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B4B08201C8 for ; Tue, 31 Mar 2015 12:53:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3913B6E0C6; Tue, 31 Mar 2015 05:53:25 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 2032C6E0C6 for ; Tue, 31 Mar 2015 05:53:24 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 31 Mar 2015 05:53:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,501,1422950400"; d="scan'208";a="688254596" Received: from phansen-mobl2.ger.corp.intel.com (HELO [10.252.20.2]) ([10.252.20.2]) by fmsmga001.fm.intel.com with ESMTP; 31 Mar 2015 05:53:22 -0700 Message-ID: <1427806397.21482.1.camel@jlahtine-mobl1> From: Joonas Lahtinen To: intel-gfx@lists.freedesktop.org, Thomas Wood Date: Tue, 31 Mar 2015 15:53:17 +0300 In-Reply-To: References: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t v5] tests: install test programs to libexec X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- lib/igt_core.c | 16 ++++++++++++++++ lib/igt_core.h | 13 +++++++++++++ tests/Makefile.am | 22 +++++++++++++++++++--- tests/Makefile.sources | 16 ++++++++++++++-- tests/testdisplay.c | 21 +++++++++++++++++++-- 5 files changed, 81 insertions(+), 7 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 783a219..8d60930 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -54,6 +54,7 @@ #include #include #include +#include #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 33f8940..4e56be8 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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 f45c6c9..69c7c4e 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 93e05e4..3e3aa57 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 f864940..92ea08c 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));