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
a4f24357
Unverified
Commit
a4f24357
authored
Feb 02, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add logging to device_add_remove
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ea299bfc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
1 deletion
+86
-1
Makefile.am
src/tests/Makefile.am
+48
-1
device_add_remove.c
src/tests/device_add_remove.c
+38
-0
No files found.
src/tests/Makefile.am
View file @
a4f24357
...
...
@@ -275,7 +275,54 @@ lxc_test_createtest_SOURCES = createtest.c
lxc_test_criu_check_feature_SOURCES
=
criu_check_feature.c lxctest.h
lxc_test_cve_2019_5736_SOURCES
=
cve-2019-5736.c lxctest.h
lxc_test_destroytest_SOURCES
=
destroytest.c
lxc_test_device_add_remove_SOURCES
=
device_add_remove.c
lxc_test_device_add_remove_SOURCES
=
device_add_remove.c
\
../lxc/af_unix.c ../lxc/af_unix.h
\
../lxc/caps.c ../lxc/caps.h
\
../lxc/cgroups/cgfsng.c
\
../lxc/cgroups/cgroup.c ../lxc/cgroups/cgroup.h
\
../lxc/cgroups/cgroup2_devices.c ../lxc/cgroups/cgroup2_devices.h
\
../lxc/cgroups/cgroup_utils.c ../lxc/cgroups/cgroup_utils.h
\
../lxc/commands.c ../lxc/commands.h
\
../lxc/commands_utils.c ../lxc/commands_utils.h
\
../lxc/conf.c ../lxc/conf.h
\
../lxc/confile.c ../lxc/confile.h
\
../lxc/confile_utils.c ../lxc/confile_utils.h
\
../lxc/error.c ../lxc/error.h
\
../lxc/file_utils.c ../lxc/file_utils.h
\
../include/netns_ifaddrs.c ../include/netns_ifaddrs.h
\
../lxc/initutils.c ../lxc/initutils.h
\
../lxc/log.c ../lxc/log.h
\
../lxc/lxclock.c ../lxc/lxclock.h
\
../lxc/mainloop.c ../lxc/mainloop.h
\
../lxc/monitor.c ../lxc/monitor.h
\
../lxc/namespace.c ../lxc/namespace.h
\
../lxc/network.c ../lxc/network.h
\
../lxc/nl.c ../lxc/nl.h
\
../lxc/parse.c ../lxc/parse.h
\
../lxc/process_utils.c ../lxc/process_utils.h
\
../lxc/ringbuf.c ../lxc/ringbuf.h
\
../lxc/start.c ../lxc/start.h
\
../lxc/state.c ../lxc/state.h
\
../lxc/storage/btrfs.c ../lxc/storage/btrfs.h
\
../lxc/storage/dir.c ../lxc/storage/dir.h
\
../lxc/storage/loop.c ../lxc/storage/loop.h
\
../lxc/storage/lvm.c ../lxc/storage/lvm.h
\
../lxc/storage/nbd.c ../lxc/storage/nbd.h
\
../lxc/storage/overlay.c ../lxc/storage/overlay.h
\
../lxc/storage/rbd.c ../lxc/storage/rbd.h
\
../lxc/storage/rsync.c ../lxc/storage/rsync.h
\
../lxc/storage/storage.c ../lxc/storage/storage.h
\
../lxc/storage/storage_utils.c ../lxc/storage/storage_utils.h
\
../lxc/storage/zfs.c ../lxc/storage/zfs.h
\
../lxc/sync.c ../lxc/sync.h
\
../lxc/string_utils.c ../lxc/string_utils.h
\
../lxc/terminal.c ../lxc/terminal.h
\
../lxc/utils.c ../lxc/utils.h
\
../lxc/uuid.c ../lxc/uuid.h
\
$(LSM_SOURCES)
if
ENABLE_SECCOMP
lxc_test_device_add_remove_SOURCES
+=
../lxc/seccomp.c ../lxc/lxcseccomp.h
endif
lxc_test_getkeys_SOURCES
=
getkeys.c
lxc_test_get_item_SOURCES
=
get_item.c
lxc_test_list_SOURCES
=
list.c
...
...
src/tests/device_add_remove.c
View file @
a4f24357
...
...
@@ -20,14 +20,41 @@
#include <stdlib.h>
#include <lxc/lxccontainer.h>
#include "lxctest.h"
#include "memory_utils.h"
#include "utils.h"
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#endif
#define NAME "device_add_remove_test"
#define DEVICE "/dev/loop-control"
int
main
(
int
argc
,
char
*
argv
[])
{
__do_close
int
fd_log
=
-
EBADF
;
int
ret
=
1
;
struct
lxc_log
log
=
{};
char
template
[
sizeof
(
P_tmpdir
"/attach_XXXXXX"
)];
struct
lxc_container
*
c
;
(
void
)
strlcpy
(
template
,
P_tmpdir
"/attach_XXXXXX"
,
sizeof
(
template
));
fd_log
=
lxc_make_tmpfile
(
template
,
false
);
if
(
fd_log
<
0
)
{
lxc_error
(
"Failed to create temporary log file for container %s
\n
"
,
NAME
);
exit
(
EXIT_FAILURE
);
}
log
.
name
=
NAME
;
log
.
file
=
template
;
log
.
level
=
"TRACE"
;
log
.
prefix
=
"device_add_remove"
;
log
.
quiet
=
false
;
log
.
lxcpath
=
NULL
;
if
(
lxc_log_init
(
&
log
))
goto
out
;
c
=
lxc_container_new
(
NAME
,
NULL
);
if
(
!
c
)
{
fprintf
(
stderr
,
"Unable to instantiate container (%s)...
\n
"
,
NAME
);
...
...
@@ -69,6 +96,17 @@ int main(int argc, char *argv[])
ret
=
0
;
out:
if
(
ret
!=
0
)
{
char
buf
[
4096
];
ssize_t
buflen
;
while
((
buflen
=
read
(
fd_log
,
buf
,
1024
))
>
0
)
{
buflen
=
write
(
STDERR_FILENO
,
buf
,
buflen
);
if
(
buflen
<=
0
)
break
;
}
}
(
void
)
unlink
(
template
);
lxc_container_put
(
c
);
return
ret
;
}
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