gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18739 - libmwmodem/src/tests


From: gnunet
Subject: [GNUnet-SVN] r18739 - libmwmodem/src/tests
Date: Wed, 21 Dec 2011 15:12:35 +0100

Author: grothoff
Date: 2011-12-21 15:12:35 +0100 (Wed, 21 Dec 2011)
New Revision: 18739

Modified:
   libmwmodem/src/tests/libmwmodem_test_ipv4.c
Log:
fixing the worst

Modified: libmwmodem/src/tests/libmwmodem_test_ipv4.c
===================================================================
--- libmwmodem/src/tests/libmwmodem_test_ipv4.c 2011-12-21 13:35:09 UTC (rev 
18738)
+++ libmwmodem/src/tests/libmwmodem_test_ipv4.c 2011-12-21 14:12:35 UTC (rev 
18739)
@@ -26,17 +26,23 @@
 #include <stdint.h>
 #include <errno.h>
 
-void Callback(void *cls, const struct MWMODEM_Package *package)
+#define MW_MAGIC_NUMBER  0x6a726f00
+
+static int global_ret;
+
+static void Callback(void *cls, const struct MWMODEM_Package *package)
 {
-       if (package->header !=(0x6a726f00))
+        if (package->header != MW_MAGIC_NUMBER)
        {
-               printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->Header!\n");
+               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->Header!\n");
+               global_ret = 2;
                return;
        }
        if ((package->time.tv_nsec!=(1*MWMODEM_TACT_NANO_SEC)% (1000 * 1000 * 
1000))&&
                                
(package->time.tv_sec!=(1*MWMODEM_TACT_NANO_SEC)/ (1000 * 1000 * 1000)))
        {
                printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->time!\n");
+               global_ret = 3;
                return;
        }
        if (package->symbolrate!=100)
@@ -50,45 +56,32 @@
                return;
        }
 
-       const struct MWMODEM_Channel channel = package->channel[0];
+       const struct MWMODEM_Channel *channel = &package->channel[0];
 
-       if (channel.modcode != 1)
+       if (channel->modcode != 1)
        {
                printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->modcode!\n");
                return;
        }
-       if (channel.queue != 10)
+       if (channel->queue != 10)
        {
                printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->queue!\n");
                return;
        }
-       if (channel.datasent != 10)
+       if (channel->datasent != 10)
        {
                printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->datasent!\n");
                return;
        }
-       if (channel.symbolratelimit != 10)
+       if (channel->symbolratelimit != 10)
        {
                printf("Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->symbolratelimit!\n");
                return;
        }
-       printf("Test of MWMODEM_run was successful!\n");
 }
 
-int testinit(struct MWMODEM_Context *context, int port)
+static int testgetsocket(struct MWMODEM_Context *context)
 {
-       MWMODEM_InformationCallback cb;
-       cb = Callback;
-
-       context = MWMODEM_init(port, AF_INET, cb, NULL);
-
-       printf("Test of MWMODEM_init was successful!\n");
-
-       return 0;
-}
-
-int testgetsocket(struct MWMODEM_Context *context)
-{
        int socket = MWMODEM_get_select_socket(context);
 
        if (-1==socket)
@@ -98,7 +91,6 @@
        }
        else
        {
-               printf("Test of MWMODEM_get_select_socket was successful!\n");
                return 0;
        }
 }
@@ -107,6 +99,7 @@
   uint8_t index;
   uint8_t modcod;
   uint8_t queue;
+  //  uint8_t RESERVED_for_align_by_c_compiler_funky;
   uint32_t datasent;
   uint32_t symbolratelimit;
 };
@@ -117,10 +110,13 @@
   uint32_t time;
   uint32_t symbolrate;
   uint8_t channelmax;
+  //  uint8_t RESERVED_for_align_by_c_compiler_funky; 
+  //  uint8_t RESERVED_for_align_by_c_compiler_funky; 
+  //  uint8_t RESERVED_for_align_by_c_compiler_funky;
   struct MWChannel *channel;
 };
 
-int generatedata()//TODO
+static int generatedata()//TODO
 {
        const struct sockaddr *address;
        struct sockaddr_in address4;
@@ -144,7 +140,7 @@
        struct MWChannel chlist[hdr.channelmax];
        chlist[0] = chl;
        hdr.channel =chlist;
-       buffer = (char) hdr;
+       buffer = (char*) &hdr;
 
        s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
@@ -163,7 +159,7 @@
 
        alen = sizeof (address4);
 
-       if (-1== sendto(s, buffer, sizeof(MWHeader), 0, address, alen))
+       if (-1== sendto(s, buffer, sizeof(struct MWHeader), 0, address, alen))
        {
                return -1;
        }
@@ -198,7 +194,7 @@
 int main(void)
 {
        struct MWMODEM_Context *context;
-       context = malloc(sizeof(context));
+       context = MWMODEM_init(port, AF_INET, &Callback, NULL);
 
        if (-1 == testinit(context, 0)) return -1;
 
@@ -210,6 +206,6 @@
 
        printf("All tests for the library with ipv4 and default port was 
successful!\n");
 
-       return 0;
+       return global_ret;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]