From: Brian Aker Date: Wed, 27 Jul 2011 18:56:27 +0000 (-0700) Subject: Update from trunk to launchpad X-Git-Tag: 1.0.2~25^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=6b2e8e60c388754cbe4f9bb3eb38f870544615c8;hp=a4f7c3b9413014291d0ca549f32455b3be10a6c0;p=m6w6%2Flibmemcached Update from trunk to launchpad --- diff --git a/.bzrignore b/.bzrignore index f091ff10..e1a61fbc 100644 --- a/.bzrignore +++ b/.bzrignore @@ -113,3 +113,4 @@ unittests/unittests out *.orig tests/memcapable +tests/memslap diff --git a/clients/execute.cc b/clients/execute.cc index 7f89f773..1ada836f 100644 --- a/clients/execute.cc +++ b/clients/execute.cc @@ -14,25 +14,28 @@ Return the number of rows set. */ -#include "config.h" +#include #include "execute.h" unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { - memcached_return_t rc; unsigned int x; unsigned int pairs_sent; for (x= 0, pairs_sent= 0; x < number_of; x++) { - rc= memcached_set(memc, pairs[x].key, pairs[x].key_length, - pairs[x].value, pairs[x].value_length, - 0, 0); + memcached_return_t rc= memcached_set(memc, pairs[x].key, pairs[x].key_length, + pairs[x].value, pairs[x].value_length, + 0, 0); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_BUFFERED) + { fprintf(stderr, "Failured on insert of %.*s\n", (unsigned int)pairs[x].key_length, pairs[x].key); + } else + { pairs_sent++; + } } return pairs_sent; diff --git a/clients/memslap.cc b/clients/memslap.cc index d8927e7e..095cd088 100644 --- a/clients/memslap.cc +++ b/clients/memslap.cc @@ -37,18 +37,20 @@ #include -#include -#include -#include -#include -#include -#include -#include + +#include +#include +#include +#include #include -#include #include +#include #include -#include +#include +#include +#include +#include +#include #include @@ -65,23 +67,16 @@ #define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers." /* Global Thread counter */ -volatile unsigned int thread_counter; -pthread_mutex_t counter_mutex; -pthread_cond_t count_threshhold; volatile unsigned int master_wakeup; pthread_mutex_t sleeper_mutex; pthread_cond_t sleep_threshhold; -void *run_task(void *p); - /* Types */ -typedef struct conclusions_st conclusions_st; -typedef struct thread_context_st thread_context_st; -typedef enum { +enum test_t { SET_TEST, GET_TEST, MGET_TEST -} test_type; +}; struct thread_context_st { unsigned int key_count; @@ -91,8 +86,37 @@ struct thread_context_st { unsigned int execute_number; char **keys; size_t *key_lengths; - test_type test; + test_t test; memcached_st *memc; + const memcached_st* root; + + thread_context_st(const memcached_st* memc_arg, test_t test_arg) : + key_count(0), + initial_pairs(NULL), + initial_number(0), + execute_pairs(NULL), + execute_number(0), + keys(0), + key_lengths(NULL), + test(test_arg), + memc(NULL), + root(memc_arg) + { + } + + void init() + { + memc= memcached_clone(NULL, root); + } + + ~thread_context_st() + { + if (execute_pairs) + { + pairs_free(execute_pairs); + } + memcached_free(memc); + } }; struct conclusions_st { @@ -100,6 +124,13 @@ struct conclusions_st { long int read_time; unsigned int rows_loaded; unsigned int rows_read; + + conclusions_st() : + load_time(0), + read_time(0), + rows_loaded(0), + rows_read() + { } }; /* Prototypes */ @@ -121,35 +152,72 @@ static unsigned int opt_concurrency= 0; static int opt_displayflag= 0; static char *opt_servers= NULL; static int opt_udp_io= 0; -test_type opt_test= SET_TEST; +test_t opt_test= SET_TEST; + +extern "C" { + +static void *run_task(void *p) +{ + thread_context_st *context= (thread_context_st *)p; + + context->init(); + + pthread_mutex_lock(&sleeper_mutex); + while (master_wakeup) + { + pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); + } + pthread_mutex_unlock(&sleeper_mutex); + + /* Do Stuff */ + switch (context->test) + { + case SET_TEST: + assert(context->execute_pairs); + execute_set(context->memc, context->execute_pairs, context->execute_number); + break; + + case GET_TEST: + execute_get(context->memc, context->initial_pairs, context->initial_number); + break; + + case MGET_TEST: + execute_mget(context->memc, (const char*const*)context->keys, context->key_lengths, context->initial_number); + break; + } + + delete context; + + pthread_exit(0); +} + +} + int main(int argc, char *argv[]) { conclusions_st conclusion; - memcached_server_st *servers; - - memset(&conclusion, 0, sizeof(conclusions_st)); srandom((unsigned int)time(NULL)); options_parse(argc, argv); - if (!opt_servers) + if (opt_servers == NULL) { char *temp; if ((temp= getenv("MEMCACHED_SERVERS"))) + { opt_servers= strdup(temp); + } else { fprintf(stderr, "No Servers provided\n"); - exit(1); + return EXIT_FAILURE; } } - servers= memcached_servers_parse(opt_servers); + memcached_server_st *servers= memcached_servers_parse(opt_servers); - pthread_mutex_init(&counter_mutex, NULL); - pthread_cond_init(&count_threshhold, NULL); pthread_mutex_init(&sleeper_mutex, NULL); pthread_cond_init(&sleep_threshhold, NULL); @@ -157,31 +225,22 @@ int main(int argc, char *argv[]) free(opt_servers); - (void)pthread_mutex_destroy(&counter_mutex); - (void)pthread_cond_destroy(&count_threshhold); (void)pthread_mutex_destroy(&sleeper_mutex); (void)pthread_cond_destroy(&sleep_threshhold); conclusions_print(&conclusion); memcached_server_list_free(servers); - return 0; + return EXIT_SUCCESS; } void scheduler(memcached_server_st *servers, conclusions_st *conclusion) { unsigned int actual_loaded= 0; /* Fix warning */ - memcached_st *memc; struct timeval start_time, end_time; - pthread_t mainthread; /* Thread descriptor */ - pthread_attr_t attr; /* Thread attributes */ pairs_st *pairs= NULL; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, - PTHREAD_CREATE_DETACHED); - - memc= memcached_create(NULL); + memcached_st *memc= memcached_create(NULL); /* We need to set udp behavior before adding servers to the client */ if (opt_udp_io) @@ -200,13 +259,14 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) if (opt_flush) flush_all(memc); + if (opt_createial_load) pairs= load_create_data(memc, opt_createial_load, &actual_loaded); char **keys= static_cast(calloc(actual_loaded, sizeof(char*))); size_t *key_lengths= static_cast(calloc(actual_loaded, sizeof(size_t))); - if (keys == NULL || key_lengths == NULL) + if (keys == NULL or key_lengths == NULL) { free(keys); free(key_lengths); @@ -226,23 +286,25 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) { if (opt_non_blocking_io) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1); + if (opt_tcp_nodelay) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); } - pthread_mutex_lock(&counter_mutex); - thread_counter= 0; - pthread_mutex_lock(&sleeper_mutex); master_wakeup= 1; pthread_mutex_unlock(&sleeper_mutex); - for (uint32_t x= 0; x < opt_concurrency; x++) + pthread_t *threads= new (std::nothrow) pthread_t[opt_concurrency]; + + if (not threads) { - thread_context_st *context; - context= (thread_context_st *)calloc(1, sizeof(thread_context_st)); + exit(EXIT_FAILURE); + } - context->memc= memcached_clone(NULL, memc); + for (uint32_t x= 0; x < opt_concurrency; x++) + { + thread_context_st *context= new thread_context_st(memc, opt_test); context->test= opt_test; context->initial_pairs= pairs; @@ -257,31 +319,25 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion) } /* now you create the thread */ - if (pthread_create(&mainthread, &attr, run_task, - (void *)context) != 0) + if (pthread_create(threads +x, NULL, run_task, (void *)context) != 0) { fprintf(stderr,"Could not create thread\n"); exit(1); } - thread_counter++; } - pthread_mutex_unlock(&counter_mutex); - pthread_attr_destroy(&attr); - pthread_mutex_lock(&sleeper_mutex); master_wakeup= 0; pthread_mutex_unlock(&sleeper_mutex); pthread_cond_broadcast(&sleep_threshhold); - gettimeofday(&start_time, NULL); - /* - We loop until we know that all children have cleaned up. - */ - pthread_mutex_lock(&counter_mutex); - while (thread_counter) - pthread_cond_wait(&count_threshhold, &counter_mutex); - pthread_mutex_unlock(&counter_mutex); + + for (uint32_t x= 0; x < opt_concurrency; x++) + { + void *retval; + pthread_join(threads[x], &retval); + } + delete [] threads; gettimeofday(&end_time, NULL); @@ -331,6 +387,7 @@ void options_parse(int argc, char *argv[]) { case 0: break; + case OPT_UDP: if (opt_test == GET_TEST) { @@ -340,24 +397,31 @@ void options_parse(int argc, char *argv[]) } opt_udp_io= 1; break; + case OPT_BINARY: opt_binary = 1; break; + case OPT_VERBOSE: /* --verbose or -v */ opt_verbose = OPT_VERBOSE; break; + case OPT_DEBUG: /* --debug or -d */ opt_verbose = OPT_DEBUG; break; + case OPT_VERSION: /* --version or -V */ version_command(PROGRAM_NAME); break; + case OPT_HELP: /* --help or -h */ help_command(PROGRAM_NAME, PROGRAM_DESCRIPTION, long_options, help_options); break; + case OPT_SERVERS: /* --servers or -s */ opt_servers= strdup(optarg); break; + case OPT_SLAP_TEST: if (!strcmp(optarg, "get")) { @@ -370,7 +434,9 @@ void options_parse(int argc, char *argv[]) opt_test= GET_TEST ; } else if (!strcmp(optarg, "set")) + { opt_test= SET_TEST; + } else if (!strcmp(optarg, "mget")) { opt_test= MGET_TEST; @@ -381,24 +447,29 @@ void options_parse(int argc, char *argv[]) exit(1); } break; + case OPT_SLAP_CONCURRENCY: opt_concurrency= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; + case OPT_SLAP_EXECUTE_NUMBER: opt_execute_number= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; + case OPT_SLAP_INITIAL_LOAD: opt_createial_load= (unsigned int)strtoul(optarg, (char **)NULL, 10); break; + case '?': /* getopt_long already printed an error message. */ exit(1); + default: abort(); } } - if ((opt_test == GET_TEST || opt_test == MGET_TEST) && opt_createial_load == 0) + if ((opt_test == GET_TEST or opt_test == MGET_TEST) && opt_createial_load == 0) opt_createial_load= DEFAULT_INITIAL_LOAD; if (opt_execute_number == 0) @@ -423,54 +494,6 @@ void conclusions_print(conclusions_st *conclusion) conclusion->read_time % 1000); } -void *run_task(void *p) -{ - thread_context_st *context= (thread_context_st *)p; - memcached_st *memc; - - memc= context->memc; - - pthread_mutex_lock(&sleeper_mutex); - while (master_wakeup) - { - pthread_cond_wait(&sleep_threshhold, &sleeper_mutex); - } - pthread_mutex_unlock(&sleeper_mutex); - - /* Do Stuff */ - switch (context->test) - { - case SET_TEST: - assert(context->execute_pairs); - execute_set(memc, context->execute_pairs, context->execute_number); - break; - case GET_TEST: - execute_get(memc, context->initial_pairs, context->initial_number); - break; - case MGET_TEST: - execute_mget(memc, (const char*const*)context->keys, context->key_lengths, - context->initial_number); - break; - default: - WATCHPOINT_ASSERT(context->test); - break; - } - - memcached_free(memc); - - if (context->execute_pairs) - pairs_free(context->execute_pairs); - - free(context); - - pthread_mutex_lock(&counter_mutex); - thread_counter--; - pthread_cond_signal(&count_threshhold); - pthread_mutex_unlock(&counter_mutex); - - return NULL; -} - void flush_all(memcached_st *memc) { memcached_flush(memc, 0); @@ -479,14 +502,11 @@ void flush_all(memcached_st *memc) pairs_st *load_create_data(memcached_st *memc, unsigned int number_of, unsigned int *actual_loaded) { - memcached_st *memc_clone; - pairs_st *pairs; - - memc_clone= memcached_clone(NULL, memc); + memcached_st *memc_clone= memcached_clone(NULL, memc); /* We always used non-blocking IO for load since it is faster */ memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); - pairs= pairs_generate(number_of, 400); + pairs_st *pairs= pairs_generate(number_of, 400); *actual_loaded= execute_set(memc_clone, pairs, number_of); memcached_free(memc_clone); diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 8727b289..e3638b46 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -131,7 +131,7 @@ static memcached_return_t set_hostinfo(memcached_server_st *server) char str_port[NI_MAXSERV]; int length= snprintf(str_port, NI_MAXSERV, "%u", (uint32_t)server->port); - if (length >= NI_MAXSERV || length < 0) + if (length >= NI_MAXSERV or length < 0) { return MEMCACHED_FAILURE; } diff --git a/libtest/COPYING.LESSER b/libtest/COPYING.LESSER new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/libtest/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/libtest/blobslap_worker.cc b/libtest/blobslap_worker.cc new file mode 100644 index 00000000..c7ac0a02 --- /dev/null +++ b/libtest/blobslap_worker.cc @@ -0,0 +1,165 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include +#include +#include + +using namespace libtest; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wold-style-cast" +#endif + +using namespace libtest; + +class BlobslapWorker : public Server +{ +private: +public: + BlobslapWorker(in_port_t port_arg) : + Server("localhost", port_arg) + { } + + pid_t get_pid(bool error_is_ok) + { + if (not pid_file().empty()) + { + Wait wait(pid_file(), 0); + + if (error_is_ok and not wait.successful()) + { + Error << "Pidfile was not found:" << pid_file(); + return -1; + + return get_pid_from_file(pid_file()); + } + } + + return -1; + } + + bool ping() + { + if (pid_file().empty()) + { + Error << "No pid file available"; + return false; + } + + Wait wait(pid_file(), 0); + if (not wait.successful()) + { + Error << "Pidfile was not found:" << pid_file(); + return false; + } + + pid_t local_pid= get_pid_from_file(pid_file()); + if (local_pid <= 0) + { + return false; + } + + if (::kill(local_pid, 0) == 0) + { + return true; + } + + return false; + } + + const char *name() + { + return "blobslap_worker"; + }; + + const char *executable() + { + return GEARMAND_BLOBSLAP_WORKER; + } + + const char *pid_file_option() + { + return "--pid-file="; + } + + const char *daemon_file_option() + { + return "--daemon"; + } + + const char *log_file_option() + { + return NULL; + } + + const char *port_option() + { + return "--port="; + } + + bool is_libtool() + { + return true; + } + + bool build(int argc, const char *argv[]); +}; + + +#include + +bool BlobslapWorker::build(int argc, const char *argv[]) +{ + std::stringstream arg_buffer; + + for (int x= 1 ; x < argc ; x++) + { + arg_buffer << " " << argv[x] << " "; + } + + set_extra_args(arg_buffer.str()); + + return true; +} + +namespace libtest { + +Server *build_blobslap_worker(in_port_t try_port) +{ + return new BlobslapWorker(try_port); +} + +} diff --git a/libtest/blobslap_worker.h b/libtest/blobslap_worker.h new file mode 100644 index 00000000..284b2351 --- /dev/null +++ b/libtest/blobslap_worker.h @@ -0,0 +1,28 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#pragma once + +namespace libtest { + +Server *build_blobslap_worker(in_port_t try_port); + +} diff --git a/libtest/callbacks.h b/libtest/callbacks.h index ea587bd9..c696526c 100644 --- a/libtest/callbacks.h +++ b/libtest/callbacks.h @@ -1,9 +1,25 @@ -/* uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #ifdef __cplusplus diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 2b67a47d..6c71f9b0 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -1,43 +1,30 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include +using namespace libtest; + #include #include #include @@ -48,13 +35,27 @@ bool exec_cmdline(const std::string& executable, const char *args[]) arg_buffer << "./libtool --mode=execute "; + if (getenv("LIBTEST_TEST_ENVIRONMENT")) + { + arg_buffer << getenv("LIBTEST_TEST_ENVIRONMENT"); + arg_buffer << " "; + } + arg_buffer << executable; for (const char **ptr= args; *ptr; ++ptr) { arg_buffer << " " << *ptr; } - arg_buffer << " > /dev/null 2>&1"; + if (getenv("LIBTEST_TEST_ENVIRONMENT")) + { + std::cerr << std::endl << arg_buffer.str() << std::endl; + } + else + { + arg_buffer << " > /dev/null 2>&1"; + } + if (system(arg_buffer.str().c_str()) == -1) { return false; diff --git a/libtest/cmdline.h b/libtest/cmdline.h index 582cb4a5..cfe29575 100644 --- a/libtest/cmdline.h +++ b/libtest/cmdline.h @@ -1,37 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/collection.h b/libtest/collection.h index e8f8f62c..940e7362 100644 --- a/libtest/collection.h +++ b/libtest/collection.h @@ -1,9 +1,25 @@ -/* uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once /** diff --git a/libtest/common.h b/libtest/common.h index c59981aa..c2fe5144 100644 --- a/libtest/common.h +++ b/libtest/common.h @@ -1,40 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ All - * rights reserved. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + /* Common include file for libmemached */ diff --git a/libtest/comparison.hpp b/libtest/comparison.hpp index 86661a28..8656e499 100644 --- a/libtest/comparison.hpp +++ b/libtest/comparison.hpp @@ -4,34 +4,19 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/core.h b/libtest/core.h index 2b62161b..f787d0a1 100644 --- a/libtest/core.h +++ b/libtest/core.h @@ -1,10 +1,25 @@ -/* - * uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once LIBTEST_API diff --git a/libtest/error.h b/libtest/error.h index ca6c575d..047d66b8 100644 --- a/libtest/error.h +++ b/libtest/error.h @@ -4,34 +4,19 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libtest/failed.cc b/libtest/failed.cc index f0f0e652..11e237dc 100644 --- a/libtest/failed.cc +++ b/libtest/failed.cc @@ -1,40 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest Framework + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include diff --git a/libtest/failed.h b/libtest/failed.h index a4b2cacc..1134d323 100644 --- a/libtest/failed.h +++ b/libtest/failed.h @@ -1,38 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest Framework + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/framework.cc b/libtest/framework.cc index deb9045d..1541e7da 100644 --- a/libtest/framework.cc +++ b/libtest/framework.cc @@ -1,37 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libtest/framework.h b/libtest/framework.h index 087268cc..69941b1b 100644 --- a/libtest/framework.h +++ b/libtest/framework.h @@ -1,40 +1,26 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once /** diff --git a/libtest/gearmand.cc b/libtest/gearmand.cc index f526e015..9a7649ef 100644 --- a/libtest/gearmand.cc +++ b/libtest/gearmand.cc @@ -4,36 +4,22 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include @@ -208,6 +194,8 @@ bool Gearmand::build(int argc, const char *argv[]) arg_buffer << " -u root "; } + arg_buffer << " --listen=127.0.0.1 "; + for (int x= 1 ; x < argc ; x++) { arg_buffer << " " << argv[x] << " "; diff --git a/libtest/gearmand.h b/libtest/gearmand.h index 6d311ead..22aaa713 100644 --- a/libtest/gearmand.h +++ b/libtest/gearmand.h @@ -4,36 +4,22 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once namespace libtest { diff --git a/libtest/get.h b/libtest/get.h index 2cd9dec8..759700e3 100644 --- a/libtest/get.h +++ b/libtest/get.h @@ -1,10 +1,25 @@ -/* - * uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #ifdef __cplusplus diff --git a/libtest/include.am b/libtest/include.am index 7cda0f9b..71b5821f 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -1,20 +1,38 @@ # vim:ft=automake -# Copyright (C) 2011 Data Differential (http://datadifferential.com/) +# Copyright (C) 2011 Data Differential, http://datadifferential.com/ # All rights reserved. # -# Use and distribution licensed under the BSD license. See -# the COPYING file in the parent directory for full text. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # included from Top Level Makefile.am # All paths should be given relative to the root # -LIBUTEST_TMP = ${abs_top_builddir}/tests/var/tmp/ +LIBTEST_TMP = ${abs_top_builddir}/tests/var/tmp/ -VALGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE -HELGRIND_COMMAND= $(LIBTOOL) --mode=execute valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 -v -DRD_COMMAND= $(LIBTOOL) --mode=execute valgrind --tool=drd -GDB_COMMAND= $(LIBTOOL) --mode=execute gdb -f -x libtest/run.gdb +LIBTOOL_COMMAND=$(LIBTOOL) --mode=execute +VALGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE +HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 +DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd +GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb + +export LIBTOOL_COMMAND +export VALGRIND_COMMAND +export HELGRIND_COMMAND +export DRD_COMMAND +export GDB_COMMAND EXTRA_DIST+= libtest/run.gdb @@ -24,11 +42,12 @@ CLEANFILES+= \ tests/var/tmp/* noinst_HEADERS+= \ + libtest/blobslap_worker.h \ libtest/callbacks.h \ libtest/cmdline.h \ libtest/collection.h \ - libtest/comparison.hpp \ libtest/common.h \ + libtest/comparison.hpp \ libtest/core.h \ libtest/error.h \ libtest/failed.h \ @@ -77,34 +96,37 @@ endif if HAVE_LIBGEARMAN LIBTEST_LDADD+= libgearman/libgearman.la +libtest_libtest_la_SOURCES+= libtest/blobslap_worker.cc libtest_libtest_la_SOURCES+= libtest/gearmand.cc libtest_libtest_la_SOURCES+= util/instance.cc +libtest_libtest_la_SOURCES+= util/operation.cc endif +libtest_tmp_dir: tests/var/log tests/var/tmp tests/var/run clearn-var + clearn-var: @rm -f tests/var/log/* @rm -f tests/var/run/* @rm -f tests/var/tmp/* +tests/var: + @$(mkdir_p) tests/var -tests/var: tests/var/log tests/var/tmp tests/var/run clearn-var - $(mkdir_p) tests/var - -tests/var/log: - $(mkdir_p) tests/var/log +tests/var/log: tests/var + @$(mkdir_p) tests/var/log -tests/var/tmp: - $(mkdir_p) tests/var/tmp +tests/var/tmp: tests/var + @$(mkdir_p) tests/var/tmp -tests/var/run: - $(mkdir_p) tests/var/run +tests/var/run: tests/var + @$(mkdir_p) tests/var/run .PHONY+= tests/var libtest_unittest_CFLAGS= libtest_unittest_LDADD= ${LIBTEST_LDADD} -libtest_unittest_DEPENDENCIES= ${LIBTEST_LDADD} +libtest_unittest_DEPENDENCIES= ${LIBTEST_LDADD} libtest_tmp_dir libtest_unittest_SOURCES= libtest/unittest.cc check_PROGRAMS+= libtest/unittest noinst_PROGRAMS+= libtest/unittest diff --git a/libtest/killpid.cc b/libtest/killpid.cc index bc9a5594..7bbdd636 100644 --- a/libtest/killpid.cc +++ b/libtest/killpid.cc @@ -1,39 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include @@ -99,12 +85,13 @@ bool kill_pid(pid_t pid_arg) } -void kill_file(const std::string &filename) +pid_t kill_file(const std::string &filename) { + pid_t ret= -1; FILE *fp; if (filename.empty()) - return; + return ret; if ((fp= fopen(filename.c_str(), "r"))) { @@ -123,4 +110,37 @@ void kill_file(const std::string &filename) } } } + + return ret; +} + +pid_t get_pid_from_file(const std::string &filename) +{ + pid_t ret= -1; + FILE *fp; + + if (filename.empty()) + { + Error << "empty pid file"; + return ret; + } + + if ((fp= fopen(filename.c_str(), "r"))) + { + char pid_buffer[1024]; + + char *ptr= fgets(pid_buffer, sizeof(pid_buffer), fp); + fclose(fp); + + if (ptr) + { + ret= (pid_t)atoi(pid_buffer); + if (ret <= 0) + { + return ret; + } + } + } + + return ret; } diff --git a/libtest/killpid.h b/libtest/killpid.h index d67ec94b..83c7bb0a 100644 --- a/libtest/killpid.h +++ b/libtest/killpid.h @@ -1,42 +1,30 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once bool kill_pid(pid_t pid_arg); -void kill_file(const std::string &filename); +pid_t kill_file(const std::string &filename); + +pid_t get_pid_from_file(const std::string &filename); diff --git a/libtest/memcached.cc b/libtest/memcached.cc index e7112ed6..475449a9 100644 --- a/libtest/memcached.cc +++ b/libtest/memcached.cc @@ -4,36 +4,22 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include diff --git a/libtest/memcached.h b/libtest/memcached.h index 5620400a..575ba001 100644 --- a/libtest/memcached.h +++ b/libtest/memcached.h @@ -4,34 +4,19 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/runner.cc b/libtest/runner.cc index 808fb13c..b205b0e7 100644 --- a/libtest/runner.cc +++ b/libtest/runner.cc @@ -1,39 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include namespace libtest { diff --git a/libtest/runner.h b/libtest/runner.h index 8eb5480a..217e2697 100644 --- a/libtest/runner.h +++ b/libtest/runner.h @@ -1,9 +1,25 @@ -/* uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once diff --git a/libtest/server.cc b/libtest/server.cc index d5329b11..c2f38ba9 100644 --- a/libtest/server.cc +++ b/libtest/server.cc @@ -1,39 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * Libtest library + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include @@ -58,6 +44,7 @@ static inline std::string &rtrim(std::string &s) #ifdef HAVE_LIBGEARMAN #include +#include #endif #ifdef HAVE_LIBMEMCACHED @@ -324,23 +311,26 @@ bool Server::set_log_file() void Server::rebuild_base_command() { _base_command.clear(); - if (is_libtool()) + if (is_libtool() and getenv("LIBTOOL_COMMAND")) { - _base_command+= "./libtool --mode=execute "; + _base_command+= getenv("LIBTOOL_COMMAND"); + _base_command+= " "; } - if (is_debug()) + if (is_debug() and getenv("GDB_COMMAND")) { - _base_command+= "gdb "; + _base_command+= getenv("GDB_COMMAND"); + _base_command+= " "; } - else if (is_valgrind()) + else if (is_valgrind() and getenv("VALGRIND_COMMAND")) { - _base_command+= "valgrind --log-file=tests/var/tmp/valgrind.out --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE "; - + _base_command+= getenv("VALGRIND_COMMAND"); + _base_command+= " "; } - else if (is_helgrind()) + else if (is_helgrind() and getenv("HELGRIND_COMMAND")) { - _base_command+= "valgrind --log-file=tests/var/tmp/helgrind.out --tool=helgrind --read-var-info=yes --error-exitcode=1 -v "; + _base_command+= getenv("HELGRIND_COMMAND"); + _base_command+= " "; } _base_command+= executable(); @@ -359,7 +349,9 @@ bool Server::args(std::string& options) if (getenv("LIBTEST_LOG") and log_file_option()) { if (not set_log_file()) + { return false; + } arg_buffer << " " << log_file_option() << _log_file; } @@ -368,7 +360,9 @@ bool Server::args(std::string& options) if (pid_file_option()) { if (not set_pid_file()) + { return false; + } arg_buffer << " " << pid_file_option() << pid_file(); } @@ -382,7 +376,9 @@ bool Server::args(std::string& options) if (_is_socket and socket_file_option()) { if (not set_socket_file()) + { return false; + } arg_buffer << " " << socket_file_option() << "\"" << _socket << "\""; } @@ -396,7 +392,9 @@ bool Server::args(std::string& options) options+= arg_buffer.str(); if (not _extra_args.empty()) + { options+= _extra_args; + } return true; } @@ -544,6 +542,18 @@ bool server_startup(server_startup_st& construct, const std::string& server_type #endif #else Error << "No gearmand binary is available"; +#endif + } + else if (server_type.compare("blobslap_worker") == 0) + { +#ifdef GEARMAND_BINARY + #ifdef HAVE_LIBGEARMAN + server= build_blobslap_worker(try_port); + #else + Error << "Libgearman was not found"; + #endif +#else + Error << "No gearmand binary is available"; #endif } else if (server_type.compare("memcached") == 0) diff --git a/libtest/server.h b/libtest/server.h index d987a0b7..a38bf428 100644 --- a/libtest/server.h +++ b/libtest/server.h @@ -1,10 +1,22 @@ -/* - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker - * All rights reserved. +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/signal.cc b/libtest/signal.cc index 45d0fd9e..50234d8d 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -1,39 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include @@ -62,10 +48,11 @@ void SignalThread::set_shutdown(shutdown_t arg) if (arg == SHUTDOWN_GRACEFUL) { - pthread_kill(thread, SIGUSR2); - - void *retval; - pthread_join(thread, &retval); + if (pthread_kill(thread, SIGUSR2) == 0) + { + void *retval; + pthread_join(thread, &retval); + } } } @@ -96,6 +83,16 @@ void SignalThread::test() assert(sigismember(&set, SIGUSR2)); } +SignalThread::~SignalThread() +{ + if (pthread_equal(thread, pthread_self()) != 0 and (pthread_kill(thread, 0) == ESRCH) == true) + { + void *retval; + pthread_join(thread, &retval); + } + sem_destroy(&lock); +} + extern "C" { static void *sig_thread(void *arg) @@ -123,7 +120,6 @@ static void *sig_thread(void *arg) case SIGQUIT: if (context->is_shutdown() == false) { - Error << "Signal handling thread got signal " << strsignal(sig); context->set_shutdown(SHUTDOWN_FORCED); } break; @@ -140,7 +136,8 @@ static void *sig_thread(void *arg) } SignalThread::SignalThread() : - magic_memory(MAGIC_MEMORY) + magic_memory(MAGIC_MEMORY), + thread(pthread_self()) { pthread_mutex_init(&shutdown_mutex, NULL); sigemptyset(&set); diff --git a/libtest/signal.h b/libtest/signal.h index eb092825..5cc823ac 100644 --- a/libtest/signal.h +++ b/libtest/signal.h @@ -1,40 +1,26 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #include @@ -69,10 +55,7 @@ public: return sigwait(&set, &sig); } - ~SignalThread() - { - sem_destroy(&lock); - } + ~SignalThread(); void set_shutdown(shutdown_t arg); bool is_shutdown(); diff --git a/libtest/stats.h b/libtest/stats.h index 29be06c6..3224d40d 100644 --- a/libtest/stats.h +++ b/libtest/stats.h @@ -1,9 +1,25 @@ -/* uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once struct Stats { int32_t collection_success; diff --git a/libtest/stream.h b/libtest/stream.h index ed5a03e5..83b1e2d1 100644 --- a/libtest/stream.h +++ b/libtest/stream.h @@ -1,37 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/strerror.h b/libtest/strerror.h index 2d6e6536..5f21b83c 100644 --- a/libtest/strerror.h +++ b/libtest/strerror.h @@ -1,8 +1,22 @@ -/* - * uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #pragma once diff --git a/libtest/string.hpp b/libtest/string.hpp index f747eef0..8c3d50c1 100644 --- a/libtest/string.hpp +++ b/libtest/string.hpp @@ -4,36 +4,22 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #include "util/string.hpp" diff --git a/libtest/test.cc b/libtest/test.cc index d71057d3..1ed61578 100644 --- a/libtest/test.cc +++ b/libtest/test.cc @@ -1,38 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest, libtest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * Copyright (C) 2006-2009 Brian Aker * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include @@ -94,6 +78,11 @@ void set_default_socket(const char *socket) static void stats_print(Stats *stats) { + if (stats->collection_failed == 0 and stats->collection_success == 0) + { + return; + } + Out << "\tTotal Collections\t\t\t\t" << stats->collection_total; Out << "\tFailed Collections\t\t\t\t" << stats->collection_failed; Out << "\tSkipped Collections\t\t\t\t" << stats->collection_skipped; @@ -179,9 +168,21 @@ int main(int argc, char *argv[]) test_return_t error; void *creators_ptr= world->create(error); - if (test_failed(error)) + + switch (error) { - Error << "create() failed"; + case TEST_SUCCESS: + break; + + case TEST_SKIPPED: + Out << "SKIP " << argv[0]; + delete world; + return EXIT_SUCCESS; + + case TEST_FATAL: + case TEST_FAILURE: + case TEST_MEMORY_ALLOCATION_FAILURE: + Error << argv[0] << "create() failed"; delete world; return EXIT_FAILURE; } @@ -368,11 +369,11 @@ cleanup: Out << "Some test failed."; exit_code= EXIT_FAILURE; } - else if (stats.collection_skipped) + else if (stats.collection_skipped and stats.collection_failed and stats.collection_success) { Out << "Some tests were skipped."; } - else + else if (stats.collection_success and stats.collection_failed == 0) { Out << "All tests completed successfully."; } diff --git a/libtest/test.h b/libtest/test.h index 6117959b..d195dd56 100644 --- a/libtest/test.h +++ b/libtest/test.h @@ -1,10 +1,25 @@ -/* - * uTest Copyright (C) 2011 Data Differential, http://datadifferential.com/ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * libtest * - * Use and distribution licensed under the BSD license. See - * the COPYING file in the parent directory for full text. + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #ifndef __INTEL_COMPILER diff --git a/libtest/test.hpp b/libtest/test.hpp index eed030cb..3e834b02 100644 --- a/libtest/test.hpp +++ b/libtest/test.hpp @@ -4,34 +4,19 @@ * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/libtest/unittest.cc b/libtest/unittest.cc index 1528106b..e3272783 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -1,48 +1,58 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest self unit test. + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include #include +#include using namespace libtest; +static test_return_t LIBTOOL_COMMAND_test(void *) +{ + test_true(getenv("LIBTOOL_COMMAND")); + return TEST_SUCCESS; +} + +static test_return_t VALGRIND_COMMAND_test(void *) +{ + test_true(getenv("VALGRIND_COMMAND")); + return TEST_SUCCESS; +} + +static test_return_t HELGRIND_COMMAND_test(void *) +{ + test_true(getenv("HELGRIND_COMMAND")); + return TEST_SUCCESS; +} + +static test_return_t GDB_COMMAND_test(void *) +{ + test_true(getenv("GDB_COMMAND")); + return TEST_SUCCESS; +} + static test_return_t test_success_test(void *) { return TEST_SUCCESS; @@ -171,6 +181,14 @@ test_st memcached_tests[] ={ {0, 0, 0} }; +test_st environment_tests[] ={ + {"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test }, + {"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test }, + {"HELGRIND_COMMAND", 0, HELGRIND_COMMAND_test }, + {"GDB_COMMAND", 0, GDB_COMMAND_test }, + {0, 0, 0} +}; + test_st tests_log[] ={ {"TEST_SUCCESS", 0, test_success_test }, {"TEST_FAILURE", 0, test_failure_test }, @@ -184,6 +202,7 @@ test_st local_log[] ={ }; collection_st collection[] ={ + {"environment", 0, 0, environment_tests}, {"return values", 0, 0, tests_log}, {"local", 0, 0, local_log}, {"gearmand", 0, 0, gearmand_tests}, diff --git a/libtest/visibility.h b/libtest/visibility.h index 73d01f18..20d84ccc 100644 --- a/libtest/visibility.h +++ b/libtest/visibility.h @@ -1,40 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * Gearmand client and server library. + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #if defined(BUILDING_LIBTEST) diff --git a/libtest/wait.cc b/libtest/wait.cc index 93265916..759d881f 100644 --- a/libtest/wait.cc +++ b/libtest/wait.cc @@ -1,38 +1,22 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include diff --git a/libtest/wait.h b/libtest/wait.h index 9c0ae79c..d72a897b 100644 --- a/libtest/wait.h +++ b/libtest/wait.h @@ -1,40 +1,25 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: * - * uTest + * libtest * * Copyright (C) 2011 Data Differential, http://datadifferential.com/ - * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * * The names of its contributors may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + #pragma once #include diff --git a/tests/include.am b/tests/include.am index 954f32b2..2dfb8f38 100644 --- a/tests/include.am +++ b/tests/include.am @@ -124,6 +124,13 @@ tests_memcapable_LDADD= $(tests_memcapable_DEPENDENCIES) check_PROGRAMS+= tests/memcapable noinst_PROGRAMS+= tests/memcapable +tests_memslap_SOURCES= tests/memslap.cc +tests_memslap_CXXFLAGS= $(AM_CXXFLAGS) $(NO_EFF_CXX) +tests_memslap_DEPENDENCIES= libtest/libtest.la $(TESTS_LDADDS) +tests_memslap_LDADD= $(tests_memslap_DEPENDENCIES) +check_PROGRAMS+= tests/memslap +noinst_PROGRAMS+= tests/memslap + test: check check-local: tests/var $(TEST_DOCS) @@ -284,9 +291,6 @@ gdb-hashplus: tests/hash_plus gdb-cycle: tests/cycle @$(DEBUG_COMMAND) tests/cycle -gdb-memslap: clients/memslap - @$(DEBUG_COMMAND) clients/memslap - valgrind-cycle: tests/cycle $(VALGRIND_COMMAND) tests/cycle diff --git a/tests/memslap.cc b/tests/memslap.cc new file mode 100644 index 00000000..45bb6e5b --- /dev/null +++ b/tests/memslap.cc @@ -0,0 +1,168 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Test memslap + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +/* + Test that we are cycling the servers we are creating during testing. +*/ + +#include + +#include +#include + +using namespace libtest; + +#ifndef __INTEL_COMPILER +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif + +static std::string executable; + +static test_return_t help_test(void *) +{ + const char *args[]= { "--help", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_initial_load_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_initial_load_execute_number_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_initial_load_execute_number_test_get_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=get", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_initial_load_execute_number_test_set_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +static test_return_t server_concurrency_initial_load_execute_number_test_set_non_blocking_test(void *) +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port())); + const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", "--non-blocking", 0 }; + + test_success(exec_cmdline(executable, args)); + return TEST_SUCCESS; +} + +test_st memslap_tests[] ={ + {"--help", true, help_test }, + {"--server_test", true, server_test }, + {"--concurrency=10", true, server_concurrency_test }, + {"--initial-load=1000", true, server_concurrency_initial_load_test }, + {"--execute-number=10", true, server_concurrency_initial_load_execute_number_test }, + {"--test=get", true, server_concurrency_initial_load_execute_number_test_get_test }, + {"--test=set", true, server_concurrency_initial_load_execute_number_test_set_test }, + {"--test=set --non-blockin", true, server_concurrency_initial_load_execute_number_test_set_non_blocking_test }, + {0, 0, 0} +}; + +collection_st collection[] ={ + {"memslap", 0, 0, memslap_tests }, + {0, 0, 0, 0} +}; + +static void *world_create(server_startup_st& servers, test_return_t& error) +{ + const char *argv[1]= { "memslap" }; + if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv)) + { + error= TEST_FAILURE; + } + + return &servers; +} + + +void get_world(Framework *world) +{ + executable= "./clients/memslap"; + world->collections= collection; + world->_create= world_create; +} +