ehlo,

It's a side effect of my effort to write integration tests for memory cache.
Attached patch simplify troubleshooting of sssd in cwrap environment.

LS
>From 1d270fee496651b8560790a98d444d86fecbc8ae Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lsleb...@redhat.com>
Date: Thu, 23 Jul 2015 12:32:29 +0200
Subject: [PATCH] CI: Set env variable for all tabs in screen

Previously, only one tab had configured all environment variables
and current working directory was set to source directory.
It's better to open shell in "chroot" directory for troubleshooting purposes.

This patch also open pre-defined tabs with useful
directories with sssd cache, sssd log files, "chroot" directory
---
 src/tests/intg/.config/screenrc | 23 +++++++++++++++++++++++
 src/tests/intg/util.py          | 20 ++++++++++++++------
 2 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 src/tests/intg/.config/screenrc

diff --git a/src/tests/intg/.config/screenrc b/src/tests/intg/.config/screenrc
new file mode 100644
index 
0000000000000000000000000000000000000000..fe1e4248a630d15dd4b4ba15dddbae4a1d4ce565
--- /dev/null
+++ b/src/tests/intg/.config/screenrc
@@ -0,0 +1,23 @@
+autodetach on
+defscrollback 1024
+startup_message off
+nethack on
+vbell off
+vbell_msg "   -- Bell,Bell!! --   "
+multiuser off
+msgminwait 0
+msgwait 10
+
+defutf8 on
+defencoding utf8
+
+hardstatus string '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f 
%t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=b C}[ %d/%m %c ]%{W}'
+hardstatus alwayslastline
+
+setenv LD_LIBRARY_PATH "$_LD_LIBRARY_PATH"
+setenv LD_PRELOAD "$_LD_PRELOAD"
+
+screen -t / 0 sh -c 'cd $ROOT_DIR; exec "${SHELL:-sh}"'
+screen -t /etc 1 sh -c 'cd $ROOT_DIR/etc; exec "${SHELL:-sh}"'
+screen -t sssd_cache 3 sh -c 'cd $ROOT_DIR/var/lib/sss/db; exec "${SHELL:-sh}"'
+screen -t sssd_log 2 sh -c 'cd $ROOT_DIR/var/log/sssd; exec "${SHELL:-sh}"'
diff --git a/src/tests/intg/util.py b/src/tests/intg/util.py
index 
5dd92b220bab0a83ee2a9f1aec3ae30d99b0623a..639b5ca691309d2d6610f202e0edc92c988bc6d5
 100644
--- a/src/tests/intg/util.py
+++ b/src/tests/intg/util.py
@@ -20,6 +20,7 @@
 import re
 import os
 import subprocess
+import config
 
 UNINDENT_RE = re.compile("^ +", re.MULTILINE)
 
@@ -40,13 +41,20 @@ def run_shell():
         Execute an interactive shell under "screen", preserving environment.
         For use as a breakpoint for debugging.
     """
+    my_env = os.environ.copy()
+    my_env["ROOT_DIR"] = config.PREFIX
+
+    # screen filter out LD_* evniroment varibles.
+    # Back-up them and set them later in screenrc
+    my_env["_LD_LIBRARY_PATH"] = os.getenv("LD_LIBRARY_PATH", "")
+    my_env["_LD_PRELOAD"] = os.getenv("LD_PRELOAD", "")
+
     subprocess.call([
-        "screen", "-D", "-m", "bash", "-c",
-        "PATH='" + os.getenv("PATH", "") + "' " +
-        "LD_LIBRARY_PATH='" + os.getenv("LD_LIBRARY_PATH", "") + "' " +
-        "LD_PRELOAD='" + os.getenv("LD_PRELOAD", "") + "' " +
-        "bash -i"
-    ])
+        "screen", "-DAm", "-S", "sssd_cwrap_session", "-c",
+        ".config/screenrc"],
+        env=my_env
+    )
+
 
 def first_dir(*args):
     """Return first argument that points to an existing directory."""
-- 
2.4.3

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to