Blame SOURCES/bz1682119-install-tests.patch

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