tests: add logging to lxc-test-unpriv

parent 7369e6bf
...@@ -66,11 +66,12 @@ which newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; ...@@ -66,11 +66,12 @@ which newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2;
DONE=0 DONE=0
KNOWN_RELEASES="precise trusty xenial yakkety zesty" KNOWN_RELEASES="precise trusty xenial yakkety zesty"
UNPRIV_LOG=$(mktemp --dry-run)
cleanup() { cleanup() {
cd / cd /
run_cmd lxc-stop -n c2 -k || true run_cmd lxc-stop -n c2 -k -l trace -o "${UNPRIV_LOG}" || true
run_cmd lxc-stop -n c1 -k || true run_cmd lxc-stop -n c1 -k -l trace -o "${UNPRIV_LOG}" || true
pkill -u $(id -u $TUSER) -9 || true pkill -u $(id -u $TUSER) -9 || true
sed -i '/lxcunpriv/d' /run/lxc/nics /etc/lxc/lxc-usernet sed -i '/lxcunpriv/d' /run/lxc/nics /etc/lxc/lxc-usernet
...@@ -81,6 +82,8 @@ cleanup() { ...@@ -81,6 +82,8 @@ cleanup() {
deluser $TUSER deluser $TUSER
if [ $DONE -eq 0 ]; then if [ $DONE -eq 0 ]; then
cat "${UNPRIV_LOG}"
rm -f "${UNPRIV_LOG}" || true
echo "FAIL" echo "FAIL"
exit 1 exit 1
fi fi
...@@ -173,45 +176,45 @@ run_cmd mkdir -p $HDIR/.cache/lxc ...@@ -173,45 +176,45 @@ run_cmd mkdir -p $HDIR/.cache/lxc
cp -R /var/cache/lxc/download $HDIR/.cache/lxc && \ cp -R /var/cache/lxc/download $HDIR/.cache/lxc && \
chown -R $TUSER: $HDIR/.cache/lxc chown -R $TUSER: $HDIR/.cache/lxc
run_cmd lxc-create -t download -n c1 -- -d ubuntu -r $release -a $ARCH run_cmd lxc-create -t download -n c1 -l trace -o "${UNPRIV_LOG}" -- -d ubuntu -r $release -a $ARCH
# Make sure we can start it - twice # Make sure we can start it - twice
for count in `seq 1 2`; do for count in `seq 1 2`; do
run_cmd lxc-start -n c1 -d run_cmd lxc-start -n c1 -d -l trace -o "${UNPRIV_LOG}"
p1=$(run_cmd lxc-info -n c1 -p -H) p1=$(run_cmd lxc-info -n c1 -p -H -l trace -o "${UNPRIV_LOG}")
[ "$p1" != "-1" ] || { echo "Failed to start container c1 (run $count)"; false; } [ "$p1" != "-1" ] || { echo "Failed to start container c1 (run $count)"; false; }
run_cmd lxc-info -n c1 run_cmd lxc-info -n c1 -l trace -o "${UNPRIV_LOG}"
run_cmd lxc-attach -n c1 -- /bin/true run_cmd lxc-attach -n c1 -l trace -o "${UNPRIV_LOG}" -- /bin/true
run_cmd lxc-stop -n c1 -k run_cmd lxc-stop -n c1 -k -l trace -o "${UNPRIV_LOG}"
done done
run_cmd lxc-copy -s -n c1 -N c2 run_cmd lxc-copy -s -n c1 -N c2 -l trace -o "${UNPRIV_LOG}"
run_cmd lxc-start -n c2 -d run_cmd lxc-start -n c2 -d -l trace -o "${UNPRIV_LOG}"
p1=$(run_cmd lxc-info -n c2 -p -H) p1=$(run_cmd lxc-info -n c2 -p -H -l trace -o "${UNPRIV_LOG}")
[ "$p1" != "-1" ] || { echo "Failed to start container c2"; false; } [ "$p1" != "-1" ] || { echo "Failed to start container c2"; false; }
run_cmd lxc-stop -n c2 -k run_cmd lxc-stop -n c2 -k -l trace -o "${UNPRIV_LOG}"
if which cgm >/dev/null 2>&1; then if which cgm >/dev/null 2>&1; then
echo "Testing containers under different cgroups per subsystem" echo "Testing containers under different cgroups per subsystem"
run_cmd cgm create freezer x1/x2 run_cmd cgm create freezer x1/x2
cgm movepid freezer x1 $$ cgm movepid freezer x1 $$
run_cmd lxc-start -n c1 -d run_cmd lxc-start -n c1 -d -l trace -o "${UNPRIV_LOG}"
p1=$(run_cmd lxc-info -n c1 -p -H) p1=$(run_cmd lxc-info -n c1 -p -H -l trace -o "${UNPRIV_LOG}")
[ "$p1" != "-1" ] || { echo "Failed to start container c1"; false; } [ "$p1" != "-1" ] || { echo "Failed to start container c1"; false; }
run_cmd lxc-info -n c1 run_cmd lxc-info -n c1 -l trace -o "${UNPRIV_LOG}"
run_cmd lxc-attach -n c1 -- /bin/true run_cmd lxc-attach -n c1 -l trace -o "${UNPRIV_LOG}" -- /bin/true
run_cmd lxc-cgroup -n c1 freezer.state run_cmd lxc-cgroup -n c1 freezer.state -l trace -o "${UNPRIV_LOG}"
echo "Testing lxc-attach and lxc-cgroup from different cgroup" echo "Testing lxc-attach and lxc-cgroup from different cgroup"
cgm movepid freezer x2 $$ cgm movepid freezer x2 $$
run_cmd lxc-attach -n c1 -- /bin/true run_cmd lxc-attach -n c1 -l trace -o "${UNPRIV_LOG}" -- /bin/true
run_cmd lxc-cgroup -n c1 freezer.state run_cmd lxc-cgroup -n c1 -l trace -o "${UNPRIV_LOG}" freezer.state
run_cmd lxc-cgroup -n c1 memory.limit_in_bytes run_cmd lxc-cgroup -n c1 -l trace -o "${UNPRIV_LOG}" memory.limit_in_bytes
fi fi
DONE=1 DONE=1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment