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
de2c6314
Unverified
Commit
de2c6314
authored
Aug 28, 2018
by
Stéphane Graber
Committed by
GitHub
Aug 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2576 from brauner/2018-08-28/command_init_id
commands: always return -1 on lxc_cmd_get_init_pid() err
parents
7ee4b4b8
e8cd1208
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
104 deletions
+177
-104
commands.c
src/lxc/commands.c
+7
-2
Makefile.am
src/tests/Makefile.am
+124
-102
basic.c
src/tests/basic.c
+46
-0
No files found.
src/lxc/commands.c
View file @
de2c6314
...
@@ -376,12 +376,17 @@ pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath)
...
@@ -376,12 +376,17 @@ pid_t lxc_cmd_get_init_pid(const char *name, const char *lxcpath)
{
{
int
ret
,
stopped
;
int
ret
,
stopped
;
struct
lxc_cmd_rr
cmd
=
{
struct
lxc_cmd_rr
cmd
=
{
.
req
=
{
.
cmd
=
LXC_CMD_GET_INIT_PID
},
.
req
=
{
.
cmd
=
LXC_CMD_GET_INIT_PID
},
.
rsp
=
{
.
data
=
INT_TO_PTR
((
int
){
-
1
})
}
};
};
ret
=
lxc_cmd
(
name
,
&
cmd
,
&
stopped
,
lxcpath
,
NULL
);
ret
=
lxc_cmd
(
name
,
&
cmd
,
&
stopped
,
lxcpath
,
NULL
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
-
1
;
return
PTR_TO_INT
(
cmd
.
rsp
.
data
);
return
PTR_TO_INT
(
cmd
.
rsp
.
data
);
}
}
...
...
src/tests/Makefile.am
View file @
de2c6314
...
@@ -2,51 +2,52 @@ if ENABLE_TESTS
...
@@ -2,51 +2,52 @@ if ENABLE_TESTS
LDADD
=
../lxc/liblxc.la
LDADD
=
../lxc/liblxc.la
lxc_test_containertests_SOURCES
=
containertests.c
lxc_test_api_reboot_SOURCES
=
api_reboot.c
lxc_test_locktests_SOURCES
=
locktests.c
lxc_test_apparmor_SOURCES
=
aa.c
lxc_test_startone_SOURCES
=
startone.c
lxc_test_attach_SOURCES
=
attach.c
lxc_test_destroytest_SOURCES
=
destroytest.c
lxc_test_basic_SOURCES
=
basic.c
lxc_test_saveconfig_SOURCES
=
saveconfig.c
lxc_test_createtest_SOURCES
=
createtest.c
lxc_test_shutdowntest_SOURCES
=
shutdowntest.c
lxc_test_get_item_SOURCES
=
get_item.c
lxc_test_getkeys_SOURCES
=
getkeys.c
lxc_test_lxcpath_SOURCES
=
lxcpath.c
lxc_test_cgpath_SOURCES
=
cgpath.c
lxc_test_cgpath_SOURCES
=
cgpath.c
lxc_test_clonetest_SOURCES
=
clonetest.c
lxc_test_clonetest_SOURCES
=
clonetest.c
lxc_test_concurrent_SOURCES
=
concurrent.c
lxc_test_config_jump_table_SOURCES
=
config_jump_table.c lxctest.h
lxc_test_console_SOURCES
=
console.c
lxc_test_console_SOURCES
=
console.c
lxc_test_console_log_SOURCES
=
console_log.c lxctest.h
lxc_test_console_log_SOURCES
=
console_log.c lxctest.h
lxc_test_snapshot_SOURCES
=
snapshot.c
lxc_test_containertests_SOURCES
=
containertests.c
lxc_test_concurrent_SOURCES
=
concurrent.c
lxc_test_createtest_SOURCES
=
createtest.c
lxc_test_may_control_SOURCES
=
may_control.c
lxc_test_criu_check_feature_SOURCES
=
criu_check_feature.c lxctest.h
lxc_test_reboot_SOURCES
=
reboot.c
lxc_test_destroytest_SOURCES
=
destroytest.c
lxc_test_api_reboot_SOURCES
=
api_reboot.c
lxc_test_list_SOURCES
=
list.c
lxc_test_attach_SOURCES
=
attach.c
lxc_test_device_add_remove_SOURCES
=
device_add_remove.c
lxc_test_device_add_remove_SOURCES
=
device_add_remove.c
lxc_test_apparmor_SOURCES
=
aa.c
lxc_test_getkeys_SOURCES
=
getkeys.c
lxc_test_utils_SOURCES
=
lxc-test-utils.c lxctest.h
lxc_test_get_item_SOURCES
=
get_item.c
lxc_test_list_SOURCES
=
list.c
lxc_test_locktests_SOURCES
=
locktests.c
lxc_test_lxcpath_SOURCES
=
lxcpath.c
lxc_test_may_control_SOURCES
=
may_control.c
lxc_test_mount_injection_SOURCES
=
mount_injection.c lxctest.h
lxc_test_parse_config_file_SOURCES
=
parse_config_file.c lxctest.h
lxc_test_parse_config_file_SOURCES
=
parse_config_file.c lxctest.h
lxc_test_config_jump_table_SOURCES
=
config_jump_table.c lxctest.h
lxc_test_raw_clone_SOURCES
=
lxc_raw_clone.c lxctest.h
lxc_test_reboot_SOURCES
=
reboot.c
lxc_test_saveconfig_SOURCES
=
saveconfig.c
lxc_test_share_ns_SOURCES
=
share_ns.c lxctest.h
lxc_test_shortlived_SOURCES
=
shortlived.c
lxc_test_shortlived_SOURCES
=
shortlived.c
lxc_test_shutdowntest_SOURCES
=
shutdowntest.c
lxc_test_snapshot_SOURCES
=
snapshot.c
lxc_test_startone_SOURCES
=
startone.c
lxc_test_state_server_SOURCES
=
state_server.c lxctest.h
lxc_test_state_server_SOURCES
=
state_server.c lxctest.h
lxc_test_share_ns_SOURCES
=
share_ns.c lxctest.h
lxc_test_utils_SOURCES
=
lxc-test-utils.c lxctest.h
lxc_test_criu_check_feature_SOURCES
=
criu_check_feature.c lxctest.h
lxc_test_raw_clone_SOURCES
=
lxc_raw_clone.c lxctest.h
lxc_test_mount_injection_SOURCES
=
mount_injection.c lxctest.h
AM_CFLAGS
=
-DLXCROOTFSMOUNT
=
\"
$(LXCROOTFSMOUNT)
\"
\
AM_CFLAGS
=
-DLXCROOTFSMOUNT
=
\"
$(LXCROOTFSMOUNT)
\"
\
-DLXCPATH
=
\"
$(LXCPATH)
\"
\
-DLXCPATH
=
\"
$(LXCPATH)
\"
\
-DLXC_GLOBAL_CONF
=
\"
$(LXC_GLOBAL_CONF)
\"
\
-DLXC_GLOBAL_CONF
=
\"
$(LXC_GLOBAL_CONF)
\"
\
-DLXCINITDIR
=
\"
$(LXCINITDIR)
\"
\
-DLXCINITDIR
=
\"
$(LXCINITDIR)
\"
\
-DLXC_DEFAULT_CONFIG
=
\"
$(LXC_DEFAULT_CONFIG)
\"
\
-DLXC_DEFAULT_CONFIG
=
\"
$(LXC_DEFAULT_CONFIG)
\"
\
-DRUNTIME_PATH
=
\"
$(RUNTIME_PATH)
\"
\
-DRUNTIME_PATH
=
\"
$(RUNTIME_PATH)
\"
\
-I
$(top_srcdir)
/src
\
-I
$(top_srcdir)
/src
\
-I
$(top_srcdir)
/src/lxc
\
-I
$(top_srcdir)
/src/lxc
\
-I
$(top_srcdir)
/src/lxc/bdev
\
-I
$(top_srcdir)
/src/lxc/bdev
\
-I
$(top_srcdir)
/src/lxc/cgroups
\
-I
$(top_srcdir)
/src/lxc/cgroups
\
-I
$(top_srcdir)
/src/lxc/tools
\
-I
$(top_srcdir)
/src/lxc/tools
\
-pthread
-pthread
if
ENABLE_APPARMOR
if
ENABLE_APPARMOR
AM_CFLAGS
+=
-DHAVE_APPARMOR
AM_CFLAGS
+=
-DHAVE_APPARMOR
...
@@ -56,84 +57,105 @@ if ENABLE_SELINUX
...
@@ -56,84 +57,105 @@ if ENABLE_SELINUX
AM_CFLAGS
+=
-DHAVE_SELINUX
AM_CFLAGS
+=
-DHAVE_SELINUX
endif
endif
bin_PROGRAMS
=
lxc-test-containertests lxc-test-locktests lxc-test-startone
\
bin_PROGRAMS
=
lxc-test-api-reboot
\
lxc-test-destroytest lxc-test-saveconfig lxc-test-createtest
\
lxc-test-apparmor
\
lxc-test-shutdowntest lxc-test-get_item lxc-test-getkeys lxc-test-lxcpath
\
lxc-test-attach
\
lxc-test-cgpath lxc-test-clonetest lxc-test-console lxc-test-console-log
\
lxc-test-basic
\
lxc-test-snapshot lxc-test-concurrent lxc-test-may-control
\
lxc-test-cgpath
\
lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove
\
lxc-test-clonetest
\
lxc-test-apparmor lxc-test-utils lxc-test-parse-config-file
\
lxc-test-concurrent
\
lxc-test-config-jump-table lxc-test-shortlived
\
lxc-test-config-jump-table
\
lxc-test-api-reboot lxc-test-state-server lxc-test-share-ns
\
lxc-test-console
\
lxc-test-criu-check-feature lxc-test-raw-clone
\
lxc-test-console-log
\
lxc-test-mount-injection
lxc-test-containertests
\
lxc-test-createtest
\
lxc-test-criu-check-feature
\
lxc-test-destroytest
\
lxc-test-device-add-remove
\
lxc-test-getkeys
\
lxc-test-get_item
\
lxc-test-list
\
lxc-test-locktests
\
lxc-test-lxcpath
\
lxc-test-may-control
\
lxc-test-mount-injection
\
lxc-test-parse-config-file
\
lxc-test-raw-clone
\
lxc-test-reboot
\
lxc-test-saveconfig
\
lxc-test-share-ns
\
lxc-test-shortlived
\
lxc-test-shutdowntest
\
lxc-test-snapshot
\
lxc-test-startone
\
lxc-test-state-server
\
lxc-test-utils
bin_SCRIPTS
=
bin_SCRIPTS
=
if
ENABLE_TOOLS
if
ENABLE_TOOLS
bin_SCRIPTS
+=
lxc-test-automount
\
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-no-new-privs
\
lxc-test-no-new-privs
\
lxc-test-rootfs
lxc-test-rootfs
if
DISTRO_UBUNTU
if
DISTRO_UBUNTU
bin_SCRIPTS
+=
\
bin_SCRIPTS
+=
lxc-test-lxc-attach
\
lxc-test-lxc-attach
\
lxc-test-apparmor-mount
\
lxc-test-apparmor-mount
\
lxc-test-apparmor-generated
\
lxc-test-apparmor-generated
\
lxc-test-checkpoint-restore
\
lxc-test-checkpoint-restore
\
lxc-test-snapdeps
\
lxc-test-snapdeps
\
lxc-test-symlink
\
lxc-test-symlink
\
lxc-test-unpriv
\
lxc-test-unpriv
\
lxc-test-usernic
lxc-test-usernic
endif
endif
endif
endif
endif
endif
EXTRA_DIST
=
\
EXTRA_DIST
=
basic.c
\
cgpath.c
\
cgpath.c
\
clonetest.c
\
clonetest.c
\
concurrent.c
\
concurrent.c
\
config_jump_table.c
\
config_jump_table.c
\
console.c
\
console.c
\
console_log.c
\
console_log.c
\
containertests.c
\
containertests.c
\
createtest.c
\
createtest.c
\
criu_check_feature.c
\
criu_check_feature.c
\
destroytest.c
\
destroytest.c
\
device_add_remove.c
\
device_add_remove.c
\
get_item.c
\
get_item.c
\
getkeys.c
\
getkeys.c
\
list.c
\
list.c
\
locktests.c
\
locktests.c
\
lxcpath.c
\
lxcpath.c
\
lxc_raw_clone.c
\
lxc_raw_clone.c
\
lxc-test-lxc-attach
\
lxc-test-lxc-attach
\
lxc-test-automount
\
lxc-test-automount
\
lxc-test-rootfs
\
lxc-test-rootfs
\
lxc-test-autostart
\
lxc-test-autostart
\
lxc-test-apparmor-mount
\
lxc-test-apparmor-mount
\
lxc-test-apparmor-generated
\
lxc-test-apparmor-generated
\
lxc-test-checkpoint-restore
\
lxc-test-checkpoint-restore
\
lxc-test-cloneconfig
\
lxc-test-cloneconfig
\
lxc-test-createconfig
\
lxc-test-createconfig
\
lxc-test-no-new-privs
\
lxc-test-no-new-privs
\
lxc-test-snapdeps
\
lxc-test-snapdeps
\
lxc-test-symlink
\
lxc-test-symlink
\
lxc-test-unpriv
\
lxc-test-unpriv
\
lxc-test-utils.c
\
lxc-test-utils.c
\
may_control.c
\
may_control.c
\
mount_injection.c
\
mount_injection.c
\
parse_config_file.c
\
parse_config_file.c
\
saveconfig.c
\
saveconfig.c
\
shortlived.c
\
shortlived.c
\
shutdowntest.c
\
shutdowntest.c
\
snapshot.c
\
snapshot.c
\
startone.c
\
startone.c
\
state_server.c
\
state_server.c
\
share_ns.c
share_ns.c
clean-local
:
clean-local
:
rm
-f
lxc-test-utils-
*
rm
-f
lxc-test-utils-
*
...
...
src/tests/basic.c
0 → 100644
View file @
de2c6314
/* liblxcapi
*
* Copyright © 2018 Christian Brauner <christian.brauner@ubuntu.com>.
* Copyright © 2018 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <lxc/lxccontainer.h>
#include "lxctest.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
;
struct
lxc_container
*
c
;
c
=
lxc_container_new
(
"init-pid"
,
NULL
);
if
(
!
c
)
exit
(
EXIT_FAILURE
);
ret
=
c
->
init_pid
(
c
);
c
->
destroy
(
c
);
lxc_container_put
(
c
);
/* Return value needs to be -1. Any other negative error code is to be
* considered invalid.
*/
if
(
ret
!=
-
1
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_SUCCESS
);
}
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