Blob Blame History Raw
diff -urp libqb-1.0.3.orig/configure.ac libqb-1.0.3/configure.ac
--- libqb-1.0.3.orig/configure.ac	2019-03-19 12:37:55.207208435 +0000
+++ libqb-1.0.3/configure.ac	2019-03-19 12:38:31.947311047 +0000
@@ -526,6 +526,17 @@ AC_ARG_WITH([force-sockets-config-file],
 	[ FORCESOCKETSFILE="$withval" ],
 	[ FORCESOCKETSFILE="$sysconfdir/libqb/force-filesystem-sockets" ])
 
+AC_ARG_ENABLE([install-tests],
+  [AS_HELP_STRING([--enable-install-tests],[install tests])],,
+  [ enable_install_tests="no" ])
+AM_CONDITIONAL([INSTALL_TESTS], [test x$enable_install_tests = xyes])
+
+AC_ARG_WITH([testdir],
+  [AS_HELP_STRING([--with-testdir=DIR],[path to /usr/lib../libqb/tests/ dir where to install the test suite])],
+        [ TESTDIR="$withval" ],
+        [ TESTDIR="$libdir/libqb/tests" ])
+AC_SUBST([TESTDIR])
+
 AC_SUBST(CP)
 # *FLAGS handling goes here
 
diff -urp libqb-1.0.3.orig/libqb.spec.in libqb-1.0.3/libqb.spec.in
--- libqb-1.0.3.orig/libqb.spec.in	2017-12-14 09:25:16.000000000 +0000
+++ libqb-1.0.3/libqb.spec.in	2019-03-19 12:38:31.948311049 +0000
@@ -1,4 +1,5 @@
 %bcond_without check
+%bcond_without testsrpm
 
 %global alphatag @alphatag@
 %global numcomm @numcomm@
@@ -26,7 +27,11 @@ and polling.
 
 %build
 ./autogen.sh
-%configure --disable-static
+%configure \
+%if %{with testsrpm}
+ --enable-install-tests \
+%endif
+ --disable-static
 make %{?_smp_mflags}
 
 %if 0%{?with_check}
@@ -67,6 +72,20 @@ developing applications that use %{name}
 %{_libdir}/pkgconfig/libqb.pc
 %{_mandir}/man3/qb*3*
 
+%if %{with testsrpm}
+%package	tests
+Summary:        Test suite for %{name}
+Group:          Development/Libraries
+Requires:       %{name}%{?_isa} = %{version}-%{release}
+
+%files		tests
+%doc COPYING
+%{_libdir}/libqb/tests/*
+
+%description	tests
+The %{name}-tests package contains the %{name} test suite.
+%endif
+
 %changelog
 * @date@ Autotools generated version <nobody@nowhere.org> - @version@-1-@numcomm@.@alphatag@.@dirty@
 - Autotools generated version
diff -urp libqb-1.0.3.orig/tests/blackbox-segfault.sh libqb-1.0.3/tests/blackbox-segfault.sh
--- libqb-1.0.3.orig/tests/blackbox-segfault.sh	2017-11-17 13:31:14.000000000 +0000
+++ libqb-1.0.3/tests/blackbox-segfault.sh	2019-03-19 12:44:06.650325170 +0000
@@ -1,25 +1,31 @@
-#!/bin/sh
+#!/bin/sh
+#
+# Needs PATH to be set to find accompanying test programs
+# - including qb-blackbox which for in-tree tests should be
+# - in ../tools
+
 #
 # create a normal blackbox
+#
 rm -f crash-test-dummy.fdata
-./crash_test_dummy
+crash_test_dummy
+rm -f core*
 
-. ./test.conf
+. test.conf
 
 # first test that reading the valid
 # blackbox data actually works.
-../tools/qb-blackbox crash-test-dummy.fdata
+qb-blackbox crash-test-dummy.fdata
 if [ $? -ne 0 ]; then
 	exit 1
 fi
 
-
 for i in $(seq $NUM_BB_TESTS)
 do
     rm -f butchered_blackbox.fdata
     echo " ==== Corrupt blackbox test $i/$NUM_BB_TESTS ===="
-    ./file_change_bytes -i crash-test-dummy.fdata -o butchered_blackbox.fdata -n 1024
-    ../tools/qb-blackbox butchered_blackbox.fdata
+    file_change_bytes -i crash-test-dummy.fdata -o butchered_blackbox.fdata -n 1024
+    qb-blackbox butchered_blackbox.fdata
     [ $? -gt 127 ] && exit 1 || true
 done
 
diff -urp libqb-1.0.3.orig/tests/Makefile.am libqb-1.0.3/tests/Makefile.am
--- libqb-1.0.3.orig/tests/Makefile.am	2017-12-14 09:25:16.000000000 +0000
+++ libqb-1.0.3/tests/Makefile.am	2019-03-19 12:39:40.658511799 +0000
@@ -23,10 +23,13 @@ CLEANFILES =
 
 SUBDIRS = functional
 
+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
+	bench-log format_compare_speed loop print_ver \
+	$(check_PROGRAMS)
 
 noinst_HEADERS = check_common.h
 
@@ -107,6 +110,7 @@ EXTRA_DIST += resources.test
 EXTRA_DIST += blackbox-segfault.sh
 
 TESTS = array.test map.test rb.test log.test blackbox-segfault.sh loop.test ipc.test resources.test
+TESTS_ENVIRONMENT = export PATH=.:../tools:$$PATH;
 
 resources.log: rb.log log.log ipc.log
 
@@ -119,6 +123,12 @@ 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 $(top_builddir)/include/qb/qblog.h