gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r18984 - libmwmodem/src/tests
Date: Wed, 4 Jan 2012 15:38:45 +0100

Author: ruppa
Date: 2012-01-04 15:38:45 +0100 (Wed, 04 Jan 2012)
New Revision: 18984

Modified:
   libmwmodem/src/tests/libmwmodem_test_ipv4.c
Log:


Modified: libmwmodem/src/tests/libmwmodem_test_ipv4.c
===================================================================
--- libmwmodem/src/tests/libmwmodem_test_ipv4.c 2012-01-04 14:37:11 UTC (rev 
18983)
+++ libmwmodem/src/tests/libmwmodem_test_ipv4.c 2012-01-04 14:38:45 UTC (rev 
18984)
@@ -29,65 +29,26 @@
 
 #define MW_MAGIC_NUMBER  0x6a726f00
 
-static int global_ret;
+#define ASSERT(c) if (! (c)) { fprintf (stderr, "Assertion failed in line 
%u\n", __LINE__); abort(); }
 
-// #define ASSERT(c) if (! (c)) { fprintf (stderr, "Assertion failed in line 
%u\n", __LINE__); abort(); }
-
 static void callback(void *cls, const struct MWMODEM_Package *package)
 {
-  //  ASSERT (package->header == MW_MAGIC_NUMBER);
+       ASSERT (package->header == MW_MAGIC_NUMBER);
 
-    if (package->header != MW_MAGIC_NUMBER)
-       {
-           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)))
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->time!\n");
-               global_ret = 3;
-               return;
-       }
-       if (package->symbolrate!=100)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->symbolrate!\n");
-               global_ret = 4;
-               return;
-       }
-       if (package->num_channels!=1)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->num_channels!\n");
-               global_ret = 5;
-               return;
-       }
-       printf("%d\n", package->channel[0].modcode);
-       if (package->channel[0].modcode != 1)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->modcode!\n");
-               global_ret = 6;
-               return;
-       }
-       if (package->channel[0].queue != 11)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->queue!\n");
-               global_ret = 7;
-               return;
-       }
+       ASSERT (package->time.tv_nsec!=(1*MWMODEM_TACT_NANO_SEC)% (1000 * 1000 
* 1000));
+       ASSERT (package->time.tv_sec!=(1*MWMODEM_TACT_NANO_SEC)/ (1000 * 1000 * 
1000));
 
-       if (package->channel[0].datasent != 10)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->datasent!\n");
-               global_ret = 8;
-               return;
-       }
-       if (package->channel[0].symbolratelimit != 12)
-       {
-               fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->symbolratelimit!\n");
-               global_ret = 9;
-               return;
-       }
+       ASSERT (package->symbolrate!=100);
+
+       ASSERT (package->num_channels!=1);
+
+       ASSERT (package->channel[0].modcode != 1);
+
+       ASSERT (package->channel[0].queue != 11);
+
+       ASSERT (package->channel[0].datasent != 10);
+
+       ASSERT (package->channel[0].symbolratelimit != 12);
 }
 
 static int testgetsocket(struct MWMODEM_Context *context)
@@ -109,7 +70,6 @@
   uint8_t index;
   uint8_t modcod;
   uint8_t queue;
-  //  uint8_t RESERVED_for_align_by_c_compiler_funky;
   uint32_t datasent;
   uint32_t symbolratelimit;
 };
@@ -120,13 +80,10 @@
   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;
 };
 
-static int fillDataBuffer(struct MWHeader d, char buffer[24], int len)
+static int fillDataBuffer(struct MWHeader d, char buffer[24], int num_channels)
 {
        buffer[0] = d.header ;
        buffer[1] = d.header >> 8;
@@ -141,17 +98,22 @@
        buffer[10] = d.symbolrate >> 16;
        buffer[11] = d.symbolrate >> 24;
        buffer[12] = d.channelmax;
-       buffer[13] = d.channel[0].index;
-       buffer[14] = d.channel[0].modcod;
-       buffer[15] = d.channel[0].queue;
-       buffer[16] = d.channel[0].datasent;
-       buffer[17] = d.channel[0].datasent >> 8;
-       buffer[18] = d.channel[0].datasent >> 16;
-       buffer[19] = d.channel[0].datasent >> 24;
-       buffer[20] = d.channel[0].symbolratelimit;
-       buffer[21] = d.channel[0].symbolratelimit >> 8;
-       buffer[22] = d.channel[0].symbolratelimit >> 16;
-       buffer[23] = d.channel[0].symbolratelimit >> 24;
+       int ptr, i;
+       ptr=13;
+       for (i=0; i<num_channels; i++)
+       {
+               buffer[13] = i;
+               buffer[14] = d.channel[i].modcod;
+               buffer[15] = d.channel[i].queue;
+               buffer[16] = d.channel[i].datasent;
+               buffer[17] = d.channel[i].datasent >> 8;
+               buffer[18] = d.channel[i].datasent >> 16;
+               buffer[19] = d.channel[i].datasent >> 24;
+               buffer[20] = d.channel[i].symbolratelimit;
+               buffer[21] = d.channel[i].symbolratelimit >> 8;
+               buffer[22] = d.channel[i].symbolratelimit >> 16;
+               buffer[23] = d.channel[i].symbolratelimit >> 24;
+       }
        return 0;
 }
 




reply via email to

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