rhel, xenserver: Run unit tests while creating rpms.
[cascardo/ovs.git] / rhel / openvswitch.spec.in
index 18bc10c..c817cce 100644 (file)
@@ -6,6 +6,10 @@
 # are permitted in any medium without royalty provided the copyright
 # notice and this notice are preserved.  This file is offered as-is,
 # without warranty of any kind.
+#
+# If tests have to be skipped while building, specify the '--without check'
+# option. For example:
+# rpmbuild -bb --without check rhel/openvswitch.spec
 
 Name: openvswitch
 Summary: Open vSwitch daemon/database/utilities
@@ -21,6 +25,8 @@ Buildroot: /tmp/openvswitch-rpm
 Requires: openvswitch-kmod, logrotate, python
 BuildRequires: openssl-devel
 
+%bcond_without check
+
 %description
 Open vSwitch provides standard network bridging functions and
 support for the OpenFlow protocol for remote per-flow control of
@@ -67,6 +73,16 @@ rm \
 
 install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
 
+%check
+%if %{with check}
+    if make check TESTSUITEFLAGS='%{_smp_mflags}' ||
+       make check TESTSUITEFLAGS='--recheck'; then :;
+    else
+        cat tests/testsuite.log
+        exit 1
+    fi
+%endif
+
 %clean
 rm -rf $RPM_BUILD_ROOT