Commit 51970afa authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm: don't fail if a test changed cwd

Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent b599cda1
...@@ -39,6 +39,8 @@ int test_fork_id(int id) ...@@ -39,6 +39,8 @@ int test_fork_id(int id)
return fork(); return fork();
} }
static int cwd = -1;
#define INPROGRESS ".inprogress" #define INPROGRESS ".inprogress"
static void test_fini(void) static void test_fini(void)
{ {
...@@ -48,9 +50,9 @@ static void test_fini(void) ...@@ -48,9 +50,9 @@ static void test_fini(void)
return; return;
snprintf(path, sizeof(path), "%s%s", outfile, INPROGRESS); 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() static void setup_outfile()
...@@ -61,6 +63,12 @@ static void setup_outfile() ...@@ -61,6 +63,12 @@ static void setup_outfile()
exit(1); exit(1);
} }
cwd = open(".", O_RDONLY);
if (cwd < 0) {
fprintf(stderr, "Unable to open\n");
exit(1);
}
if (atexit(test_fini)) { if (atexit(test_fini)) {
fprintf(stderr, "Can't register exit function\n"); fprintf(stderr, "Can't register exit function\n");
exit(1); exit(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment