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
45794802
Commit
45794802
authored
Feb 11, 2014
by
Stéphane Graber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Add lxc-test-autostart
Signed-off-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
Acked-by:
Serge E. Hallyn
<
serge.hallyn@ubuntu.com
>
parent
a7ef8753
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
12 deletions
+91
-12
Makefile.am
src/tests/Makefile.am
+13
-12
lxc-test-autostart
src/tests/lxc-test-autostart
+78
-0
No files found.
src/tests/Makefile.am
View file @
45794802
...
@@ -46,33 +46,34 @@ bin_PROGRAMS = lxc-test-containertests lxc-test-locktests lxc-test-startone \
...
@@ -46,33 +46,34 @@ bin_PROGRAMS = lxc-test-containertests lxc-test-locktests lxc-test-startone \
lxc-test-snapshot lxc-test-concurrent lxc-test-may-control
\
lxc-test-snapshot lxc-test-concurrent lxc-test-may-control
\
lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove
lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove
bin_SCRIPTS
=
lxc-test-
usernic
bin_SCRIPTS
=
lxc-test-
autostart
if
DISTRO_UBUNTU
if
DISTRO_UBUNTU
bin_SCRIPTS
+=
lxc-test-ubuntu lxc-test-unpriv
bin_SCRIPTS
+=
lxc-test-u
sernic lxc-test-u
buntu lxc-test-unpriv
endif
endif
endif
endif
EXTRA_DIST
=
\
EXTRA_DIST
=
\
cgpath.c
\
cgpath.c
\
clonetest.c
\
concurrent.c
\
console.c
\
containertests.c
\
containertests.c
\
createtest.c
\
createtest.c
\
destroytest.c
\
destroytest.c
\
device_add_remove.c
\
get_item.c
\
get_item.c
\
getkeys.c
\
getkeys.c
\
list.c
locktests.c
\
locktests.c
\
lxcpath.c
\
lxcpath.c
\
lxc-test-autostart
\
lxc-test-ubuntu
\
lxc-test-unpriv
\
lxc-test-usernic
\
may_control.c
\
saveconfig.c
\
saveconfig.c
\
shutdowntest.c
\
shutdowntest.c
\
clonetest.c
\
startone.c
\
console.c
\
lxc-test-usernic
\
snapshot.c
\
snapshot.c
\
concurrent.c
\
startone.c
\
may_control.c
\
lxc-test-ubuntu
\
lxc-test-unpriv
\
device_add_remove.c
\
list.c
src/tests/lxc-test-autostart
0 → 100755
View file @
45794802
#!/bin/sh
# lxc: linux Container library
# Authors:
# Stéphane Graber <stgraber@ubuntu.com>
#
# This is a test script for lxc-autostart
# 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
DONE
=
0
cleanup
()
{
lxc-destroy
-n
$CONTAINER_NAME
>
/dev/null 2>&1
||
true
if
[
$DONE
-eq
0
]
;
then
echo
"FAIL"
exit
1
fi
echo
"PASS"
}
trap
cleanup EXIT HUP INT TERM
set
-eu
# Create a container
CONTAINER_NAME
=
lxc-test-auto
lxc-create
-t
download
-n
$CONTAINER_NAME
--
-d
ubuntu
-r
trusty
-a
i386
CONTAINER_PATH
=
$(
dirname
$(
lxc-info
-n
$CONTAINER_NAME
-c
lxc.rootfs
-H
))
cp
$CONTAINER_PATH
/config
$CONTAINER_PATH
/config.bak
# Ensure it's not in lxc-autostart
lxc-autostart
-L
|
grep
-q
$CONTAINER_NAME
&&
\
(
echo
"Container shouldn't be auto-started"
&&
exit
1
)
# Mark it as auto-started and re-check
echo
"lxc.start.auto = 1"
>>
$CONTAINER_PATH
/config
lxc-autostart
-L
|
grep
-q
$CONTAINER_NAME
||
\
(
echo
"Container should be auto-started"
&&
exit
1
)
# Put it in a test group and set a delay
echo
"lxc.group = lxc-auto-test"
>>
$CONTAINER_PATH
/config
echo
"lxc.start.delay = 5"
>>
$CONTAINER_PATH
/config
# Check that everything looks good
if
[
"
$(
lxc-autostart
-L
-g
lxc-auto-test |
grep
$CONTAINER_NAME
)
"
!=
"
$CONTAINER_NAME
5"
]
;
then
echo
"Invalid autostart setting"
&&
exit
1
fi
# Start it
lxc-autostart
-g
lxc-auto-test
lxc-wait
-n
$CONTAINER_NAME
-t
5
-s
RUNNING
||
(
echo
"Container didn't start"
&&
exit
1
)
# Restart it
lxc-autostart
-g
lxc-auto-test
-r
lxc-wait
-n
$CONTAINER_NAME
-t
5
-s
RUNNING
||
(
echo
"Container didn't restart"
&&
exit
1
)
# Shut it down
lxc-autostart
-g
lxc-auto-test
-s
lxc-wait
-n
$CONTAINER_NAME
-t
60
-s
STOPPED
||
(
echo
"Container didn't stop"
&&
exit
1
)
# Kill it
lxc-autostart
-g
lxc-auto-test
-k
lxc-wait
-n
$CONTAINER_NAME
-t
60
-s
STOPPED
||
(
echo
"Container didn't die"
&&
exit
1
)
DONE
=
1
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