[Pkg-owncloud-commits] [owncloud-client] 180/333: Fix statedb tests.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit a5ede054d633e9b8cb890a5d2d90e1aba568574f
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Mar 20 12:34:54 2014 +0100

    Fix statedb tests.
---
 csync/src/csync_statedb.c                           | 16 +++++++---------
 csync/tests/csync_tests/check_csync_statedb_load.c  |  5 +++--
 csync/tests/csync_tests/check_csync_statedb_query.c |  6 +++---
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/csync/src/csync_statedb.c b/csync/src/csync_statedb.c
index 978561f..ed0483a 100644
--- a/csync/src/csync_statedb.c
+++ b/csync/src/csync_statedb.c
@@ -307,17 +307,15 @@ int csync_statedb_close(CSYNC *ctx, int jwritten) {
   /* close the temporary database */
   sqlite3_close(ctx->statedb.db);
 
-  if (asprintf(&statedb_tmp, "%s.ctmp", ctx->statedb.file) < 0) {
-    return -1;
-  }
-
-  /* If we successfully synchronized, overwrite the original statedb */
-
-  /*
-   * Check the integrity of the tmp db. If ok, overwrite the old database with
-   * the tmp db.
+  /* If we successfully synchronized, overwrite the original statedb
+   *
+   * First check the integrity of the tmp db. If ok, overwrite the old
+   * database with the tmp db.
    */
   if (jwritten) {
+      if (!ctx->statedb.file || asprintf(&statedb_tmp, "%s.ctmp", ctx->statedb.file) < 0) {
+        return -1;
+      }
       /* statedb check returns either
        * 0  : database exists and is fine
        * 1  : new database was set up
diff --git a/csync/tests/csync_tests/check_csync_statedb_load.c b/csync/tests/csync_tests/check_csync_statedb_load.c
index b4d7e09..3ef2f05 100644
--- a/csync/tests/csync_tests/check_csync_statedb_load.c
+++ b/csync/tests/csync_tests/check_csync_statedb_load.c
@@ -43,6 +43,7 @@ static void setup(void **state) {
 
     csync_set_config_dir(csync, "/tmp/check_csync1/");
 
+    csync->statedb.file = c_strdup( TESTDB );
     *state = csync;
 }
 
@@ -123,7 +124,7 @@ static void check_csync_statedb_close(void **state)
     assert_int_equal(rc, 0);
     modtime = sb.st_mtime;
 
-    rc = csync_statedb_close(TESTDB, csync->statedb.db, 0);
+    rc = csync_statedb_close(csync, 0);
     assert_int_equal(rc, 0);
 
     rc = _tstat(testdb, &sb);
@@ -140,7 +141,7 @@ static void check_csync_statedb_close(void **state)
     sleep(1);
 
     /* statedb written */
-    rc = csync_statedb_close(TESTDB, csync->statedb.db, 1);
+    rc = csync_statedb_close(csync, 1);
     assert_int_equal(rc, 0);
 
     rc = _tstat(testdb, &sb);
diff --git a/csync/tests/csync_tests/check_csync_statedb_query.c b/csync/tests/csync_tests/check_csync_statedb_query.c
index 0e3fb97..151d6d0 100644
--- a/csync/tests/csync_tests/check_csync_statedb_query.c
+++ b/csync/tests/csync_tests/check_csync_statedb_query.c
@@ -237,7 +237,7 @@ static void check_csync_statedb_get_stat_by_hash_not_found(void **state)
     CSYNC *csync = *state;
     csync_file_stat_t *tmp;
 
-    tmp = csync_statedb_get_stat_by_hash(csync->statedb.db, (uint64_t) 666);
+    tmp = csync_statedb_get_stat_by_hash(csync, (uint64_t) 666);
     assert_null(tmp);
 
     free(tmp);
@@ -248,7 +248,7 @@ static void check_csync_statedb_get_stat_by_inode(void **state)
     CSYNC *csync = *state;
     csync_file_stat_t *tmp;
 
-    tmp = csync_statedb_get_stat_by_inode(csync->statedb.db, (ino_t) 23);
+    tmp = csync_statedb_get_stat_by_inode(csync, (ino_t) 23);
     assert_non_null(tmp);
 
     assert_int_equal(tmp->phash, 42);
@@ -262,7 +262,7 @@ static void check_csync_statedb_get_stat_by_inode_not_found(void **state)
     CSYNC *csync = *state;
     csync_file_stat_t *tmp;
 
-    tmp = csync_statedb_get_stat_by_inode(csync->statedb.db, (ino_t) 666);
+    tmp = csync_statedb_get_stat_by_inode(csync, (ino_t) 666);
     assert_null(tmp);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list