diff --git a/docs/Makefile.am b/docs/Makefile.am index fa1bac6..ab58a46 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,259 +1,259 @@ # Copyright (C) 2010 Red Hat, Inc. # # Authors: Angus Salkeld # # This file is part of libqb. # # libqb 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 2.1 of the License, or # (at your option) any later version. # # libqb 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 libqb. If not, see . MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = man.dox.in noinst_HEADERS = mainpage.h dist_man_MANS = man8/qb-blackbox.8 if HAVE_DOXYGEN if BUILD_MAN doxygen2man_flags = -q -i qb/ -o man3/ -m -g -P -H "libqb Programmer's Manual" $$($(UTC_DATE_AT)$(SOURCE_EPOCH) +"-D %F -Y %Y") \ -p LIBQB -c -O ../include/qb -Y $(SOURCE_EPOCH) man3_MANS = \ man3/qb_array_create_2.3 \ man3/qb_array_create.3 \ man3/qb_array_elems_per_bin_get.3 \ man3/qb_array_free.3 \ man3/qb_array_grow.3 \ man3/qbarray.h.3 \ man3/qb_array_index.3 \ man3/qb_array_new_bin_cb_set.3 \ man3/qb_array_num_bins_get.3 \ man3/qbatomic.h.3 \ man3/qb_atomic_init.3 \ man3/qb_atomic_int_add.3 \ man3/qb_atomic_int_compare_and_exchange.3 \ man3/qb_atomic_int_exchange_and_add.3 \ man3/qb_atomic_int_get.3 \ man3/qb_atomic_int_set.3 \ man3/qb_atomic_pointer_compare_and_exchange.3 \ man3/qb_atomic_pointer_get.3 \ man3/qb_atomic_pointer_set.3 \ man3/qbdefs.h.3 \ man3/qb_hashtable_create.3 \ man3/qb_hdb_base_convert.3 \ man3/qb_hdb_create.3 \ man3/qb_hdb_destroy.3 \ man3/qbhdb.h.3 \ man3/qb_hdb_handle_create.3 \ man3/qb_hdb_handle_destroy.3 \ man3/qb_hdb_handle_get.3 \ man3/qb_hdb_handle_get_always.3 \ man3/qb_hdb_handle_put.3 \ man3/qb_hdb_handle_refcount_get.3 \ man3/qb_hdb_iterator_next.3 \ man3/qb_hdb_iterator_reset.3 \ man3/qb_hdb_nocheck_convert.3 \ man3/qb_ipcc_connect.3 \ man3/qb_ipcc_context_get.3 \ man3/qb_ipcc_context_set.3 \ man3/qb_ipcc_disconnect.3 \ man3/qb_ipcc_event_recv.3 \ man3/qb_ipcc_fc_enable_max_set.3 \ man3/qb_ipcc_fd_get.3 \ man3/qb_ipcc_get_buffer_size.3 \ man3/qbipcc.h.3 \ man3/qb_ipcc_is_connected.3 \ man3/qbipc_common.h.3 \ man3/qb_ipcc_recv.3 \ man3/qb_ipcc_send.3 \ man3/qb_ipcc_sendv.3 \ man3/qb_ipcc_sendv_recv.3 \ man3/qb_ipcc_verify_dgram_max_msg_size.3 \ man3/qb_ipcs_connection_auth_set.3 \ man3/qb_ipcs_connection_first_get.3 \ man3/qb_ipcs_connection_get_buffer_size.3 \ man3/qb_ipcs_connection_next_get.3 \ man3/qb_ipcs_connection_ref.3 \ man3/qb_ipcs_connection_service_context_get.3 \ man3/qb_ipcs_connection_stats_get_2.3 \ man3/qb_ipcs_connection_stats_get.3 \ man3/qb_ipcs_connection_unref.3 \ man3/qb_ipcs_context_get.3 \ man3/qb_ipcs_context_set.3 \ man3/qb_ipcs_create.3 \ man3/qb_ipcs_destroy.3 \ man3/qb_ipcs_disconnect.3 \ man3/qb_ipcs_enforce_buffer_size.3 \ man3/qb_ipcs_event_send.3 \ man3/qb_ipcs_event_sendv.3 \ man3/qbipcs.h.3 \ man3/qb_ipcs_poll_handlers_set.3 \ man3/qb_ipcs_ref.3 \ man3/qb_ipcs_request_rate_limit.3 \ man3/qb_ipcs_response_send.3 \ man3/qb_ipcs_response_sendv.3 \ man3/qb_ipcs_run.3 \ man3/qb_ipcs_service_context_get.3 \ man3/qb_ipcs_service_context_set.3 \ man3/qb_ipcs_service_id_get.3 \ man3/qb_ipcs_stats_get.3 \ man3/qb_ipcs_unref.3 \ man3/qb_list_add.3 \ man3/qb_list_add_tail.3 \ man3/qb_list_del.3 \ man3/qb_list_empty.3 \ man3/qblist.h.3 \ man3/qb_list_init.3 \ man3/qb_list_is_last.3 \ man3/qb_list_length.3 \ man3/qb_list_replace.3 \ man3/qb_list_splice.3 \ man3/qb_list_splice_tail.3 \ man3/qb_log_blackbox_print_from_file.3 \ man3/qb_log_blackbox_write_to_file.3 \ man3/qb_log_callsite_get.3 \ man3/qb_log_callsites_dump.3 \ man3/qb_log_callsites_register.3 \ man3/qb_log_ctl2.3 \ man3/qb_log_ctl.3 \ man3/qb_log_custom_close.3 \ man3/qb_log_custom_open.3 \ man3/qb_log_facility2int.3 \ man3/qb_log_facility2str.3 \ man3/qb_log_file_close.3 \ man3/qb_log_file_open.3 \ man3/qb_log_file_reopen.3 \ man3/qb_log_filter_ctl2.3 \ man3/qb_log_filter_ctl.3 \ man3/qb_log_filter_fn_set.3 \ man3/qb_log_fini.3 \ man3/qb_log_format_set.3 \ man3/qb_log_from_external_source.3 \ man3/qb_log_from_external_source_va.3 \ man3/qblog.h.3 \ man3/qb_log_init.3 \ man3/qb_log_real_.3 \ man3/qb_log_real_va_.3 \ man3/qb_log_tags_stringify_fn_set.3 \ man3/qb_log_target_format.3 \ man3/qb_log_target_user_data_get.3 \ man3/qb_log_target_user_data_set.3 \ man3/qb_log_thread_priority_set.3 \ man3/qb_log_thread_start.3 \ man3/qb_loop_create.3 \ man3/qb_loop_destroy.3 \ man3/qbloop.h.3 \ man3/qb_loop_job_add.3 \ man3/qb_loop_job_del.3 \ man3/qb_loop_poll_add.3 \ man3/qb_loop_poll_del.3 \ man3/qb_loop_poll_low_fds_event_set.3 \ man3/qb_loop_poll_mod.3 \ man3/qb_loop_run.3 \ man3/qb_loop_signal_add.3 \ man3/qb_loop_signal_del.3 \ man3/qb_loop_signal_mod.3 \ man3/qb_loop_stop.3 \ man3/qb_loop_timer_add.3 \ man3/qb_loop_timer_del.3 \ man3/qb_loop_timer_expire_time_get.3 \ man3/qb_loop_timer_expire_time_remaining.3 \ man3/qb_loop_timer_is_running.3 \ man3/qb_map_count_get.3 \ man3/qb_map_destroy.3 \ man3/qb_map_foreach.3 \ man3/qb_map_get.3 \ man3/qbmap.h.3 \ man3/qb_map_iter_create.3 \ man3/qb_map_iter_free.3 \ man3/qb_map_iter_next.3 \ man3/qb_map_notify_add.3 \ man3/qb_map_notify_del_2.3 \ man3/qb_map_notify_del.3 \ man3/qb_map_pref_iter_create.3 \ man3/qb_map_put.3 \ man3/qb_map_rm.3 \ man3/qb_rb_chmod.3 \ man3/qb_rb_chown.3 \ man3/qb_rb_chunk_alloc.3 \ man3/qb_rb_chunk_commit.3 \ man3/qb_rb_chunk_peek.3 \ man3/qb_rb_chunk_read.3 \ man3/qb_rb_chunk_reclaim.3 \ man3/qb_rb_chunks_used.3 \ man3/qb_rb_chunk_write.3 \ man3/qb_rb_close.3 \ man3/qb_rb_create_from_file.3 \ man3/qbrb.h.3 \ man3/qb_rb_name_get.3 \ man3/qb_rb_open.3 \ man3/qb_rb_refcount_get.3 \ man3/qb_rb_shared_user_data_get.3 \ man3/qb_rb_space_free.3 \ man3/qb_rb_space_used.3 \ man3/qb_rb_write_to_file.3 \ man3/qb_skiplist_create.3 \ man3/qb_strerror_r.3 \ man3/qb_thread_lock.3 \ man3/qb_thread_lock_create.3 \ man3/qb_thread_lock_destroy.3 \ man3/qb_thread_trylock.3 \ man3/qb_thread_unlock.3 \ man3/qb_timespec_add_ms.3 \ man3/qb_trie_create.3 \ man3/qb_trie_dump.3 \ man3/qbutil.h.3 \ man3/qb_util_nano_current_get.3 \ man3/qb_util_nano_from_epoch_get.3 \ man3/qb_util_nano_monotonic_hz.3 \ man3/qb_util_set_log_function.3 \ man3/qb_util_stopwatch_create.3 \ man3/qb_util_stopwatch_free.3 \ man3/qb_util_stopwatch_sec_elapsed_get.3 \ man3/qb_util_stopwatch_split.3 \ man3/qb_util_stopwatch_split_ctl.3 \ man3/qb_util_stopwatch_split_last.3 \ man3/qb_util_stopwatch_start.3 \ man3/qb_util_stopwatch_stop.3 \ man3/qb_util_stopwatch_time_split_get.3 \ man3/qb_util_stopwatch_us_elapsed_get.3 \ man3/qb_util_timespec_from_epoch_get.3 $(man3_MANS): txt-man txt-man: man.dox doxygen man.dox xml-man: txt-man mkdir -p man3 - $(DOXYGEN2MAN) $(doxygen2man_flags) qbarray_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbatomic_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbdefs_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbhdb_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbipcc_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbipc__common_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbipcs_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qblist_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qblog_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbloop_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbmap_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbrb_8h.xml - $(DOXYGEN2MAN) $(doxygen2man_flags) qbutil_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbarray_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbatomic_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbdefs_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbhdb_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbipcc_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbipc__common_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbipcs_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qblist_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qblog_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbloop_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbmap_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbrb_8h.xml + "$(DOXYGEN2MAN)" $(doxygen2man_flags) qbutil_8h.xml all: $(man3_MANS) xml-man endif endif clean-local: rm -rf man3 xml diff --git a/tests/Makefile.am b/tests/Makefile.am index 7fc40b3..093bd1e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,207 +1,212 @@ # Copyright (c) 2010 Red Hat, Inc. # # Authors: Angus Salkeld # # This file is part of libqb. # # libqb 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 2.1 of the License, or # (at your option) any later version. # # libqb 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 libqb. If not, see . # MAINTAINERCLEANFILES = Makefile.in EXTRA_DIST = CLEANFILES = export SOCKETDIR AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include noinst_PROGRAMS = bmc bmcpt bms rbreader rbwriter \ bench-log format_compare_speed loop print_ver \ $(check_PROGRAMS) noinst_HEADERS = check_common.h format_compare_speed_SOURCES = format_compare_speed.c $(top_builddir)/include/qb/qbutil.h format_compare_speed_LDADD = $(top_builddir)/lib/libqb.la bmc_SOURCES = bmc.c bmc_LDADD = $(top_builddir)/lib/libqb.la bmcpt_SOURCES = bmcpt.c bmcpt_CFLAGS = $(PTHREAD_CFLAGS) bmcpt_LDADD = $(PTHREAD_LIBS) $(top_builddir)/lib/libqb.la bms_SOURCES = bms.c bms_CFLAGS = $(GLIB_CFLAGS) bms_LDADD = $(top_builddir)/lib/libqb.la $(GLIB_LIBS) rbwriter_SOURCES = rbwriter.c rbwriter_LDADD = $(top_builddir)/lib/libqb.la rbreader_SOURCES = rbreader.c rbreader_LDADD = $(top_builddir)/lib/libqb.la loop_SOURCES = loop.c loop_LDADD = $(top_builddir)/lib/libqb.la inc_dir = $(top_srcdir)/include/qb public_headers = $(sort $(patsubst %.in,%,$(subst $(inc_dir)/,,$(shell \ printf 'include $(inc_dir)/Makefile.am\n\n%%.var:\n\t@echo $$($$*)' \ | MAKEFLAGS= ${MAKE} --no-print-directory -f- inst_HEADERS.var \ || echo $(inc_dir)/qb*.h*)))) auto_c_files = $(patsubst %.h,auto_check_header_%.c,$(public_headers)) CLEANFILES += $(auto_c_files) # this works for both non/generated headers thanks to VPATH being # automatically set to $(top_srcdir)/tests and $(top_builddir) # being resolved to ".." by automake # ($(top_srcdir)/tests/../include/qb/%.h = $(top_srcdir)/include/qb/%.h) auto_check_header_%.c: $(top_builddir)/include/qb/%.h @name=$$(echo "$<" | sed "s|.*qb/qb||" | sed "s|\.h||") ;\ NAME=$$(echo $$name | tr [:lower:] [:upper:]) ;\ echo "#include " > $@_ ;\ echo "#ifndef QB_$${NAME}_H_DEFINED" >> $@_ ;\ echo "#error no header protector in file qb$$name.h" >> $@_ ;\ echo "#endif" >> $@_ ;\ echo "int main(void) {return 0;}" >> $@_ $(AM_V_GEN)mv $@_ $@ check: check-headers # rely on implicit automake rule to include right (local) includes .PHONY: check-headers check-headers: $(auto_c_files:.c=.o) $(auto_c_files:.c=.opp) # this is to check basic sanity of using libqb from C++ code, if possible %.opp: %.c if HAVE_GXX $(AM_V_GEN)$(CXX) $(AM_CPPFLAGS) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< else @echo "C++ compatibility tests not run" endif CLEANFILES += ${auto_c_files:.c=.opp} distclean-local: rm -rf auto_*.c rm -rf .deps if HAVE_DICT_WORDS if HAVE_SLOW_TESTS EXTRA_DIST += make-log-test.sh CLEANFILES += auto_write_logs.c MAINTAINERCLEANFILES += auto_write_logs.c nodist_bench_log_SOURCES = auto_write_logs.c bench_log: auto_write_logs.c $(builddir)/auto_write_logs.c: make-log-test.sh @$(srcdir)/make-log-test.sh > $(builddir)/write_logs-tmp.c $(AM_V_GEN)mv $(builddir)/write_logs-tmp.c $(builddir)/auto_write_logs.c endif endif bench_log_SOURCES = bench-log.c bench_log_LDADD = $(top_builddir)/lib/libqb.la +lib_LTLIBRARIES = libstat_wrapper.la +libstat_wrapper_la_SOURCES = libstat_wrapper.c +libstat_wrapper_la_LIBADD = -ldl +libdir= $(TESTDIR) + if HAVE_CHECK -EXTRA_DIST += start.test resources.test +EXTRA_DIST += start.test resources.test ipc_sock.test EXTRA_DIST += blackbox-segfault.sh -TESTS = start.test array.test map.test rb.test list.test log.test blackbox-segfault.sh loop.test ipc.test resources.test +TESTS = start.test array.test map.test rb.test list.test log.test blackbox-segfault.sh loop.test ipc.test ipc_sock.test resources.test TESTS_ENVIRONMENT = export PATH=.:../tools:$$PATH; resources.log: rb.log log.log ipc.log check_LTLIBRARIES = check_PROGRAMS = array.test ipc.test list.test log.test loop.test \ map.test rb.test util.test tlist.test \ crash_test_dummy file_change_bytes -dist_check_SCRIPTS = start.test resources.test blackbox-segfault.sh +dist_check_SCRIPTS = start.test resources.test blackbox-segfault.sh ipc_sock.test if HAVE_SLOW_TESTS TESTS += util.test check_PROGRAMS += util.test endif if INSTALL_TESTS testsuitedir = $(TESTDIR) testsuite_PROGRAMS = $(check_PROGRAMS) testsuite_SCRIPTS = $(dist_check_SCRIPTS) test.conf endif file_change_bytes_SOURCES = file_change_bytes.c crash_test_dummy_SOURCES = crash_test_dummy.c crash_test_dummy_CFLAGS = @CHECK_CFLAGS@ crash_test_dummy_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ array_test_SOURCES = check_array.c array_test_CFLAGS = @CHECK_CFLAGS@ array_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ map_test_SOURCES = check_map.c map_test_CFLAGS = @CHECK_CFLAGS@ map_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ rb_test_SOURCES = check_rb.c rb_test_CFLAGS = @CHECK_CFLAGS@ rb_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ loop_test_SOURCES = check_loop.c loop_test_CFLAGS = @CHECK_CFLAGS@ loop_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ tlist_test_SOURCES = check_tlist.c tlist_test_CFLAGS = @CHECK_CFLAGS@ tlist_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ ipc_test_SOURCES = check_ipc.c ipc_test_CFLAGS = @CHECK_CFLAGS@ ipc_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ if HAVE_FAILURE_INJECTION ipc_test_LDADD += _failure_injection.la if HAVE_GLIB ipc_test_CFLAGS += $(GLIB_CFLAGS) ipc_test_LDADD += $(GLIB_LIBS) endif check_LTLIBRARIES += _failure_injection.la _failure_injection_la_SOURCES = _failure_injection.c _failure_injection.h _failure_injection_la_LDFLAGS = -module _failure_injection_la_LIBADD = $(dlopen_LIBS) endif check_LTLIBRARIES += _syslog_override.la _syslog_override_la_SOURCES = _syslog_override.c _syslog_override.h _syslog_override_la_LDFLAGS = -module log_test_SOURCES = check_log.c log_test_CFLAGS = @CHECK_CFLAGS@ log_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ log_test_LDADD += _syslog_override.la util_test_SOURCES = check_util.c util_test_CFLAGS = @CHECK_CFLAGS@ util_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ list_test_SOURCES = check_list.c list_test_CFLAGS = @CHECK_CFLAGS@ list_test_LDADD = $(top_builddir)/lib/libqb.la @CHECK_LIBS@ endif clean-local: rm -f *.log rm -f *.fdata diff --git a/tests/ipc_sock.test b/tests/ipc_sock.test new file mode 100755 index 0000000..0bcebe2 --- /dev/null +++ b/tests/ipc_sock.test @@ -0,0 +1,19 @@ +#!/bin/sh +# +# Run the IPC tests under the stat wrapper, +# this simulates /etc/libqb/use-filesystem-sockets existing +# so we can test both options without breaking other things +# that might be running on this system +# +if [ "$(uname -s)" = "Linux" ] +then + if [ -f "$(pwd)/.libs/libstat_wrapper.so" ] + then + export "LD_PRELOAD=$(pwd)/.libs/libstat_wrapper.so" + else + export "LD_PRELOAD=$(pwd)/libstat_wrapper.so" + fi + ./ipc.test +else + exit 0 +fi diff --git a/tests/libstat_wrapper.c b/tests/libstat_wrapper.c new file mode 100644 index 0000000..37f51e6 --- /dev/null +++ b/tests/libstat_wrapper.c @@ -0,0 +1,58 @@ +/* + * Simulate FORCESOCKETSFILE existing for the IPC tests + */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include "../include/config.h" +#if defined(QB_LINUX) || defined(QB_CYGWIN) +#include +#endif + +// __xstat for earlier libc +int __xstat(int __ver, const char *__filename, struct stat *__stat_buf) +{ +#if defined(QB_LINUX) || defined(QB_CYGWIN) + static int opened = 0; + static int (*real_xstat)(int __ver, const char *__filename, void *__stat_buf); + + if (!opened) { + real_xstat = dlsym(RTLD_NEXT, "__xstat"); + opened = 1; + } + + if (strcmp(__filename, FORCESOCKETSFILE) == 0) { + fprintf(stderr, "__xstat called for %s\n", __filename); + return 0; /* it exists! */ + } + + return real_xstat(__ver, __filename, __stat_buf); +#else + return -1; /* Error in the unlikely event we get called on *BSD* */ +#endif +} + +// stat for F35 and later +int stat(const char *__filename, struct stat *__stat_buf) +{ +#if defined(QB_LINUX) || defined(QB_CYGWIN) + static int opened = 0; + static int (*real_stat)(const char *__filename, void *__stat_buf); + + if (!opened) { + real_stat = dlsym(RTLD_NEXT, "stat"); + opened = 1; + } + + if (strcmp(__filename, FORCESOCKETSFILE) == 0) { + fprintf(stderr, "stat called for %s\n", __filename); + return 0; /* it exists! */ + } + + return real_stat(__filename, __stat_buf); +#else + return -1; /* Error in the unlikely event we get called on *BSD* */ +#endif +} diff --git a/tests/resources.test b/tests/resources.test index 252c71a..d3f8e0f 100755 --- a/tests/resources.test +++ b/tests/resources.test @@ -1,60 +1,70 @@ #!/bin/sh RETURN=0 SOCKS_PER_PROCESS=3 +EXPECTED_DLOCK=6 +EXPECTED_LEFTOVER=2 + +# Linux also runs filesystem socket tests +if [ "$(uname -s)" = "Linux" ] +then + EXPECTED_DLOCK=12 + EXPECTED_LEFTOVER=4 +fi tidy_qb_dirs() { for dd in "$@"; do rm $dd - rmdir `dirname $dd` 2> /dev/null + rmdir $(dirname $dd) 2> /dev/null done } -IPC_NAME=`cat ipc-test-name 2>/dev/null` +IPC_NAME=$(cat ipc-test-name 2>/dev/null) for d in /dev/shm /var/run $SOCKETDIR; do # Tidy up the deadlock checker sockets first dlocks=$(find $d -name "qb-*-test_*dlock*${IPC_NAME}*" -size +0c 2>/dev/null) - if [ "`echo $dlocks|wc -w`" -eq $(($SOCKS_PER_PROCESS * 6)) ]; then - tidy_qb_dirs $dlocks + if [ "$(echo $dlocks|wc -w)" -eq $(($SOCKS_PER_PROCESS * $EXPECTED_DLOCK)) ]; then + tidy_qb_dirs $dlocks + rm $dlocks elif [ -n "${dlocks}" ]; then echo echo "Error: dlock shared memory segments not closed/unlinked" echo RETURN=1 fi # Now look for other expected leftovers leftovers=$(find $d -name "qb-*-test_*${IPC_NAME}*" -size +0c 2>/dev/null | wc -l) if [ "${leftovers}" -gt 0 ]; then echo echo "Error: shared memory segments not closed/unlinked" echo RETURN=1 fi leftovers="$(find $d -name "qb-*-test_*${IPC_NAME}*" -size 0c 2>/dev/null)" - if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq $(($SOCKS_PER_PROCESS * 2)) ]; then + if [ "$(printf '%s\n' "${leftovers}" | wc -l)" -eq $(($SOCKS_PER_PROCESS * $EXPECTED_LEFTOVER)) ]; then echo echo "There were some empty leftovers (expected), removing them" echo "${leftovers}" echo tidy_qb_dirs $leftovers elif [ -n "${leftovers}" ]; then echo echo "Error: unexpected number of empty leftovers" echo "${leftovers}" echo RETURN=1 fi done ps aux | grep -v grep | grep -E 'lt-.*\.test' if [ $? -eq 0 ]; then echo "test program frozen" RETURN=1 fi # Keep it tidy - distcheck checks we have not left a mess rm -f ipc-test-name rm -f crash_test_dummy.core exit $RETURN diff --git a/tests/start.test b/tests/start.test index 91d1734..7f63540 100755 --- a/tests/start.test +++ b/tests/start.test @@ -1,13 +1,13 @@ #!/bin/sh # # Generate a unique(ish) name for the IPCs we will use in the tests and # save it in a file for all of the tests to use. This way we know for sure # which sockets are our and which we can ignore. # The test programs all add "qb-test--" to the front of this. # -NAME="$$-`date +%s`" +NAME="$$-$(date +%s)" printf "$NAME" > ipc-test-name mkdir -p $SOCKETDIR