Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
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
zhul
criu
Commits
441b9b9e
Commit
441b9b9e
authored
May 08, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: Stupid test for task-in-cgroup
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
203c2914
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
zdtm.sh
test/zdtm.sh
+2
-0
Makefile
test/zdtm/live/static/Makefile
+1
-0
cgroup00.c
test/zdtm/live/static/cgroup00.c
+94
-0
No files found.
test/zdtm.sh
View file @
441b9b9e
...
...
@@ -137,6 +137,7 @@ transition/ipc
ns/static/tun
static/netns-nf
static/netns
static/cgroup00
"
TEST_CR_KERNEL
=
"
...
...
@@ -166,6 +167,7 @@ tempfs
bind-mount
mountpoints
inotify_irmap
cgroup00
"
source
$(
readlink
-f
`
dirname
$0
`
/env.sh
)
||
exit
1
...
...
test/zdtm/live/static/Makefile
View file @
441b9b9e
...
...
@@ -154,6 +154,7 @@ TST_DIR = \
overmount_sock
\
tempfs
\
bind-mount
\
cgroup00
\
TST_DIR_FILE
=
\
chroot
\
...
...
test/zdtm/live/static/cgroup00.c
0 → 100644
View file @
441b9b9e
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Check that cgroups layout is preserved"
;
const
char
*
test_author
=
"Pavel Emelianov <xemul@parallels.com>"
;
char
*
dirname
;
TEST_OPTION
(
dirname
,
string
,
"cgroup directory name"
,
1
);
static
const
char
*
cgname
=
"zdtmtst"
;
static
const
char
*
subname
=
"subcg"
;
int
main
(
int
argc
,
char
**
argv
)
{
int
cgfd
,
l
,
ret
=
1
;
char
aux
[
32
],
paux
[
1024
];
FILE
*
cgf
;
test_init
(
argc
,
argv
);
if
(
mkdir
(
dirname
,
0700
)
<
0
)
{
err
(
"Can't make dir"
);
goto
out
;
}
sprintf
(
aux
,
"none,name=%s"
,
cgname
);
if
(
mount
(
"none"
,
dirname
,
"cgroup"
,
0
,
aux
))
{
err
(
"Can't mount cgroups"
);
goto
out_rd
;
}
sprintf
(
paux
,
"%s/%s"
,
dirname
,
subname
);
mkdir
(
paux
,
0600
);
l
=
sprintf
(
aux
,
"%d"
,
getpid
());
sprintf
(
paux
,
"%s/%s/tasks"
,
dirname
,
subname
);
cgfd
=
open
(
paux
,
O_WRONLY
);
if
(
cgfd
<
0
)
{
err
(
"Can't open tasks"
);
goto
out_rs
;
}
l
=
write
(
cgfd
,
aux
,
l
);
close
(
cgfd
);
if
(
l
<
0
)
{
err
(
"Can't move self to subcg"
);
goto
out_rs
;
}
close
(
cgfd
);
test_daemon
();
test_waitsig
();
cgf
=
fopen
(
"/proc/self/cgroup"
,
"r"
);
if
(
cgf
==
NULL
)
{
fail
(
"No cgroups file"
);
goto
out_rs
;
}
sprintf
(
aux
,
"name=%s:/%s
\n
"
,
cgname
,
subname
);
while
(
fgets
(
paux
,
sizeof
(
paux
),
cgf
))
{
char
*
s
;
s
=
strchr
(
paux
,
':'
)
+
1
;
test_msg
(
"CMP [%s] vs [%s]
\n
"
,
s
,
aux
);
if
(
!
strcmp
(
s
,
aux
))
{
ret
=
0
;
break
;
}
}
fclose
(
cgf
);
if
(
!
ret
)
pass
();
else
fail
(
"Task is not in subgroups"
);
out_rs:
sprintf
(
paux
,
"%s/%s"
,
dirname
,
subname
);
rmdir
(
paux
);
umount
(
dirname
);
out_rd:
rmdir
(
dirname
);
out:
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