Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
f09700da
Unverified
Commit
f09700da
authored
Oct 30, 2019
by
Christian Brauner
Committed by
GitHub
Oct 30, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3175 from ralt/pr/execute-attach-exit-code-tests
tests: add tests making sure the exit code is appropriate.
parents
202d2ca3
188f8836
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
Makefile.am
src/tests/Makefile.am
+1
-0
lxc-test-exit-code
src/tests/lxc-test-exit-code
+53
-0
No files found.
src/tests/Makefile.am
View file @
f09700da
...
@@ -108,6 +108,7 @@ bin_SCRIPTS += lxc-test-automount \
...
@@ -108,6 +108,7 @@ bin_SCRIPTS += lxc-test-automount \
lxc-test-autostart
\
lxc-test-autostart
\
lxc-test-cloneconfig
\
lxc-test-cloneconfig
\
lxc-test-createconfig
\
lxc-test-createconfig
\
lxc-test-exit-code
\
lxc-test-no-new-privs
\
lxc-test-no-new-privs
\
lxc-test-rootfs
lxc-test-rootfs
...
...
src/tests/lxc-test-exit-code
0 → 100755
View file @
f09700da
#!/bin/sh
# lxc: linux Container library
# Authors:
# Florian Margaine <florian@platform.sh>
#
# This is a test script for the lxc-attach and lxc-execute
# programs. It tests whether the exit code is not 0 when a script
# fails to execute.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# 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
FAIL
()
{
echo
-n
"Failed "
>
&2
echo
"
$*
"
>
&2
lxc-destroy
-n
busy
-f
exit
1
}
# Create a container
lxc-create
-t
busybox
-n
busy
||
FAIL
"creating busybox container"
# Run lxc-execute to make sure it fails when the command fails, and
# succeed when the command succeeds.
lxc-execute
-n
busy
--
sh
-c
'exit 1'
&&
FAIL
"should be failing"
||
true
lxc-execute
-n
busy
--
sh
-c
'exit 0'
||
FAIL
"should be succeeding"
# Now, start the container and wait for it to be in running state.
lxc-start
-n
busy
-d
||
FAIL
"starting busybox container"
lxc-wait
-n
busy
-s
RUNNING
||
FAIL
"waiting for busybox container to run"
# And run the same tests on lxc-attach.
lxc-attach
-n
busy
--
sh
-c
'exit 1'
&&
FAIL
"should be failing"
||
true
lxc-attach
-n
busy
--
sh
-c
'exit 0'
||
FAIL
"should be succeeding"
lxc-destroy
-n
busy
-f
exit
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment