On Fri, 1 Mar 2019 at 11:02, Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > czw., 28 lut 2019 o 16:35 Anders Roxell <anders.roxell@xxxxxxxxxx> 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@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 > > > > Hi Anders, > > I now tested it and it turns out that test cases for gpio-tools run > from the top source directory don't work anymore because the path to > executables is no longer figured out dynamically depending on > program_invocation_name. You may need to add a config switch that - > depending on --enable-install-tests either does what we're doing now, > or uses your approach. Hi Bartosz, I'm unsure what you are seeing, I'm sure I'm missing something. I do this: $ ./autogen.sh --enable-install-tests --enable-tests --enable-tools --prefix=$(pwd)/../install-libgpiod $ make $ make install $ ./tests/gpiod-test [INFO] libgpiod test suite [INFO] 117 tests registered [INFO] checking the linux kernel version [INFO] kernel release is v4.18.0 - ok to run tests [INFO] checking gpio-mockup availability [FATAL] the gpio-mockup module does not exist in the system or is built into the kernel [INFO] cleaning up $ cd ../install-libgpiod $ ./bin/gpiod-test [INFO] libgpiod test suite [INFO] 117 tests registered [INFO] checking the linux kernel version [INFO] kernel release is v4.18.0 - ok to run tests [INFO] checking gpio-mockup availability [FATAL] the gpio-mockup module does not exist in the system or is built into the kernel [INFO] cleaning up Cheers, Anders