[CRIU] [PATCH 1/2] zdtm: don't fail if a test changed cwd
Andrey Vagin
avagin at openvz.org
Thu Jun 2 19:47:11 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
test/zdtm/lib/test.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 62608e8..ed7aaa6 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -39,6 +39,8 @@ int test_fork_id(int id)
return fork();
}
+static int cwd = -1;
+
#define INPROGRESS ".inprogress"
static void test_fini(void)
{
@@ -48,9 +50,9 @@ static void test_fini(void)
return;
snprintf(path, sizeof(path), "%s%s", outfile, INPROGRESS);
- rename(path, outfile);
+ renameat(cwd, path, cwd, outfile);
- unlink(pidfile);
+ unlinkat(cwd, pidfile, 0);
}
static void setup_outfile()
@@ -61,6 +63,12 @@ static void setup_outfile()
exit(1);
}
+ cwd = open(".", O_RDONLY);
+ if (cwd < 0) {
+ fprintf(stderr, "Unable to open\n");
+ exit(1);
+ }
+
if (atexit(test_fini)) {
fprintf(stderr, "Can't register exit function\n");
exit(1);
--
2.7.4
More information about the CRIU
mailing list