[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3396 - GNUnet/src/applications/fs/fsui
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3396 - GNUnet/src/applications/fs/fsui |
Date: |
Sun, 10 Sep 2006 23:27:23 -0700 (PDT) |
Author: grothoff
Date: 2006-09-10 23:27:20 -0700 (Sun, 10 Sep 2006)
New Revision: 3396
Modified:
GNUnet/src/applications/fs/fsui/Makefile.am
GNUnet/src/applications/fs/fsui/fsuitest.c
GNUnet/src/applications/fs/fsui/fsuitest2.c
GNUnet/src/applications/fs/fsui/searchtest.c
Log:
towards compiling fsui tests:
Modified: GNUnet/src/applications/fs/fsui/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/fsui/Makefile.am 2006-09-11 05:58:23 UTC (rev
3395)
+++ GNUnet/src/applications/fs/fsui/Makefile.am 2006-09-11 06:27:20 UTC (rev
3396)
@@ -25,6 +25,7 @@
fsui_loader_SOURCES = \
fsui-loader.c
fsui_loader_LDADD = \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
@@ -42,6 +43,8 @@
fsuitest_SOURCES = \
fsuitest.c
fsuitest_LDADD = \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -49,6 +52,8 @@
fsuitest2_SOURCES = \
fsuitest2.c
fsuitest2_LDADD = \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -56,6 +61,8 @@
searchtest_SOURCES = \
searchtest.c
searchtest_LDADD = \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/util/libgnunetutil.la
@@ -63,6 +70,8 @@
downloadtest_SOURCES = \
downloadtest.c
downloadtest_LDADD = \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
$(top_builddir)/src/applications/fs/ecrs/libgnunetecrs.la \
$(top_builddir)/src/applications/fs/fsui/libgnunetfsui.la \
$(top_builddir)/src/util/libgnunetutil.la
Modified: GNUnet/src/applications/fs/fsui/fsuitest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest.c 2006-09-11 05:58:23 UTC (rev
3395)
+++ GNUnet/src/applications/fs/fsui/fsuitest.c 2006-09-11 06:27:20 UTC (rev
3396)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -27,33 +27,18 @@
#include "platform.h"
#include "gnunet_util.h"
#include "gnunet_fsui_lib.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
-static int parseCommandLine(int argc,
- char * argv[]) {
- FREENONNULL(setConfigurationString("GNUNETD",
- "_MAGIC_",
- "NO"));
- FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
- FREENONNULL(setConfigurationString("GNUNET",
- "LOGLEVEL",
- "NOTHING"));
- FREENONNULL(setConfigurationString("GNUNET",
- "GNUNETD-CONFIG",
- "check.conf"));
- return OK;
-}
-
static char * makeName(unsigned int i) {
char * name;
char * fn;
fn = STRDUP("/tmp/gnunet-fsuitest");
- name = expandFileName(fn);
- disk_directory_create(ectx, name);
+ name = string_expandFileName(NULL, fn);
+ disk_directory_create(NULL, name);
FREE(fn);
fn = MALLOC(strlen(name) + 40);
SNPRINTF(fn,
@@ -67,13 +52,22 @@
}
static volatile enum FSUI_EventType lastEvent;
+
static struct FSUI_Context * ctx;
-static void eventCallback(void * cls,
- const FSUI_Event * event) {
+static struct FSUI_DownloadList * download;
+
+static void * eventCallback(void * cls,
+ const FSUI_Event * event) {
+ static char unused;
char * fn;
switch(event->type) {
+ case FSUI_search_resuming:
+ case FSUI_download_resuming:
+ case FSUI_upload_resuming:
+ case FSUI_unindex_resuming:
+ return &unused;
case FSUI_search_result:
printf("Received search result\n");
break;
@@ -90,16 +84,18 @@
break;
}
if (lastEvent == FSUI_download_complete)
- return; /* ignore all other events */
+ return NULL; /* ignore all other events */
lastEvent = event->type;
if (event->type == FSUI_search_result) {
fn = makeName(43);
- FSUI_startDownload(ctx,
- 0,
- event->data.SearchResult.fi.uri,
- fn);
+ download = FSUI_startDownload(ctx,
+ 0,
+ NO,
+ event->data.SearchResult.fi.uri,
+ fn);
FREE(fn);
}
+ return NULL;
}
@@ -117,40 +113,58 @@
int prog;
struct ECRS_MetaData * meta;
struct ECRS_URI * kuri;
-
- if (OK != initUtil(argc,
- argv,
- &parseCommandLine))
- return -1;
- daemon = startGNUnetDaemon(NO);
- GE_ASSERT(ectx, daemon > 0);
+ struct GC_Configuration * cfg;
+ struct FSUI_UploadList * upload;
+ struct FSUI_SearchList * search;
+ struct FSUI_UnindexList * unindex;
+
+ cfg = GC_create_C_impl();
+ if (-1 == GC_parse_configuration(cfg,
+ "check.conf")) {
+ GC_free(cfg);
+ return -1;
+ }
+ daemon = os_daemon_start(NULL,
+ cfg,
+ "peer.conf",
+ NO);
+ GE_ASSERT(NULL, daemon > 0);
+ GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+ cfg,
+ 30 * cronSECONDS));
+ PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
ok = YES;
- startCron();
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(2 * cronMINUTES));
- PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
- ctx = FSUI_start("fsuitest",
- NO,
+ ctx = FSUI_start(NULL,
+ cfg,
+ "fsuitest",
+ 32, /* thread pool size */
+ NO, /* no resume */
&eventCallback,
NULL);
CHECK(ctx != NULL);
filename = makeName(42);
- writeFile(filename,
- "foo bar test!",
- strlen("foo bar test!"),
- "600");
+ disk_file_write(NULL,
+ filename,
+ "foo bar test!",
+ strlen("foo bar test!"),
+ "600");
meta = ECRS_createMetaData();
- kuri = FSUI_parseListKeywordURI(2,
+ kuri = ECRS_parseListKeywordURI(NULL,
+ 2,
(const char**)keywords);
- CHECK(OK ==
- FSUI_upload(ctx,
- filename,
- 0,
- YES,
- NO,
- meta,
- kuri));
+ upload = FSUI_startUpload(ctx,
+ filename,
+ 0, /* anonymity */
+ 0, /* priority */
+ YES,
+ NO,
+ NO,
+ meta,
+ kuri,
+ kuri);
+ CHECK(upload != NULL);
ECRS_freeUri(kuri);
ECRS_freeMetaData(meta);
prog = 0;
@@ -166,10 +180,12 @@
keywords[0],
_("AND"),
keywords[1]);
- uri = FSUI_parseCharKeywordURI(keyword);
- CHECK(OK == FSUI_startSearch(ctx,
- 0,
- uri));
+ uri = ECRS_parseCharKeywordURI(NULL,
+ keyword);
+ search = FSUI_startSearch(ctx,
+ 0,
+ uri);
+ CHECK(search != NULL);
prog = 0;
while (lastEvent != FSUI_download_complete) {
prog++;
@@ -177,8 +193,15 @@
PTHREAD_SLEEP(50 * cronMILLIS);
}
FSUI_stopSearch(ctx,
- uri);
- CHECK(OK == FSUI_unindex(ctx, filename));
+ search);
+ unindex = FSUI_unindex(ctx, filename);
+ prog = 0;
+ while (lastEvent != FSUI_unindex_complete) {
+ prog++;
+ CHECK(prog < 10000);
+ PTHREAD_SLEEP(50 * cronMILLIS);
+ }
+
/* END OF TEST CODE */
FAILURE:
@@ -193,10 +216,9 @@
UNLINK(filename);
FREE(filename);
- stopCron();
- GE_ASSERT(ectx, OK == stopGNUnetDaemon());
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
- doneUtil();
+ GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
+ GC_free(cfg);
+
return (ok == YES) ? 0 : 1;
}
Modified: GNUnet/src/applications/fs/fsui/fsuitest2.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsuitest2.c 2006-09-11 05:58:23 UTC (rev
3395)
+++ GNUnet/src/applications/fs/fsui/fsuitest2.c 2006-09-11 06:27:20 UTC (rev
3396)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -27,57 +27,56 @@
#include "platform.h"
#include "gnunet_util.h"
#include "gnunet_fsui_lib.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
-static int parseCommandLine(int argc,
- char * argv[]) {
- FREENONNULL(setConfigurationString("GNUNETD",
- "_MAGIC_",
- "NO"));
- FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
- FREENONNULL(setConfigurationString("GNUNET",
- "LOGLEVEL",
- "NOTHING"));
- FREENONNULL(setConfigurationString("GNUNET",
- "GNUNETD-CONFIG",
- "check.conf"));
- return OK;
-}
static struct FSUI_Context * ctx;
-static void eventCallback(void * cls,
- const FSUI_Event * event) {
+static void * eventCallback(void * cls,
+ const FSUI_Event * event) {
+ return NULL;
}
int main(int argc, char * argv[]){
pid_t daemon;
int ok;
+ struct GC_Configuration * cfg;
- if (OK != initUtil(argc,
- argv,
- &parseCommandLine))
- return -1;
- daemon = startGNUnetDaemon(NO);
- GE_ASSERT(ectx, daemon > 0);
+ cfg = GC_create_C_impl();
+ if (-1 == GC_parse_configuration(cfg,
+ "check.conf")) {
+ GC_free(cfg);
+ return -1;
+ }
+ daemon = os_daemon_start(NULL,
+ cfg,
+ "peer.conf",
+ NO);
+ GE_ASSERT(NULL, daemon > 0);
ok = YES;
- startCron();
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(30 * cronSECONDS));
+ GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
/* ACTUAL TEST CODE */
- ctx = FSUI_start("fsuitest2",
- YES,
+ ctx = FSUI_start(NULL,
+ cfg,
+ "fsuitest2",
+ 32,
+ YES, /* do resume! */
&eventCallback,
NULL);
CHECK(ctx != NULL);
FSUI_stop(ctx);
- /* ACTUAL TEST CODE */
- ctx = FSUI_start("fsuitest2",
+ ctx = FSUI_start(NULL,
+ cfg,
+ "fsuitest2",
+ 32,
YES,
&eventCallback,
NULL);
@@ -86,10 +85,9 @@
if (ctx != NULL)
FSUI_stop(ctx);
- stopCron();
- GE_ASSERT(ectx, OK == stopGNUnetDaemon());
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
- doneUtil();
+ GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
+ GC_free(cfg);
+
return (ok == YES) ? 0 : 1;
}
Modified: GNUnet/src/applications/fs/fsui/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/searchtest.c 2006-09-11 05:58:23 UTC
(rev 3395)
+++ GNUnet/src/applications/fs/fsui/searchtest.c 2006-09-11 06:27:20 UTC
(rev 3396)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -27,33 +27,18 @@
#include "platform.h"
#include "gnunet_util.h"
#include "gnunet_fsui_lib.h"
+#include "gnunet_util_config_impl.h"
+#include "gnunet_util_network_client.h"
-#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(ectx, 0); goto FAILURE; }
+#define CHECK(a) if (!(a)) { ok = NO; GE_BREAK(NULL, 0); goto FAILURE; }
-static int parseCommandLine(int argc,
- char * argv[]) {
- FREENONNULL(setConfigurationString("GNUNETD",
- "_MAGIC_",
- "NO"));
- FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
- FREENONNULL(setConfigurationString("GNUNET",
- "LOGLEVEL",
- "NOTHING"));
- FREENONNULL(setConfigurationString("GNUNET",
- "GNUNETD-CONFIG",
- "check.conf"));
- return OK;
-}
-
static char * makeName(unsigned int i) {
char * name;
char * fn;
fn = STRDUP("/tmp/gnunet-fsuisearchtest");
- name = expandFileName(fn);
- disk_directory_create(ectx, name);
+ name = string_expandFileName(NULL, fn);
+ disk_directory_create(NULL, name);
FREE(fn);
fn = MALLOC(strlen(name) + 40);
SNPRINTF(fn,
@@ -67,13 +52,20 @@
}
static volatile enum FSUI_EventType lastEvent;
+
static struct FSUI_Context * ctx;
-static void eventCallback(void * cls,
- const FSUI_Event * event) {
+static void * eventCallback(void * cls,
+ const FSUI_Event * event) {
+ static char unused;
char * fn;
-
+
switch(event->type) {
+ case FSUI_search_resuming:
+ case FSUI_download_resuming:
+ case FSUI_upload_resuming:
+ case FSUI_unindex_resuming:
+ return &unused;
case FSUI_search_result:
printf("Received search result\n");
break;
@@ -90,16 +82,18 @@
break;
}
if (lastEvent == FSUI_download_complete)
- return; /* ignore all other events */
+ return NULL; /* ignore all other events */
lastEvent = event->type;
if (event->type == FSUI_search_result) {
fn = makeName(43);
FSUI_startDownload(ctx,
0,
+ NO,
event->data.SearchResult.fi.uri,
fn);
FREE(fn);
}
+ return NULL;
}
@@ -117,21 +111,30 @@
int prog;
struct ECRS_MetaData * meta;
struct ECRS_URI * kuri;
+ struct GC_Configuration * cfg;
+ struct FSUI_SearchList * search;
- if (OK != initUtil(argc,
- argv,
- &parseCommandLine))
- return -1;
- daemon = startGNUnetDaemon(NO);
- GE_ASSERT(ectx, daemon > 0);
- ok = YES;
- startCron();
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonRunning(30 * cronSECONDS));
+ cfg = GC_create_C_impl();
+ if (-1 == GC_parse_configuration(cfg,
+ "check.conf")) {
+ GC_free(cfg);
+ return -1;
+ }
+ daemon = os_daemon_start(NULL,
+ cfg,
+ "peer.conf",
+ NO);
+ GE_ASSERT(NULL, daemon > 0);
+ GE_ASSERT(NULL, OK == connection_wait_for_running(NULL,
+ cfg,
+ 30 * cronSECONDS));
PTHREAD_SLEEP(5 * cronSECONDS); /* give apps time to start */
-
/* ACTUAL TEST CODE */
- ctx = FSUI_start("fsuisearchtest",
+ ctx = FSUI_start(NULL,
+ cfg,
+ "fsuisearchtest",
+ 32,
YES,
&eventCallback,
NULL);
@@ -142,32 +145,41 @@
keywords[0],
_("AND"),
keywords[1]);
- uri = FSUI_parseCharKeywordURI(keyword);
- CHECK(OK == FSUI_startSearch(ctx,
- 0,
- uri));
+ uri = ECRS_parseCharKeywordURI(NULL, keyword);
+ search = FSUI_startSearch(ctx,
+ 0,
+ uri);
+ CHECK(NULL != search);
FSUI_stop(ctx);
/* resume search! */
- ctx = FSUI_start("fsuisearchtest",
+ ctx = FSUI_start(NULL,
+ cfg,
+ "fsuisearchtest",
+ 32,
YES,
&eventCallback,
NULL);
fn = makeName(42);
- writeFile(fn,
- "foo bar test!",
- strlen("foo bar test!"),
- "600");
+ disk_file_write(NULL,
+ fn,
+ "foo bar test!",
+ strlen("foo bar test!"),
+ "600");
meta = ECRS_createMetaData();
- kuri = FSUI_parseListKeywordURI(2,
+ kuri = ECRS_parseListKeywordURI(NULL,
+ 2,
(const char**)keywords);
- CHECK(OK ==
- FSUI_upload(ctx,
- fn,
- 0,
- YES,
- NO,
- meta,
- kuri));
+ CHECK(NULL !=
+ FSUI_startUpload(ctx,
+ fn,
+ 0,
+ 0,
+ YES,
+ NO,
+ NO,
+ meta,
+ kuri,
+ kuri));
ECRS_freeUri(kuri);
ECRS_freeMetaData(meta);
prog = 0;
@@ -185,9 +197,16 @@
PTHREAD_SLEEP(50 * cronMILLIS);
}
FSUI_stopSearch(ctx,
- uri);
- CHECK(OK == FSUI_unindex(ctx, fn));
+ search);
+ CHECK(NULL != FSUI_unindex(ctx, fn));
+ prog = 0;
+ while (lastEvent != FSUI_unindex_complete) {
+ prog++;
+ CHECK(prog < 10000);
+ PTHREAD_SLEEP(50 * cronMILLIS);
+ }
+
/* END OF TEST CODE */
FAILURE:
if (uri != NULL)
@@ -203,10 +222,9 @@
UNLINK(fn);
FREE(fn);
- stopCron();
- GE_ASSERT(ectx, OK == stopGNUnetDaemon());
- GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
- doneUtil();
+
+ GE_ASSERT(NULL, OK == os_daemon_stop(NULL, daemon));
+ GC_free(cfg);
return (ok == YES) ? 0 : 1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3396 - GNUnet/src/applications/fs/fsui,
grothoff <=