]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/lxc-test-exit-code
3 # lxc: linux Container library
6 # Florian Margaine <florian@platform.sh>
8 # This is a test script for the lxc-attach and lxc-execute
9 # programs. It tests whether the exit code is not 0 when a script
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Lesser General Public
14 # License as published by the Free Software Foundation; either
15 # version 2.1 of the License, or (at your option) any later version.
17 # This library is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # Lesser General Public License for more details.
22 # You should have received a copy of the GNU Lesser General Public
23 # License along with this library; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 lxc-destroy
-n busy
-f
36 lxc-create
-t busybox
-n busy || FAIL
"creating busybox container"
38 # Run lxc-execute to make sure it fails when the command fails, and
39 # succeed when the command succeeds.
40 lxc-execute
-n busy
-- sh
-c 'exit 1' && FAIL
"should be failing" || true
41 lxc-execute
-n busy
-- sh
-c 'exit 0' || FAIL
"should be succeeding"
43 # Now, start the container and wait for it to be in running state.
44 lxc-start
-n busy
-d || FAIL
"starting busybox container"
45 lxc-wait
-n busy
-s RUNNING || FAIL
"waiting for busybox container to run"
47 # And run the same tests on lxc-attach.
48 lxc-attach
-n busy
-- sh
-c 'exit 1' && FAIL
"should be failing" || true
49 lxc-attach
-n busy
-- sh
-c 'exit 0' || FAIL
"should be succeeding"
51 lxc-destroy
-n busy
-f