[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3325 - in GNUnet/src/util: containers network_client
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3325 - in GNUnet/src/util: containers network_client |
Date: |
Sat, 26 Aug 2006 20:27:48 -0700 (PDT) |
Author: grothoff
Date: 2006-08-26 20:27:46 -0700 (Sat, 26 Aug 2006)
New Revision: 3325
Modified:
GNUnet/src/util/containers/Makefile.am
GNUnet/src/util/containers/bloomtest.c
GNUnet/src/util/containers/hashtabletest.c
GNUnet/src/util/containers/vectortest.c
GNUnet/src/util/network_client/tcpiotest.c
Log:
fixing container testcases
Modified: GNUnet/src/util/containers/Makefile.am
===================================================================
--- GNUnet/src/util/containers/Makefile.am 2006-08-27 03:17:12 UTC (rev
3324)
+++ GNUnet/src/util/containers/Makefile.am 2006-08-27 03:27:46 UTC (rev
3325)
@@ -27,17 +27,17 @@
bloomtest.c
bloomtest_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/libgnunetutil_containers.la
+ $(top_builddir)/src/util/containers/libgnunetutil_containers.la
hashtabletest_SOURCES = \
hashtabletest.c
hashtabletest_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/libgnunetutil_containers.la
+ $(top_builddir)/src/util/containers/libgnunetutil_containers.la
vectortest_SOURCES = \
vectortest.c
vectortest_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/libgnunetutil_containers.la
+ $(top_builddir)/src/util/containers/libgnunetutil_containers.la
Modified: GNUnet/src/util/containers/bloomtest.c
===================================================================
--- GNUnet/src/util/containers/bloomtest.c 2006-08-27 03:17:12 UTC (rev
3324)
+++ GNUnet/src/util/containers/bloomtest.c 2006-08-27 03:27:46 UTC (rev
3325)
@@ -18,12 +18,14 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file test/bloomtest.c
+ * @file test/containers/bloomtest.c
* @brief Testcase for the bloomfilter.
* @author Igor Wronsky
*/
#include "gnunet_util.h"
+#include "gnunet_util_containers.h"
+#include "gnunet_util_crypto.h"
#include "platform.h"
#define K 4
@@ -43,10 +45,12 @@
int ok;
int falseok;
- initUtil(argc, argv, NULL);
srand(1);
UNLINK("/tmp/bloomtest.dat");
- bf = loadBloomfilter("/tmp/bloomtest.dat", SIZE, K);
+ bf = loadBloomfilter(NULL,
+ "/tmp/bloomtest.dat",
+ SIZE,
+ K);
for(i=0;i<200;i++) {
nextHC(&tmp);
@@ -63,13 +67,15 @@
printf(" Got %d elements out of"
"200 expected after insertion.\n",
ok);
- doneUtil();
return -1;
}
freeBloomfilter(bf);
- bf=loadBloomfilter("/tmp/bloomtest.dat", SIZE, K);
+ bf=loadBloomfilter(NULL,
+ "/tmp/bloomtest.dat",
+ SIZE,
+ K);
srand(1);
ok=0;
@@ -82,7 +88,6 @@
printf(" Got %d elements out of 200"
"expected after reloading.\n",
ok);
- doneUtil();
return -1;
}
@@ -105,7 +110,6 @@
printf(" Expected 100 elements in filter"
" after adding 200 and deleting 100, got %d\n",
ok);
- doneUtil();
return -1;
}
@@ -121,8 +125,7 @@
freeBloomfilter(bf);
UNLINK("/tmp/bloomtest.dat");
- doneUtil();
- return(0);
+ return 0;
}
Modified: GNUnet/src/util/containers/hashtabletest.c
===================================================================
--- GNUnet/src/util/containers/hashtabletest.c 2006-08-27 03:17:12 UTC (rev
3324)
+++ GNUnet/src/util/containers/hashtabletest.c 2006-08-27 03:27:46 UTC (rev
3325)
@@ -18,12 +18,13 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file util/hashtabletest.c
- * @brief testcase for util/hashtable.c
+ * @file util/containers/hashtabletest.c
+ * @brief testcase for util/containers/hashtable.c
* @author Nils Durner
*/
#include "gnunet_util.h"
+#include "gnunet_util_containers.h"
#include "platform.h"
static int testHT()
@@ -94,53 +95,10 @@
return 0;
}
-
-/**
- * Perform option parsing from the command line.
- */
-static int parseCommandLine(int argc,
- char * argv[]) {
- char c;
-
- while (1) {
- int option_index = 0;
- static struct GNoption long_options[] = {
- { "loglevel",1, 0, 'L' },
- { "config", 1, 0, 'c' },
- { 0,0,0,0 }
- };
-
- c = GNgetopt_long(argc,
- argv,
- "c:L:",
- long_options,
- &option_index);
-
- if (c == -1)
- break; /* No more flags to process */
-
- switch(c) {
- case 'L':
- FREENONNULL(setConfigurationString("GNUNET",
- "LOGLEVEL",
- GNoptarg));
- break;
- case 'c':
- FREENONNULL(setConfigurationString("FILES",
- "gnunet.conf",
- GNoptarg));
- break;
- } /* end of parsing commandline */
- }
- return OK;
-}
-
int main(int argc, char * argv[]){
int ret = 0;
- initUtil(argc, argv, &parseCommandLine);
ret = testHT();
- doneUtil();
return ret;
}
Modified: GNUnet/src/util/containers/vectortest.c
===================================================================
--- GNUnet/src/util/containers/vectortest.c 2006-08-27 03:17:12 UTC (rev
3324)
+++ GNUnet/src/util/containers/vectortest.c 2006-08-27 03:27:46 UTC (rev
3325)
@@ -1,5 +1,6 @@
/*
This file is part of GNUnet
+ (C) 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
@@ -21,8 +22,9 @@
* This is a testcase for the vector, waiting to be extended.
*/
+#include "gnunet_util.h"
+#include "gnunet_util_containers.h"
#include "platform.h"
-#include "gnunet_util.h"
#define DUMP(v) fprintf(stderr, "At %d: \n", __LINE__); vectorDump(v);
Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c 2006-08-27 03:17:12 UTC (rev
3324)
+++ GNUnet/src/util/network_client/tcpiotest.c 2006-08-27 03:27:46 UTC (rev
3325)
@@ -1,9 +1,29 @@
+/*
+ This file is part of GNUnet
+ (C) 2002, 2003, 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
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
/**
- * @file test/tcpiotest.c
- * @brief testcase for util/tcpiotest.c
+ * @file util/network_client/tcpiotest.c
+ * @brief testcase for util/network_client/tcpiotest.c
*/
#include "gnunet_util.h"
+#include "gnunet_util_network_client.h"
#include "platform.h"
static int openServerSocket() {
@@ -15,11 +35,12 @@
listenerPort = getGNUnetPort();
/* create the socket */
while ( (listenerFD = SOCKET(PF_INET, SOCK_STREAM, 0)) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- "ERROR opening socket (%s). "
- "No client service started. "
- "Trying again in 30 seconds.\n",
- STRERROR(errno));
+ GE_LOG(NULL,
+ GE_ERROR | GE_BULK | GE_USER,
+ "ERROR opening socket (%s). "
+ "No client service started. "
+ "Trying again in 30 seconds.\n",
+ STRERROR(errno));
sleep(30);
}
@@ -41,19 +62,21 @@
if (BIND (listenerFD,
(struct sockaddr *) &serverAddr,
sizeof(serverAddr)) < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- "ERROR (%s) binding the TCP listener to port %d. "
- "Test failed. Is gnunetd running?\n",
- STRERROR(errno),
- listenerPort);
+ GE_LOG(NULL,
+ GE_ERROR | GE_BULK | GE_USER,
+ "ERROR (%s) binding the TCP listener to port %d. "
+ "Test failed. Is gnunetd running?\n",
+ STRERROR(errno),
+ listenerPort);
return -1;
}
/* start listening for new connections */
if (0 != LISTEN(listenerFD, 5)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- " listen failed: %s\n",
- STRERROR(errno));
+ GE_LOG(NULL,
+ GE_ERROR | GE_BULK | GE_USER,
+ " listen failed: %s\n",
+ STRERROR(errno));
return -1;
}
return listenerFD;
@@ -71,68 +94,29 @@
(struct sockaddr *)&clientAddr,
&lenOfIncomingAddr);
if (incomingFD < 0) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- "ERROR accepting new connection (%s).\n",
- STRERROR(errno));
+ GE_LOG(NULL,
+ GE_ERROR | GE_BULK | GE_USER,
+ "ERROR accepting new connection (%s).\n",
+ STRERROR(errno));
continue;
}
}
return incomingFD;
}
-/**
- * Perform option parsing from the command line.
- */
-static int parseCommandLine(int argc,
- char * argv[]) {
- char c;
-
- while (1) {
- int option_index = 0;
- static struct GNoption long_options[] = {
- { "config", 1, 0, 'c' },
- { 0,0,0,0 }
- };
-
- c = GNgetopt_long(argc,
- argv,
- "c:",
- long_options,
- &option_index);
-
- if (c == -1)
- break; /* No more flags to process */
-
- switch(c) {
- case 'c':
- FREENONNULL(setConfigurationString("FILES",
- "gnunet.conf",
- GNoptarg));
- break;
- } /* end of parsing commandline */
- }
- FREENONNULL(setConfigurationString("GNUNETD",
- "LOGFILE",
- NULL));
- FREENONNULL(setConfigurationString("GNUNETD",
- "LOGLEVEL",
- "DEBUG"));
- return OK;
-}
-
static int testTransmission(struct ClientServerConnection * a,
struct ClientServerConnection * b) {
- CS_MESSAGE_HEADER * hdr;
- CS_MESSAGE_HEADER * buf;
+ MESSAGE_HEADER * hdr;
+ MESSAGE_HEADER * buf;
int i;
int j;
hdr = MALLOC(1024);
- for (i=0;i<1024-sizeof(CS_MESSAGE_HEADER);i+=7) {
+ for (i=0;i<1024-sizeof(MESSAGE_HEADER);i+=7) {
fprintf(stderr, ".");
for (j=0;j<i;j++)
((char*)&hdr[1])[j] = (char)i+j;
- hdr->size = htons(i+sizeof(CS_MESSAGE_HEADER));
+ hdr->size = htons(i+sizeof(MESSAGE_HEADER));
hdr->type = 0;
if (OK != connection_write(a, hdr)) {
FREE(hdr);
@@ -143,7 +127,7 @@
FREE(hdr);
return 2;
}
- if (0 != memcmp(buf, hdr, i+sizeof(CS_MESSAGE_HEADER))) {
+ if (0 != memcmp(buf, hdr, i+sizeof(MESSAGE_HEADER))) {
FREE(buf);
FREE(hdr);
return 4;
@@ -156,15 +140,15 @@
static int testNonblocking(struct ClientServerConnection * a,
struct ClientServerConnection * b) {
- CS_MESSAGE_HEADER * hdr;
- CS_MESSAGE_HEADER * buf;
+ MESSAGE_HEADER * hdr;
+ MESSAGE_HEADER * buf;
int i;
int cnt;
hdr = MALLOC(1024);
- for (i=0;i<1024-sizeof(CS_MESSAGE_HEADER);i+=11)
+ for (i=0;i<1024-sizeof(MESSAGE_HEADER);i+=11)
((char*)&hdr[1])[i] = (char)i;
- hdr->size = htons(64+sizeof(CS_MESSAGE_HEADER));
+ hdr->size = htons(64+sizeof(MESSAGE_HEADER));
hdr->type = 0;
while (OK == connection_writeNonBlocking(a,
hdr))
@@ -181,7 +165,7 @@
FREE(hdr);
return 16;
}
- if (0 != memcmp(buf, hdr, 64+sizeof(CS_MESSAGE_HEADER))) {
+ if (0 != memcmp(buf, hdr, 64+sizeof(MESSAGE_HEADER))) {
printf("Failure in message %u. Headers: %d ? %d\n",
i,
buf->type,
@@ -207,7 +191,7 @@
FREE(hdr);
return 128;
}
- if (0 != memcmp(buf, hdr, 64+sizeof(CS_MESSAGE_HEADER))) {
+ if (0 != memcmp(buf, hdr, 64+sizeof(MESSAGE_HEADER))) {
FREE(buf);
FREE(hdr);
return 256;
@@ -225,12 +209,10 @@
struct ClientServerConnection acceptSocket;
ret = 0;
- initUtil(argc, argv, &parseCommandLine);
serverSocket = openServerSocket();
clientSocket = getClientSocket();
if (serverSocket == -1) {
connection_destroy(clientSocket);
- doneUtil();
return 1;
}
for (i=0;i<2;i++) {
@@ -254,7 +236,6 @@
}
}
connection_destroy(clientSocket);
- doneUtil();
if (ret > 0)
fprintf(stderr, "Error %d\n", ret);
return ret;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3325 - in GNUnet/src/util: containers network_client,
grothoff <=