On (21/10/15 09:20), Sumit Bose wrote: >On Tue, Oct 20, 2015 at 10:15:06PM +0200, Jakub Hrozek wrote: >> On Tue, Oct 20, 2015 at 05:17:49PM +0300, Nikolai Kondrashov wrote: >> > Hi Jakub, >> > >> > On 10/19/2015 09:43 PM, Jakub Hrozek wrote: >> > >I'm working on pam_sss.so tests[1] and I ran into a problem that I don't >> > >know how to solve best. >> > > >> > >tl;dr, I would like to set different environment variables for different >> > >tests in order to set up cwrap libraries differently per-test. >> > > >> > >I can't use setenv() in the test itself, because that's too late, I need >> > >the variables to be set when __attribute__(constructor) is run, so >> > >normally >> > >at program startup, when the libraries are loaded. >> > > >> > >With cmake it's easy, use set(TEST_ENVIRONMENT). But with autotools, I >> > >only found two ways: >> > > - TESTS_ENVIRONMENT - this is fine, but it's per Makefile.am. So I >> > > would have to split the tests more, into pam_wrapper tests that >> > > also >> > > require uid_wrapper, tests that only require pam_wrapper, ... >> > > - LOG_COMPILER - this allows to run a wrapper script before a test >> > > that receives the test name as argv. So this is pretty much what I >> > > want except this is a feature new to automake 1.12, which would >> > > rule out both RHEL-6 and Ubuntu Trusty (which is used by Travis) >> > > >> > >So I'm really leaning towards creating a src/tests/cwrap/pwrap/Makefile.am >> > >and src/tests/cwrap/pwrap_root/Makefile.am. The downside of multiple >> > >Makefile.am files is that there is some code duplication and the build >> > >takes longer. But I still think there is enough interest (from us and from >> > >our users) to support git master on old platforms. I can file a ticket to >> > >remove this and use LOG_COMPILER when we drop support for RHEL-6 and old >> > >Ubuntu versions... >> > > >> > >If you disagree, please reply, otherwise I'm going to send a patch with >> > >per-test Makefile... >> > >> > Ah, so these are unit tests, not integration tests? >> >> I'm working on both, actually. The first part is more or less an >> isolated unit test of all the options that pam_sss supports. The reason >> is that some options (2FA, smart cards, ...) are not really easily >> testable without a mock back end, at the moment we only have openldap in >> the integration tests. >> >> The next step I will start right after I finish this part is integration >> tests that will exercise LDAP authentication, password change and maybe >> authorisation if there's time left. >> >> > >> > I'm not sure I understood everything right, sorry, but perhaps you can find >> > something useful in contrib/ci/run, contrib/ci/make-check-wrap and >> > contrib/ci/valgrind-condense where CI matches and handles particular tests >> > differently regardless of whether LOG_COMPILER is supported or not. Ping >> > me >> > if you need help figuring out what's going on there. >> >> So more or less I wanted to have two tests and wanted to run the first >> as (simplified): >> PAM_WRAPPER=1 ./src/tests/cwrap/pam_sss_wrapper-tests >> and other as: >> PAM_WRAPPER=1 UID_WRAPPER=1 ./src/tests/cwrap/pam_sss_wrapper-root--tests >> >> but it occured to me that I can always start with UID wrapper, just drop >> privileges if I need a strictly non-root test. It's a bit of a hack :-) >> but since the root is fake anyway, I think it's acceptable. >> >> > >> > Granted this is from outside the build, but maybe you can concoct something >> > from inside as well. >> >> I think this might work as well; thank you! > >I had a short look at libtool. Since we use it during 'make check' not >the actual binaries are called but a libtool generated wrapper script. >If it would be possible to set the environment variables here they would >be visible for the binary at startup. > >Libtool has the concept of 'executable wrappers' to support cygwin and >similar environments but I didn't found an easy way to add own wrapper >here. > >Adding the variables directly in the generated wrapper scripts would be >quite a hack. But maybe it would be possible if we add our own version >of build/ltmain.sh where the wrapper scripts are generated in >func_emit_wrapper()? > >So, I'm afraid this is not a direct answer to your question but maybe >libtool might be useful here. >
I read this thread after are came up with almost similar solution as Sumit. With a small difference. I did not decide to inject env variables to generated script but I decided to write yet another wrapper on top of and set env variable there. Here is a POC version. What do you think about such solution. LS
>From 79e8f0e1cdd09ca791755bb03c1e8f38b8078dc3 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Fri, 23 Oct 2015 13:06:00 +0200 Subject: [PATCH] temp --- src/tests/cwrap/Makefile.am | 8 ++++++-- src/tests/cwrap/become_user-tests.sh | 5 +++++ src/tests/cwrap/responder_common-tests.sh | 5 +++++ src/tests/cwrap/server-tests.sh | 5 +++++ src/tests/cwrap/usertools-tests.sh | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 src/tests/cwrap/become_user-tests.sh create mode 100755 src/tests/cwrap/responder_common-tests.sh create mode 100755 src/tests/cwrap/server-tests.sh create mode 100755 src/tests/cwrap/usertools-tests.sh diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am index 34b5d8beabf6b444cac9757a4e8023c4cc4fb610..28bbb1eda13acec5c718faba38581dcac1a6d824 100644 --- a/src/tests/cwrap/Makefile.am +++ b/src/tests/cwrap/Makefile.am @@ -14,7 +14,6 @@ AM_CPPFLAGS = \ TESTS_ENVIRONMENT = \ CWRAP_TEST_SRCDIR=$(abs_srcdir) \ - . $(srcdir)/cwrap_test_setup.sh; \ $(AUX_TESTS_ENVIRONMENT) \ $(NULL) @@ -55,7 +54,12 @@ endif # HAVE_UID_WRAPPER endif # HAVE_NSS_WRAPPER endif # HAVE_CMOCKA -TESTS = $(check_PROGRAMS) +TESTS = \ + become_user-tests.sh \ + server-tests.sh \ + usertools-tests.sh \ + responder_common-tests.sh \ + $(NULL) become_user_tests_SOURCES = \ test_become_user.c \ diff --git a/src/tests/cwrap/become_user-tests.sh b/src/tests/cwrap/become_user-tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..fdd610cdc1af81fe1cbb3c0d0ad5f8bc431e8ad3 --- /dev/null +++ b/src/tests/cwrap/become_user-tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. $CWRAP_TEST_SRCDIR/cwrap_test_setup.sh + +exec ./become_user-tests "$@" diff --git a/src/tests/cwrap/responder_common-tests.sh b/src/tests/cwrap/responder_common-tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..5bdecbab86fb62178b27dca3d100f8181ea42986 --- /dev/null +++ b/src/tests/cwrap/responder_common-tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. $CWRAP_TEST_SRCDIR/cwrap_test_setup.sh + +exec ./responder_common-tests "$@" diff --git a/src/tests/cwrap/server-tests.sh b/src/tests/cwrap/server-tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..248f17cf1834417450715f7a86e1118566bc303c --- /dev/null +++ b/src/tests/cwrap/server-tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. $CWRAP_TEST_SRCDIR/cwrap_test_setup.sh + +exec ./server-tests "$@" diff --git a/src/tests/cwrap/usertools-tests.sh b/src/tests/cwrap/usertools-tests.sh new file mode 100755 index 0000000000000000000000000000000000000000..4479663c99edd92afdcf7c62815db4eeb2beec96 --- /dev/null +++ b/src/tests/cwrap/usertools-tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +. $CWRAP_TEST_SRCDIR/cwrap_test_setup.sh + +exec ./usertools-tests "$@" -- 2.5.0
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/sssd-devel