diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-08-27 07:32:47 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-08-27 07:32:47 -0400 |
commit | 876159d97dd14eb94601104900f6ffba5fc63a39 (patch) | |
tree | 6ef3ad4002a232b1971affc582e8df6a9bfdab57 /examples/c | |
parent | 1b372b9bf3b3c290db115d79a82504891100b65e (diff) | |
parent | cf53696eeaef346a730e71a46990086f49447041 (diff) | |
download | mongo-876159d97dd14eb94601104900f6ffba5fc63a39.tar.gz |
Merge branch 'develop' into wt-1967-evict-any
Diffstat (limited to 'examples/c')
-rw-r--r-- | examples/c/ex_log.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/examples/c/ex_log.c b/examples/c/ex_log.c index c33772a1858..d5a8f32487d 100644 --- a/examples/c/ex_log.c +++ b/examples/c/ex_log.c @@ -128,20 +128,22 @@ print_record(WT_LSN *lsn, uint32_t opcount, * A simple walk of the log. */ static int -simple_walk_log(WT_SESSION *session) +simple_walk_log(WT_SESSION *session, int count_min) { WT_CURSOR *cursor; WT_LSN lsn; WT_ITEM logrec_key, logrec_value; uint64_t txnid; uint32_t fileid, opcount, optype, rectype; - int ret; + int count, ret; /*! [log cursor open] */ ret = session->open_cursor(session, "log:", NULL, NULL, &cursor); /*! [log cursor open] */ + count = 0; while ((ret = cursor->next(cursor)) == 0) { + count++; /*! [log cursor get_key] */ ret = cursor->get_key(cursor, &lsn.file, &lsn.offset, &opcount); /*! [log cursor get_key] */ @@ -156,6 +158,12 @@ simple_walk_log(WT_SESSION *session) if (ret == WT_NOTFOUND) ret = 0; ret = cursor->close(cursor); + if (count < count_min) { + fprintf(stderr, + "Expected minimum %d records, found %d\n", + count_min, count); + abort(); + } return (ret); } /*! [log cursor walk] */ @@ -278,9 +286,10 @@ main(void) WT_CONNECTION *wt_conn; WT_CURSOR *cursor; WT_SESSION *session; - int i, record_count, ret; + int count_min, i, record_count, ret; char cmd_buf[256], k[16], v[16]; + count_min = 0; snprintf(cmd_buf, sizeof(cmd_buf), "rm -rf %s %s && mkdir %s %s", home1, home2, home1, home2); if ((ret = system(cmd_buf)) != 0) { @@ -295,6 +304,7 @@ main(void) ret = wt_conn->open_session(wt_conn, NULL, NULL, &session); ret = session->create(session, uri, "key_format=S,value_format=S"); + count_min++; ret = session->open_cursor(session, uri, NULL, NULL, &cursor); /* @@ -306,6 +316,7 @@ main(void) cursor->set_key(cursor, k); cursor->set_value(cursor, v); ret = cursor->insert(cursor); + count_min++; } ret = session->begin_transaction(session, NULL); /* @@ -319,10 +330,12 @@ main(void) ret = cursor->insert(cursor); } ret = session->commit_transaction(session, NULL); + count_min++; ret = cursor->close(cursor); /*! [log cursor printf] */ ret = session->log_printf(session, "Wrote %d records", record_count); + count_min++; /*! [log cursor printf] */ /* @@ -338,7 +351,7 @@ main(void) } ret = wt_conn->open_session(wt_conn, NULL, NULL, &session); - ret = simple_walk_log(session); + ret = simple_walk_log(session, count_min); ret = walk_log(session); ret = wt_conn->close(wt_conn, NULL); return (ret); |