From patchwork Mon Mar 11 22:20:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 160049 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12430047jad; Mon, 11 Mar 2019 15:20:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH1nzH24ojC/orHthrEo86rbQVqqrIftYDKQ3PDcHAvcg8fwPhHgnAAAtSZKRMgJYawk/2 X-Received: by 2002:a63:8b43:: with SMTP id j64mr14642396pge.332.1552342843272; Mon, 11 Mar 2019 15:20:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552342843; cv=none; d=google.com; s=arc-20160816; b=SIcpMvuQryGfwdvCqsGQe72LNGzcL4ogVj2AvZCFBZXdJjOlzrR0EEl4T7h8BT6p5e tLLWW8ehshdznTOG5fJLXho5PmeuueLPcDK2fVxMcN7ZEO6UmH7MhhxmPeQip5CtOdXh i8/rVNCB3exdEPkHiWbO91RAW54XsIsh4YcN6gNbHQIFDZUj7fSNsEDLb45ElOD+qMre GBmcFG/wISNL7Ar19mNEEfzmMhxdFA5lqXQ3+4f8WILEM8oecWGpPOfUNu+bVJXDyViM MqiB2lD3oaAPcriuQPUZ0XR7yMOuZI50KETW96ZvSTCxzrxs8RwXTWfaTNjVc9HLszTy ntKg== 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=spqdtR+9uOf9Z8qyLaG08JD+fSrPBvAoRA/MoN+PApc=; b=WX/DcaeJw0TZxTgkZ2EUR5rp+ZCG8CtKO45hTVSoeb5xEws7NjmycknR86b2VNbiTW 7GoHj/HQowoSraKpCzhgCCg2gSpMV1/nY1rKvcb5nag+FuqWRpSGwaZiCrPS1Fus2HfQ gE++SaTKf51kZm36ipQCwhLm+GIOiwq+tcZsA32NzOsv6KGHRAf+kl/sgUgaoM1ltBOn Ss9p9C4kyT9XFqbdhJ/e7kmL8sVZu0s6hX+Jw2xQyFSdovo1bIn/cEenBJwgFnEytX9e 0/3K+R46B399rnTtC+EKz4SrzNNOweDnRRyN2mOpF9q53hLqJs40u4szqnAyLNW4aMOQ 96yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UjoTRzp4; 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 u16si6421874plq.398.2019.03.11.15.20.42; Mon, 11 Mar 2019 15:20:43 -0700 (PDT) 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=UjoTRzp4; 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 S1727548AbfCKWUm (ORCPT + 5 others); Mon, 11 Mar 2019 18:20:42 -0400 Received: from mail-lf1-f42.google.com ([209.85.167.42]:41034 "EHLO mail-lf1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbfCKWUm (ORCPT ); Mon, 11 Mar 2019 18:20:42 -0400 Received: by mail-lf1-f42.google.com with SMTP id 10so502805lfr.8 for ; Mon, 11 Mar 2019 15:20:41 -0700 (PDT) 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=spqdtR+9uOf9Z8qyLaG08JD+fSrPBvAoRA/MoN+PApc=; b=UjoTRzp4t0PLh74rVwnV+1uYjnAgz+O8ZfL4rGdvcZz7TDRagfsymUPiIGpgM84EXP Gg0eiqtOhUomGz5loOQd8/zsPYR8YkSLIwLX5trf1zpxiXLQTRthjid/F4ifbc5TdH0e 6+Y44Yp4+FpjVHOy+bxXzo4EIug7SE3RotYlbNMqMcvIsJf56KVUe/Dwc2V32vcK8w3+ EeXV/73GLAjlx+NJ0Jc0TQ0JLdEJEefAANwDlbnjOh1Wb+951FSTuWsL0PUrEvXSYdfm A67LfSYTxDabl/0x6mTi4aMiGwBS+BWdAcyqxM28Y9/dX6W+e2NERGqrP6HgCqO/Gdwg MhEA== 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=spqdtR+9uOf9Z8qyLaG08JD+fSrPBvAoRA/MoN+PApc=; b=IisS1qYLCZVUYrtaXR5L3uuFj62h/ZzY8szfijaXiKqRCHXoZ9s2zP0yhTX5MjADAj 2l1Y6hU899/xpJs/YTyukf+3nkJAcs84J7aTFoO11FUmS9IVXAbhnC3F0ePWaMgtHauf pcJuW1v0egh76wnAzn1t0dStDEAX+y6mkBv/oC67wGF2p1JnzJaYmk/YXwDeBNaMSonx Pmur2mUDVk1bvpSU+dh2SQqiwYzDPrvhToH+qjehrx47trMQ5sOGvLXgsPZcKRf3wIlP xXpwpKHEG3njIdc9HNXN7XUkjucF88eTjxa+Tawxtn6XSfcVDO21GBfw04aywMCB0PjL mj+A== X-Gm-Message-State: APjAAAUtxHlaWPfABjhj/NxXGB/MTefYr2BxaGPWSZKjomC51d4NL73y 3bxJgrKKbjprZius3lqhhX1Jrw== X-Received: by 2002:a19:7114:: with SMTP id m20mr6607916lfc.63.1552342840011; Mon, 11 Mar 2019 15:20:40 -0700 (PDT) Received: from localhost (c-573670d5.07-21-73746f28.bbcust.telenor.se. [213.112.54.87]) by smtp.gmail.com with ESMTPSA id m1sm1411797lfh.36.2019.03.11.15.20.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 15:20:39 -0700 (PDT) From: Anders Roxell To: bartekgola@gmail.com Cc: linux-gpio@vger.kernel.org, Anders Roxell Subject: [libgpiod] [PATCH v4] install-tests to bindir test Date: Mon, 11 Mar 2019 23:20:06 +0100 Message-Id: <20190311222007.15311-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 --- changes since v3: If you don't enable install-tests you can now run the ./tests/gpiod-test which you couldn't before. configure.ac | 7 +++++++ libgpiod.pc.in | 1 + tests/Makefile.am | 9 +++++++++ tests/gpiod-test.c | 10 +++++----- 4 files changed, 22 insertions(+), 5 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..80631b4f528d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,6 +13,15 @@ LDADD = ../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="$(abs_top_builddir)/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; }