[CRIU] [PATCH 1/3] zdtm: check, that stopped tasks are restored correctly
Andrey Vagin
avagin at openvz.org
Thu Sep 26 06:37:38 EDT 2013
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/stopped.c | 67 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
create mode 100644 test/zdtm/live/static/stopped.c
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index ee66a81..92c18c9 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -102,6 +102,7 @@ TST_NOFILE = \
grow_map \
grow_map02 \
tun \
+ stopped \
# jobctl00 \
TST_FILE = \
diff --git a/test/zdtm/live/static/stopped.c b/test/zdtm/live/static/stopped.c
new file mode 100644
index 0000000..6194d6b
--- /dev/null
+++ b/test/zdtm/live/static/stopped.c
@@ -0,0 +1,67 @@
+#include <errno.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check, that stopped tasts are restored correctly";
+const char *test_author = "Andrew Vagin <avagin at parallels.com>";
+
+int main(int argc, char **argv)
+{
+ pid_t pid;
+ int p[2], ret, status;
+
+ test_init(argc, argv);
+
+ if (pipe(p)) {
+ err("Unable to create pipe");
+ return 1;
+ }
+
+ pid = test_fork();
+ if (pid < 0)
+ return -1;
+ else if (pid == 0) {
+ char c;
+
+ close(p[1]);
+ ret = read(p[0], &c, 1);
+ if (ret != 1) {
+ err("Unable to read: %d", ret);
+ return 1;
+ }
+
+ ret = read(p[0], &c, 1);
+ if (ret != 0) {
+ err("Unable to read: %d", ret);
+ return 1;
+ }
+
+ return 0;
+ }
+ close(p[0]);
+
+ kill(pid, SIGSTOP);
+ write(p[1], "0", 1);
+
+ test_daemon();
+ test_waitsig();
+
+ kill(pid, SIGCONT);
+ if (waitpid(pid, &status, WCONTINUED) == -1) {
+ err("Unable to wait child");
+ goto out;
+ }
+
+ if (WIFCONTINUED(status))
+ pass();
+ else
+ fail("The process doesn't continue");
+out:
+ close(p[1]);
+ waitpid(pid, &status, 0);
+
+ return 0;
+}
--
1.8.3.1
More information about the CRIU
mailing list