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) ...@@ -22,10 +22,11 @@ int main(int argc, char ** argv)
gid_t gid; gid_t gid;
uint8_t buf[fsize]; uint8_t buf[fsize];
struct stat fst; struct stat fst;
uint32_t crc;
test_init(argc, argv); 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) { if (fd < 0) {
err("can't open %s: %m\n", filename); err("can't open %s: %m\n", filename);
exit(1); exit(1);
...@@ -45,7 +46,9 @@ int main(int argc, char ** argv) ...@@ -45,7 +46,9 @@ int main(int argc, char ** argv)
err("%s file size eq %d\n", fst.st_size); err("%s file size eq %d\n", fst.st_size);
goto failed; goto failed;
} }
memset(buf, '0', sizeof(buf));
crc = ~0;
datagen(buf, sizeof(buf), &crc);
if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
err("can't write %s: %m\n", filename); err("can't write %s: %m\n", filename);
goto failed; goto failed;
...@@ -100,6 +103,21 @@ int main(int argc, char ** argv) ...@@ -100,6 +103,21 @@ int main(int argc, char ** argv)
goto failed; 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); close(fd);
pass(); 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