python: Make build number format consistent with C.
authorEthan Jackson <ethan@nicira.com>
Wed, 7 Mar 2012 23:48:32 +0000 (15:48 -0800)
committerEthan Jackson <ethan@nicira.com>
Thu, 8 Mar 2012 00:50:16 +0000 (16:50 -0800)
The C code displays the build number as the empty string when 0,
and as +build<num> otherwise.  This commit updates version.py to be
consistent and tests that it is in the unit tests.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
python/automake.mk
python/ovs/unixctl.py
tests/atlocal.in
tests/unixctl-py.at

index f9d2c57..9672042 100644 (file)
@@ -64,5 +64,8 @@ ALL_LOCAL += $(srcdir)/python/ovs/version.py
 $(srcdir)/python/ovs/version.py: config.status
        $(ro_shell) > $@.tmp
        echo 'VERSION = "$(VERSION)"' >> $@.tmp
-       echo 'BUILDNR = "$(BUILDNR)"' >> $@.tmp
+       if [ "$(BUILDNR)" != "0" ]; \
+           then echo 'BUILDNR = "+build$(BUILDNR)"' >> $@.tmp; \
+           else echo 'BUILDNR = ""' >> $@.tmp; \
+       fi;
        mv $@.tmp $@
index 8921ba8..4a591a7 100644 (file)
@@ -57,9 +57,9 @@ def _unixctl_help(conn, unused_argv, unused_aux):
 
 def _unixctl_version(conn, unused_argv, unused_aux):
     assert isinstance(conn, UnixctlConnection)
-    version = "%s (Open vSwitch) %s %s" % (ovs.util.PROGRAM_NAME,
-                                           ovs.version.VERSION,
-                                           ovs.version.BUILDNR)
+    version = "%s (Open vSwitch) %s%s" % (ovs.util.PROGRAM_NAME,
+                                          ovs.version.VERSION,
+                                          ovs.version.BUILDNR)
     conn.reply(version)
 
 
index 400a5c5..1d37b59 100644 (file)
@@ -1,6 +1,4 @@
 # -*- shell-script -*-
-VERSION='@VERSION@'
-BUILDNR='@BUILDNR@'
 HAVE_OPENSSL='@HAVE_OPENSSL@'
 HAVE_PYTHON='@HAVE_PYTHON@'
 PERL='@PERL@'
index 8317add..52fb72a 100644 (file)
@@ -109,7 +109,7 @@ The available commands are:
 mv stdout expout
 AT_CHECK([PYAPPCTL -t test-unixctl.py help], [0], [expout])
 
-AT_CHECK([echo "test-unixctl.py (Open vSwitch) $VERSION $BUILDNR" > expout])
+AT_CHECK([ovs-vsctl --version | sed 's/ovs-vsctl/test-unixctl.py/' | head -1 > expout])
 AT_CHECK([APPCTL -t test-unixctl.py version], [0], [expout])
 AT_CHECK([PYAPPCTL -t test-unixctl.py version], [0], [expout])