From: adilger Date: Tue, 19 Aug 2003 22:22:50 +0000 (+0000) Subject: Close and unlink test file if we didn't encounter any errors. X-Git-Tag: v1_7_0_51~2^7~655 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=6b78ee47afdbff2f6facc998535b08cbbed45f90;p=fs%2Flustre-release.git Close and unlink test file if we didn't encounter any errors. Set default iteration count to 50k instead of 100k. --- diff --git a/lustre/tests/write_append_truncate.c b/lustre/tests/write_append_truncate.c index fd187da..026609e 100644 --- a/lustre/tests/write_append_truncate.c +++ b/lustre/tests/write_append_truncate.c @@ -27,6 +27,7 @@ #include #include "mpi.h" +#define DEFAULT_ITER 50000 #define CHUNK_SIZE_MAX 123456 #define CHUNK_CHAR 'C' @@ -41,8 +42,9 @@ void usage(char *prog) { printf("usage: %s [nloops]\n", prog); - printf("%s must be run on 2 nodes\n", prog); + printf("%s must be run with 2 processes\n", prog); + MPI_Finalize(); exit(1); } @@ -57,6 +59,7 @@ int rprintf(int rank, int loop, const char *fmt, ...) printf(fmt, ap); + MPI_Finalize(); exit(1); } @@ -111,7 +114,7 @@ int main(int argc, char *argv[]) if (argc == 3) nloops = strtoul(argv[2], NULL, 0); if (nloops == 0) - nloops = 100000; + nloops = DEFAULT_ITER; if (rank == 0) { fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666); @@ -232,15 +235,15 @@ int main(int argc, char *argv[]) /* Check case 2: first truncate then append */ if (memcmp(read_buf+chunk_size, trunc_buf, trunc_offset-chunk_size)) { - printf("loop %d: append-after-TRUNC" - " bad [%d-%d]/[%#x-%#x] != 0\n", + printf("loop %d: append-after-TRUNC bad" + " [%d-%d]/[%#x-%#x] != 0\n", n, chunk_size, trunc_offset - 1, chunk_size, trunc_offset - 1); error = 1; } else if (memcmp(read_buf+trunc_offset, append_buf, append_size)) { - printf("loop %d: APPEND-after-trunc" - " bad [%d-%d]/[%#x-%#x] != %c\n", + printf("loop %d: APPEND-after-trunc bad" + " [%d-%d]/[%#x-%#x] != %c\n", n, trunc_offset, append_size - 1, trunc_offset, append_size - 1, APPEND_CHAR); @@ -270,6 +273,13 @@ int main(int argc, char *argv[]) } printf("rank %d, loop %d: finished\n", rank, n); + close(fd); + + if (rank == 0) { + error = unlink(fname); + if (error < 0) + rprintf("unlink %s failed: %s\n",fname,strerror(errno)); + } MPI_Finalize(); return 0;