1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 * Data Differential YATL (i.e. libtest) library
5 * Copyright (C) 2012 Data Differential, http://datadifferential.com/
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include "libtest/yatlcon.h"
39 #include <libtest/yatl.h>
41 #if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
42 # include <libmemcached-1.0/types/return.h>
45 #if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
46 # include <libgearman-1.0/return.h>
52 using namespace libtest
;
54 static std::string testing_service
;
56 // Used to track setups where we see if failure is happening
57 static uint32_t fatal_calls
= 0;
59 static test_return_t
getenv_TEST(void *)
62 for (char **ptr
= environ
; *ptr
; ptr
++)
71 static test_return_t
LIBTOOL_COMMAND_test(void *)
73 test_true(getenv("LIBTOOL_COMMAND"));
77 static test_return_t
VALGRIND_COMMAND_test(void *)
79 test_true(getenv("VALGRIND_COMMAND"));
83 static test_return_t
HELGRIND_COMMAND_test(void *)
85 test_true(getenv("HELGRIND_COMMAND"));
89 static test_return_t
GDB_COMMAND_test(void *)
91 test_true(getenv("GDB_COMMAND"));
95 static test_return_t
test_success_equals_one_test(void *)
97 test_skip(HAVE_LIBMEMCACHED
, 1);
98 #if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
99 test_zero(MEMCACHED_SUCCESS
);
104 static test_return_t
test_success_test(void *)
109 static test_return_t
test_throw_success_TEST(void *)
114 catch (const libtest::__success
&)
126 static test_return_t
test_throw_skip_macro_TEST(void *)
131 catch (const libtest::__skipped
&)
137 FAIL("SLIP_IF() failed to throw libtest::_skipped");
140 FAIL("SLIP_IF() failed to throw");
145 static test_return_t
test_throw_skip_unless_macro_TEST(void *)
150 catch (const libtest::__skipped
&)
156 FAIL("SLIP_UNLESS() failed to throw libtest::_skipped");
159 FAIL("SLIP_UNLESS() failed to throw");
164 static test_return_t
test_throw_skip_TEST(void *)
167 throw libtest::__skipped(LIBYATL_DEFAULT_PARAM
, "basic test");
169 catch (const libtest::__skipped
&)
175 FAIL("SLIP_IF() failed to throw libtest::_skipped");
178 FAIL("SLIP_IF() failed to throw");
183 static test_return_t
test_throw_fail_TEST(void *)
186 FAIL("test message!");
188 catch (const libtest::__failure
& e
)
190 std::string
compare_message("test message!");
191 test_zero(compare_message
.compare(e
.what()));
201 #pragma GCC diagnostic ignored "-Wstack-protector"
204 # pragma GCC diagnostic push
205 # pragma GCC diagnostic ignored "-Wformat-security"
208 static test_return_t
ASSERT_FALSE__TEST(void *)
213 catch (const libtest::__failure
& e
)
215 ASSERT_STREQ(e
.what(), "Assertion '!true'");
227 # pragma GCC diagnostic pop
230 static test_return_t
ASSERT_NEQ_FAIL_TEST(void *)
235 catch (const libtest::__failure
& e
)
237 ASSERT_STREQ(e
.what(), "Assertion '1' == '1'");
248 static test_return_t
ASSERT_NEQ_TEST(void *)
255 static test_return_t
ASSERT_FALSE_TEST(void *)
260 catch (const libtest::__failure
& e
)
262 ASSERT_STREQ(e
.what(), __func__
);
273 static test_return_t
test_failure_test(void *)
275 return TEST_SKIPPED
; // Only run this when debugging
281 static test_return_t
local_test(void *)
283 if (getenv("LIBTEST_LOCAL"))
285 test_true(test_is_local());
289 test_false(test_is_local());
295 static test_return_t
local_not_test(void *)
302 if ((ptr
= getenv("LIBTEST_LOCAL")) == NULL
)
307 // unsetenv() will cause issues with valgrind
308 _compare(__FILE__
, __LINE__
, __func__
, 0, unsetenv("LIBTEST_LOCAL"), true);
309 ASSERT_EQ(0, unsetenv("LIBTEST_LOCAL"));
310 test_false(test_is_local());
312 ASSERT_EQ(0, setenv("LIBTEST_LOCAL", "1", 1));
313 test_true(test_is_local());
317 ASSERT_EQ(0, unsetenv("LIBTEST_LOCAL"));
321 char *old_string
= strdup(temp
.c_str());
322 ASSERT_EQ(0, setenv("LIBTEST_LOCAL", old_string
, 1));
328 static test_return_t
var_exists_test(void *)
330 ASSERT_EQ(0, access("var", R_OK
| W_OK
| X_OK
));
334 static test_return_t
var_tmp_exists_test(void *)
336 ASSERT_EQ(0, access("var/tmp", R_OK
| W_OK
| X_OK
));
340 static test_return_t
var_run_exists_test(void *)
342 ASSERT_EQ(0, access("var/run", R_OK
| W_OK
| X_OK
));
346 static test_return_t
var_log_exists_test(void *)
348 ASSERT_EQ(0, access("var/log", R_OK
| W_OK
| X_OK
));
352 static test_return_t
var_drizzle_exists_test(void *)
354 ASSERT_EQ(0, access("var/drizzle", R_OK
| W_OK
| X_OK
));
358 static test_return_t
var_tmp_test(void *)
360 FILE *file
= fopen("var/tmp/junk", "w+");
366 static test_return_t
var_run_test(void *)
368 FILE *file
= fopen("var/run/junk", "w+");
374 static test_return_t
var_log_test(void *)
376 FILE *file
= fopen("var/log/junk", "w+");
382 static test_return_t
var_drizzle_test(void *)
384 FILE *file
= fopen("var/drizzle/junk", "w+");
390 static test_return_t
var_tmp_rm_test(void *)
392 test_true(unlink("var/tmp/junk") == 0);
396 static test_return_t
var_run_rm_test(void *)
398 test_true(unlink("var/run/junk") == 0);
402 static test_return_t
var_log_rm_test(void *)
404 test_true(unlink("var/log/junk") == 0);
408 static test_return_t
var_drizzle_rm_test(void *)
410 test_true(unlink("var/drizzle/junk") == 0);
414 static test_return_t
_compare_test_return_t_test(void *)
416 ASSERT_EQ(TEST_SUCCESS
, TEST_SUCCESS
);
421 static test_return_t
_compare_memcached_return_t_test(void *)
423 test_skip(HAVE_LIBMEMCACHED
, true);
424 #if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
425 ASSERT_EQ(MEMCACHED_SUCCESS
, MEMCACHED_SUCCESS
);
431 static test_return_t
_compare_gearman_return_t_test(void *)
433 test_skip(HAVE_LIBGEARMAN
, true);
434 #if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
435 ASSERT_EQ(GEARMAN_SUCCESS
, GEARMAN_SUCCESS
);
441 static test_return_t
drizzled_cycle_test(void *object
)
443 server_startup_st
*servers
= (server_startup_st
*)object
;
444 test_true(servers
and servers
->validate());
446 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
447 test_true(has_drizzled());
450 test_skip(true, has_drizzled());
452 test_skip(true, server_startup(*servers
, "drizzled", get_free_port(), NULL
));
457 static test_return_t
gearmand_cycle_test(void *object
)
459 server_startup_st
*servers
= (server_startup_st
*)object
;
460 test_true(servers
and servers
->validate());
462 test_skip(true, has_gearmand());
463 test_skip(true, server_startup(*servers
, "gearmand", get_free_port(), NULL
));
469 static test_return_t
skip_shim(bool a
, bool b
)
475 static test_return_t
test_skip_true_TEST(void*)
477 ASSERT_EQ(true, true);
478 ASSERT_EQ(false, false);
479 ASSERT_EQ(TEST_SUCCESS
, skip_shim(true, true));
480 ASSERT_EQ(TEST_SUCCESS
, skip_shim(false, false));
485 static test_return_t
test_skip_false_TEST(void*)
487 ASSERT_EQ(TEST_SKIPPED
, skip_shim(true, false));
488 ASSERT_EQ(TEST_SKIPPED
, skip_shim(false, true));
492 static test_return_t
server_startup_fail_TEST(void *object
)
494 server_startup_st
*servers
= (server_startup_st
*)object
;
498 ASSERT_EQ(servers
->start_server(testing_service
, LIBTEST_FAIL_PORT
, NULL
), true);
504 static test_return_t
server_startup_TEST(void *object
)
506 server_startup_st
*servers
= (server_startup_st
*)object
;
509 ASSERT_EQ(servers
->start_server(testing_service
, get_free_port(), NULL
), true);
511 test_true(servers
->last());
512 pid_t last_pid
= servers
->last()->pid();
514 ASSERT_EQ(servers
->last()->pid(), last_pid
);
515 test_true(last_pid
> 1);
516 ASSERT_EQ(kill(last_pid
, 0), 0);
518 test_true(servers
->shutdown());
520 ASSERT_EQ(servers
->last()->pid(), -1);
521 ASSERT_EQ(kill(last_pid
, 0), -1);
527 static test_return_t
socket_server_startup_TEST(void *object
)
529 server_startup_st
*servers
= (server_startup_st
*)object
;
532 test_true(servers
->start_socket_server(testing_service
, get_free_port(), NULL
));
538 static test_return_t
memcached_sasl_test(void *object
)
540 server_startup_st
*servers
= (server_startup_st
*)object
;
543 test_skip(false, bool(getenv("TESTS_ENVIRONMENT")));
545 if (MEMCACHED_SASL_BINARY
)
547 if (HAVE_LIBMEMCACHED
)
549 test_true(has_memcached_sasl());
550 test_true(server_startup(*servers
, "memcached-sasl", get_free_port(), NULL
));
560 static test_return_t
application_true_BINARY(void *)
562 test_skip(0, access("/usr/bin/true", X_OK
));
563 Application
true_app("/usr/bin/true");
565 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
566 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
571 static test_return_t
application_gdb_true_BINARY2(void *)
573 test_skip(0, access("/usr/bin/gdb", X_OK
));
574 test_skip(0, access("/usr/bin/true", X_OK
));
576 Application
true_app("/usr/bin/true");
577 true_app
.use_gdb(true);
579 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
580 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
585 static test_return_t
application_gdb_true_BINARY(void *)
587 test_skip(0, access("/usr/bin/gdb", X_OK
));
588 test_skip(0, access("/usr/bin/true", X_OK
));
590 Application
true_app("/usr/bin/true");
591 true_app
.use_gdb(true);
593 const char *args
[]= { "--fubar", 0 };
594 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
595 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
600 static test_return_t
application_true_fubar_BINARY(void *)
602 test_skip(0, access("/usr/bin/true", X_OK
));
603 Application
true_app("/usr/bin/true");
605 const char *args
[]= { "--fubar", 0 };
606 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
607 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
608 test_zero(true_app
.stdout_result().size());
613 static test_return_t
application_doesnotexist_BINARY(void *)
616 test_skip_valgrind();
617 Application
true_app("doesnotexist");
618 true_app
.will_fail();
620 const char *args
[]= { "--fubar", 0 };
621 #if defined(__APPLE__) && __APPLE__
622 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
623 #elif defined(__FreeBSD__) && __FreeBSD__
624 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
626 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
627 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.join());
630 test_zero(true_app
.stdout_result().size());
635 static test_return_t
GET_TEST(void *)
637 libtest::http::GET
get("http://foo.example.com/");
639 ASSERT_EQ(false, get
.execute());
644 static test_return_t
POST_TEST(void *)
646 libtest::vchar_t body
;
647 libtest::http::POST
post("http://foo.example.com/", body
);
649 ASSERT_EQ(false, post
.execute());
654 static test_return_t
TRACE_TEST(void *)
656 libtest::vchar_t body
;
657 libtest::http::TRACE
trace("http://foo.example.com/", body
);
659 ASSERT_EQ(false, trace
.execute());
665 static test_return_t
vchar_t_TEST(void *)
667 libtest::vchar_t response
;
668 libtest::make_vector(response
, test_literal_param("fubar\n"));
669 ASSERT_EQ(response
, response
);
674 static test_return_t
vchar_t_make_append_TEST(void *)
676 libtest::vchar_t hostname
;
677 libtest::vchar::make(hostname
, 23);
678 libtest::vchar::append(hostname
, ".com");
679 ASSERT_EQ(28, hostname
.size());
680 ASSERT_EQ(0, hostname
[27]);
685 static test_return_t
vchar_t_compare_neg_TEST(void *)
687 libtest::vchar_t response
;
688 libtest::vchar_t response2
;
689 libtest::make_vector(response
, test_literal_param("fubar\n"));
690 libtest::make_vector(response2
, test_literal_param(__func__
));
691 test_true(response
!= response2
);
696 static test_return_t
application_echo_fubar_BINARY(void *)
700 test_skip(0, access("/bin/echo", X_OK
));
701 Application
true_app("/bin/echo");
703 const char *args
[]= { "fubar", 0 };
704 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
706 while (true_app
.slurp() == false) {} ;
708 libtest::vchar_t response
;
709 make_vector(response
, test_literal_param("fubar\n"));
710 ASSERT_EQ(response
, true_app
.stdout_result());
716 static test_return_t
application_echo_fubar_BINARY2(void *)
720 test_skip(0, access("/bin/echo", X_OK
));
721 Application
true_app("/bin/echo");
723 true_app
.add_option("fubar");
725 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
726 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
728 libtest::vchar_t response
;
729 make_vector(response
, test_literal_param("fubar\n"));
730 ASSERT_EQ(response
, true_app
.stdout_result());
736 static test_return_t
echo_fubar_BINARY(void *)
738 const char *args
[]= { "fubar", 0 };
739 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("/bin/echo", args
));
744 static test_return_t
core_count_BINARY(void *)
746 const char *args
[]= { 0 };
748 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/core-count", args
, true));
753 static test_return_t
wait_BINARY(void *)
755 const char *args
[]= { "--quiet", 0 };
757 ASSERT_EQ(EXIT_FAILURE
, exec_cmdline("libtest/wait", args
, true));
762 static test_return_t
wait_help_BINARY(void *)
764 const char *args
[]= { "--quiet", "--help", 0 };
766 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
771 static test_return_t
wait_version_BINARY(void *)
773 const char *args
[]= { "--quiet", "--version", 0 };
775 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
780 static test_return_t
wait_services_BINARY(void *)
782 test_skip(0, access("/etc/services", R_OK
));
784 const char *args
[]= { "--quiet", "/etc/services", 0 };
786 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
791 static test_return_t
wait_services_BINARY2(void *)
793 test_skip(0, access("/etc/services", R_OK
));
795 const char *args
[]= { "/etc/services", 0 };
797 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
802 static test_return_t
wait_services_appliction_TEST(void *)
804 test_skip(0, access("/etc/services", R_OK
));
805 test_skip(0, access("/usr/bin/gdb", X_OK
));
806 test_skip(0, access("libtest/wait", X_OK
));
808 libtest::Application
wait_app("libtest/wait", true);
809 wait_app
.use_gdb(true);
811 const char *args
[]= { "/etc/services", 0 };
812 ASSERT_EQ(Application::SUCCESS
, wait_app
.run(args
));
813 ASSERT_EQ(Application::SUCCESS
, wait_app
.join());
818 static test_return_t
gdb_wait_services_appliction_TEST(void *)
820 test_skip(true, false);
821 #if defined(__APPLE__) && __APPLE__
822 test_skip(0, __APPLE__
);
825 test_skip(0, access("/etc/services", R_OK
));
826 test_skip(0, access("/usr/bin/gdb", X_OK
));
827 test_skip(0, access("libtest/wait", X_OK
));
829 libtest::Application
wait_app("libtest/wait", true);
830 wait_app
.use_gdb(true);
832 const char *args
[]= { "/etc/services", 0 };
833 ASSERT_EQ(Application::SUCCESS
, wait_app
.run(args
));
834 ASSERT_EQ(Application::SUCCESS
, wait_app
.join());
839 static test_return_t
gdb_abort_services_appliction_TEST(void *)
841 test_skip(0, access("/usr/bin/gdb", X_OK
));
842 test_skip(0, access("libtest/abort", X_OK
));
843 test_skip(true, false);
845 #if defined(__APPLE__) && __APPLE__
846 test_skip(0, __APPLE__
);
849 libtest::Application
abort_app("libtest/abort", true);
850 abort_app
.use_gdb(true);
852 ASSERT_EQ(Application::SUCCESS
, abort_app
.run());
853 ASSERT_EQ(Application::SUCCESS
, abort_app
.join());
855 std::string gdb_filename
= abort_app
.gdb_filename();
856 test_skip(0, access(gdb_filename
.c_str(), R_OK
));
857 const char *args
[]= { "SIGABRT", gdb_filename
.c_str(), 0 };
858 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("grep", args
));
861 args
[0]= "THIS_WILL_NOT_BE_FOUND";
862 ASSERT_EQ(EXIT_FAILURE
, exec_cmdline("grep", args
));
867 static test_return_t
get_free_port_TEST(void *)
870 test_true((ret_port
= get_free_port()));
871 test_true(get_free_port() != default_port());
872 test_true(get_free_port() != get_free_port());
877 static test_return_t
fatal_TEST(void *)
879 ASSERT_EQ(fatal_calls
++, fatal::disabled_counter());
880 throw libtest::fatal(LIBYATL_DEFAULT_PARAM
, "Testing va_args based fatal(): %d", 10);
885 static test_return_t
number_of_cpus_TEST(void *)
887 test_true(number_of_cpus() >= 1);
892 static test_return_t
check_dns_TEST(void *)
894 test_warn(libtest::check_dns(), "Broken DNS server/no DNS server found");
899 static test_return_t
Timer_TEST(void *)
901 int64_t minutes
= random() % 50;
907 check
.offset(minutes
, 2, 200);
909 ASSERT_EQ(check
.minutes(), minutes
);
914 static test_return_t
lookup_true_TEST(void *)
916 test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
920 static test_return_t
lookup_false_TEST(void *)
922 SKIP_IF_(libtest::lookup("does_not_exist.gearman.info"),
923 "Broken DNS server detected");
928 static test_return_t
create_tmpfile_TEST(void *)
930 test_skip(0, access("/usr/bin/touch", X_OK
));
931 std::string tmp
= create_tmpfile(__func__
);
932 ASSERT_EQ(-1, access(tmp
.c_str(), R_OK
));
933 ASSERT_EQ(-1, access(tmp
.c_str(), F_OK
));
935 Application
touch_app("/usr/bin/touch");
936 const char *args
[]= { tmp
.c_str(), 0 };
937 ASSERT_EQ(Application::SUCCESS
, touch_app
.run(args
));
938 ASSERT_EQ(Application::SUCCESS
, touch_app
.join());
940 ASSERT_EQ(0, access(tmp
.c_str(), R_OK
));
941 ASSERT_EQ(0, unlink(tmp
.c_str()));
946 static test_return_t
fatal_message_TEST(void *)
948 ASSERT_EQ(fatal_calls
++, fatal::disabled_counter());
954 static test_return_t
default_port_TEST(void *)
956 in_port_t ret_port
= default_port();
957 ASSERT_EQ(ret_port
, libtest::default_port());
958 ASSERT_EQ(ret_port
, libtest::default_port());
963 static test_return_t
check_for_VALGRIND(void *)
965 test_skip_valgrind();
969 static test_return_t
check_for_gearman(void *)
971 test_skip(true, HAVE_LIBGEARMAN
);
972 test_skip(true, has_gearmand());
973 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
976 if (strcmp(GEARMAND_BINARY
, "./gearmand/gearmand"))
978 test_zero(access(GEARMAND_BINARY
, X_OK
));
987 testing_service
= "gearmand";
992 static test_return_t
check_for_drizzle(void *)
994 test_skip(true, has_drizzled());
996 testing_service
= "drizzled";
1002 test_st drizzled_tests
[] ={
1003 {"drizzled startup-shutdown", 0, drizzled_cycle_test
},
1007 test_st gearmand_tests
[] ={
1009 {"pause", 0, pause_test
},
1011 {"gearmand startup-shutdown", 0, gearmand_cycle_test
},
1012 {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test
},
1013 {"server_startup(fail)", 0, server_startup_fail_TEST
},
1017 static test_return_t
clear_servers(void* object
)
1019 server_startup_st
*servers
= (server_startup_st
*)object
;
1023 testing_service
.clear();
1025 return TEST_SUCCESS
;
1028 static test_return_t
check_for_memcached(void* object
)
1030 test_skip(true, has_memcached());
1032 server_startup_st
*servers
= (server_startup_st
*)object
;
1036 testing_service
= "memcached";
1038 return TEST_SUCCESS
;
1041 test_st memcached_TESTS
[] ={
1042 {"memcached startup-shutdown", 0, server_startup_TEST
},
1043 {"memcached(socket file) startup-shutdown", 0, socket_server_startup_TEST
},
1044 {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test
},
1045 {"server_startup(fail)", 0, server_startup_fail_TEST
},
1049 test_st test_skip_TESTS
[] ={
1050 {"true, true", 0, test_skip_true_TEST
},
1051 {"true, false", 0, test_skip_false_TEST
},
1055 test_st environment_tests
[] ={
1056 {"getenv()", 0, getenv_TEST
},
1057 {"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test
},
1058 {"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test
},
1059 {"HELGRIND_COMMAND", 0, HELGRIND_COMMAND_test
},
1060 {"GDB_COMMAND", 0, GDB_COMMAND_test
},
1064 test_st tests_log
[] ={
1065 {"TEST_SUCCESS", false, test_success_test
},
1066 {"TEST_FAILURE", false, test_failure_test
},
1067 {"TEST_SUCCESS == 0", false, test_success_equals_one_test
},
1068 {"SUCCESS", false, test_throw_success_TEST
},
1069 {"libtest::__skipped", false, test_throw_skip_TEST
},
1070 {"SKIP_IF", false, test_throw_skip_macro_TEST
},
1071 {"SKIP_UNLESS", false, test_throw_skip_unless_macro_TEST
},
1072 {"FAIL", false, test_throw_fail_TEST
},
1073 {"ASSERT_FALSE_", false, ASSERT_FALSE__TEST
},
1074 {"ASSERT_FALSE", false, ASSERT_FALSE_TEST
},
1075 {"ASSERT_NEQ", false, ASSERT_NEQ_TEST
},
1076 {"ASSERT_NEQ FAIL", false, ASSERT_NEQ_FAIL_TEST
},
1080 test_st local_log
[] ={
1081 {"test_is_local()", 0, local_test
},
1082 {"test_is_local(NOT)", 0, local_not_test
},
1086 test_st directories_tests
[] ={
1087 {"var exists", 0, var_exists_test
},
1088 {"var/tmp exists", 0, var_tmp_exists_test
},
1089 {"var/run exists", 0, var_run_exists_test
},
1090 {"var/log exists", 0, var_log_exists_test
},
1091 {"var/drizzle exists", 0, var_drizzle_exists_test
},
1092 {"var/tmp", 0, var_tmp_test
},
1093 {"var/run", 0, var_run_test
},
1094 {"var/log", 0, var_log_test
},
1095 {"var/drizzle", 0, var_drizzle_test
},
1096 {"var/tmp rm", 0, var_tmp_rm_test
},
1097 {"var/run rm", 0, var_run_rm_test
},
1098 {"var/log rm", 0, var_log_rm_test
},
1099 {"var/drizzle rm", 0, var_drizzle_rm_test
},
1103 test_st comparison_tests
[] ={
1104 {"_compare(test_return_t)", 0, _compare_test_return_t_test
},
1108 test_st cmdline_tests
[] ={
1109 {"echo fubar", 0, echo_fubar_BINARY
},
1110 {"core-count", 0, core_count_BINARY
},
1111 {"wait --quiet", 0, wait_BINARY
},
1112 {"wait --quiet --help", 0, wait_help_BINARY
},
1113 {"wait --quiet --version", 0, wait_version_BINARY
},
1114 {"wait --quiet /etc/services", 0, wait_services_BINARY
},
1115 {"wait /etc/services", 0, wait_services_BINARY2
},
1116 {"wait /etc/services", 0, wait_services_appliction_TEST
},
1117 {"gdb wait /etc/services", 0, gdb_wait_services_appliction_TEST
},
1118 {"gdb abort", 0, gdb_abort_services_appliction_TEST
},
1122 test_st get_free_port_TESTS
[] ={
1123 {"get_free_port()", 0, get_free_port_TEST
},
1124 {"default_port()", 0, default_port_TEST
},
1128 test_st fatal_message_TESTS
[] ={
1129 {"libtest::fatal", 0, fatal_TEST
},
1130 {"fatal_message()", 0, fatal_message_TEST
},
1134 test_st number_of_cpus_TESTS
[] ={
1135 {"libtest::number_of_cpus()", 0, number_of_cpus_TEST
},
1139 test_st create_tmpfile_TESTS
[] ={
1140 {"libtest::create_tmpfile()", 0, create_tmpfile_TEST
},
1144 test_st timer_TESTS
[] ={
1145 {"libtest::Timer", 0, Timer_TEST
},
1149 test_st dns_TESTS
[] ={
1150 {"libtest::lookup(true)", 0, lookup_true_TEST
},
1151 {"libtest::lookup(false)", 0, lookup_false_TEST
},
1152 {"libtest::check_dns()", 0, check_dns_TEST
},
1156 test_st application_tests
[] ={
1157 {"vchar_t", 0, vchar_t_TEST
},
1158 {"vchar_t make() append()", 0, vchar_t_make_append_TEST
},
1159 {"vchar_t compare()", 0, vchar_t_compare_neg_TEST
},
1160 {"true", 0, application_true_BINARY
},
1161 {"gbd true --fubar", 0, application_gdb_true_BINARY
},
1162 {"gbd true", 0, application_gdb_true_BINARY2
},
1163 {"true --fubar", 0, application_true_fubar_BINARY
},
1164 {"doesnotexist --fubar", 0, application_doesnotexist_BINARY
},
1165 {"echo fubar", 0, application_echo_fubar_BINARY
},
1166 {"echo fubar (as option)", 0, application_echo_fubar_BINARY2
},
1170 static test_return_t
check_for_curl(void *)
1172 test_skip_valgrind();
1173 test_skip(true, HAVE_LIBCURL
);
1174 return TEST_SUCCESS
;
1177 static test_return_t
disable_fatal_exception(void *)
1181 return TEST_SUCCESS
;
1184 static test_return_t
enable_fatal_exception(void *)
1187 return TEST_SUCCESS
;
1190 test_st http_tests
[] ={
1191 {"GET", 0, GET_TEST
},
1192 {"POST", 0, POST_TEST
},
1193 {"TRACE", 0, TRACE_TEST
},
1197 collection_st collection
[] ={
1198 {"environment", 0, 0, environment_tests
},
1199 {"return values", 0, 0, tests_log
},
1200 {"test_skip()", 0, 0, test_skip_TESTS
},
1201 {"local", 0, 0, local_log
},
1202 {"directories", 0, 0, directories_tests
},
1203 {"comparison", 0, 0, comparison_tests
},
1204 {"gearmand", check_for_gearman
, clear_servers
, gearmand_tests
},
1205 {"memcached", check_for_memcached
, clear_servers
, memcached_TESTS
},
1206 {"drizzled", check_for_drizzle
, clear_servers
, drizzled_tests
},
1207 {"cmdline", 0, 0, cmdline_tests
},
1208 {"application", 0, 0, application_tests
},
1209 {"http", check_for_curl
, 0, http_tests
},
1210 {"http", check_for_curl
, 0, http_tests
},
1211 {"get_free_port()", 0, 0, get_free_port_TESTS
},
1212 {"fatal", disable_fatal_exception
, enable_fatal_exception
, fatal_message_TESTS
},
1213 {"number_of_cpus()", 0, 0, number_of_cpus_TESTS
},
1214 {"create_tmpfile()", 0, 0, create_tmpfile_TESTS
},
1215 {"dns", check_for_VALGRIND
, 0, dns_TESTS
},
1216 {"libtest::Timer", 0, 0, timer_TESTS
},
1220 static void *world_create(server_startup_st
& servers
, test_return_t
&)
1225 void get_world(libtest::Framework
*world
)
1227 world
->collections(collection
);
1228 world
->create(world_create
);