diff options
| author | Elie De Brauwer <eliedebrauwer@gmail.com> | 2013-03-01 19:37:38 +0100 | 
|---|---|---|
| committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-03-11 10:36:02 +0200 | 
| commit | 3ff90433ab22c001215d9a26c65de1b7f448dc79 (patch) | |
| tree | 3e415b39434b2674e1351399a9c8592aa416c91a /tests/fs-tests/integrity | |
| parent | 681d1d6c311ac918986e964f65097d556b2acd78 (diff) | |
integck.c: rework file_check_data to immediately dump the buffer containing the errors
See my problem description int the previous commit, the point is that integck
in file_check_data reads a buffer, and then checks if the data is correct,  it
will do a seek(0), and reread from the same fd. The point is that in the
scenario I observed integck failed (due to a buffer mismatch) but the it saved
(and what was in flash) was actually correct. So I modified this function to
dump the buffers to stderr at the moment an error is found.
Signed-off-by: Elie De Brauwer <eliedebrauwer@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'tests/fs-tests/integrity')
| -rw-r--r-- | tests/fs-tests/integrity/integck.c | 36 | 
1 files changed, 24 insertions, 12 deletions
| diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 2c6ffea..5ea3642 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -1502,7 +1502,8 @@ static void file_check_data(struct file_info *file, int fd,  {  	size_t remains, block, i;  	off_t r; -	char buf[IO_BUFFER_SIZE]; +	unsigned char read_buf[IO_BUFFER_SIZE]; +	unsigned char check_buf[IO_BUFFER_SIZE];  	unsigned int seed = w->random_seed;  	if (args.power_cut_mode && !file->clean) @@ -1517,17 +1518,28 @@ static void file_check_data(struct file_info *file, int fd,  			block = IO_BUFFER_SIZE;  		else  			block = remains; -		CHECK(read(fd, buf, block) == block); -		for (i = 0; i < block; ++i) { -			char c = (char)rand_r(&seed); -			if (buf[i] != c) { -				errmsg("file_check_data failed at %zu checking " -				       "data at %llu size %zu", w->size - remains + i, -					(unsigned long long)w->offset, w->size); -				file_info_display(file); -				save_file(fd, file); -			} -			CHECK(buf[i] == c); +		CHECK(read(fd, read_buf, block) == block); +		for (i = 0; i < block; ++i) +			check_buf[i] = (char)rand_r(&seed); + +		if (memcmp(check_buf, read_buf, block) != 0) { +			errmsg("file_check_data failed, dumping " +				"data at offset %llu size %zu", +				(unsigned long long)w->offset, w->size); + +			fprintf (stderr, "Read data:\n"); +			for (r = 0; r < block; ++r) +				fprintf(stderr, "%02x%c", +					read_buf[r], ((r+1)%16)?' ':'\n'); +			fprintf(stderr, "\nExpected data:\n"); +			for (r = 0; r < block; ++r) +				fprintf(stderr, "%02x%c", +					check_buf[r], ((r+1)%16)?' ':'\n'); +			fprintf(stderr, " \n"); + +			file_info_display(file); +			save_file(fd, file); +			CHECK(0);  		}  		remains -= block;  	} | 
