summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/test/utility
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2016-04-05 14:43:57 +1000
committerAlex Gorrod <alexg@wiredtiger.com>2016-04-05 14:44:50 +1000
commitde6f136d83b20f8a58ba6fe4ba02be229b6c9159 (patch)
tree3221d66b54cbf6208fc3c995fdbb36d347ae85ff /src/third_party/wiredtiger/test/utility
parent5d1262cc394d685b59ae3185d7315227085e897d (diff)
downloadmongo-de6f136d83b20f8a58ba6fe4ba02be229b6c9159.tar.gz
Import wiredtiger-wiredtiger-2.8.0-134-g5047aab.tar.gz from wiredtiger branch mongodb-3.4
ref: 9cf8eb2..5047aab SERVER-23504 Coverity analysis defect 98177: Resource leak WT-2330 in-memory configurations should not create on-disk collection files WT-2513 conversion from 'int64_t' to 'uint32_t' WT-2522 Incorrect format code in message WT-2525 in-memory configurations: miscellaneous cleanups WT-2527 OS X compile error, missing POSIX_FADV_WILLNEED #define WT-2528 style error in WiredTiger build WT-2529 The readonly test case is crashing with a stack overflow WT-2531 in-memory tables are allocating unnecessary memory WT-2532 WT_STREAM_APPEND and WT_STREAM_LINE_BUFFER flag overlap WT-2533 Ensure that in-memory tables don't report a zero size SERVER-23517 WiredTiger changes for MongoDB 3.3.5
Diffstat (limited to 'src/third_party/wiredtiger/test/utility')
-rw-r--r--src/third_party/wiredtiger/test/utility/test_util.i47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/third_party/wiredtiger/test/utility/test_util.i b/src/third_party/wiredtiger/test/utility/test_util.i
index c5cebadcb5c..43982d9e4a1 100644
--- a/src/third_party/wiredtiger/test/utility/test_util.i
+++ b/src/third_party/wiredtiger/test/utility/test_util.i
@@ -101,13 +101,13 @@ testutil_die(int e, const char *fmt, ...)
* Creates the full intended work directory in buffer.
*/
static inline void
-testutil_work_dir_from_path(char *buffer, size_t inputSize, const char *dir)
+testutil_work_dir_from_path(char *buffer, size_t len, const char *dir)
{
/* If no directory is provided, use the default. */
if (dir == NULL)
dir = DEFAULT_DIR;
- if (inputSize < strlen(dir) + 1)
+ if (len < strlen(dir) + 1)
testutil_die(ENOMEM,
"Not enough memory in buffer for directory %s", dir);
@@ -116,55 +116,48 @@ testutil_work_dir_from_path(char *buffer, size_t inputSize, const char *dir)
/*
* testutil_clean_work_dir --
- * Remove any existing work directories, can optionally fail on error
+ * Remove the work directory.
*/
static inline void
testutil_clean_work_dir(char *dir)
{
- size_t inputSize;
+ size_t len;
int ret;
- bool exist;
- char *buffer;
+ char *buf;
/* Additional bytes for the Windows rd command. */
- inputSize = strlen(dir) + sizeof(RM_COMMAND);
- if ((buffer = malloc(inputSize)) == NULL)
+ len = strlen(dir) + strlen(RM_COMMAND) + 1;
+ if ((buf = malloc(len)) == NULL)
testutil_die(ENOMEM, "Failed to allocate memory");
- snprintf(buffer, inputSize, "%s%s", RM_COMMAND, dir);
+ snprintf(buf, len, "%s%s", RM_COMMAND, dir);
- exist = 0;
- if ((ret = __wt_exist(NULL, dir, &exist)) != 0)
- testutil_die(ret,
- "Unable to check if directory exists");
- if (exist == 1 && (ret = system(buffer)) != 0)
- testutil_die(ret,
- "System call to remove directory failed");
- free(buffer);
+ if ((ret = system(buf)) != 0 && ret != ENOENT)
+ testutil_die(ret, "%s", buf);
+ free(buf);
}
/*
* testutil_make_work_dir --
- * Delete the existing work directory if it exists, then create a new one.
+ * Delete the existing work directory, then create a new one.
*/
static inline void
testutil_make_work_dir(char *dir)
{
- size_t inputSize;
+ size_t len;
int ret;
- char *buffer;
+ char *buf;
testutil_clean_work_dir(dir);
/* Additional bytes for the mkdir command */
- inputSize = strlen(dir) + sizeof(MKDIR_COMMAND);
- if ((buffer = malloc(inputSize)) == NULL)
+ len = strlen(dir) + strlen(MKDIR_COMMAND) + 1;
+ if ((buf = malloc(len)) == NULL)
testutil_die(ENOMEM, "Failed to allocate memory");
/* mkdir shares syntax between Windows and Linux */
- snprintf(buffer, inputSize, "%s%s", MKDIR_COMMAND, dir);
- if ((ret = system(buffer)) != 0)
- testutil_die(ret, "directory create call of '%s%s' failed",
- MKDIR_COMMAND, dir);
- free(buffer);
+ snprintf(buf, len, "%s%s", MKDIR_COMMAND, dir);
+ if ((ret = system(buf)) != 0)
+ testutil_die(ret, "%s", buf);
+ free(buf);
}