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 (libtest::__success
)
126 static test_return_t
test_throw_skip_macro_TEST(void *)
131 catch (libtest::__skipped e
)
137 FAIL("SLIP_IF() failed to throw libtest::_skipped");
140 FAIL("SLIP_IF() failed to throw");
145 static test_return_t
test_throw_skip_TEST(void *)
148 throw libtest::__skipped(LIBYATL_DEFAULT_PARAM
, "basic test");
150 catch (libtest::__skipped e
)
156 FAIL("SLIP_IF() failed to throw libtest::_skipped");
159 FAIL("SLIP_IF() failed to throw");
164 static test_return_t
test_throw_fail_TEST(void *)
167 FAIL("test message!");
169 catch (const libtest::__failure
& e
)
171 std::string
compare_message("test message!");
172 test_zero(compare_message
.compare(e
.what()));
182 #pragma GCC diagnostic ignored "-Wstack-protector"
184 static test_return_t
ASSERT_FALSE__TEST(void *)
187 ASSERT_FALSE_(true, __func__
);
189 catch (const libtest::__failure
& e
)
191 ASSERT_STREQ(e
.what(), "Assertion '!true' [ ASSERT_FALSE__TEST ]");
202 static test_return_t
ASSERT_FALSE_TEST(void *)
207 catch (const libtest::__failure
& e
)
209 ASSERT_STREQ(e
.what(), __func__
);
220 static test_return_t
test_failure_test(void *)
222 return TEST_SKIPPED
; // Only run this when debugging
228 static test_return_t
local_test(void *)
230 if (getenv("LIBTEST_LOCAL"))
232 test_true(test_is_local());
236 test_false(test_is_local());
242 static test_return_t
local_not_test(void *)
249 if ((ptr
= getenv("LIBTEST_LOCAL")) == NULL
)
254 // unsetenv() will cause issues with valgrind
255 _compare(__FILE__
, __LINE__
, __func__
, 0, unsetenv("LIBTEST_LOCAL"), true);
256 ASSERT_EQ(0, unsetenv("LIBTEST_LOCAL"));
257 test_false(test_is_local());
259 ASSERT_EQ(0, setenv("LIBTEST_LOCAL", "1", 1));
260 test_true(test_is_local());
264 ASSERT_EQ(0, unsetenv("LIBTEST_LOCAL"));
268 char *old_string
= strdup(temp
.c_str());
269 ASSERT_EQ(0, setenv("LIBTEST_LOCAL", old_string
, 1));
275 static test_return_t
var_exists_test(void *)
277 ASSERT_EQ(0, access("var", R_OK
| W_OK
| X_OK
));
281 static test_return_t
var_tmp_exists_test(void *)
283 ASSERT_EQ(0, access("var/tmp", R_OK
| W_OK
| X_OK
));
287 static test_return_t
var_run_exists_test(void *)
289 ASSERT_EQ(0, access("var/run", R_OK
| W_OK
| X_OK
));
293 static test_return_t
var_log_exists_test(void *)
295 ASSERT_EQ(0, access("var/log", R_OK
| W_OK
| X_OK
));
299 static test_return_t
var_drizzle_exists_test(void *)
301 ASSERT_EQ(0, access("var/drizzle", R_OK
| W_OK
| X_OK
));
305 static test_return_t
var_tmp_test(void *)
307 FILE *file
= fopen("var/tmp/junk", "w+");
313 static test_return_t
var_run_test(void *)
315 FILE *file
= fopen("var/run/junk", "w+");
321 static test_return_t
var_log_test(void *)
323 FILE *file
= fopen("var/log/junk", "w+");
329 static test_return_t
var_drizzle_test(void *)
331 FILE *file
= fopen("var/drizzle/junk", "w+");
337 static test_return_t
var_tmp_rm_test(void *)
339 test_true(unlink("var/tmp/junk") == 0);
343 static test_return_t
var_run_rm_test(void *)
345 test_true(unlink("var/run/junk") == 0);
349 static test_return_t
var_log_rm_test(void *)
351 test_true(unlink("var/log/junk") == 0);
355 static test_return_t
var_drizzle_rm_test(void *)
357 test_true(unlink("var/drizzle/junk") == 0);
361 static test_return_t
_compare_test_return_t_test(void *)
363 ASSERT_EQ(TEST_SUCCESS
, TEST_SUCCESS
);
368 static test_return_t
_compare_memcached_return_t_test(void *)
370 test_skip(HAVE_LIBMEMCACHED
, true);
371 #if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
372 ASSERT_EQ(MEMCACHED_SUCCESS
, MEMCACHED_SUCCESS
);
378 static test_return_t
_compare_gearman_return_t_test(void *)
380 test_skip(HAVE_LIBGEARMAN
, true);
381 #if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
382 ASSERT_EQ(GEARMAN_SUCCESS
, GEARMAN_SUCCESS
);
388 static test_return_t
drizzled_cycle_test(void *object
)
390 server_startup_st
*servers
= (server_startup_st
*)object
;
391 test_true(servers
and servers
->validate());
393 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
394 test_true(has_drizzled());
397 test_skip(true, has_drizzled());
399 test_skip(true, server_startup(*servers
, "drizzled", get_free_port(), 0, NULL
, false));
404 static test_return_t
gearmand_cycle_test(void *object
)
406 server_startup_st
*servers
= (server_startup_st
*)object
;
407 test_true(servers
and servers
->validate());
409 test_skip(true, has_gearmand());
410 test_skip(true, server_startup(*servers
, "gearmand", get_free_port(), 0, NULL
, false));
416 static test_return_t
skip_shim(bool a
, bool b
)
422 static test_return_t
test_skip_true_TEST(void*)
424 ASSERT_EQ(true, true);
425 ASSERT_EQ(false, false);
426 ASSERT_EQ(TEST_SUCCESS
, skip_shim(true, true));
427 ASSERT_EQ(TEST_SUCCESS
, skip_shim(false, false));
432 static test_return_t
test_skip_false_TEST(void*)
434 ASSERT_EQ(TEST_SKIPPED
, skip_shim(true, false));
435 ASSERT_EQ(TEST_SKIPPED
, skip_shim(false, true));
439 static test_return_t
server_startup_fail_TEST(void *object
)
441 server_startup_st
*servers
= (server_startup_st
*)object
;
445 ASSERT_EQ(servers
->start_server(testing_service
, LIBTEST_FAIL_PORT
, 0, NULL
, false), true);
451 static test_return_t
server_startup_TEST(void *object
)
453 server_startup_st
*servers
= (server_startup_st
*)object
;
456 ASSERT_EQ(servers
->start_server(testing_service
, get_free_port(), 0, NULL
, false), true);
458 test_true(servers
->last());
459 pid_t last_pid
= servers
->last()->pid();
461 ASSERT_EQ(servers
->last()->pid(), last_pid
);
462 test_true(last_pid
> 1);
463 ASSERT_EQ(kill(last_pid
, 0), 0);
465 test_true(servers
->shutdown());
467 ASSERT_EQ(servers
->last()->pid(), -1);
468 ASSERT_EQ(kill(last_pid
, 0), -1);
474 static test_return_t
socket_server_startup_TEST(void *object
)
476 server_startup_st
*servers
= (server_startup_st
*)object
;
479 test_true(servers
->start_socket_server(testing_service
, get_free_port(), 0, NULL
, false));
485 static test_return_t
memcached_sasl_test(void *object
)
487 server_startup_st
*servers
= (server_startup_st
*)object
;
490 test_skip(false, bool(getenv("TESTS_ENVIRONMENT")));
492 if (MEMCACHED_SASL_BINARY
)
494 if (HAVE_LIBMEMCACHED
)
496 test_true(has_memcached_sasl());
497 test_true(server_startup(*servers
, "memcached-sasl", get_free_port(), 0, NULL
, false));
507 static test_return_t
application_true_BINARY(void *)
509 test_skip(0, access("/usr/bin/true", X_OK
));
510 Application
true_app("/usr/bin/true");
512 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
513 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
518 static test_return_t
application_gdb_true_BINARY2(void *)
520 test_skip(0, access("/usr/bin/gdb", X_OK
));
521 test_skip(0, access("/usr/bin/true", X_OK
));
523 Application
true_app("/usr/bin/true");
524 true_app
.use_gdb(true);
526 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
527 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
532 static test_return_t
application_gdb_true_BINARY(void *)
534 test_skip(0, access("/usr/bin/gdb", X_OK
));
535 test_skip(0, access("/usr/bin/true", X_OK
));
537 Application
true_app("/usr/bin/true");
538 true_app
.use_gdb(true);
540 const char *args
[]= { "--fubar", 0 };
541 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
542 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
547 static test_return_t
application_true_fubar_BINARY(void *)
549 test_skip(0, access("/usr/bin/true", X_OK
));
550 Application
true_app("/usr/bin/true");
552 const char *args
[]= { "--fubar", 0 };
553 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
554 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
555 test_zero(true_app
.stdout_result().size());
560 static test_return_t
application_doesnotexist_BINARY(void *)
563 test_skip_valgrind();
564 Application
true_app("doesnotexist");
565 true_app
.will_fail();
567 const char *args
[]= { "--fubar", 0 };
568 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
569 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
570 #elif defined(TARGET_OS_FREEBSD) && TARGET_OS_FREEBSD
571 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
573 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
574 ASSERT_EQ(Application::INVALID_POSIX_SPAWN
, true_app
.join());
577 test_zero(true_app
.stdout_result().size());
582 static test_return_t
GET_TEST(void *)
584 libtest::http::GET
get("http://foo.example.com/");
586 ASSERT_EQ(false, get
.execute());
591 static test_return_t
POST_TEST(void *)
593 libtest::vchar_t body
;
594 libtest::http::POST
post("http://foo.example.com/", body
);
596 ASSERT_EQ(false, post
.execute());
601 static test_return_t
TRACE_TEST(void *)
603 libtest::vchar_t body
;
604 libtest::http::TRACE
trace("http://foo.example.com/", body
);
606 ASSERT_EQ(false, trace
.execute());
612 static test_return_t
vchar_t_TEST(void *)
614 libtest::vchar_t response
;
615 libtest::make_vector(response
, test_literal_param("fubar\n"));
616 ASSERT_EQ(response
, response
);
621 static test_return_t
vchar_t_make_append_TEST(void *)
623 libtest::vchar_t hostname
;
624 libtest::vchar::make(hostname
, 23);
625 libtest::vchar::append(hostname
, ".com");
626 ASSERT_EQ(28, hostname
.size());
627 ASSERT_EQ(0, hostname
[27]);
632 static test_return_t
vchar_t_compare_neg_TEST(void *)
634 libtest::vchar_t response
;
635 libtest::vchar_t response2
;
636 libtest::make_vector(response
, test_literal_param("fubar\n"));
637 libtest::make_vector(response2
, test_literal_param(__func__
));
638 test_true(response
!= response2
);
643 static test_return_t
application_echo_fubar_BINARY(void *)
647 test_skip(0, access("/bin/echo", X_OK
));
648 Application
true_app("/bin/echo");
650 const char *args
[]= { "fubar", 0 };
651 ASSERT_EQ(Application::SUCCESS
, true_app
.run(args
));
653 while (true_app
.slurp() == false) {} ;
655 libtest::vchar_t response
;
656 make_vector(response
, test_literal_param("fubar\n"));
657 ASSERT_EQ(response
, true_app
.stdout_result());
663 static test_return_t
application_echo_fubar_BINARY2(void *)
667 test_skip(0, access("/bin/echo", X_OK
));
668 Application
true_app("/bin/echo");
670 true_app
.add_option("fubar");
672 ASSERT_EQ(Application::SUCCESS
, true_app
.run());
673 ASSERT_EQ(Application::SUCCESS
, true_app
.join());
675 libtest::vchar_t response
;
676 make_vector(response
, test_literal_param("fubar\n"));
677 ASSERT_EQ(response
, true_app
.stdout_result());
683 static test_return_t
echo_fubar_BINARY(void *)
685 const char *args
[]= { "fubar", 0 };
686 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("/bin/echo", args
));
691 static test_return_t
core_count_BINARY(void *)
693 const char *args
[]= { 0 };
695 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/core-count", args
, true));
700 static test_return_t
wait_BINARY(void *)
702 const char *args
[]= { "--quiet", 0 };
704 ASSERT_EQ(EXIT_FAILURE
, exec_cmdline("libtest/wait", args
, true));
709 static test_return_t
wait_help_BINARY(void *)
711 const char *args
[]= { "--quiet", "--help", 0 };
713 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
718 static test_return_t
wait_version_BINARY(void *)
720 const char *args
[]= { "--quiet", "--version", 0 };
722 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
727 static test_return_t
wait_services_BINARY(void *)
729 test_skip(0, access("/etc/services", R_OK
));
731 const char *args
[]= { "--quiet", "/etc/services", 0 };
733 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
738 static test_return_t
wait_services_BINARY2(void *)
740 test_skip(0, access("/etc/services", R_OK
));
742 const char *args
[]= { "/etc/services", 0 };
744 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
749 static test_return_t
wait_services_appliction_TEST(void *)
751 test_skip(0, access("/etc/services", R_OK
));
752 test_skip(0, access("/usr/bin/gdb", X_OK
));
753 test_skip(0, access("libtest/wait", X_OK
));
755 libtest::Application
wait_app("libtest/wait", true);
756 wait_app
.use_gdb(true);
758 const char *args
[]= { "/etc/services", 0 };
759 ASSERT_EQ(Application::SUCCESS
, wait_app
.run(args
));
760 ASSERT_EQ(Application::SUCCESS
, wait_app
.join());
765 static test_return_t
gdb_wait_services_appliction_TEST(void *)
767 test_skip(true, false);
768 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
769 test_skip(0, TARGET_OS_OSX
);
772 test_skip(0, access("/etc/services", R_OK
));
773 test_skip(0, access("/usr/bin/gdb", X_OK
));
774 test_skip(0, access("libtest/wait", X_OK
));
776 libtest::Application
wait_app("libtest/wait", true);
777 wait_app
.use_gdb(true);
779 const char *args
[]= { "/etc/services", 0 };
780 ASSERT_EQ(Application::SUCCESS
, wait_app
.run(args
));
781 ASSERT_EQ(Application::SUCCESS
, wait_app
.join());
786 static test_return_t
gdb_abort_services_appliction_TEST(void *)
788 test_skip(0, access("/usr/bin/gdb", X_OK
));
789 test_skip(0, access("libtest/abort", X_OK
));
790 test_skip(true, false);
792 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
793 test_skip(0, TARGET_OS_OSX
);
796 libtest::Application
abort_app("libtest/abort", true);
797 abort_app
.use_gdb(true);
799 ASSERT_EQ(Application::SUCCESS
, abort_app
.run());
800 ASSERT_EQ(Application::SUCCESS
, abort_app
.join());
802 std::string gdb_filename
= abort_app
.gdb_filename();
803 test_skip(0, access(gdb_filename
.c_str(), R_OK
));
804 const char *args
[]= { "SIGABRT", gdb_filename
.c_str(), 0 };
805 ASSERT_EQ(EXIT_SUCCESS
, exec_cmdline("grep", args
));
808 args
[0]= "THIS_WILL_NOT_BE_FOUND";
809 ASSERT_EQ(EXIT_FAILURE
, exec_cmdline("grep", args
));
814 static test_return_t
get_free_port_TEST(void *)
817 test_true((ret_port
= get_free_port()));
818 test_true(get_free_port() != default_port());
819 test_true(get_free_port() != get_free_port());
824 static test_return_t
fatal_TEST(void *)
826 ASSERT_EQ(fatal_calls
++, fatal::disabled_counter());
827 throw libtest::fatal(LIBYATL_DEFAULT_PARAM
, "Testing va_args based fatal(): %d", 10);
832 static test_return_t
number_of_cpus_TEST(void *)
834 test_true(number_of_cpus() >= 1);
839 static test_return_t
check_dns_TEST(void *)
841 test_warn(libtest::check_dns(), "Broken DNS server/no DNS server found");
846 static test_return_t
Timer_TEST(void *)
848 int64_t minutes
= random() % 50;
854 check
.offset(minutes
, 2, 200);
856 ASSERT_EQ(check
.minutes(), minutes
);
861 static test_return_t
lookup_true_TEST(void *)
863 test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
867 static test_return_t
lookup_false_TEST(void *)
869 if (libtest::lookup("does_not_exist.gearman.info"))
871 Error
<< "Broken DNS server detected";
878 static test_return_t
create_tmpfile_TEST(void *)
880 test_skip(0, access("/usr/bin/touch", X_OK
));
881 std::string tmp
= create_tmpfile(__func__
);
882 ASSERT_EQ(-1, access(tmp
.c_str(), R_OK
));
883 ASSERT_EQ(-1, access(tmp
.c_str(), F_OK
));
885 Application
touch_app("/usr/bin/touch");
886 const char *args
[]= { tmp
.c_str(), 0 };
887 ASSERT_EQ(Application::SUCCESS
, touch_app
.run(args
));
888 ASSERT_EQ(Application::SUCCESS
, touch_app
.join());
890 ASSERT_EQ(0, access(tmp
.c_str(), R_OK
));
891 ASSERT_EQ(0, unlink(tmp
.c_str()));
896 static test_return_t
fatal_message_TEST(void *)
898 ASSERT_EQ(fatal_calls
++, fatal::disabled_counter());
899 fatal_message("Fatal test");
904 static test_return_t
default_port_TEST(void *)
906 in_port_t ret_port
= default_port();
907 ASSERT_EQ(ret_port
, libtest::default_port());
908 ASSERT_EQ(ret_port
, libtest::default_port());
913 static test_return_t
check_for_gearman(void *)
915 test_skip(true, HAVE_LIBGEARMAN
);
916 test_skip(true, has_gearmand());
917 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
920 if (strcmp(GEARMAND_BINARY
, "./gearmand/gearmand"))
922 test_zero(access(GEARMAND_BINARY
, X_OK
));
931 testing_service
= "gearmand";
936 static test_return_t
check_for_drizzle(void *)
938 test_skip(true, HAVE_LIBDRIZZLE
);
939 test_skip(true, has_drizzled());
941 testing_service
= "drizzled";
947 test_st drizzled_tests
[] ={
948 {"drizzled startup-shutdown", 0, drizzled_cycle_test
},
952 test_st gearmand_tests
[] ={
954 {"pause", 0, pause_test
},
956 {"gearmand startup-shutdown", 0, gearmand_cycle_test
},
957 {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test
},
958 {"server_startup(fail)", 0, server_startup_fail_TEST
},
962 static test_return_t
clear_servers(void* object
)
964 server_startup_st
*servers
= (server_startup_st
*)object
;
968 testing_service
.clear();
973 static test_return_t
check_for_memcached(void* object
)
975 test_skip(true, has_memcached());
977 server_startup_st
*servers
= (server_startup_st
*)object
;
981 testing_service
= "memcached";
986 test_st memcached_TESTS
[] ={
987 {"memcached startup-shutdown", 0, server_startup_TEST
},
988 {"memcached(socket file) startup-shutdown", 0, socket_server_startup_TEST
},
989 {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test
},
990 {"server_startup(fail)", 0, server_startup_fail_TEST
},
994 test_st test_skip_TESTS
[] ={
995 {"true, true", 0, test_skip_true_TEST
},
996 {"true, false", 0, test_skip_false_TEST
},
1000 test_st environment_tests
[] ={
1001 {"getenv()", 0, getenv_TEST
},
1002 {"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test
},
1003 {"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test
},
1004 {"HELGRIND_COMMAND", 0, HELGRIND_COMMAND_test
},
1005 {"GDB_COMMAND", 0, GDB_COMMAND_test
},
1009 test_st tests_log
[] ={
1010 {"TEST_SUCCESS", false, test_success_test
},
1011 {"TEST_FAILURE", false, test_failure_test
},
1012 {"TEST_SUCCESS == 0", false, test_success_equals_one_test
},
1013 {"SUCCESS", false, test_throw_success_TEST
},
1014 {"libtest::__skipped", false, test_throw_skip_TEST
},
1015 {"SKIP_IF", false, test_throw_skip_macro_TEST
},
1016 {"FAIL", false, test_throw_fail_TEST
},
1017 {"ASSERT_FALSE_", false, ASSERT_FALSE__TEST
},
1018 {"ASSERT_FALSE", false, ASSERT_FALSE_TEST
},
1022 test_st local_log
[] ={
1023 {"test_is_local()", 0, local_test
},
1024 {"test_is_local(NOT)", 0, local_not_test
},
1028 test_st directories_tests
[] ={
1029 {"var exists", 0, var_exists_test
},
1030 {"var/tmp exists", 0, var_tmp_exists_test
},
1031 {"var/run exists", 0, var_run_exists_test
},
1032 {"var/log exists", 0, var_log_exists_test
},
1033 {"var/drizzle exists", 0, var_drizzle_exists_test
},
1034 {"var/tmp", 0, var_tmp_test
},
1035 {"var/run", 0, var_run_test
},
1036 {"var/log", 0, var_log_test
},
1037 {"var/drizzle", 0, var_drizzle_test
},
1038 {"var/tmp rm", 0, var_tmp_rm_test
},
1039 {"var/run rm", 0, var_run_rm_test
},
1040 {"var/log rm", 0, var_log_rm_test
},
1041 {"var/drizzle rm", 0, var_drizzle_rm_test
},
1045 test_st comparison_tests
[] ={
1046 {"_compare(test_return_t)", 0, _compare_test_return_t_test
},
1050 test_st cmdline_tests
[] ={
1051 {"echo fubar", 0, echo_fubar_BINARY
},
1052 {"core-count", 0, core_count_BINARY
},
1053 {"wait --quiet", 0, wait_BINARY
},
1054 {"wait --quiet --help", 0, wait_help_BINARY
},
1055 {"wait --quiet --version", 0, wait_version_BINARY
},
1056 {"wait --quiet /etc/services", 0, wait_services_BINARY
},
1057 {"wait /etc/services", 0, wait_services_BINARY2
},
1058 {"wait /etc/services", 0, wait_services_appliction_TEST
},
1059 {"gdb wait /etc/services", 0, gdb_wait_services_appliction_TEST
},
1060 {"gdb abort", 0, gdb_abort_services_appliction_TEST
},
1064 test_st get_free_port_TESTS
[] ={
1065 {"get_free_port()", 0, get_free_port_TEST
},
1066 {"default_port()", 0, default_port_TEST
},
1070 test_st fatal_message_TESTS
[] ={
1071 {"libtest::fatal", 0, fatal_TEST
},
1072 {"fatal_message()", 0, fatal_message_TEST
},
1076 test_st number_of_cpus_TESTS
[] ={
1077 {"libtest::number_of_cpus()", 0, number_of_cpus_TEST
},
1081 test_st create_tmpfile_TESTS
[] ={
1082 {"libtest::create_tmpfile()", 0, create_tmpfile_TEST
},
1086 test_st timer_TESTS
[] ={
1087 {"libtest::Timer", 0, Timer_TEST
},
1091 test_st dns_TESTS
[] ={
1092 {"libtest::lookup(true)", 0, lookup_true_TEST
},
1093 {"libtest::lookup(false)", 0, lookup_false_TEST
},
1094 {"libtest::check_dns()", 0, check_dns_TEST
},
1098 test_st application_tests
[] ={
1099 {"vchar_t", 0, vchar_t_TEST
},
1100 {"vchar_t make() append()", 0, vchar_t_make_append_TEST
},
1101 {"vchar_t compare()", 0, vchar_t_compare_neg_TEST
},
1102 {"true", 0, application_true_BINARY
},
1103 {"gbd true --fubar", 0, application_gdb_true_BINARY
},
1104 {"gbd true", 0, application_gdb_true_BINARY2
},
1105 {"true --fubar", 0, application_true_fubar_BINARY
},
1106 {"doesnotexist --fubar", 0, application_doesnotexist_BINARY
},
1107 {"echo fubar", 0, application_echo_fubar_BINARY
},
1108 {"echo fubar (as option)", 0, application_echo_fubar_BINARY2
},
1112 static test_return_t
check_for_curl(void *)
1114 test_skip(true, HAVE_LIBCURL
);
1115 return TEST_SUCCESS
;
1118 static test_return_t
disable_fatal_exception(void *)
1122 return TEST_SUCCESS
;
1125 static test_return_t
enable_fatal_exception(void *)
1128 return TEST_SUCCESS
;
1131 test_st http_tests
[] ={
1132 {"GET", 0, GET_TEST
},
1133 {"POST", 0, POST_TEST
},
1134 {"TRACE", 0, TRACE_TEST
},
1138 collection_st collection
[] ={
1139 {"environment", 0, 0, environment_tests
},
1140 {"return values", 0, 0, tests_log
},
1141 {"test_skip()", 0, 0, test_skip_TESTS
},
1142 {"local", 0, 0, local_log
},
1143 {"directories", 0, 0, directories_tests
},
1144 {"comparison", 0, 0, comparison_tests
},
1145 {"gearmand", check_for_gearman
, clear_servers
, gearmand_tests
},
1146 {"memcached", check_for_memcached
, clear_servers
, memcached_TESTS
},
1147 {"drizzled", check_for_drizzle
, clear_servers
, drizzled_tests
},
1148 {"cmdline", 0, 0, cmdline_tests
},
1149 {"application", 0, 0, application_tests
},
1150 {"http", check_for_curl
, 0, http_tests
},
1151 {"http", check_for_curl
, 0, http_tests
},
1152 {"get_free_port()", 0, 0, get_free_port_TESTS
},
1153 {"fatal", disable_fatal_exception
, enable_fatal_exception
, fatal_message_TESTS
},
1154 {"number_of_cpus()", 0, 0, number_of_cpus_TESTS
},
1155 {"create_tmpfile()", 0, 0, create_tmpfile_TESTS
},
1156 {"dns", 0, 0, dns_TESTS
},
1157 {"libtest::Timer", 0, 0, timer_TESTS
},
1161 static void *world_create(server_startup_st
& servers
, test_return_t
&)
1166 void get_world(libtest::Framework
*world
)
1168 world
->collections(collection
);
1169 world
->create(world_create
);