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_TEST(void *)
131 catch (libtest::__skipped
)
143 static test_return_t
test_throw_fail_TEST(void *)
146 FAIL("test message!");
148 catch (const libtest::__failure
& e
)
150 std::string
compare_message("test message!");
151 test_zero(compare_message
.compare(e
.what()));
161 #pragma GCC diagnostic ignored "-Wstack-protector"
163 static test_return_t
ASSERT_FALSE__TEST(void *)
166 ASSERT_FALSE_(true, __func__
);
168 catch (const libtest::__failure
& e
)
170 ASSERT_STREQ(e
.what(), "Assertion '!true' [ ASSERT_FALSE__TEST ]");
181 static test_return_t
ASSERT_FALSE_TEST(void *)
186 catch (const libtest::__failure
& e
)
188 ASSERT_STREQ(e
.what(), __func__
);
199 static test_return_t
test_failure_test(void *)
201 return TEST_SKIPPED
; // Only run this when debugging
207 static test_return_t
local_test(void *)
209 if (getenv("LIBTEST_LOCAL"))
211 test_true(test_is_local());
215 test_false(test_is_local());
221 static test_return_t
local_not_test(void *)
228 if ((ptr
= getenv("LIBTEST_LOCAL")) == NULL
)
233 // unsetenv() will cause issues with valgrind
234 _compare(__FILE__
, __LINE__
, __func__
, 0, unsetenv("LIBTEST_LOCAL"), true);
235 test_compare(0, unsetenv("LIBTEST_LOCAL"));
236 test_false(test_is_local());
238 test_compare(0, setenv("LIBTEST_LOCAL", "1", 1));
239 test_true(test_is_local());
243 test_compare(0, unsetenv("LIBTEST_LOCAL"));
247 char *old_string
= strdup(temp
.c_str());
248 test_compare(0, setenv("LIBTEST_LOCAL", old_string
, 1));
254 static test_return_t
var_exists_test(void *)
256 test_compare(0, access("var", R_OK
| W_OK
| X_OK
));
260 static test_return_t
var_tmp_exists_test(void *)
262 test_compare(0, access("var/tmp", R_OK
| W_OK
| X_OK
));
266 static test_return_t
var_run_exists_test(void *)
268 test_compare(0, access("var/run", R_OK
| W_OK
| X_OK
));
272 static test_return_t
var_log_exists_test(void *)
274 test_compare(0, access("var/log", R_OK
| W_OK
| X_OK
));
278 static test_return_t
var_drizzle_exists_test(void *)
280 test_compare(0, access("var/drizzle", R_OK
| W_OK
| X_OK
));
284 static test_return_t
var_tmp_test(void *)
286 FILE *file
= fopen("var/tmp/junk", "w+");
292 static test_return_t
var_run_test(void *)
294 FILE *file
= fopen("var/run/junk", "w+");
300 static test_return_t
var_log_test(void *)
302 FILE *file
= fopen("var/log/junk", "w+");
308 static test_return_t
var_drizzle_test(void *)
310 FILE *file
= fopen("var/drizzle/junk", "w+");
316 static test_return_t
var_tmp_rm_test(void *)
318 test_true(unlink("var/tmp/junk") == 0);
322 static test_return_t
var_run_rm_test(void *)
324 test_true(unlink("var/run/junk") == 0);
328 static test_return_t
var_log_rm_test(void *)
330 test_true(unlink("var/log/junk") == 0);
334 static test_return_t
var_drizzle_rm_test(void *)
336 test_true(unlink("var/drizzle/junk") == 0);
340 static test_return_t
_compare_test_return_t_test(void *)
342 test_compare(TEST_SUCCESS
, TEST_SUCCESS
);
347 static test_return_t
_compare_memcached_return_t_test(void *)
349 test_skip(HAVE_LIBMEMCACHED
, true);
350 #if defined(HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H) && HAVE_LIBMEMCACHED_1_0_TYPES_RETURN_H
351 test_compare(MEMCACHED_SUCCESS
, MEMCACHED_SUCCESS
);
357 static test_return_t
_compare_gearman_return_t_test(void *)
359 test_skip(HAVE_LIBGEARMAN
, true);
360 #if defined(HAVE_LIBGEARMAN_1_0_RETURN_H) && HAVE_LIBGEARMAN_1_0_RETURN_H
361 test_compare(GEARMAN_SUCCESS
, GEARMAN_SUCCESS
);
367 static test_return_t
drizzled_cycle_test(void *object
)
369 server_startup_st
*servers
= (server_startup_st
*)object
;
370 test_true(servers
and servers
->validate());
372 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
373 test_true(has_drizzled());
376 test_skip(true, has_drizzled());
378 test_skip(true, server_startup(*servers
, "drizzled", get_free_port(), 0, NULL
, false));
383 static test_return_t
gearmand_cycle_test(void *object
)
385 server_startup_st
*servers
= (server_startup_st
*)object
;
386 test_true(servers
and servers
->validate());
388 test_skip(true, has_gearmand());
389 test_skip(true, server_startup(*servers
, "gearmand", get_free_port(), 0, NULL
, false));
395 static test_return_t
skip_shim(bool a
, bool b
)
401 static test_return_t
test_skip_true_TEST(void*)
403 test_compare(true, true);
404 test_compare(false, false);
405 test_compare(TEST_SUCCESS
, skip_shim(true, true));
406 test_compare(TEST_SUCCESS
, skip_shim(false, false));
411 static test_return_t
test_skip_false_TEST(void*)
413 test_compare(TEST_SKIPPED
, skip_shim(true, false));
414 test_compare(TEST_SKIPPED
, skip_shim(false, true));
418 static test_return_t
server_startup_fail_TEST(void *object
)
420 server_startup_st
*servers
= (server_startup_st
*)object
;
424 test_compare(servers
->start_server(testing_service
, LIBTEST_FAIL_PORT
, 0, NULL
, false), true);
430 static test_return_t
server_startup_TEST(void *object
)
432 server_startup_st
*servers
= (server_startup_st
*)object
;
435 test_compare(servers
->start_server(testing_service
, get_free_port(), 0, NULL
, false), true);
437 test_true(servers
->last());
438 pid_t last_pid
= servers
->last()->pid();
440 test_compare(servers
->last()->pid(), last_pid
);
441 test_true(last_pid
> 1);
442 test_compare(kill(last_pid
, 0), 0);
444 test_true(servers
->shutdown());
446 test_compare(servers
->last()->pid(), -1);
447 test_compare(kill(last_pid
, 0), -1);
453 static test_return_t
socket_server_startup_TEST(void *object
)
455 server_startup_st
*servers
= (server_startup_st
*)object
;
458 test_true(servers
->start_socket_server(testing_service
, get_free_port(), 0, NULL
, false));
464 static test_return_t
memcached_sasl_test(void *object
)
466 server_startup_st
*servers
= (server_startup_st
*)object
;
469 test_skip(false, bool(getenv("TESTS_ENVIRONMENT")));
471 if (MEMCACHED_SASL_BINARY
)
473 if (HAVE_LIBMEMCACHED
)
475 test_true(has_memcached_sasl());
476 test_true(server_startup(*servers
, "memcached-sasl", get_free_port(), 0, NULL
, false));
486 static test_return_t
application_true_BINARY(void *)
488 test_skip(0, access("/usr/bin/true", X_OK
));
489 Application
true_app("/usr/bin/true");
491 test_compare(Application::SUCCESS
, true_app
.run());
492 test_compare(Application::SUCCESS
, true_app
.join());
497 static test_return_t
application_gdb_true_BINARY2(void *)
499 test_skip(0, access("/usr/bin/gdb", X_OK
));
500 test_skip(0, access("/usr/bin/true", X_OK
));
502 Application
true_app("/usr/bin/true");
503 true_app
.use_gdb(true);
505 test_compare(Application::SUCCESS
, true_app
.run());
506 test_compare(Application::SUCCESS
, true_app
.join());
511 static test_return_t
application_gdb_true_BINARY(void *)
513 test_skip(0, access("/usr/bin/gdb", X_OK
));
514 test_skip(0, access("/usr/bin/true", X_OK
));
516 Application
true_app("/usr/bin/true");
517 true_app
.use_gdb(true);
519 const char *args
[]= { "--fubar", 0 };
520 test_compare(Application::SUCCESS
, true_app
.run(args
));
521 test_compare(Application::SUCCESS
, true_app
.join());
526 static test_return_t
application_true_fubar_BINARY(void *)
528 test_skip(0, access("/usr/bin/true", X_OK
));
529 Application
true_app("/usr/bin/true");
531 const char *args
[]= { "--fubar", 0 };
532 test_compare(Application::SUCCESS
, true_app
.run(args
));
533 test_compare(Application::SUCCESS
, true_app
.join());
534 test_zero(true_app
.stdout_result().size());
539 static test_return_t
application_doesnotexist_BINARY(void *)
542 test_skip_valgrind();
543 Application
true_app("doesnotexist");
544 true_app
.will_fail();
546 const char *args
[]= { "--fubar", 0 };
547 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
548 test_compare(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
549 #elif defined(TARGET_OS_FREEBSD) && TARGET_OS_FREEBSD
550 test_compare(Application::INVALID_POSIX_SPAWN
, true_app
.run(args
));
552 test_compare(Application::SUCCESS
, true_app
.run(args
));
553 test_compare(Application::INVALID_POSIX_SPAWN
, true_app
.join());
556 test_zero(true_app
.stdout_result().size());
561 static test_return_t
GET_TEST(void *)
563 libtest::http::GET
get("http://foo.example.com/");
565 test_compare(false, get
.execute());
570 static test_return_t
POST_TEST(void *)
572 libtest::vchar_t body
;
573 libtest::http::POST
post("http://foo.example.com/", body
);
575 test_compare(false, post
.execute());
580 static test_return_t
TRACE_TEST(void *)
582 libtest::vchar_t body
;
583 libtest::http::TRACE
trace("http://foo.example.com/", body
);
585 test_compare(false, trace
.execute());
591 static test_return_t
vchar_t_TEST(void *)
593 libtest::vchar_t response
;
594 libtest::make_vector(response
, test_literal_param("fubar\n"));
595 test_compare(response
, response
);
600 static test_return_t
vchar_t_compare_neg_TEST(void *)
602 libtest::vchar_t response
;
603 libtest::vchar_t response2
;
604 libtest::make_vector(response
, test_literal_param("fubar\n"));
605 libtest::make_vector(response2
, test_literal_param(__func__
));
606 test_true(response
!= response2
);
611 static test_return_t
application_echo_fubar_BINARY(void *)
615 test_skip(0, access("/bin/echo", X_OK
));
616 Application
true_app("/bin/echo");
618 const char *args
[]= { "fubar", 0 };
619 test_compare(Application::SUCCESS
, true_app
.run(args
));
621 while (true_app
.slurp() == false) {} ;
623 libtest::vchar_t response
;
624 make_vector(response
, test_literal_param("fubar\n"));
625 test_compare(response
, true_app
.stdout_result());
631 static test_return_t
application_echo_fubar_BINARY2(void *)
635 test_skip(0, access("/bin/echo", X_OK
));
636 Application
true_app("/bin/echo");
638 true_app
.add_option("fubar");
640 test_compare(Application::SUCCESS
, true_app
.run());
641 test_compare(Application::SUCCESS
, true_app
.join());
643 libtest::vchar_t response
;
644 make_vector(response
, test_literal_param("fubar\n"));
645 test_compare(response
, true_app
.stdout_result());
651 static test_return_t
echo_fubar_BINARY(void *)
653 const char *args
[]= { "fubar", 0 };
654 test_compare(EXIT_SUCCESS
, exec_cmdline("/bin/echo", args
));
659 static test_return_t
core_count_BINARY(void *)
661 const char *args
[]= { 0 };
663 test_compare(EXIT_SUCCESS
, exec_cmdline("libtest/core-count", args
, true));
668 static test_return_t
wait_BINARY(void *)
670 const char *args
[]= { "--quiet", 0 };
672 test_compare(EXIT_FAILURE
, exec_cmdline("libtest/wait", args
, true));
677 static test_return_t
wait_help_BINARY(void *)
679 const char *args
[]= { "--quiet", "--help", 0 };
681 test_compare(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
686 static test_return_t
wait_version_BINARY(void *)
688 const char *args
[]= { "--quiet", "--version", 0 };
690 test_compare(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
695 static test_return_t
wait_services_BINARY(void *)
697 test_skip(0, access("/etc/services", R_OK
));
699 const char *args
[]= { "--quiet", "/etc/services", 0 };
701 test_compare(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
706 static test_return_t
wait_services_BINARY2(void *)
708 test_skip(0, access("/etc/services", R_OK
));
710 const char *args
[]= { "/etc/services", 0 };
712 test_compare(EXIT_SUCCESS
, exec_cmdline("libtest/wait", args
, true));
717 static test_return_t
wait_services_appliction_TEST(void *)
719 test_skip(0, access("/etc/services", R_OK
));
720 test_skip(0, access("/usr/bin/gdb", X_OK
));
721 test_skip(0, access("libtest/wait", X_OK
));
723 libtest::Application
wait_app("libtest/wait", true);
724 wait_app
.use_gdb(true);
726 const char *args
[]= { "/etc/services", 0 };
727 test_compare(Application::SUCCESS
, wait_app
.run(args
));
728 test_compare(Application::SUCCESS
, wait_app
.join());
733 static test_return_t
gdb_wait_services_appliction_TEST(void *)
735 test_skip(true, false);
736 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
737 test_skip(0, TARGET_OS_OSX
);
740 test_skip(0, access("/etc/services", R_OK
));
741 test_skip(0, access("/usr/bin/gdb", X_OK
));
742 test_skip(0, access("libtest/wait", X_OK
));
744 libtest::Application
wait_app("libtest/wait", true);
745 wait_app
.use_gdb(true);
747 const char *args
[]= { "/etc/services", 0 };
748 test_compare(Application::SUCCESS
, wait_app
.run(args
));
749 test_compare(Application::SUCCESS
, wait_app
.join());
754 static test_return_t
gdb_abort_services_appliction_TEST(void *)
756 test_skip(0, access("/usr/bin/gdb", X_OK
));
757 test_skip(0, access("libtest/abort", X_OK
));
758 test_skip(true, false);
760 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
761 test_skip(0, TARGET_OS_OSX
);
764 libtest::Application
abort_app("libtest/abort", true);
765 abort_app
.use_gdb(true);
767 test_compare(Application::SUCCESS
, abort_app
.run());
768 test_compare(Application::SUCCESS
, abort_app
.join());
770 std::string gdb_filename
= abort_app
.gdb_filename();
771 test_skip(0, access(gdb_filename
.c_str(), R_OK
));
772 const char *args
[]= { "SIGABRT", gdb_filename
.c_str(), 0 };
773 test_compare(EXIT_SUCCESS
, exec_cmdline("grep", args
));
776 args
[0]= "THIS_WILL_NOT_BE_FOUND";
777 test_compare(EXIT_FAILURE
, exec_cmdline("grep", args
));
782 static test_return_t
get_free_port_TEST(void *)
785 test_true((ret_port
= get_free_port()));
786 test_true(get_free_port() != default_port());
787 test_true(get_free_port() != get_free_port());
792 static test_return_t
fatal_TEST(void *)
794 test_compare(fatal_calls
++, fatal::disabled_counter());
795 throw libtest::fatal(LIBYATL_DEFAULT_PARAM
, "Testing va_args based fatal(): %d", 10);
800 static test_return_t
number_of_cpus_TEST(void *)
802 test_true(number_of_cpus() >= 1);
807 static test_return_t
check_dns_TEST(void *)
809 test_warn(libtest::check_dns(), "Broken DNS server/no DNS server found");
814 static test_return_t
Timer_TEST(void *)
816 int64_t minutes
= random() % 50;
822 check
.offset(minutes
, 2, 200);
824 test_compare(check
.minutes(), minutes
);
829 static test_return_t
lookup_true_TEST(void *)
831 test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
835 static test_return_t
lookup_false_TEST(void *)
837 if (libtest::lookup("does_not_exist.gearman.info"))
839 Error
<< "Broken DNS server detected";
846 static test_return_t
create_tmpfile_TEST(void *)
848 test_skip(0, access("/usr/bin/touch", X_OK
));
849 std::string tmp
= create_tmpfile(__func__
);
850 test_compare(-1, access(tmp
.c_str(), R_OK
));
851 test_compare(-1, access(tmp
.c_str(), F_OK
));
853 Application
touch_app("/usr/bin/touch");
854 const char *args
[]= { tmp
.c_str(), 0 };
855 test_compare(Application::SUCCESS
, touch_app
.run(args
));
856 test_compare(Application::SUCCESS
, touch_app
.join());
858 test_compare(0, access(tmp
.c_str(), R_OK
));
859 test_compare(0, unlink(tmp
.c_str()));
864 static test_return_t
fatal_message_TEST(void *)
866 test_compare(fatal_calls
++, fatal::disabled_counter());
867 fatal_message("Fatal test");
872 static test_return_t
default_port_TEST(void *)
874 in_port_t ret_port
= default_port();
875 test_compare(ret_port
, libtest::default_port());
876 test_compare(ret_port
, libtest::default_port());
881 static test_return_t
check_for_gearman(void *)
883 test_skip(true, HAVE_LIBGEARMAN
);
884 test_skip(true, has_gearmand());
885 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
888 if (strcmp(GEARMAND_BINARY
, "./gearmand/gearmand"))
890 test_zero(access(GEARMAND_BINARY
, X_OK
));
899 testing_service
= "gearmand";
904 static test_return_t
check_for_drizzle(void *)
906 test_skip(true, HAVE_LIBDRIZZLE
);
907 test_skip(true, has_drizzled());
909 testing_service
= "drizzled";
915 test_st drizzled_tests
[] ={
916 {"drizzled startup-shutdown", 0, drizzled_cycle_test
},
920 test_st gearmand_tests
[] ={
922 {"pause", 0, pause_test
},
924 {"gearmand startup-shutdown", 0, gearmand_cycle_test
},
925 {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test
},
926 {"server_startup(fail)", 0, server_startup_fail_TEST
},
930 static test_return_t
clear_servers(void* object
)
932 server_startup_st
*servers
= (server_startup_st
*)object
;
936 testing_service
.clear();
941 static test_return_t
check_for_memcached(void* object
)
943 test_skip(true, has_memcached());
945 server_startup_st
*servers
= (server_startup_st
*)object
;
949 testing_service
= "memcached";
954 test_st memcached_TESTS
[] ={
955 {"memcached startup-shutdown", 0, server_startup_TEST
},
956 {"memcached(socket file) startup-shutdown", 0, socket_server_startup_TEST
},
957 {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test
},
958 {"server_startup(fail)", 0, server_startup_fail_TEST
},
962 test_st test_skip_TESTS
[] ={
963 {"true, true", 0, test_skip_true_TEST
},
964 {"true, false", 0, test_skip_false_TEST
},
968 test_st environment_tests
[] ={
969 {"getenv()", 0, getenv_TEST
},
970 {"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test
},
971 {"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test
},
972 {"HELGRIND_COMMAND", 0, HELGRIND_COMMAND_test
},
973 {"GDB_COMMAND", 0, GDB_COMMAND_test
},
977 test_st tests_log
[] ={
978 {"TEST_SUCCESS", false, test_success_test
},
979 {"TEST_FAILURE", false, test_failure_test
},
980 {"TEST_SUCCESS == 0", false, test_success_equals_one_test
},
981 {"SUCCESS", false, test_throw_success_TEST
},
982 {"SKIP", false, test_throw_skip_TEST
},
983 {"FAIL", false, test_throw_fail_TEST
},
984 {"ASSERT_FALSE_", false, ASSERT_FALSE__TEST
},
985 {"ASSERT_FALSE", false, ASSERT_FALSE_TEST
},
989 test_st local_log
[] ={
990 {"test_is_local()", 0, local_test
},
991 {"test_is_local(NOT)", 0, local_not_test
},
995 test_st directories_tests
[] ={
996 {"var exists", 0, var_exists_test
},
997 {"var/tmp exists", 0, var_tmp_exists_test
},
998 {"var/run exists", 0, var_run_exists_test
},
999 {"var/log exists", 0, var_log_exists_test
},
1000 {"var/drizzle exists", 0, var_drizzle_exists_test
},
1001 {"var/tmp", 0, var_tmp_test
},
1002 {"var/run", 0, var_run_test
},
1003 {"var/log", 0, var_log_test
},
1004 {"var/drizzle", 0, var_drizzle_test
},
1005 {"var/tmp rm", 0, var_tmp_rm_test
},
1006 {"var/run rm", 0, var_run_rm_test
},
1007 {"var/log rm", 0, var_log_rm_test
},
1008 {"var/drizzle rm", 0, var_drizzle_rm_test
},
1012 test_st comparison_tests
[] ={
1013 {"_compare(test_return_t)", 0, _compare_test_return_t_test
},
1017 test_st cmdline_tests
[] ={
1018 {"echo fubar", 0, echo_fubar_BINARY
},
1019 {"core-count", 0, core_count_BINARY
},
1020 {"wait --quiet", 0, wait_BINARY
},
1021 {"wait --quiet --help", 0, wait_help_BINARY
},
1022 {"wait --quiet --version", 0, wait_version_BINARY
},
1023 {"wait --quiet /etc/services", 0, wait_services_BINARY
},
1024 {"wait /etc/services", 0, wait_services_BINARY2
},
1025 {"wait /etc/services", 0, wait_services_appliction_TEST
},
1026 {"gdb wait /etc/services", 0, gdb_wait_services_appliction_TEST
},
1027 {"gdb abort", 0, gdb_abort_services_appliction_TEST
},
1031 test_st get_free_port_TESTS
[] ={
1032 {"get_free_port()", 0, get_free_port_TEST
},
1033 {"default_port()", 0, default_port_TEST
},
1037 test_st fatal_message_TESTS
[] ={
1038 {"libtest::fatal", 0, fatal_TEST
},
1039 {"fatal_message()", 0, fatal_message_TEST
},
1043 test_st number_of_cpus_TESTS
[] ={
1044 {"libtest::number_of_cpus()", 0, number_of_cpus_TEST
},
1048 test_st create_tmpfile_TESTS
[] ={
1049 {"libtest::create_tmpfile()", 0, create_tmpfile_TEST
},
1053 test_st timer_TESTS
[] ={
1054 {"libtest::Timer", 0, Timer_TEST
},
1058 test_st dns_TESTS
[] ={
1059 {"libtest::lookup(true)", 0, lookup_true_TEST
},
1060 {"libtest::lookup(false)", 0, lookup_false_TEST
},
1061 {"libtest::check_dns()", 0, check_dns_TEST
},
1065 test_st application_tests
[] ={
1066 {"vchar_t", 0, vchar_t_TEST
},
1067 {"vchar_t compare()", 0, vchar_t_compare_neg_TEST
},
1068 {"true", 0, application_true_BINARY
},
1069 {"gbd true --fubar", 0, application_gdb_true_BINARY
},
1070 {"gbd true", 0, application_gdb_true_BINARY2
},
1071 {"true --fubar", 0, application_true_fubar_BINARY
},
1072 {"doesnotexist --fubar", 0, application_doesnotexist_BINARY
},
1073 {"echo fubar", 0, application_echo_fubar_BINARY
},
1074 {"echo fubar (as option)", 0, application_echo_fubar_BINARY2
},
1078 static test_return_t
check_for_curl(void *)
1080 test_skip(true, HAVE_LIBCURL
);
1081 return TEST_SUCCESS
;
1084 static test_return_t
disable_fatal_exception(void *)
1088 return TEST_SUCCESS
;
1091 static test_return_t
enable_fatal_exception(void *)
1094 return TEST_SUCCESS
;
1097 test_st http_tests
[] ={
1098 {"GET", 0, GET_TEST
},
1099 {"POST", 0, POST_TEST
},
1100 {"TRACE", 0, TRACE_TEST
},
1104 collection_st collection
[] ={
1105 {"environment", 0, 0, environment_tests
},
1106 {"return values", 0, 0, tests_log
},
1107 {"test_skip()", 0, 0, test_skip_TESTS
},
1108 {"local", 0, 0, local_log
},
1109 {"directories", 0, 0, directories_tests
},
1110 {"comparison", 0, 0, comparison_tests
},
1111 {"gearmand", check_for_gearman
, clear_servers
, gearmand_tests
},
1112 {"memcached", check_for_memcached
, clear_servers
, memcached_TESTS
},
1113 {"drizzled", check_for_drizzle
, clear_servers
, drizzled_tests
},
1114 {"cmdline", 0, 0, cmdline_tests
},
1115 {"application", 0, 0, application_tests
},
1116 {"http", check_for_curl
, 0, http_tests
},
1117 {"http", check_for_curl
, 0, http_tests
},
1118 {"get_free_port()", 0, 0, get_free_port_TESTS
},
1119 {"fatal", disable_fatal_exception
, enable_fatal_exception
, fatal_message_TESTS
},
1120 {"number_of_cpus()", 0, 0, number_of_cpus_TESTS
},
1121 {"create_tmpfile()", 0, 0, create_tmpfile_TESTS
},
1122 {"dns", 0, 0, dns_TESTS
},
1123 {"libtest::Timer", 0, 0, timer_TESTS
},
1127 static void *world_create(server_startup_st
& servers
, test_return_t
&)
1132 void get_world(libtest::Framework
*world
)
1134 world
->collections(collection
);
1135 world
->create(world_create
);