summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-06-26 18:34:57 -0400
committerGitHub <noreply@github.com>2017-06-26 18:34:57 -0400
commitf380bcf23b696743e50913b0c0245df212b19ebd (patch)
tree7d335bb746ee20b6b8a21eecc992784335b13351
parent7447cce1eb75659b00489b200be6aae9be7e3a03 (diff)
downloadmongo-f380bcf23b696743e50913b0c0245df212b19ebd.tar.gz
WT-1939 Improve error handling in example code (#3484)
* WT-1939 Improve error handling in example code Fix a typo in some not-normally-compiled code. * Add a smoke-test program that can be used to test compile and library loads. (We've been using ex_access, but it now requires test_util include files and libraries, which is too complicated.) * Don't bother building ex_smoke on Windows, it would require dealing with the Windows shim file and it's not worth the effort.
-rw-r--r--examples/c/Makefile.am1
-rw-r--r--examples/c/ex_all.c2
-rw-r--r--examples/c/ex_smoke.c67
3 files changed, 69 insertions, 1 deletions
diff --git a/examples/c/Makefile.am b/examples/c/Makefile.am
index f79a4ff3fb2..41a9bcdc6bb 100644
--- a/examples/c/Makefile.am
+++ b/examples/c/Makefile.am
@@ -22,6 +22,7 @@ noinst_PROGRAMS = \
ex_pack \
ex_process \
ex_schema \
+ ex_smoke \
ex_stat \
ex_sync \
ex_thread
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c
index 0384c711697..7dce4744db3 100644
--- a/examples/c/ex_all.c
+++ b/examples/c/ex_all.c
@@ -667,7 +667,7 @@ session_ops(WT_SESSION *session)
/* Requires posix_fadvise */
/*! [os_cache_max configuration] */
error_check(session->create(
- session, "table:mytable", "os_cache_max=1GB");
+ session, "table:mytable", "os_cache_max=1GB"));
/*! [os_cache_max configuration] */
error_check(session->drop(session, "table:mytable", NULL));
#endif
diff --git a/examples/c/ex_smoke.c b/examples/c/ex_smoke.c
new file mode 100644
index 00000000000..ab4e085d2f0
--- /dev/null
+++ b/examples/c/ex_smoke.c
@@ -0,0 +1,67 @@
+/*-
+ * Public Domain 2014-2017 MongoDB, Inc.
+ * Public Domain 2008-2014 WiredTiger, Inc.
+ *
+ * This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * In jurisdictions that recognize copyright laws, the author or authors
+ * of this software dedicate any and all copyright interest in the
+ * software to the public domain. We make this dedication for the benefit
+ * of the public at large and to the detriment of our heirs and
+ * successors. We intend this dedication to be an overt act of
+ * relinquishment in perpetuity of all present and future rights to this
+ * software under copyright law.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ex_smoke.c
+ * A simple program you can build to prove include files and libraries
+ * are linking correctly.
+ */
+#include <stdlib.h>
+
+#include <wiredtiger.h>
+
+int
+main(int argc, char *argv[])
+{
+ WT_CONNECTION *conn;
+ int ret;
+
+ (void)argc; /* Unused variable */
+
+ /*
+ * This code deliberately doesn't use the standard test_util macros,
+ * we don't want to link against that code to smoke-test a build.
+ */
+ (void)system("rm -rf WT_HOME && mkdir WT_HOME");
+
+ /* Open a connection to the database, creating it if necessary. */
+ if ((ret = wiredtiger_open("WT_HOME", NULL, "create", &conn)) != 0) {
+ fprintf(stderr,
+ "%s: wiredtiger_open: %s\n",
+ argv[0], wiredtiger_strerror(ret));
+ return (EXIT_FAILURE);
+ }
+
+ /* Close the connection to the database. */
+ if ((ret = conn->close(conn, NULL)) != 0) {
+ fprintf(stderr,
+ "%s: WT_CONNECTION.close: %s\n",
+ argv[0], wiredtiger_strerror(ret));
+ return (EXIT_FAILURE);
+ }
+
+ return (EXIT_SUCCESS);
+}