025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# lxc-test-ubuntu: some tests of ubuntu-specific features of lxc.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# Some features of lxc - networking and LSM configuration for instance -
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# are generally configured by the distro packages. This program
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# tests the Ubuntu configuration.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# These require the ubuntu lxc package to be installed.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# General lxc functionality testing does not belong here.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# This program is free software; you can redistribute it and/or
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# modify it under the terms of the GNU Lesser General Public
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# License as published by the Free Software Foundation; either
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# version 2.1 of the License, or (at your option) any later version.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# This library is distributed in the hope that it will be useful,
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# but WITHOUT ANY WARRANTY; without even the implied warranty of
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# Lesser General Public License for more details.
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# You should have received a copy of the GNU Lesser General Public
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# License along with this library; if not, write to the Free Software
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn# Only run on a normally configured ubuntu lxc system
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn echo "lxcbr0 is not configured."
c26adb82536952e27b05d237049b938d697e8ed9Stéphane Graber echo "ERROR: Must run as root."
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn # need a different name for each container so dnsmasq doesn't
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn # mess us up with its caching
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn lxc-create -t $template -n $name || FAIL "creating $template container"
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn lxc-start -n $name -d || FAIL "starting $template container"
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn lxc-wait -n $name -s RUNNING || FAIL "waiting for $template container to run"
1d1774b1ac705364c8eb7959a554935d8c134230Bogdan Purcareata lxcip=$(lxc-info -i -n $name -H | head -n 1)
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn [ -z "$lxcip" ] || break
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn [ -n "$lxcip" ] || FAIL "to start networking in $template container"
45997a79453b22713f06b6216767bd446703e439Stéphane Graber ping6 -c 1 $lxcip || FAIL "to ping $template container"
45997a79453b22713f06b6216767bd446703e439Stéphane Graber ping -c 1 $lxcip || FAIL "to ping $template container"
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn # Check apparmor
f58236fd702f8979a68a74e17c7a81f37899edf7Serge Hallyn if [ "$aa" != "lxc-container-default-with-nesting (enforce)" -a \
f58236fd702f8979a68a74e17c7a81f37899edf7Serge Hallyn "$aa" != "lxc-container-default-cgns (enforce)" -a \
f58236fd702f8979a68a74e17c7a81f37899edf7Serge Hallyn "$aa" != "lxc-container-default (enforce)" ]; then
025f59ab98217b7e9caf6d3ac7e910853d95f621Serge Hallyn FAIL " to correctly set apparmor profile (profile is \"$aa\")"