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