From patchwork Wed Feb 27 19:12:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 159287 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4794477jad; Wed, 27 Feb 2019 11:12:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IYTmJkaiRdRcgp808vRHbj6IKGCpdoi8TJbFduild5HxICsVp8KhRnsAlpwCFjo+9nwsFGa X-Received: by 2002:aa7:90c7:: with SMTP id k7mr3215491pfk.186.1551294777361; Wed, 27 Feb 2019 11:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551294777; cv=none; d=google.com; s=arc-20160816; b=iecXP4hfG3plakUl7CNkPaCEq7/8IAixAeN9u81ofeHI6kZRRC7yBq2PBizX2hDZqR w4hupC8PIsipu2awtomdnHH/LHBJErbYThfMv1L4I1tIU3VToRaJ/ApFd3irDnFOU6lr xX2oXEutbIYF3Qvjxbbuhe/bkzdGDbkRqhZdvI/IhqUN1Ko4PkjjJ3KLGBKRXVMDxe8Y LcXJhwxePBqge74adUHXGqayNn2zJeuXpSRyd7Kvj51DyiXL8bzYbbwoF8zDzuYjlROv 1LfCzRyL+0TfUtsZWFRLC+HE3cVISA3Fn8O4vRoooCwYJf8bPVeNu8aF5ZzGQN5ZbpqJ ghPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+biE6TvgDw2/zb84+2m23DalLJodvkeqokPIck4A2MQ=; b=0Ae/kzbdTer9uss2hOnd7W3XLz+sqIjaTKAxgqwwOXWZ6SkuKBg0nRNHu1e156sqDZ r0wr8roWJ9TgLZeIrD+g7+2w5GXkGsfNKCWQ46mIxJupXaH1l76DteDFr3H90lcJ/80H qVPt6xCKJQ0llqyWmb/ltuNuhthg+1G5719Q7YESHLuQJYMmIdA3An7CN08UEWH+K7V5 tgJJgwwIBdC3MV2K880G2M+5VSM59Nudx/IdVGxwBMBwZ3T1t+fzsbecCauN/IRpJJas oKAGTQ3qgbPIGstT+LstYC0EJuZcJtDmQXxjPJrpqzNAIKPHsbtbRJqSGj6gqNfGao6S GokQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0uZUOZC; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si16881955plc.250.2019.02.27.11.12.56; Wed, 27 Feb 2019 11:12:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0uZUOZC; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbfB0TM4 (ORCPT + 5 others); Wed, 27 Feb 2019 14:12:56 -0500 Received: from mail-ed1-f54.google.com ([209.85.208.54]:44623 "EHLO mail-ed1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbfB0TM4 (ORCPT ); Wed, 27 Feb 2019 14:12:56 -0500 Received: by mail-ed1-f54.google.com with SMTP id b20so14844771edw.11 for ; Wed, 27 Feb 2019 11:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+biE6TvgDw2/zb84+2m23DalLJodvkeqokPIck4A2MQ=; b=K0uZUOZCzTrQez72HAfEpx5VjLs7mBSG9fRsP3uDq3vvRFO2vp9qy3iH4w8KBRYjjq 8dvoKr8dO/Qsl17XCzDA4JjJJLK9heBwMxRaTzG198KtZHEnEar0/tcDGLrM2uKzf1dX 1sxGiv5oYINJMQWKra3IDeJQxeLboMIElqmPg/sCZAKwrDAAuHDApi/cMikNQF92ygSW tN+wludZC2pyvrwncpNYyUnamdO/J9P6uYTzKPqTb4AjkjiBep655XWluTVlKPR8LYSN IIou7z2pG7UwzXy/6tgMEnvu2oiF2g+4jyDOGcs7Lo9DN8Z3olwi3F4sQop3Eul368nY trWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+biE6TvgDw2/zb84+2m23DalLJodvkeqokPIck4A2MQ=; b=m31ZreKJSDjIARp1U2tkATEwqeLZo7g24duhRNMcQc/l5wdI97OKY7GHipTDC424i4 h2D7zdXqvZZzvZQaniflV0IwIxVCQA5R9OJCAUclgAW/knEgAEPoPC2w+Gy8eMP6p1cy 1oHsIdnSXt4XqDBvA+FsQzLHaZlQ60wxk5aOzB7DizwML1kcnjy0YlkO1LII+E1w62dX WLEugemKxUa4yNSdKqssJ6SlbXmUJB/9DnXCzcegsHHSVqWFaqTRFF2LvvP+LpuoRtpw zm5PDv235ZY2SZNFqgdPefulpyNNt/TGmC+V9poCbooS1VqVBWjnSTVLVCl0HAxULs2p U7jQ== X-Gm-Message-State: AHQUAuZNb+160AU8lxS63PYpAzMl1TcmRnJqp7xgNKr6hXxzAV/f1R20 F896gaHQVuSpCZB/zYPfs+HPuzz1wBf9Lw== X-Received: by 2002:a50:b646:: with SMTP id c6mr3645931ede.149.1551294773726; Wed, 27 Feb 2019 11:12:53 -0800 (PST) Received: from localhost (c-573670d5.07-21-73746f28.bbcust.telenor.se. [213.112.54.87]) by smtp.gmail.com with ESMTPSA id f5sm1304791ejf.25.2019.02.27.11.12.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 11:12:52 -0800 (PST) From: Anders Roxell To: bartekgola@gmail.com Cc: linux-gpio@vger.kernel.org, Anders Roxell Subject: [libgpiod] [PATCH v2] install-tests to bindir test Date: Wed, 27 Feb 2019 20:12:47 +0100 Message-Id: <20190227191247.11582-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When building the tests it assumes that the build artifacts is located in the srcdir. Rework so we install tests into the bindir, if that is done we look for the binaries in bin dir and not in the src dir. Signed-off-by: Anders Roxell --- configure.ac | 7 +++++++ libgpiod.pc.in | 1 + tests/Makefile.am | 11 ++++++++++- tests/gpiod-test.c | 10 +++++----- 4 files changed, 23 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/configure.ac b/configure.ac index 1253cb14749c..6455af5331e0 100644 --- a/configure.ac +++ b/configure.ac @@ -107,6 +107,13 @@ then AC_CHECK_HEADERS([sys/signalfd.h], [], [HEADER_NOT_FOUND_TOOLS([sys/signalfd.h])]) fi +AC_ARG_ENABLE([install-tests], + [AC_HELP_STRING([--enable-install-tests], + [enable install tests [default=no]])], + [if test "x$enableval" = xyes; then with_install_tests=true; with_tests=true; fi;], + [with_install_tests=false]) +AM_CONDITIONAL([WITH_INSTALL_TESTS], [test "x$with_install_tests" = xtrue]) + AC_ARG_ENABLE([tests], [AC_HELP_STRING([--enable-tests], [enable libgpiod tests [default=no]])], diff --git a/libgpiod.pc.in b/libgpiod.pc.in index 48ff11392ae4..96d1111324e5 100644 --- a/libgpiod.pc.in +++ b/libgpiod.pc.in @@ -1,5 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +bindir=@bindir@ libdir=@libdir@ includedir=@includedir@ diff --git a/tests/Makefile.am b/tests/Makefile.am index a9319a725f0d..7eaf28529ceb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,10 +9,19 @@ AM_CFLAGS = -I$(top_srcdir)/include/ -include $(top_builddir)/config.h AM_CFLAGS += -Wall -Wextra -g $(KMOD_CFLAGS) $(UDEV_CFLAGS) AM_LDFLAGS = -pthread -LDADD = ../src/lib/libgpiod.la $(KMOD_LIBS) $(UDEV_LIBS) +LDADD = $(top_builddir)/src/lib/libgpiod.la $(KMOD_LIBS) $(UDEV_LIBS) check_PROGRAMS = gpiod-test +if WITH_INSTALL_TESTS +bin_PROGRAMS = $(check_PROGRAMS) +GPIOD_TOOLS_PATH=@prefix@/bin +else +noinst_PROGRAMS = $(check_PROGRAMS) +GPIOD_TOOLS_PATH="./../../src/tools" +endif +AM_CFLAGS += -DGPIOD_TOOLS_PATH=$(GPIOD_TOOLS_PATH)/ + gpiod_test_SOURCES = gpiod-test.c \ gpiod-test.h \ tests-chip.c \ diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index c67314332e41..2ed229e61b45 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -30,6 +30,9 @@ #define NORETURN __attribute__((noreturn)) #define MALLOC __attribute__((malloc)) +#define xstr(s) str(s) +#define str(s) #s + static const unsigned int min_kern_major = 4; static const unsigned int min_kern_minor = 16; static const unsigned int min_kern_release = 0; @@ -449,12 +452,9 @@ static void gpiotool_proc_dup_fds(int in_fd, int out_fd, int err_fd) static char *gpiotool_proc_get_path(const char *tool) { - char *path, *progpath, *progdir; + char *path; - progpath = xstrdup(program_invocation_name); - progdir = dirname(progpath); - path = xappend(NULL, "%s/../../src/tools/%s", progdir, tool); - free(progpath); + path = xappend(NULL, "%s%s", xstr(GPIOD_TOOLS_PATH), tool); return path; }