From patchwork Tue Feb 26 15:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 159223 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3350672jad; Tue, 26 Feb 2019 07:37:03 -0800 (PST) X-Google-Smtp-Source: AHgI3IY0fCdlT4sm4x9hSKuHCzcU2MdlXGPDlcP62yebIThMDqFFlS71qVZSmP3dyQfpaiFwzo6s X-Received: by 2002:a63:5720:: with SMTP id l32mr17795859pgb.268.1551195423756; Tue, 26 Feb 2019 07:37:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551195423; cv=none; d=google.com; s=arc-20160816; b=pvoMet6Fvb5IwdSgVIu/QjsZ2bjHpWpoHa9CzBrt/lMPs+X92NtQ8hje08J0DTLup0 LThuKz8m6r94jr59CL5hDUybiYuNnPsbML3zf9CdWCySia+hQYDKwJM1FGHCVM5m++Pb hTua0ZQaLJiCWXFwaayZrGCVBcn1Ya7l8niq2V3TKngcpYApALUD7kvGMa6mxTcP07ik z8vnnQJ54XA/GYGyj0x8ivMK3ZYaI45jqc64BsWZfDK2PoFa9uYRYUUQc3p84NYh4QiO msT51e4KgHwaPJq4rQJMv0czBT12ihkGC1YMLVvlIQmhMRj7mxoFSaJA66YiJUDkANQ/ aIzA== 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=kBx5/HpiLxb9lCAzZvGld0DmOzlrBiTf2m/kuZnKHQ4=; b=O2rXhg6mwqd3G0Y80X92WNWRjZabUKvuDL5YIn0tqMlBK7jfKwaZfjnJIJZvSh1CiI gmSFtt6GcVabnrKI6oKi1P+LImBeUmp9OoVEla6ZppDNHYKZ/GuMgdtfBDQAr61WUs4+ m/YNK0b3pj47AKiVKtk5nsSFNwMoxp2SFlittTC4WLBBIDdGlotlFKz+BoQNEX3Em/58 727fREZBHU+tPXon5TDqqozk8HfZHFOQ3/F04vYDt78/oud1sRZuGjDuaN9zUpL7m/QL PS7lS3s+KA/N/n4qxKHD6fSaoN2YtUFzMR5XbZc9BToGkX36Yct9n3xCue+jozMx391O ldHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdj7kn2W; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x80si13000470pfe.224.2019.02.26.07.37.03; Tue, 26 Feb 2019 07:37:03 -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=pdj7kn2W; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726553AbfBZPhC (ORCPT + 5 others); Tue, 26 Feb 2019 10:37:02 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44824 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbfBZPhC (ORCPT ); Tue, 26 Feb 2019 10:37:02 -0500 Received: by mail-lf1-f65.google.com with SMTP id g2so9929466lfh.11 for ; Tue, 26 Feb 2019 07:37:01 -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=kBx5/HpiLxb9lCAzZvGld0DmOzlrBiTf2m/kuZnKHQ4=; b=pdj7kn2WU/2ymJwVSVzIwZefgWyhfd0ZWzwYPJKpb31v+7sy8o6pWnV3/gN+Lf4jMT i9VNWu3o+xpCrEC7ZDQp8PPj1oYBQhrFBWcWks4ubEyKw10dSUFtmLLkDw5Kd7e+8HAw qBFM82NSJzwgpbqqrJ+rA2JOTC+2MsMoI05sRzl1Uwrf9y+tINo7a7RmVVE+91zLhGon h7OKCEeIYAgLrYKdeF0Nd4NquetxQMHR/Zc6DMQJfmeHK1g9ISuSdJYQawiXhHsnTl64 /9K0bcnlZcnIbrcqPtAnYZcD+Fd5TlFsriMR+K3ncvSOCM4VejYXyaBKeiIm8kXLDmBw h7FA== 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=kBx5/HpiLxb9lCAzZvGld0DmOzlrBiTf2m/kuZnKHQ4=; b=L85uPAFIfEMRaIHPxAvs+/7LE7weaUNSYxNeg8xL9jCK2qzsJCotinQkYHKnLU0TKN MZ6LqxYGvOLMEZnqk6t2NrTgxbw+Z9xzk0aZ89zRax+LHyzTKpLM86Bzs9u2Tt4s0KlY hJZtA501mfqUHZDHxx0u0krkRrIhf0TmFTEo/6G9cYCHSt2b+FA5N48xQ2e7Jq2+Wjqa w/VlpoPI+2HrRjDE6ZQKzsLAp+dqF1kTAMDTu7E8JmApcybM8WDX1B8KC8R42D9fmVDa 0SWl1LlYRV8J5edlW95iL3HEJ07I03uRq7n5+aKZ2mcDjgcUPrV6JJwJxd3PivfqLo11 elFA== X-Gm-Message-State: AHQUAub2DMADgqx1jQN05/opQTeCCQ23p6aBLzu8O77ZwOxHEA6mU11Z i+oeKnmtw4ey6LLot4hbhqBUMw== X-Received: by 2002:ac2:4243:: with SMTP id m3mr13642989lfl.5.1551195420301; Tue, 26 Feb 2019 07:37:00 -0800 (PST) Received: from localhost (c-573670d5.07-21-73746f28.bbcust.telenor.se. [213.112.54.87]) by smtp.gmail.com with ESMTPSA id o67sm3270630lfe.40.2019.02.26.07.36.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 07:36:59 -0800 (PST) From: Anders Roxell To: bartekgola@gmail.com Cc: linux-gpio@vger.kernel.org, Anders Roxell Subject: [libgpiod] [PATCH] install-tests to bindir test Date: Tue, 26 Feb 2019 16:36:30 +0100 Message-Id: <20190226153630.20803-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 | 15 +++++++++++++++ libgpiod.pc.in | 1 + tests/Makefile.am | 11 ++++++++++- tests/gpiod-test.c | 10 +++++----- 4 files changed, 31 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/configure.ac b/configure.ac index 49bedf4d2410..b93feab6ebcc 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,21 @@ 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 + else + with_install_tests=false + 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..e4b14274081f 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) +TOOLS_PATH=@prefix@/bin +else +noinst_PROGRAMS = $(check_PROGRAMS) +TOOLS_PATH="./../../src/tools" +endif +AM_CFLAGS += -DTOOLS_PATH=$(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 92d6b7875fef..fda9d9d50fb5 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(TOOLS_PATH), tool); return path; }