Commit d6a1d206 authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

zdtm: add test cases for shared sturct file-s

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 37782e6e
......@@ -14,6 +14,7 @@ zdtm/live/static/write_read00
zdtm/live/static/write_read01
zdtm/live/static/write_read02
zdtm/live/static/wait00
zdtm/live/static/file_shared
zdtm/live/streaming/pipe_loop00
zdtm/live/streaming/pipe_shared00
zdtm/live/transition/file_read"
......
......@@ -44,6 +44,7 @@ TST_FILE = \
fifo_wronly \
unlink_fifo \
unlink_fifo_wronly \
file_shared \
TST_DIR = \
cwd00 \
......
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include "zdtmtst.h"
#define OFFSET 1000
const char *test_doc = "Check shared struct file-s";
const char *test_author = "Andrey Vagin <xemul@parallels.com>";
char *filename;
TEST_OPTION(filename, string, "file name", 1);
int main(int argc, char **argv)
{
pid_t pid;
int fd, ret, status;
off_t off;
test_init(argc, argv);
fd = open(filename, O_RDWR | O_CREAT);
if (fd == -1)
return 1;
fd = dup(fd);
if (fd < 0)
return 1;
test_daemon();
pid = test_fork();
if (pid == -1)
return 1;
else if (pid) {
test_waitsig();
off = lseek(fd, OFFSET, SEEK_SET);
if (off == (off_t) -1)
return 1;
ret = kill(pid, SIGTERM);
if (ret == -1) {
err("kill() failed: %m");
}
ret = wait(&status);
if (ret == -1) {
err("wait() failed: %m");
return 1;
}
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
fail("Child exited with non-zero status");
return 1;
}
} else {
test_waitsig();
off = lseek(fd, 0, SEEK_CUR);
if (off != OFFSET) {
fail("offset should be %d insted of %d\n");
return 1;
}
return 0;
}
pass();
return 0;
}
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