[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3873 - GNUnet/src/applications/dstore
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3873 - GNUnet/src/applications/dstore |
Date: |
Sun, 3 Dec 2006 17:41:41 -0800 (PST) |
Author: grothoff
Date: 2006-12-03 17:41:39 -0800 (Sun, 03 Dec 2006)
New Revision: 3873
Modified:
GNUnet/src/applications/dstore/dstore.c
GNUnet/src/applications/dstore/dstore_test.c
Log:
fixes
Modified: GNUnet/src/applications/dstore/dstore.c
===================================================================
--- GNUnet/src/applications/dstore/dstore.c 2006-12-04 01:04:04 UTC (rev
3872)
+++ GNUnet/src/applications/dstore/dstore.c 2006-12-04 01:41:39 UTC (rev
3873)
@@ -218,6 +218,7 @@
cron_t expire;
unsigned int size;
const char * dat;
+ unsigned int cnt;
MUTEX_LOCK(lock);
if (SQLITE_OK != sqlite3_open(fn,
@@ -242,6 +243,7 @@
sqlite3_bind_int(stmt,
2,
type);
+ cnt = 0;
while (sqlite3_step(stmt) == SQLITE_ROW) {
size = sqlite3_column_int(stmt, 1);
if (size != sqlite3_column_bytes(stmt, 6)) {
@@ -257,11 +259,12 @@
size,
dat,
closure);
+ cnt++;
}
sqlite3_finalize(stmt);
sqlite3_close(dbh);
MUTEX_UNLOCK(lock);
- return 0;
+ return cnt;
}
Dstore_ServiceAPI *
Modified: GNUnet/src/applications/dstore/dstore_test.c
===================================================================
--- GNUnet/src/applications/dstore/dstore_test.c 2006-12-04 01:04:04 UTC
(rev 3872)
+++ GNUnet/src/applications/dstore/dstore_test.c 2006-12-04 01:41:39 UTC
(rev 3873)
@@ -18,8 +18,8 @@
Boston, MA 02111-1307, USA.
*/
/*
- * @file applications/kvstore_sqlite/kv_sqlitetest.c
- * @brief Test for the kvstore implementations.
+ * @file applications/dstore/dstore_test.c
+ * @brief Test for the dstore implementations.
* @author Nils Durner
*/
@@ -28,53 +28,70 @@
#include "gnunet_util_cron.h"
#include "gnunet_util_config_impl.h"
#include "gnunet_protocols.h"
-#include "gnunet_kvstore_service.h"
+#include "gnunet_dstore_service.h"
#include "core.h"
#define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__,
__LINE__); goto FAILURE;} } while (0)
+static int error;
+static void checkIt(const HashCode512 * key,
+ unsigned int type,
+ unsigned int size,
+ const char * data,
+ void * cls) {
+ if (size != sizeof(HashCode512))
+ error = 2;
+ if (0 != memcmp(data, cls, size))
+ error = 3;
+}
+
/**
* Add testcode here!
*/
-static int test(KVstore_ServiceAPI * api) {
- KVHandle *kv;
- HashCode512 k, v;
- HashCode512 *r;
+static int test(Dstore_ServiceAPI * api) {
+ HashCode512 k;
+ HashCode512 n;
+ cron_t exp;
+ unsigned int i;
- cron_t timeStmp;
-
- kv = api->getTable("TEST", "KV");
- ASSERT(kv != NULL);
-
- timeStmp = get_time();
- ASSERT(api->put(kv, (void *) &k, sizeof(k), (void *) &v, sizeof(v),
- timeStmp) == OK);
-
- r = api->get(kv, (void *) &k, sizeof(k), 0, 0, NULL, NULL);
- ASSERT(r != NULL);
- ASSERT(memcmp(&v, r, sizeof(v)) == 0);
- FREE(r);
-
- ASSERT(api->del(kv, (void *) &k, sizeof(k), 0) == OK);
-
- ASSERT(api->get(kv, (void *) &k, sizeof(k), 0, 0, NULL, NULL) == NULL);
-
- ASSERT(api->dropTable(kv) == OK);
-
- api->dropDatabase("TEST");
-
+ exp = get_time() + 5 * cronSECONDS;
+ memset(&k,
+ 0,
+ sizeof(HashCode512));
+ for (i=0;i<100;i++) {
+ hash(&k,
+ sizeof(HashCode512),
+ &n);
+ ASSERT(OK == api->put(&k,
+ i % 2,
+ exp,
+ sizeof(HashCode512),
+ (const char*) &k));
+ k = n;
+ }
+ memset(&k,
+ 0,
+ sizeof(HashCode512));
+ for (i=0;i<100;i++) {
+ hash(&k,
+ sizeof(HashCode512),
+ &n);
+ ASSERT(1 == api->get(&k,
+ i % 2,
+ &checkIt,
+ &n));
+ k = n;
+ }
return OK;
-
FAILURE:
- api->dropDatabase("TEST");
return SYSERR;
}
-#define TEST_DB "/tmp/GNUnet_sqstore_test/"
+#define TEST_DB "/tmp/GNUnet_dstore_test/"
int main(int argc, char *argv[]) {
- KVstore_ServiceAPI * api;
+ Dstore_ServiceAPI * api;
int ok;
struct GC_Configuration * cfg;
struct CronManager * cron;
@@ -90,7 +107,7 @@
cfg,
cron,
NULL);
- api = requestService("kvstore_sqlite");
+ api = requestService("dstore");
if (api != NULL) {
ok = test(api);
releaseService(api);
@@ -99,7 +116,7 @@
doneCore();
if (ok == SYSERR)
return 1;
- return 0;
+ return error;
}
-/* end of kv_sqlitetest.c */
+/* end of dstore_test.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3873 - GNUnet/src/applications/dstore,
grothoff <=