[PATCH v3] install-tests to bindir test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <anders.roxell@xxxxxxxxxx>
---
 configure.ac       |  7 +++++++
 libgpiod.pc.in     |  1 +
 tests/Makefile.am  |  9 +++++++++
 tests/gpiod-test.c | 10 +++++-----
 4 files changed, 22 insertions(+), 5 deletions(-)

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;
 }
-- 
2.20.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux