From patchwork Thu Feb 28 15:35:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 159398 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp784054jad; Thu, 28 Feb 2019 07:35:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IabvLA1qttYYIFPNBkPNubcaUzigPyTs5hCCXnHnJtLQhhcqfIlB84gzv+2+Q86Ecol9hvW X-Received: by 2002:a63:c80c:: with SMTP id z12mr5158247pgg.397.1551368145233; Thu, 28 Feb 2019 07:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551368145; cv=none; d=google.com; s=arc-20160816; b=A6zl4qc4n2mlhFCQfLuV6AQ0qEMkqvSBv93vHN4icMFeQD5hchyGNdCFxrg4KOl4+h u9k+Jy7Ywdcz6JeejX3k+ahUtPu+eR591aB6EOdNQt2ThpTXg/+r7GDangE2Zce3bXw4 PyAErX6P2xUgKwCX1wJ3SiD1Ngd/nUSdcIvE7bl1ljehXOkLMtR9koRnHIyMc6xATELh /kIKIb4aJZLTbWv96HqfDUfwbnDAfhvfp8MEyF8r0yYRTrD0A1FTvulpFFSAHm5woU5w 6elTHAR9/267aq6DDbPVaAicYQ5Zs5fkek5JbzjgtvtCuTUxU7z1hBexaQ7IcXfxolMj DMnA== 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=L4ES8amDnV+Lkh/pwbiZyl+TYzMdCxw6P2qJaZyTaWc=; b=iA3kBk5G987aP3ngRj0aqFQu/xbF3wd8n3TGEYaCJh3WOCg2yD7Wsv9oQ2Yegk9Ydf h5GeHj+nBgVrjY5QKfrUMHHCRLdgHZZj50+cpRGfxsK5lEymOobkjGZMaL0kclusBYyG nLa99Eh41ig3FI9i6TZAO2ANEAi/drN/fFXJE8cnaf3pJFstVz4nIlorh5LiZqEH2SjK 5avjRVX+waZKuVq3CeofbhkDTvvUqivKSDZK7XWxlTYlek0Br0Gwk1M1QR8ORNSTCcYn 7Gm+/0kPjEazJ3nukWHUcf5mNbCD9FdTlyQMsENsMVGH3AP8c866GorxMjjuOKtHDFzF N8rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WmqFwK6W; 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 w191si8505374pgd.15.2019.02.28.07.35.44; Thu, 28 Feb 2019 07:35:45 -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=WmqFwK6W; 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 S1733075AbfB1Pfo (ORCPT + 5 others); Thu, 28 Feb 2019 10:35:44 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:47070 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727789AbfB1Pfo (ORCPT ); Thu, 28 Feb 2019 10:35:44 -0500 Received: by mail-lj1-f194.google.com with SMTP id v16so17496822ljg.13 for ; Thu, 28 Feb 2019 07:35:42 -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=L4ES8amDnV+Lkh/pwbiZyl+TYzMdCxw6P2qJaZyTaWc=; b=WmqFwK6Wu9CWW6dve7TciVhyx52c5dqeukUyP/h9xOPpfyoDtuzD6hAExT+2QAkHf9 o28ctB/NXLFeO1O3+mIt9wvuM54f5Isx4KZkjW+y87KoXRB5sCfdDjDVeuTly8JLG9hH vXixyMay1nnVRU/qnLqnItpT8ZKvsHkuYkgWK+IHUgz2AoRipMcueASV/n4USiuB6au+ MqmILxO1SaWt058l9YiZsba3NZc50vcPefLjoaoGL7HjuxyaA1difC1Xx6dBk/Z5WsYS 7LFqONlMtksQkJ47FRwlf/P5FixEC/gvkF04bj/iIZ/g2RsMG/XvdpXeUkkghrElThGA dx8Q== 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=L4ES8amDnV+Lkh/pwbiZyl+TYzMdCxw6P2qJaZyTaWc=; b=ib2KMqSpaHVa0zYQ9QIL8Xy5yt3repqmHvXCc0yBvkRXAbZfDV63R9se4xTKo6HFSe lZjXkAuFIrdHKAWDyFxZEQk32oy3M28lu6EJZZXvAzhHm7GFPBBc6tHTTPThuKMMRaqa 1j2DZLmeNP0LmYxKrPFW15wmXrTzUCufkrzKw7BL2Tac6G4Sumb38n0RtRsKNPD9kJwP slq0oTy6OSRjjS0md+kk0d/9WRccr1E25GX14R3K95XW4aKKoe4krBRM5gxHLp6+p9oZ 4BnT+Ss5W5znwp41DeYlTiTLopNhdnDLVQRTen8VPFsg/O9fFl6YIyfQOltejTlNXCpC ktIQ== X-Gm-Message-State: AHQUAuaM/bzrwqDQBb0fx1gZBUAwaismY+14RY0QecBOy/JLY5vU3J2/ 1F+EfQuZUlVWcDZQZs4B9OqX4Q== X-Received: by 2002:a2e:90cd:: with SMTP id o13mr5119579ljg.153.1551368141805; Thu, 28 Feb 2019 07:35:41 -0800 (PST) Received: from localhost (c-573670d5.07-21-73746f28.bbcust.telenor.se. [213.112.54.87]) by smtp.gmail.com with ESMTPSA id l72sm4703172lfg.75.2019.02.28.07.35.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 07:35:41 -0800 (PST) From: Anders Roxell To: bartekgola@gmail.com Cc: linux-gpio@vger.kernel.org, Anders Roxell Subject: [PATCH v3] install-tests to bindir test Date: Thu, 28 Feb 2019 16:35:33 +0100 Message-Id: <20190228153534.1786-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 | 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..bf03ac7aa27a 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="./../../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; }