From: pschwan Date: Fri, 6 Sep 2002 03:33:07 +0000 (+0000) Subject: Small open/close test to help narrow down our LOV bug X-Git-Tag: 0.5.7~63 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3eca0f643440d051100740bd5abd36629869ec33;p=fs%2Flustre-release.git Small open/close test to help narrow down our LOV bug --- diff --git a/lustre/tests/openclose.c b/lustre/tests/openclose.c new file mode 100644 index 0000000..9077e3d --- /dev/null +++ b/lustre/tests/openclose.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char *filename; + unsigned long count, i; + int fd; + + if (argc != 3) { + fprintf(stderr, "usage: %s \n", argv[0]); + exit(1); + } + + filename = argv[1]; + count = strtoul(argv[2], NULL, 0); + + fd = open(filename, O_RDWR|O_CREAT, 0644); + if (fd < 0) { + fprintf(stderr, "open(%s, O_CREAT): %s\n", filename, + strerror(errno)); + exit(1); + } + if (close(fd) < 0) { + fprintf(stderr, "close(): %s\n", strerror(errno)); + exit(1); + } + + for (i = 0; i < count; i++) { + fd = open(filename, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "open(%s, O_RDONLY): %s\n", filename, + strerror(errno)); + exit(1); + } + if (close(fd) < 0) { + fprintf(stderr, "close(): %s\n", strerror(errno)); + exit(1); + } + } + if (unlink(filename) < 0) { + fprintf(stderr, "unlink(%s): %s\n", filename, strerror(errno)); + exit(1); + } + printf("Done.\n"); + return 0; +}