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