# include <limits.h>
# include <time.h>
# include <strings.h>
+# include <sys/time.h>
#endif
#include <fcntl.h>
#include <sys/mman.h>
struct log_entry {
int operation;
+ struct timeval tv;
int args[3];
};
char *good_buf; /* a pointer to the correct data */
char *temp_buf; /* a pointer to the current data */
char *fname; /* name of our test file */
+char logfile[1024]; /* name of our log file */
+char goodfile[1024]; /* name of our test file */
int fd; /* fd for our test file */
off_t file_size = 0;
void
-log4(int operation, int arg0, int arg1, int arg2)
+log4(int operation, int arg0, int arg1, int arg2, struct timeval *tv)
{
struct log_entry *le;
le = &oplog[logptr];
+ le->tv = *tv;
le->operation = operation;
if (closeopen)
le->operation = ~ le->operation;
int opnum;
opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE;
- prt("%d(%d mod 256): ", opnum, opnum%256);
lp = &oplog[i];
+ prt("%d(%d mod 256): %lu.%lu ", opnum, opnum%256,
+ lp->tv.tv_sec, lp->tv.tv_usec);
if ((closeopen = lp->operation < 0))
lp->operation = ~ lp->operation;
if (good_buf) {
save_buffer(good_buf, file_size, fsxgoodfd);
prt("Correct content saved for comparison\n");
- prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n",
- fname, fname);
+ prt("(maybe hexdump \"%s\" vs \"%s\")\n",
+ fname, goodfile);
}
close(fsxgoodfd);
}
void
doread(unsigned offset, unsigned size)
{
+ struct timeval t;
off_t ret;
unsigned iret;
offset -= offset % readbdy;
+ gettimeofday(&t, NULL);
if (size == 0) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping zero size read\n");
- log4(OP_SKIPPED, OP_READ, offset, size);
+ log4(OP_SKIPPED, OP_READ, offset, size, &t);
return;
}
if (size + offset > file_size) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping seek/read past end of file\n");
- log4(OP_SKIPPED, OP_READ, offset, size);
+ log4(OP_SKIPPED, OP_READ, offset, size, &t);
return;
}
- log4(OP_READ, offset, size, 0);
+ log4(OP_READ, offset, size, 0, &t);
if (testcalls <= simulatedopcount)
return;
(monitorstart == -1 ||
(offset + size > monitorstart &&
(monitorend == -1 || offset <= monitorend))))))
- prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
- offset, offset + size - 1, size);
+ prt("%lu %lu.%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n",
+ testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1,
+ size);
ret = lseek(fd, (off_t)offset, SEEK_SET);
if (ret == (off_t)-1) {
prterr("doread: lseek");
void
domapread(unsigned offset, unsigned size)
{
+ struct timeval t;
unsigned pg_offset;
unsigned map_size;
char *p;
offset -= offset % readbdy;
+ gettimeofday(&t, NULL);
if (size == 0) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping zero size read\n");
- log4(OP_SKIPPED, OP_MAPREAD, offset, size);
+ log4(OP_SKIPPED, OP_MAPREAD, offset, size, &t);
return;
}
if (size + offset > file_size) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping seek/read past end of file\n");
- log4(OP_SKIPPED, OP_MAPREAD, offset, size);
+ log4(OP_SKIPPED, OP_MAPREAD, offset, size, &t);
return;
}
- log4(OP_MAPREAD, offset, size, 0);
+ log4(OP_MAPREAD, offset, size, 0, &t);
if (testcalls <= simulatedopcount)
return;
(monitorstart == -1 ||
(offset + size > monitorstart &&
(monitorend == -1 || offset <= monitorend))))))
- prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
- offset, offset + size - 1, size);
+ prt("%lu %lu.%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n",
+ testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1,
+ size);
pg_offset = offset & page_mask;
map_size = pg_offset + size;
- if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE |
-MAP_SHARED, fd,
+ if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd,
(off_t)(offset - pg_offset))) == (char *)-1) {
prterr("domapread: mmap");
report_failure(190);
void
dowrite(unsigned offset, unsigned size)
{
+ struct timeval t;
off_t ret;
unsigned iret;
offset -= offset % writebdy;
+ gettimeofday(&t, NULL);
if (size == 0) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping zero size write\n");
- log4(OP_SKIPPED, OP_WRITE, offset, size);
+ log4(OP_SKIPPED, OP_WRITE, offset, size, &t);
return;
}
- log4(OP_WRITE, offset, size, file_size);
+ log4(OP_WRITE, offset, size, file_size, &t);
gendata(original_buf, good_buf, offset, size);
if (file_size < offset + size) {
(monitorstart == -1 ||
(offset + size > monitorstart &&
(monitorend == -1 || offset <= monitorend))))))
- prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
- offset, offset + size - 1, size);
+ prt("%lu %lu.%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n",
+ testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1,
+ size);
ret = lseek(fd, (off_t)offset, SEEK_SET);
if (ret == (off_t)-1) {
prterr("dowrite: lseek");
void
domapwrite(unsigned offset, unsigned size)
{
+ struct timeval t;
unsigned pg_offset;
unsigned map_size;
off_t cur_filesize;
char *p;
offset -= offset % writebdy;
+ gettimeofday(&t, NULL);
if (size == 0) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping zero size write\n");
- log4(OP_SKIPPED, OP_MAPWRITE, offset, size);
+ log4(OP_SKIPPED, OP_MAPWRITE, offset, size, &t);
return;
}
cur_filesize = file_size;
- log4(OP_MAPWRITE, offset, size, 0);
+ log4(OP_MAPWRITE, offset, size, 0, &t);
gendata(original_buf, good_buf, offset, size);
if (file_size < offset + size) {
(monitorstart == -1 ||
(offset + size > monitorstart &&
(monitorend == -1 || offset <= monitorend))))))
- prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls,
- offset, offset + size - 1, size);
+ prt("%lu %lu.%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n",
+ testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1,
+ size);
if (file_size > cur_filesize) {
if (ftruncate(fd, file_size) == -1) {
void
dotruncate(unsigned size)
{
+ struct timeval t;
int oldsize = file_size;
size -= size % truncbdy;
+ gettimeofday(&t, NULL);
if (size > biggest) {
biggest = size;
if (!quiet && testcalls > simulatedopcount)
prt("truncating to largest ever: 0x%x\n", size);
}
- log4(OP_TRUNCATE, size, (unsigned)file_size, 0);
+ log4(OP_TRUNCATE, size, (unsigned)file_size, 0, &t);
if (size > file_size)
memset(good_buf + file_size, '\0', size - file_size);
if ((progressinterval && testcalls % progressinterval == 0) ||
(debug && (monitorstart == -1 || monitorend == -1 ||
size <= monitorend)))
- prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize,
-size);
+ prt("%lu %lu.%lu trunc\tfrom 0x%x to 0x%x\n",
+ testcalls, t.tv_sec, t.tv_usec, oldsize, size);
if (ftruncate(fd, (off_t)size) == -1) {
prt("ftruncate1: %x\n", size);
prterr("dotruncate: ftruncate");
void
docloseopen(void)
{
+ struct timeval t;
+
if (testcalls <= simulatedopcount)
return;
+ log4(OP_CLOSEOPEN, file_size, (unsigned)file_size, 0, &t);
+
+ gettimeofday(&t, NULL);
if (debug)
- prt("%lu close/open\n", testcalls);
+ prt("%lu %lu.%lu close/open\n", testcalls, t.tv_sec, t.tv_usec);
if (close(fd)) {
prterr("docloseopen: close");
report_failure(180);
}
+static const char *basename(const char *path)
+{
+ char *c = strrchr(path, '/');
+
+ return c ? c++ : path;
+}
+
int
main(int argc, char **argv)
{
int i, style, ch;
char *endp;
- char goodfile[1024];
- char logfile[1024];
+ int dirpath = 0;
goodfile[0] = 0;
logfile[0] = 0;
strcat(goodfile, "/");
strncpy(logfile, optarg, sizeof(logfile));
strcat(logfile, "/");
+ dirpath = 1;
break;
case 'R':
mapped_reads = 0;
prterr(fname);
exit(91);
}
- strncat(goodfile, fname, 256);
+ strncat(goodfile, dirpath ? basename(fname) : fname, 256);
strcat (goodfile, ".fsxgood");
fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
if (fsxgoodfd < 0) {
prterr(goodfile);
exit(92);
}
- strncat(logfile, fname, 256);
+ strncat(logfile, dirpath ? basename(fname) : fname, 256);
strcat (logfile, ".fsxlog");
fsxlogf = fopen(logfile, "w");
if (fsxlogf == NULL) {