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
7833260b
Commit
7833260b
authored
Aug 08, 2014
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: Make cgroup00 test check several tasks and sub-cgroup
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
5a44f7f4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
cgroup00.c
test/zdtm/live/static/cgroup00.c
+98
-0
No files found.
test/zdtm/live/static/cgroup00.c
View file @
7833260b
...
...
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <stdlib.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Check that cgroups layout is preserved"
;
...
...
@@ -13,6 +14,7 @@ char *dirname;
TEST_OPTION
(
dirname
,
string
,
"cgroup directory name"
,
1
);
static
const
char
*
cgname
=
"zdtmtst"
;
#define SUBNAME "subcg"
#define SUBNAME2 SUBNAME"/subsubcg"
static
int
cg_move
(
char
*
name
)
{
...
...
@@ -79,9 +81,22 @@ static void cg_cleanup(void)
int
main
(
int
argc
,
char
**
argv
)
{
char
aux
[
64
];
int
p1
[
2
],
p2
[
2
],
pr
[
2
],
status
;
test_init
(
argc
,
argv
);
/*
* Pipes to talk to two kids.
* First, they report that they are ready (int),
* then they report the restore status (int).
*/
pipe
(
p1
);
pipe
(
p2
);
/* "Restore happened" pipe */
pipe
(
pr
);
if
(
mkdir
(
dirname
,
0700
)
<
0
)
{
err
(
"Can't make dir"
);
goto
out
;
...
...
@@ -96,14 +111,92 @@ int main(int argc, char **argv)
if
(
cg_move
(
SUBNAME
))
goto
out_rs
;
if
(
fork
()
==
0
)
{
if
(
fork
()
==
0
)
{
/*
* 2nd level kid -- moves into its own
* cgroup and triggers slow-path cg_set
* restore in criu
*/
close
(
p1
[
0
]);
close
(
p1
[
1
]);
close
(
p2
[
0
]);
close
(
pr
[
1
]);
status
=
cg_move
(
SUBNAME2
);
write
(
p2
[
1
],
&
status
,
sizeof
(
status
));
if
(
status
==
0
)
{
read
(
pr
[
0
],
&
status
,
sizeof
(
status
));
status
=
cg_check
(
SUBNAME2
);
write
(
p2
[
1
],
&
status
,
sizeof
(
status
));
}
exit
(
0
);
}
/*
* 1st level kid -- inherits cgroup from
* parent and triggers fast-path cg_set
* restore in criu
*/
close
(
p1
[
0
]);
close
(
p2
[
0
]);
close
(
p2
[
1
]);
close
(
pr
[
1
]);
status
=
0
;
write
(
p1
[
1
],
&
status
,
sizeof
(
status
));
read
(
pr
[
0
],
&
status
,
sizeof
(
status
));
status
=
cg_check
(
SUBNAME
);
write
(
p1
[
1
],
&
status
,
sizeof
(
status
));
exit
(
0
);
}
close
(
p1
[
1
]);
close
(
p2
[
1
]);
close
(
pr
[
0
]);
status
=
-
1
;
read
(
p1
[
0
],
&
status
,
sizeof
(
status
));
if
(
status
!=
0
)
goto
out_ks
;
status
=
-
1
;
read
(
p2
[
0
],
&
status
,
sizeof
(
status
));
if
(
status
!=
0
)
goto
out_ks
;
test_daemon
();
test_waitsig
();
close
(
pr
[
1
]);
if
(
cg_check
(
SUBNAME
))
{
fail
(
"Top level task cg changed"
);
goto
out_rs
;
}
status
=
-
1
;
read
(
p1
[
0
],
&
status
,
sizeof
(
status
));
if
(
status
!=
0
)
{
fail
(
"1st level task cg changed"
);
goto
out_rs
;
}
status
=
-
1
;
read
(
p2
[
0
],
&
status
,
sizeof
(
status
));
if
(
status
!=
0
)
{
fail
(
"2nd level task cg changed"
);
goto
out_rs
;
}
pass
();
out_rs:
...
...
@@ -113,4 +206,9 @@ out_rd:
rmdir
(
dirname
);
out:
return
0
;
out_ks:
err
(
"Error moving into cgroups"
);
close
(
pr
[
0
]);
goto
out_rs
;
}
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