1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 * Data Differential YATL (i.e. libtest) library
5 * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include "libtest/yatlcon.h"
38 #include <libtest/common.h>
46 bool has_libmemcached_sasl(void)
51 bool has_libmemcached(void)
53 #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
54 if (HAVE_LIBMEMCACHED
)
63 bool has_libdrizzle(void)
65 #if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE
75 bool has_postgres_support(void)
78 if (bool((getenv_ptr
= getenv("POSTGES_IS_RUNNING_AND_SETUP"))))
93 #if defined(GEARMAND_BINARY) && defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
94 if (HAVE_GEARMAND_BINARY
)
96 std::stringstream arg_buffer
;
99 if (bool((getenv_ptr
= getenv("PWD"))) and
100 ((strcmp(GEARMAND_BINARY
, "./gearmand/gearmand") == 0) or (strcmp(GEARMAND_BINARY
, "gearmand/gearmand") == 0)))
102 arg_buffer
<< getenv_ptr
;
105 arg_buffer
<< GEARMAND_BINARY
;
107 if (access(arg_buffer
.str().c_str(), X_OK
) == 0)
119 #if defined(DRIZZLED_BINARY) && defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY
120 if (HAVE_DRIZZLED_BINARY
)
122 if (access(DRIZZLED_BINARY
, X_OK
) == 0)
134 #if defined(MYSQLD_BINARY) && defined(HAVE_MYSQLD_BUILD) && HAVE_MYSQLD_BUILD
135 if (HAVE_MYSQLD_BUILD
)
137 if (access(MYSQLD_BINARY
, X_OK
) == 0)
147 static char memcached_binary_path
[FILENAME_MAX
];
149 static void initialize_memcached_binary_path()
151 memcached_binary_path
[0]= 0;
153 #if defined(MEMCACHED_BINARY) && defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
154 if (HAVE_MEMCACHED_BINARY
)
156 std::stringstream arg_buffer
;
159 if (bool((getenv_ptr
= getenv("PWD"))) and strcmp(MEMCACHED_BINARY
, "memcached/memcached") == 0)
161 arg_buffer
<< getenv_ptr
;
164 arg_buffer
<< MEMCACHED_BINARY
;
166 if (access(arg_buffer
.str().c_str(), X_OK
) == 0)
168 strncpy(memcached_binary_path
, arg_buffer
.str().c_str(), FILENAME_MAX
);
174 static pthread_once_t memcached_binary_once
= PTHREAD_ONCE_INIT
;
175 static void initialize_memcached_binary(void)
178 if ((ret
= pthread_once(&memcached_binary_once
, initialize_memcached_binary_path
)) != 0)
180 FATAL(strerror(ret
));
186 initialize_memcached_binary();
188 if (memcached_binary_path
[0] and (strlen(memcached_binary_path
) > 0))
196 const char* memcached_binary()
198 initialize_memcached_binary();
200 if (memcached_binary_path
[0])
202 return memcached_binary_path
;
208 const char *gearmand_binary()
210 #if defined(GEARMAND_BINARY)
211 return GEARMAND_BINARY
;
217 const char *drizzled_binary()
219 #if defined(DRIZZLED_BINARY)
220 return DRIZZLED_BINARY
;
226 } // namespace libtest