diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-11-21 13:37:16 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-11-21 13:41:39 -0500 |
commit | dfca7d5b0578651dd25f4454b89a49cf0952ec6d (patch) | |
tree | 8ad918c773c83585fdb10814fb3006cc4a30905e /test | |
parent | a2d6197d65a6648e2b6f53b379197a4848131846 (diff) | |
download | mongo-dfca7d5b0578651dd25f4454b89a49cf0952ec6d.tar.gz |
Move the test run into a subdirectory, WT_TEST.
Make it possible to pass additional information to the die functon's fprintf.
Diffstat (limited to 'test')
-rw-r--r-- | test/fops/Makefile.am | 2 | ||||
-rw-r--r-- | test/fops/file.c | 48 | ||||
-rw-r--r-- | test/fops/fops.c | 4 | ||||
-rw-r--r-- | test/fops/t.c | 25 | ||||
-rw-r--r-- | test/fops/thread.h | 2 |
5 files changed, 46 insertions, 35 deletions
diff --git a/test/fops/Makefile.am b/test/fops/Makefile.am index bfa22452e36..f83dcce714f 100644 --- a/test/fops/Makefile.am +++ b/test/fops/Makefile.am @@ -8,4 +8,4 @@ t_LDFLAGS = -static TESTS = $(noinst_PROGRAMS) clean-local: - rm -rf WiredTiger* __* *.core + rm -rf WT_TEST diff --git a/test/fops/file.c b/test/fops/file.c index b4c59e8b483..49b8c1c4a87 100644 --- a/test/fops/file.c +++ b/test/fops/file.c @@ -35,11 +35,11 @@ obj_bulk(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->create(session, uri, config)) != 0) if (ret != EEXIST && ret != EBUSY) - die("session.create", ret); + die(ret, "session.create"); if (ret == 0) { if ((ret = session->open_cursor( @@ -47,12 +47,12 @@ obj_bulk(void) /* Yield so that other threads can interfere. */ sched_yield(); if ((ret = c->close(c)) != 0) - die("cursor.close", ret); + die(ret, "cursor.close"); } else if (ret != ENOENT && ret != EBUSY && ret != EINVAL) - die("session.open_cursor", ret); + die(ret, "session.open_cursor"); } if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -63,18 +63,18 @@ obj_cursor(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->open_cursor(session, uri, NULL, NULL, &cursor)) != 0) { if (ret != ENOENT && ret != EBUSY) - die("session.open_cursor", ret); + die(ret, "session.open_cursor"); } else { if ((ret = cursor->close(cursor)) != 0) - die("cursor.close", ret); + die(ret, "cursor.close"); } if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -84,14 +84,14 @@ obj_create(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->create(session, uri, config)) != 0) if (ret != EEXIST && ret != EBUSY) - die("session.create", ret); + die(ret, "session.create"); if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -101,14 +101,14 @@ obj_drop(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->drop(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die("session.drop", ret); + die(ret, "session.drop"); if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -118,15 +118,15 @@ obj_checkpoint(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); /* Force the checkpoint so it has to be taken. */ if ((ret = session->checkpoint(session, "force")) != 0) if (ret != ENOENT) - die("session.checkpoint", ret); + die(ret, "session.checkpoint"); if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -136,14 +136,14 @@ obj_upgrade(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->upgrade(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die("session.upgrade", ret); + die(ret, "session.upgrade"); if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } void @@ -153,12 +153,12 @@ obj_verify(void) int ret; if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) - die("conn.session", ret); + die(ret, "conn.session"); if ((ret = session->verify(session, uri, NULL)) != 0) if (ret != ENOENT && ret != EBUSY) - die("session.verify", ret); + die(ret, "session.verify"); if ((ret = session->close(session, NULL)) != 0) - die("session.close", ret); + die(ret, "session.close"); } diff --git a/test/fops/fops.c b/test/fops/fops.c index 61b881318d1..6dc3904fb2f 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -81,7 +81,7 @@ fop_start(u_int nthreads) if ((run_stats = calloc( (size_t)(nthreads), sizeof(*run_stats))) == NULL || (tids = calloc((size_t)(nthreads), sizeof(*tids))) == NULL) - die("calloc", errno); + die(errno, "calloc"); (void)gettimeofday(&start, NULL); @@ -89,7 +89,7 @@ fop_start(u_int nthreads) for (i = 0; i < nthreads; ++i) if ((ret = pthread_create( &tids[i], NULL, fop, (void *)(uintptr_t)i)) != 0) - die("pthread_create", ret); + die(ret, "pthread_create"); /* Wait for the threads. */ for (i = 0; i < nthreads; ++i) diff --git a/test/fops/t.c b/test/fops/t.c index 41cca99bedd..edce91c6d09 100644 --- a/test/fops/t.c +++ b/test/fops/t.c @@ -151,6 +151,9 @@ wt_startup(char *config_open) int ret; char config_buf[128]; + if ((ret = system("rm -rf WT_TEST && mkdir WT_TEST")) != 0) + die(ret, "directory cleanup call failed"); + snprintf(config_buf, sizeof(config_buf), "create,error_prefix=\"%s\",cache_size=5MB%s%s", progname, @@ -158,8 +161,8 @@ wt_startup(char *config_open) config_open == NULL ? "" : config_open); if ((ret = wiredtiger_open( - NULL, &event_handler, config_buf, &conn)) != 0) - die("wiredtiger_open", ret); + "WT_TEST", &event_handler, config_buf, &conn)) != 0) + die(ret, "wiredtiger_open"); } /* @@ -172,7 +175,7 @@ wt_shutdown(void) int ret; if ((ret = conn->close(conn, NULL)) != 0) - die("conn.close", ret); + die(ret, "conn.close"); } /* @@ -184,8 +187,8 @@ shutdown(void) { int ret; - if ((ret = system("rm -f WiredTiger* __wt*")) != 0) - die("system cleanup call failed", ret); + if ((ret = system("rm -rf WT_TEST")) != 0) + die(ret, "directory cleanup call failed"); } static int @@ -241,9 +244,17 @@ onint(int signo) * Report an error and quit. */ void -die(const char *m, int e) +die(int e, const char *fmt, ...) { - fprintf(stderr, "%s: %s: %s\n", progname, m, wiredtiger_strerror(e)); + va_list ap; + + fprintf(stderr, "%s: ", progname); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + if (e != 0) + fprintf(stderr, ": %s", wiredtiger_strerror(e)); + fprintf(stderr, "\n"); exit(EXIT_FAILURE); } diff --git a/test/fops/thread.h b/test/fops/thread.h index 00273052e59..3e3e683740f 100644 --- a/test/fops/thread.h +++ b/test/fops/thread.h @@ -55,7 +55,7 @@ void obj_drop(void); void obj_upgrade(void); void obj_verify(void); -void die(const char *, int) +void die(int, const char *, ...) #if defined(__GNUC__) __attribute__((noreturn)) #endif |