summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2007-10-29 14:45:37 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-06-16 18:02:31 +0300
commit7c850d4be465aee464c91f04753b6c1537edb48a (patch)
treee1ccaa4a0392c9ab628f351fef4b31cda29350d3 /tests
parent1db3a302e91faedca5fa51330eb80404b8909993 (diff)
fs-tests: make integrity test record truncations
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/fs-tests/integrity/integck.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 3da4bac..e64af9d 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -42,6 +42,7 @@ struct write_info /* Record of random data written into a file */
size_t size; /* Number of bytes written */
unsigned random_seed; /* Seed for rand() to create random data */
off_t random_offset; /* Call rand() this number of times first */
+ int trunc; /* Records a truncation (raw_writes only) */
};
struct file_info /* Each file has one of these */
@@ -440,16 +441,21 @@ static void file_info_display(struct file_info *file)
wcnt = 0;
w = file->raw_writes;
while (w) {
- fprintf(stderr, " Offset: %u Size: %u Seed: %u"
- " R.Off: %u\n",
- (unsigned) w->offset,
- (unsigned) w->size,
- (unsigned) w->random_seed,
- (unsigned) w->random_offset);
+ if (w->trunc)
+ fprintf(stderr, " Trunc from %u to %u\n",
+ (unsigned) w->offset,
+ (unsigned) w->random_offset);
+ else
+ fprintf(stderr, " Offset: %u Size: %u Seed: %u"
+ " R.Off: %u\n",
+ (unsigned) w->offset,
+ (unsigned) w->size,
+ (unsigned) w->random_seed,
+ (unsigned) w->random_offset);
wcnt += 1;
w = w->next;
}
- fprintf(stderr, " %u writes\n", wcnt);
+ fprintf(stderr, " %u writes or truncations\n", wcnt);
fprintf(stderr, " ============================================\n");
}
@@ -720,6 +726,7 @@ static void file_write_file(struct file_info *file)
static void file_truncate_info(struct file_info *file, size_t new_length)
{
struct write_info *w, **prev, *tmp;
+ size_t sz;
/* Remove / truncate file->writes */
w = file->writes;
@@ -738,6 +745,16 @@ static void file_truncate_info(struct file_info *file, size_t new_length)
prev = &w->next;
w = w->next;
}
+ /* Add an entry in raw_writes for the truncation */
+ sz = sizeof(struct write_info);
+ w = (struct write_info *) malloc(sz);
+ CHECK(w != NULL);
+ memset(w, 0, sz);
+ w->next = file->raw_writes;
+ w->offset = file->length;
+ w->random_offset = new_length; /* Abuse random_offset */
+ w->trunc = 1;
+ file->raw_writes = w;
/* Update file length */
file->length = new_length;
}