[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] bug in svn_ver_compatible?

From: Uwe Zeisberger <zeisberg_at_informatik.uni-freiburg.de>
Date: 2004-10-27 16:53:48 CEST

Hello list,

if I link a program to libsvn_something version 1.0.0 and then update to
subversion 1.1.0 the program should continue to run, shouldn't it?

But in revision 11637, svn_ver_compatible(1.0.0, 1.1.0) returns FALSE.

I think the last `>=' in svn_ver_compatible should be a `<='.

If I'm right, here is a patch including a new test.

Regards
Uwe

----------
Fixes svn_ver_compatible to allow upgrading libs changing the minor

* subversion/libsvn_client/version.c
  (svn_ver_compatible): my_version->minor should be <= lib_version->minor

* subversion/tests/libsvn_subr/compat-test.c
  New file

* build.conf
  add section for compat-test

Index: build.conf
===================================================================
--- build.conf (revision 11637)
+++ build.conf (working copy)
@@ -584,6 +584,14 @@
 install = test
 libs = libsvn_test libsvn_delta libsvn_subr aprutil apriconv apr
 
+# test compatibility functions
+[compat-test]
+type = exe
+path = subversion/tests/libsvn_subr
+sources = compat-test.c
+install = test
+libs = libsvn_test apr
+
 # test path library
 [path-test]
 type = exe
Index: subversion/libsvn_subr/version.c
===================================================================
--- subversion/libsvn_subr/version.c (revision 11637)
+++ subversion/libsvn_subr/version.c (working copy)
@@ -48,7 +48,7 @@
   else
     /* General compatibility rules for released versions. */
     return (my_version->major == lib_version->major
- && my_version->minor >= lib_version->minor);
+ && my_version->minor <= lib_version->minor);
 }
 
 
Index: subversion/tests/libsvn_subr/compat-test.c
===================================================================
--- subversion/tests/libsvn_subr/compat-test.c (revision 0)
+++ subversion/tests/libsvn_subr/compat-test.c (revision 0)
@@ -0,0 +1,71 @@
+/*
+ * compat-test.c: tests svn_ver_compatible
+ */
+
+#include <string.h>
+
+#include <apr_pools.h>
+
+#include "svn_error.h"
+#include "svn_test.h"
+#include "svn_version.h"
+
+static const svn_version_t ver_1_0_0 = { 1, 0, 0, ""};
+static const svn_version_t ver_1_0_1 = { 1, 0, 1, ""};
+static const svn_version_t ver_1_1_0 = { 1, 1, 0, ""};
+
+static svn_error_t *
+test_version_patch (const char **msg,
+ svn_boolean_t msg_only,
+ apr_pool_t *pool)
+{
+ *msg = "library compatibility with changing patch numbers";
+ if (msg_only)
+ return SVN_NO_ERROR;
+
+ if (!svn_ver_compatible (&ver_1_0_0, &ver_1_0_1))
+ return svn_error_create
+ (SVN_ERR_TEST_FAILED, NULL,
+ "svn_ver_compatible (1.0.0, 1.0.1) returned FALSE");
+
+ if (!svn_ver_compatible (&ver_1_0_1, &ver_1_0_0))
+ return svn_error_create
+ (SVN_ERR_TEST_FAILED, NULL,
+ "svn_ver_compatible (1.0.1, 1.0.0) returned FALSE");
+
+ if (!svn_ver_compatible (&ver_1_0_1, &ver_1_0_1))
+ return svn_error_create
+ (SVN_ERR_TEST_FAILED, NULL,
+ "svn_ver_compatible (1.0.1, 1.0.1) returned FALSE");
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+test_version_minor (const char **msg,
+ svn_boolean_t msg_only,
+ apr_pool_t *pool)
+{
+ *msg = "library compatibility with changing minors";
+ if (msg_only)
+ return SVN_NO_ERROR;
+
+ if (!svn_ver_compatible (&ver_1_0_0, &ver_1_1_0))
+ return svn_error_create
+ (SVN_ERR_TEST_FAILED, NULL,
+ "svn_ver_compatible (1.0.0, 1.1.0) returned FALSE");
+
+ if (svn_ver_compatible (&ver_1_1_0, &ver_1_0_0))
+ return svn_error_create
+ (SVN_ERR_TEST_FAILED, NULL,
+ "svn_ver_compatible (1.1.0, 1.0.0) returned TRUE");
+ return SVN_NO_ERROR;
+}
+
+/* An array of all test functions */
+struct svn_test_descriptor_t test_funcs[] =
+ {
+ SVN_TEST_NULL,
+ SVN_TEST_PASS (test_version_patch),
+ SVN_TEST_PASS (test_version_minor),
+ SVN_TEST_NULL
+ };

-- 
Uwe Zeisberger
http://www.google.com/search?q=1+year+in+days

Received on Wed Oct 27 16:54:01 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.