Add ability to execute kernel datapath tests when building rpms.
These tests are disabled by default, and can optionally be run
by providing "--with check_datapath_kernel" on the rpmbuild command
line.  This is intended to facilitate automated testing, and
should not be used in production environments (it is generally not
recommended to run rpmbuild as root).

Suggested-by: Flavio Leitner <f...@sysclose.org>
Signed-off-by: Lance Richardson <lrich...@redhat.com>
---
v1->v2: Added comments about testing with out-of-tree modules.

 rhel/openvswitch-fedora.spec.in | 20 +++++++++++++++++++-
 rhel/openvswitch.spec.in        | 20 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in
index e61ff69..eda8767 100644
--- a/rhel/openvswitch-fedora.spec.in
+++ b/rhel/openvswitch-fedora.spec.in
@@ -9,7 +9,17 @@
 #
 # If tests have to be skipped while building, specify the '--without check'
 # option. For example:
-# rpmbuild -bb --without check rhel/openvswitch-fedora.spec
+#     rpmbuild -bb --without check rhel/openvswitch-fedora.spec
+#
+# Support for executing kernel data path tests under rpmbuild is
+# provided, however this is intended for use only in test environments
+# and should not be used otherwise (these tests require root privileges).
+# These tests can be executed, for example, via:
+#    rpmbuild -rb --with check_datapath_kernel openvswitch-fedora.src.rpm
+#
+# These tests will use the currently installed OVS kernel modules, when
+# testing out of tree kernel modules the appropriate openvswitch-kmod
+# package should be installed first.
 
 #%define kernel 2.6.40.4-5.fc15.x86_64
 
@@ -67,6 +77,7 @@ Requires(postun): systemd-units
 Obsoletes: openvswitch-controller <= 0:2.1.0-1
 
 %bcond_without check
+%bcond_with check_datapath_kernel
 
 %description
 Open vSwitch provides standard network bridging functions and
@@ -234,6 +245,13 @@ rm -f $RPM_BUILD_ROOT%{_bindir}/ovs-parse-backtrace \
         exit 1
     fi
 %endif
+%if %{with check_datapath_kernel}
+    if make check-kernel RECHECK=yes; then :;
+    else
+        cat tests/system-kmod-testsuite.log
+        exit 1
+    fi
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/rhel/openvswitch.spec.in b/rhel/openvswitch.spec.in
index fbca1ef..0ef0b04 100644
--- a/rhel/openvswitch.spec.in
+++ b/rhel/openvswitch.spec.in
@@ -9,7 +9,17 @@
 #
 # If tests have to be skipped while building, specify the '--without check'
 # option. For example:
-# rpmbuild -bb --without check rhel/openvswitch.spec
+#     rpmbuild -bb --without check rhel/openvswitch.spec
+#
+# Support for executing kernel data path tests under rpmbuild is
+# provided, however this is intended for use only in test environments
+# and should not be used otherwise (these tests require root privileges).
+# These tests can be executed, for example, via:
+#    rpmbuild -rb --with check_datapath_kernel openvswitch.src.rpm
+#
+# These tests will use the currently installed OVS kernel modules, when
+# testing out of tree kernel modules the appropriate openvswitch-kmod
+# package should be installed first.
 
 Name: openvswitch
 Summary: Open vSwitch daemon/database/utilities
@@ -27,6 +37,7 @@ BuildRequires: openssl-devel
 BuildRequires: checkpolicy, selinux-policy-devel
 
 %bcond_without check
+%bcond_with check_datapath_kernel
 
 %description
 Open vSwitch provides standard network bridging functions and
@@ -123,6 +134,13 @@ install -D -m 0644 lib/.libs/libopenvswitch.a \
         exit 1
     fi
 %endif
+%if %{with check_datapath_kernel}
+    if make check-kernel RECHECK=yes; then :;
+    else
+        cat tests/system-kmod-testsuite.log
+        exit 1
+    fi
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
-- 
2.5.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to