X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fiopentest1.c;h=acc1112fa9c4897e39198571ab71897dd5a23369;hb=e52a140eb7f65a63f07dbb7e2aaff7f9e22974f2;hp=25ad4019e42f2f7728d889693d799f1fdfdbba19;hpb=ead624f0815c7b82d45b92322e9fb0abef027e49;p=fs%2Flustre-release.git diff --git a/lustre/tests/iopentest1.c b/lustre/tests/iopentest1.c index 25ad401..acc1112 100644 --- a/lustre/tests/iopentest1.c +++ b/lustre/tests/iopentest1.c @@ -1,3 +1,7 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + */ + #include #include #include @@ -33,16 +37,24 @@ static char *get_iname(char *fname, const char *mtpt) CHECK_IT(iname, "malloc() failed"); fd = open(fname, O_CREAT, 0644); - CHECK_IT(fd >= 0 || errno == EISDIR, "open(fname) failed"); + if (fd < 0 && errno != EISDIR) { + fprintf(stderr, "%s:%d: open(%s) failed: %s\n", __FILE__, + __LINE__, fname, strerror(errno)); + exit(1); + } if (fd >= 0) close(fd); rc = stat(fname, &buf); - CHECK_IT(rc == 0, "stat(fname) failed"); + if (rc != 0) { + fprintf(stderr, "%s:%d: stat(%s) failed: %s\n", __FILE__, + __LINE__, fname, strerror(errno)); + exit(1); + } rc = snprintf(iname, INAME_LEN, - "%s/__iopen__/%lu", mtpt, buf.st_ino); + "%s/__iopen__/%lu", mtpt, (unsigned long)buf.st_ino); CHECK_SNPRINTF(rc, INAME_LEN); return iname; @@ -67,16 +79,23 @@ int main(int argc, char *argv[]) mtpt = argv[2]; iname = get_iname(fname, mtpt); - i=10000; - printf("%s:started...\n",argv[0]); - do { + printf("%s:started...\n", argv[0]); + for (i = 0; i < 10000; i++) { rc = stat(fname, &buf); - CHECK_IT(rc == 0, "stat(fname) failed"); - + if (rc != 0) { + fprintf(stderr, "%s:%d: stat(%s) failed: %s\n", + __FILE__, __LINE__, fname, strerror(errno)); + exit(1); + } + rc = stat(iname, &buf); - CHECK_IT(rc == 0, "stat(iname) failed"); - i--; - } while (i>=1); + if (rc != 0) { + fprintf(stderr, "%s:%d: stat(%s) failed: %s\n", + __FILE__, __LINE__, iname, strerror(errno)); + exit(1); + } + } + printf("%s:finished...\n", argv[0]); return 0; }