[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18544 - in libmwmodem/src: include main tests
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18544 - in libmwmodem/src: include main tests |
Date: |
Sun, 11 Dec 2011 00:01:11 +0100 |
Author: ruppa
Date: 2011-12-11 00:01:11 +0100 (Sun, 11 Dec 2011)
New Revision: 18544
Added:
libmwmodem/src/tests/libmwmodem_test_ipv4.c
libmwmodem/src/tests/libmwmodem_test_ipv6.c
Removed:
libmwmodem/src/tests/libmwmodem_test.c
Modified:
libmwmodem/src/include/libmwmodem.h
libmwmodem/src/main/libmwmodem.c
libmwmodem/src/tests/Makefile.am
Log:
Modified: libmwmodem/src/include/libmwmodem.h
===================================================================
--- libmwmodem/src/include/libmwmodem.h 2011-12-10 13:49:39 UTC (rev 18543)
+++ libmwmodem/src/include/libmwmodem.h 2011-12-10 23:01:11 UTC (rev 18544)
@@ -52,7 +52,7 @@
*/
#define MWMODEM_MAX_QUEUE 64
-#define MWMODWM_TACT_NANO_SEC 37
+#define MWMODEM_TACT_NANO_SEC 37
/**
* Definition of all existend Modcodes of DVB-S2 with a Prefix (MOD_).
@@ -159,8 +159,8 @@
/**
* The list of actualy existing channels at the satellite modem.
*/
- //const struct MWMODEM_Channel *channel;
- struct MWMODEM_Channel *channel;
+ const struct MWMODEM_Channel *channel;
+ //struct MWMODEM_Channel *channel;
};
/**
Modified: libmwmodem/src/main/libmwmodem.c
===================================================================
--- libmwmodem/src/main/libmwmodem.c 2011-12-10 13:49:39 UTC (rev 18543)
+++ libmwmodem/src/main/libmwmodem.c 2011-12-10 23:01:11 UTC (rev 18544)
@@ -175,7 +175,7 @@
return;
}
- if (package_length==0)
+ if (package_length<=0)
{
fprintf(stderr, "Error: no message to receive!");
// FIXME: Denial of service!
@@ -224,7 +224,7 @@
else
{
package.header = ntohl(hdr->header);
- unsigned long long nstime = ntohl(hdr->time) *
MWMODWM_TACT_NANO_SEC;
+ unsigned long long nstime = ntohl(hdr->time) *
MWMODEM_TACT_NANO_SEC;
package.time.tv_nsec = nstime % (1000 * 1000 * 1000);
package.time.tv_sec = nstime / (1000 * 1000 * 1000);
package.symbolrate = ntohl(hdr->symbolrate);
@@ -268,7 +268,7 @@
}
}
- package.channel = list;
+ package.channel =(const struct MWMODEM_Channel *) list;
fc->cb(fc->cls, &package);
Modified: libmwmodem/src/tests/Makefile.am
===================================================================
--- libmwmodem/src/tests/Makefile.am 2011-12-10 13:49:39 UTC (rev 18543)
+++ libmwmodem/src/tests/Makefile.am 2011-12-10 23:01:11 UTC (rev 18544)
@@ -6,11 +6,17 @@
-I$(top_srcdir)/src/main
check_PROGRAMS = \
- libmwmodem_test
+ libmwmodem_test_ipv4 \
+ libmwmodem_test_ipv6
TESTS = $(check_PROGRAMS)
-libmwmodem_test_SOURCES = \
- libmwmodem_test.c
-libmwmodem_test_LDADD = \
+libmwmodem_test_ipv4_SOURCES = \
+ libmwmodem_test_ipv4.c
+libmwmodem_test_ipv4_LDADD = \
$(top_builddir)/src/main/libmwmodem.la
+
+libmwmodem_test_ipv6_SOURCES = \
+ libmwmodem_test_ipv6.c
+libmwmodem_test_ipv6_LDADD = \
+ $(top_builddir)/src/main/libmwmodem.la
Deleted: libmwmodem/src/tests/libmwmodem_test.c
===================================================================
--- libmwmodem/src/tests/libmwmodem_test.c 2011-12-10 13:49:39 UTC (rev
18543)
+++ libmwmodem/src/tests/libmwmodem_test.c 2011-12-10 23:01:11 UTC (rev
18544)
@@ -1,106 +0,0 @@
-/*
- This file is part of libmwmodem
- (C) 2011 Christian Rupp (and other contributing authors)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
-*/
-
-#include <libmwmodem.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <malloc.h>
-
-void MWMODEM_InformationCallback(void *cls,
- const struct MWMODEM_Package
*package)
-{
-
-}
-
-int testinit(struct MWMODEM_Context *context, int port)
-{
- void (*cb)(NULL, const struct MWMODEM_Package);
- *cb = MWMODEM_InformationCallback;
- if (-1==port)
- {
- context = MWMODEM_init(0, AF_INET, cb, NULL);
- }
- else
- {
-
- }
- return -1;
-}
-
-int testgetsocket(struct MWMODEM_Context *context, int *socket)
-{
- *socket = MWMODEM_get_select_socket(context);
-
- if (-1==*socket)
- {
- printf("Error: failure of Test from
MWMODEM_get_select_socket!");
- return -1;
- }
- else
- {
- printf("Test of MWMODEM_get_select_socket was successful!");
- return 0;
- }
-}
-
-void generatedata(int socket)
-{
-
-}
-
-int testrun(struct MWMODEM_Context *context, int socket)
-{
- generatedata(socket);
- MWMODEM_run(context);
- return 0;
-}
-
-int testfree(struct MWMODEM_Context *context)
-{
- MWMODEM_free (context);
- return 0;
-}
-
-
-int main(void)
-{
- struct MWMODEM_Context *context;
- int socket;
- context = malloc(sizeof(context));
-
- if (-1 == testinit(context, -1)) return -1;
-
- if (-1 == testgetsocket(context, &socket)) return -1;
-
- if (-1 == testrun(context, socket)) return -1;
-
- if (-1 == testfree(context)) return -1;
-
- if (-1 == testinit(context, 5)) return -1;
-
- if (-1 == testgetsocket(context, &socket)) return -1;
-
- if (-1 == testrun(context, socket)) return -1;
-
- if (-1 == testfree(context)) return -1;
-
- return 0;
-}
-
Copied: libmwmodem/src/tests/libmwmodem_test_ipv4.c (from rev 18463,
libmwmodem/src/tests/libmwmodem_test.c)
===================================================================
--- libmwmodem/src/tests/libmwmodem_test_ipv4.c (rev 0)
+++ libmwmodem/src/tests/libmwmodem_test_ipv4.c 2011-12-10 23:01:11 UTC (rev
18544)
@@ -0,0 +1,139 @@
+/*
+ This file is part of libmwmodem
+ (C) 2011 Christian Rupp (and other contributing authors)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#include <libmwmodem.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <malloc.h>
+
+typedef MWMODEM_InformationCallback(void *cls,
+ const struct MWMODEM_Package
*package)
+{
+ if (package->header != "joh0")
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->Header!");
+ return;
+ }
+ if ((package->time.tv_nsec!=(1*MWMODEM_TACT_NANO_SEC)% (1000 * 1000 *
1000))&&
+
(package->time.tvsec!=(1*MWMODEM_TACT_NANO_SEC)/ (1000 * 1000 * 1000)))
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->time!");
+ return;
+ }
+ if (package->symbolrate!=100)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->symbolrate!");
+ return;
+ }
+ if (package->num_channels!=1)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->num_channels!");
+ return;
+ }
+
+ const struct MWMODEM_Channel channel = package->channel[0];
+
+ if (channel.modcode != 1)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->modcode!");
+ return;
+ }
+ if (channel.queue != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->queue!");
+ return;
+ }
+ if (channel.datasent != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->datasent!");
+ return;
+ }
+ if (channel.symbolratelimit != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->symbolratelimit!");
+ return;
+ }
+ printf("Test of MWMODEM_run was successful!");
+};
+
+int testinit(struct MWMODEM_Context *context, int port)
+{
+ void (*cb)(NULL, const struct MWMODEM_Package);
+ *cb = MWMODEM_InformationCallback;
+
+ context = MWMODEM_init(port, AF_INET, cb, NULL);
+
+ return -1;
+}
+
+int testgetsocket(struct MWMODEM_Context *context, int *socket)
+{
+ *socket = MWMODEM_get_select_socket(context);
+
+ if (-1==*socket)
+ {
+ printf("Error: failure of Test from
MWMODEM_get_select_socket!");
+ return -1;
+ }
+ else
+ {
+ printf("Test of MWMODEM_get_select_socket was successful!");
+ return 0;
+ }
+}
+
+void generatedata(int socket)
+{
+
+}
+
+int testrun(struct MWMODEM_Context *context, int socket)
+{
+ generatedata(socket);
+ MWMODEM_run(context);
+ return 0;
+}
+
+int testfree(struct MWMODEM_Context *context)
+{
+ MWMODEM_free (context);
+ return 0;
+}
+
+
+int main(void)
+{
+ struct MWMODEM_Context *context;
+ int socket;
+ context = malloc(sizeof(context));
+
+ if (-1 == testinit(context, 0)) return -1;
+
+ if (-1 == testgetsocket(context, &socket)) return -1;
+
+ if (-1 == testrun(context, socket)) return -1;
+
+ if (-1 == testfree(context)) return -1;
+
+ printf("All tests for the library with ipv4 and default port was
successful!");
+
+ return 0;
+}
+
Property changes on: libmwmodem/src/tests/libmwmodem_test_ipv4.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: libmwmodem/src/tests/libmwmodem_test_ipv6.c
===================================================================
--- libmwmodem/src/tests/libmwmodem_test_ipv6.c (rev 0)
+++ libmwmodem/src/tests/libmwmodem_test_ipv6.c 2011-12-10 23:01:11 UTC (rev
18544)
@@ -0,0 +1,137 @@
+/*
+ This file is part of libmwmodem
+ (C) 2011 Christian Rupp (and other contributing authors)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
+#include <libmwmodem.h>
+#include <string.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <malloc.h>
+
+typedef MWMODEM_InformationCallback(void *cls,
+ const struct MWMODEM_Package
*package)
+{
+ if (package->header != "joh0")
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->Header!");
+ return;
+ }
+ if ((package->time.tv_nsec!=(1*MWMODEM_TACT_NANO_SEC)% (1000 * 1000 *
1000))&&
+ (package->time.tvsec!=(1*MWMODEM_TACT_NANO_SEC)/ (1000
* 1000 * 1000)))
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->time!");
+ return;
+ }
+ if (package->symbolrate!=100)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->symbolrate!");
+ return;
+ }
+ if (package->num_channels!=1)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->num_channels!");
+ return;
+ }
+ const struct MWMODEM_Channel channel = package->channel[0];
+ if (channel.modcode != 1)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->modcode!");
+ return;
+ }
+ if (channel.queue != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->queue!");
+ return;
+ }
+ if (channel.datasent != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->datasent!");
+ return;
+ }
+ if (channel.symbolratelimit != 10)
+ {
+ printf("Error: failure of Test from MWMODEM_run in
MWMODEM_InformationCallback at package->channel[0]->symbolratelimit!");
+ return;
+ }
+ printf("Test of MWMODEM_run was successful!");
+};
+
+int testinit(struct MWMODEM_Context *context, int port)
+{
+ void (*cb)(NULL, const struct MWMODEM_Package);
+ *cb = MWMODEM_InformationCallback;
+
+ context = MWMODEM_init(port, AF_INET6, cb, NULL);
+
+ return -1;
+}
+
+int testgetsocket(struct MWMODEM_Context *context, int *socket)
+{
+ *socket = MWMODEM_get_select_socket(context);
+
+ if (-1==*socket)
+ {
+ printf("Error: failure of Test from
MWMODEM_get_select_socket!");
+ return -1;
+ }
+ else
+ {
+ printf("Test of MWMODEM_get_select_socket was successful!");
+ return 0;
+ }
+}
+
+void generatedata(int socket)
+{
+
+}
+
+int testrun(struct MWMODEM_Context *context, int socket)
+{
+ generatedata(socket);
+ MWMODEM_run(context);
+ return 0;
+}
+
+int testfree(struct MWMODEM_Context *context)
+{
+ MWMODEM_free (context);
+ return 0;
+}
+
+
+int main(void)
+{
+ struct MWMODEM_Context *context;
+ int socket;
+ context = malloc(sizeof(context));
+
+ if (-1 == testinit(context, 5)) return -1;
+
+ if (-1 == testgetsocket(context, &socket)) return -1;
+
+ if (-1 == testrun(context, socket)) return -1;
+
+ if (-1 == testfree(context)) return -1;
+
+ printf("All tests for the library with ipv6 and user specified port was
successful!");
+
+ return 0;
+}
+
Property changes on: libmwmodem/src/tests/libmwmodem_test_ipv6.c
___________________________________________________________________
Added: svn:mime-type
+ text/plain
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18544 - in libmwmodem/src: include main tests,
gnunet <=