Message ID | 20190227191247.11582-1-anders.roxell@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | [libgpiod,v2] install-tests to bindir test | expand |
śr., 27 lut 2019 o 20:12 Anders Roxell <anders.roxell@linaro.org> napisał(a): > > 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@linaro.org> > --- > configure.ac | 7 +++++++ > libgpiod.pc.in | 1 + > tests/Makefile.am | 11 ++++++++++- > tests/gpiod-test.c | 10 +++++----- > 4 files changed, 23 insertions(+), 6 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..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) > Hi Anders, sorry, I missed that the last time, but could you split this patch into two commits? This change, while correct, is logically separate from the test installation. With that I'll apply these changes. Thanks in advance, Bartosz > 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 >
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; }
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@linaro.org> --- 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