aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-18 09:50:30 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-04-22 14:29:51 +0300
commit6254515b631a4f7ca21c1ef26b0749388086faa9 (patch)
tree7cdd0a949eebf1e4f34d0f909f95bf8921ce2a31 /tests
parentfc1c0f7d52bc4dab130a74fea383629c7a341f14 (diff)
fs-tests: integck: handle all failures in operate_on_open_file
Make 'operate_on_open_file()' to handle possible 'fsync()' and 'fdatasync()' errors by returning -1 up to the caller. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/fs-tests/integrity/integck.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 7ccbcb1..7348e14 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -1947,26 +1947,33 @@ static int operate_on_dir(struct dir_info *dir)
*/
static int operate_on_open_file(struct fd_info *fdi)
{
+ int ret = 0;
unsigned int r = random_no(1000);
if (shrink && r < 5)
- return file_truncate(fdi->file, fdi->fd);
+ ret = file_truncate(fdi->file, fdi->fd);
else if (r < 21)
file_close(fdi);
else if (shrink && r < 121 && !fdi->file->deleted)
- return file_delete(fdi->file);
+ ret = file_delete(fdi->file);
else {
- if (file_write(fdi->file, fdi->fd))
- return -1;
- if (r >= 999) {
- if (random_no(100) >= 50)
- CHECK(fsync(fdi->fd) == 0);
- else
- CHECK(fdatasync(fdi->fd) == 0);
+ ret = file_write(fdi->file, fdi->fd);
+ if (!ret && r >= 999) {
+ if (random_no(100) >= 50) {
+ ret = fsync(fdi->fd);
+ if (ret)
+ pcv("fsync failed for %s",
+ fdi->file->name);
+ } else {
+ ret = fdatasync(fdi->fd);
+ if (ret)
+ pcv("fdatasync failed for %s",
+ fdi->file->name);
+ }
}
}
- return 0;
+ return ret;
}
/*