mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
zdtm: Extend file_shared test
Check for files with equal paths are handled" Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "zdtmtst.h"
|
||||
#define OFFSET 1000
|
||||
#define OFFSET2 500
|
||||
|
||||
const char *test_doc = "Check shared struct file-s";
|
||||
const char *test_author = "Andrey Vagin <avagin@openvz.org>";
|
||||
@@ -18,7 +19,7 @@ TEST_OPTION(filename, string, "file name", 1);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
int fd, ret, status;
|
||||
int fd, fd2, fd3, ret, status;
|
||||
off_t off;
|
||||
|
||||
test_init(argc, argv);
|
||||
@@ -27,10 +28,14 @@ int main(int argc, char **argv)
|
||||
if (fd == -1)
|
||||
return 1;
|
||||
|
||||
fd = dup(fd);
|
||||
fd2 = dup(fd);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
|
||||
fd3 = open(filename, O_RDWR | O_CREAT);
|
||||
if (fd3 == -1)
|
||||
return 1;
|
||||
|
||||
test_daemon();
|
||||
|
||||
pid = test_fork();
|
||||
@@ -43,6 +48,10 @@ int main(int argc, char **argv)
|
||||
if (off == (off_t) -1)
|
||||
return 1;
|
||||
|
||||
off = lseek(fd3, OFFSET2, SEEK_SET);
|
||||
if (off == (off_t) -1)
|
||||
return 1;
|
||||
|
||||
ret = kill(pid, SIGTERM);
|
||||
if (ret == -1) {
|
||||
err("kill() failed: %m");
|
||||
@@ -58,11 +67,31 @@ int main(int argc, char **argv)
|
||||
fail("Child exited with non-zero status");
|
||||
return 1;
|
||||
}
|
||||
off = lseek(fd2, 0, SEEK_CUR);
|
||||
if (off != OFFSET) {
|
||||
fail("offset1 fail\n");
|
||||
return 1;
|
||||
}
|
||||
off = lseek(fd3, 0, SEEK_CUR);
|
||||
if (off != OFFSET2) {
|
||||
fail("offset2 fail\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
test_waitsig();
|
||||
off = lseek(fd, 0, SEEK_CUR);
|
||||
if (off != OFFSET) {
|
||||
fail("offset should be %d insted of %d\n");
|
||||
fail("offset3 fail\n");
|
||||
return 1;
|
||||
}
|
||||
off = lseek(fd2, 0, SEEK_CUR);
|
||||
if (off != OFFSET) {
|
||||
fail("offset4 fail\n");
|
||||
return 1;
|
||||
}
|
||||
off = lseek(fd3, 0, SEEK_CUR);
|
||||
if (off != OFFSET2) {
|
||||
fail("offset5 fail\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user