Commit 16c410b1 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: check content of an unlinked file

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 29cb7de1
......@@ -22,10 +22,11 @@ int main(int argc, char ** argv)
gid_t gid;
uint8_t buf[fsize];
struct stat fst;
uint32_t crc;
test_init(argc, argv);
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
err("can't open %s: %m\n", filename);
exit(1);
......@@ -45,7 +46,9 @@ int main(int argc, char ** argv)
err("%s file size eq %d\n", fst.st_size);
goto failed;
}
memset(buf, '0', sizeof(buf));
crc = ~0;
datagen(buf, sizeof(buf), &crc);
if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
err("can't write %s: %m\n", filename);
goto failed;
......@@ -100,6 +103,21 @@ int main(int argc, char ** argv)
goto failed;
}
if (lseek(fd, 0, SEEK_SET) != 0) {
err("can't reposition to 0: %m");
goto failed;
}
if (read(fd, buf, sizeof(buf)) != sizeof(buf)) {
fail("can't read %s: %m\n", filename);
goto failed;
}
crc = ~0;
if (datachk(buf, sizeof(buf), &crc)) {
fail("CRC mismatch\n");
goto failed;
}
close(fd);
pass();
......
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