rhel, xenserver: Run unit tests while creating rpms.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 23 Jun 2014 21:05:00 +0000 (14:05 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Tue, 1 Jul 2014 15:36:02 +0000 (08:36 -0700)
For RHEL, Fedora and Xenserver, run unit tests while
building rpms.  This may catch some cross-platform bugs.

The commit also allows the users to optionally skip unit tests.
(On debian, the default is to run unit tests. For consistency,
do the same for rpms.)

VMware-BZ: 1267127

CC: Flavio Leitner <fbl@redhat.com>
CC: Ben Pfaff <blp@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Flavio Leitner <fbl@redhat.com>
Tested-by: Flavio Leitner <fbl@redhat.com>
INSTALL.Fedora
INSTALL.RHEL
INSTALL.XenServer
rhel/openvswitch-fedora.spec.in
rhel/openvswitch.spec.in
xenserver/openvswitch-xen.spec.in

index 708cae6..484fb87 100644 (file)
@@ -31,6 +31,11 @@ Fedora.  On Fedora 17, it is $HOME/rpmbuild/SOURCES.
 
    This produces one RPM: "openvswitch".
 
+   The above command automatically runs the Open vSwitch unit tests.
+   To disable the unit tests, run:
+
+       rpmbuild -bb --without check rhel/openvswitch-fedora.spec
+
 5. On Fedora 17, to build the Open vSwitch kernel module, run:
 
        rpmbuild -bb rhel/openvswitch-kmod-fedora.spec
index f46ad98..b7b294b 100644 (file)
@@ -79,6 +79,11 @@ RHEL.  On RHEL 5, the default RPM source directory is
 
    This produces two RPMs: "openvswitch" and "openvswitch-debuginfo".
 
+   The above command automatically runs the Open vSwitch unit tests.
+   To disable the unit tests, run:
+
+       rpmbuild -bb --without check rhel/openvswitch.spec
+
    If the build fails with "configure: error: source dir
    /lib/modules/2.6.32-279.el6.x86_64/build doesn't exist" or similar,
    then the kernel-devel package is missing or buggy.  Go back to step
index d6f5816..852a042 100644 (file)
@@ -36,6 +36,11 @@ RPMs for Citrix XenServer is the DDK VM available from Citrix.
    "openvswitch", "openvswitch-modules-xen", and
    "openvswitch-debuginfo".
 
+   The above command automatically runs the Open vSwitch unit tests.
+   To disable the unit tests, run:
+
+       rpmbuild -bb --without check xenserver/openvswitch-xen.spec
+
 Build Parameters
 ----------------
 
index 44cd7b9..30fe439 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-fedora.spec
 
 #%define kernel 2.6.40.4-5.fc15.x86_64
 
@@ -26,6 +30,8 @@ Requires(post):  systemd-units
 Requires(preun): systemd-units
 Requires(postun): systemd-units
 
+%bcond_without check
+
 %description
 Open vSwitch provides standard network bridging functions augmented with
 support for the OpenFlow protocol for remote per-flow control of
@@ -74,6 +80,16 @@ install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
 # Get rid of stuff we don't want to make RPM happy.
 (cd "$RPM_BUILD_ROOT" && rm -f usr/lib/lib*)
 
+%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
 
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
 
index ae29649..73ac9e3 100644 (file)
 #      -D "kernel_version 2.6.32.12-0.7.1.xs5.6.100.323.170596"
 #      -D "kernel_flavor xen"
 #      -bb /usr/src/redhat/SPECS/openvswitch-xen.spec
+#
+# If tests have to be skipped while building, specify the '--without check'
+# option. For example:
+# rpmbuild -bb --without check xenserver/openvswitch-xen.spec
 
 %if %{?openvswitch_version:0}%{!?openvswitch_version:1}
 %define openvswitch_version @VERSION@
@@ -37,6 +41,8 @@
 # build-supplemental-pack.sh requires this naming for kernel module packages
 %define module_package modules-%{kernel_flavor}-%{kernel_version}
 
+%bcond_without check
+
 Name: openvswitch
 Summary: Open vSwitch daemon/database/utilities
 Group: System Environment/Daemons
@@ -134,6 +140,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