[lxc-devel] [lxc/master] 2016 04 08/lxc attach simplify and log
hallyn on Github
lxc-bot at linuxcontainers.org
Sun Apr 10 03:11:44 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 331 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160410/1065a6fd/attachment.bin>
-------------- next part --------------
From 366101ee3815e966ce8054df916f9cadd5132cf6 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at mailbox.org>
Date: Fri, 8 Apr 2016 22:43:51 +0200
Subject: [PATCH 1/2] add minimal test whether pty logging works
Signed-off-by: Christian Brauner <christian.brauner at mailbox.org>
---
src/tests/lxc-test-lxc-attach | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/tests/lxc-test-lxc-attach b/src/tests/lxc-test-lxc-attach
index 664b028..2bd2205 100755
--- a/src/tests/lxc-test-lxc-attach
+++ b/src/tests/lxc-test-lxc-attach
@@ -60,7 +60,7 @@ lxc-wait -n busy -s RUNNING || FAIL "waiting for busybox container to run"
# stderr --> attached to pty
attach=$(lxc-attach -n busy -- hostname || FAIL " to allocate or setup pty")
if [ "$attach" != "busy" ]; then
- FAIL " simple attach"
+ FAIL " lxc-attach -n busy -- hostname"
fi
# stdin --> /dev/null
@@ -161,6 +161,8 @@ if [ "$outcontent" != "OUT" ] || [ "$errcontent" != "ERR" ]; then
FAIL " lxc-attach -n busy -- sh -c 'echo OUT; echo ERR >&2' > $out 2> $err"
fi
+rm -f $out $err
+
# stdin --> $in
# stdout --> $out
# stderr --> $err
@@ -175,6 +177,17 @@ if [ "$outcontent" != "busy" ] || [ -z "$errcontent" ]; then
FAIL " echo 'hostname; rm' | lxc-attach -n busy > $out 2> $err"
fi
+rm -f $out $err
+
+# Test whether logging pty output to a file works.
+trap "rm -f /tmp/ptylog" EXIT INT QUIT PIPE
+lxc-attach -n busy -L /tmp/ptylog -- hostname || FAIL " to allocate or setup pty"
+if [ ! -s /tmp/ptylog ]; then
+ FAIL " lxc-attach -n busy -L /tmp/ptylog -- hostname"
+fi
+
+rm -f /tmp/ptylog
+
lxc-destroy -n busy -f
exit 0
From d1452c13a78e1f823d47e65b98e0b007096f429b Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn at ubuntu.com>
Date: Sat, 9 Apr 2016 21:57:34 -0500
Subject: [PATCH 2/2] debug
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
src/tests/lxc-test-lxc-attach | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/tests/lxc-test-lxc-attach b/src/tests/lxc-test-lxc-attach
index 2bd2205..61203df 100755
--- a/src/tests/lxc-test-lxc-attach
+++ b/src/tests/lxc-test-lxc-attach
@@ -22,7 +22,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-set -e
+set -ex
# NOTE:
# lxc-attach allocates a pty on the host and attaches any standard file
@@ -182,6 +182,9 @@ rm -f $out $err
# Test whether logging pty output to a file works.
trap "rm -f /tmp/ptylog" EXIT INT QUIT PIPE
lxc-attach -n busy -L /tmp/ptylog -- hostname || FAIL " to allocate or setup pty"
+echo "Result: $?"
+echo "/tmp contents:"
+ls -l /tmp
if [ ! -s /tmp/ptylog ]; then
FAIL " lxc-attach -n busy -L /tmp/ptylog -- hostname"
fi
More information about the lxc-devel
mailing list