diff --git a/test/zdtm/live/static/file_shared.c b/test/zdtm/live/static/file_shared.c index 82222de29..915a2e476 100644 --- a/test/zdtm/live/static/file_shared.c +++ b/test/zdtm/live/static/file_shared.c @@ -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 "; @@ -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;