Hi Nikos,

seems you don't get a point of fakesmsc...

with you version it's only possible to test:
fakesmsc->bearerbox->smsbox->(reply) way but fakesmsc should also allow to test:
 smsbox->bearerbox->faksesmsc

Thanks,
Alex

Nikos Balkanas schrieb:
Oops! Pretty obvious and straightforward, too. Guess too tired to read the code (or just testing if anyone was watching) Anyway please disregard previous patch. This one seems to work for both interactive and batch modes: 1) fakesmsc will wait for input if interactive, else will run messages and when receives all responses prints stats and exits.
2) Statistics only in batch mode. Meaningless in interactive mode.
3) Rudimentary matching of messages by comparing the to: field to the returned text. It is very primitive, but better than nothing.
4) No more errors like sending 10 messages and getting 24 responses.
5) Better logging. from: and to: fields are displayed in the Sent msg.
Overall more "polished" behaviour. Try it out to get the feel.
I am good for what I said. Is there interest for the multithreaded version?
It should take me less than a day to whip up one.
BR Nikos *** fakesmsc.c Thu Nov 20 03:22:30 2008
--- fakesmsc.c.orig Thu Nov 20 03:24:31 2008
***************
*** 230,236 ****
      double first_received_at, last_received_at;
      double first_sent_at, last_sent_at;
      double start_time, end_time;
!     double delta = 0;
      int interactive, maxfd;
      char *cptr;
      char buffer[IN_BUFSIZE];
--- 230,236 ----
      double first_received_at, last_received_at;
      double first_sent_at, last_sent_at;
      double start_time, end_time;
!     double delta;
      int interactive, maxfd;
      char *cptr;
      char buffer[IN_BUFSIZE];
***************
*** 237,243 ****
      fd_set rset;
      struct timeval alarm;
      FILE *fp;
-  char *p, from[25], to[11];
gwlib_init();
      setup_signal_handlers();
--- 237,242 ----
***************
*** 246,252 ****
mptr = get_and_set_debugs(argc, argv, check_args);
      num_msgs = argc - mptr;
!
      interactive = 0;
      msgs = NULL;
      fp = NULL;
--- 245,251 ----
mptr = get_and_set_debugs(argc, argv, check_args);
      num_msgs = argc - mptr;
! interactive = 0;
      msgs = NULL;
      fp = NULL;
***************
*** 283,289 ****
      last_sent_at = 0;
/* infinitely loop */
!     while (interactive || delta >= 0) {
          /* Are we on interactive mode? */
          if (interactive == 1) {
              /* Check if we need to clean things up beforehand */
--- 282,288 ----
      last_sent_at = 0;
/* infinitely loop */
!     while (1) {
          /* Are we on interactive mode? */
          if (interactive == 1) {
              /* Check if we need to clean things up beforehand */
***************
*** 326,340 ****
                  panic(0, "write failed");
++num_sent;
-     strncpy(from, octstr_get_cstr(msg), 24);
-     p = strchr(from, ' ');
-     *p = '\0';
-     strncpy(to, ++p, 10);
-     if ((p = strchr(to, ' '))) *p = '\0';
              if (num_sent == max_send)
! info(0, "fakesmsc: Sent msg %ld <%s %s>", num_sent, to, from);
              else
! debug("send", 0, "fakesmsc: Sent msg %ld <%s %s>", num_sent, to, from);
              if (rnd > 0)
                  octstr_destroy(msg);
--- 325,335 ----
                  panic(0, "write failed");
++num_sent;
              if (num_sent == max_send)
!                 info(0, "fakesmsc: sent message %ld", num_sent);
              else
!                 debug("send", 0, "fakesmsc: sent message %ld", num_sent);
! if (rnd > 0)
                  octstr_destroy(msg);
***************
*** 349,355 ****
                  delta = 0;
              if (num_sent >= max_send)
                  delta = -1;
!     if (delta > 0 || interactive) conn_wait(server, delta);
              if (conn_error(server) || conn_eof(server) || sigint_received)
                  goto over;
--- 344,350 ----
                  delta = 0;
              if (num_sent >= max_send)
                  delta = -1;
!             conn_wait(server, delta);
              if (conn_error(server) || conn_eof(server) || sigint_received)
                  goto over;
***************
*** 358,378 ****
                  last_received_at = get_current_time();
                  if (first_received_at == 0)
                      first_received_at = last_received_at;
!       if (strstr(octstr_get_cstr(line), to))
!       {
!        ++num_received;
!        if (num_received == max_send) {
!          info(0, "Got message %ld: <%s>", num_received,
!           octstr_get_cstr(line));
!           if (!interactive) break;
!        } else {
!          debug("receive", 0, "fakesmsc: Got msg %ld: <%s>", num_received,
!            octstr_get_cstr(line));
!        }
!       }
                  octstr_destroy(line);
              }
!         } while (delta > 0 || num_received < num_sent);
      }
over:
--- 353,369 ----
                  last_received_at = get_current_time();
                  if (first_received_at == 0)
                      first_received_at = last_received_at;
!                 ++num_received;
!                 if (num_received == max_send) {
!                     info(0, "Got message %ld: <%s>", num_received,
!                            octstr_get_cstr(line));
!                 } else {
! debug("receive", 0, "Got message %ld: <%s>", num_received,
!                           octstr_get_cstr(line));
!                 }
                  octstr_destroy(line);
              }
!         } while (delta > 0 || num_sent >= max_send);
      }
over:
***************
*** 385,408 ****
end_time = get_current_time(); ! if (!interactive)
!   {
! info(0, "fakesmsc: %ld messages sent and %ld received", num_sent, num_received); ! info(0, "fakesmsc: total running time %.1f seconds", end_time - start_time);
!    delta = last_sent_at - first_sent_at;
!    if (delta == 0)
!      delta = .01;
!    if (num_sent > 1)
!      info(0, "fakesmsc: from first to last sent message %.1f s, "
!        "%.1f msgs/s", delta, (num_sent - 1) / delta);
!    delta = last_received_at - first_received_at;
!    if (delta == 0)
!      delta = .01;
!    if (num_received > 1)
!      info(0, "fakesmsc: from first to last received message %.1f s, "
!        "%.1f msgs/s", delta, (num_received - 1) / delta);
!   }
      info(0, "fakesmsc: terminating");
return 0;
  }
--- 376,397 ----
end_time = get_current_time(); ! info(0, "fakesmsc: %ld messages sent and %ld received", num_sent, num_received); ! info(0, "fakesmsc: total running time %.1f seconds", end_time - start_time);
!     delta = last_sent_at - first_sent_at;
!     if (delta == 0)
!         delta = .01;
!     if (num_sent > 1)
!         info(0, "fakesmsc: from first to last sent message %.1f s, "
!                 "%.1f msgs/s", delta, (num_sent - 1) / delta);
!     delta = last_received_at - first_received_at;
!     if (delta == 0)
!         delta = .01;
!     if (num_received > 1)
!         info(0, "fakesmsc: from first to last received message %.1f s, "
!                 "%.1f msgs/s", delta, (num_received - 1) / delta);
      info(0, "fakesmsc: terminating");
return 0;
  }

    ----- Original Message -----
    *From:* Alejandro Guerrieri <mailto:[EMAIL PROTECTED]>
    *To:* Nikos Balkanas <mailto:[EMAIL PROTECTED]>
    *Cc:* [email protected] <mailto:[email protected]>
    *Sent:* Thursday, November 20, 2008 1:32 AM
    *Subject:* Re: fakesmsmc.c patch

    Nikos,

    The interactive mechanism allows you to type messages from the
    command line (one per line). Each time enter is pressed a new
    message is sent.

    Regards,

    Alejandro Guerrieri

    El 19/11/2008, a las 07:20 p.m., Nikos Balkanas escribiσ:

    Dear list,
This patch will address the following issues in test/fakesmsc.c 1) fakesmsc will no longer hangup on conn_wait when delta == -1
    (end) and will exit as soon as messages are finished.
    2) Rudimentary matching of messages by comparing the to: field to
    the returned text. It is very simple, but better than nothing.
    3) Better logging. Now from: and to: fields are displayed in the
    Sent msg.
If someone would care to explain me the logic behind interactive,
    I could also provide a serious multithreaded matrix tool able to
    grind the CPU to dust.
Fakesmsc.c.orig is the 1 month old CVS version. BR,
    Nikos
*** fakesmsc.c.orig Wed Nov 19 22:56:43 2008
    --- fakesmsc.c Wed Nov 19 18:31:12 2008
    ***************
    *** 230,236 ****
          double first_received_at, last_received_at;
          double first_sent_at, last_sent_at;
          double start_time, end_time;
    !     double delta;
          int interactive, maxfd;
          char *cptr;
          char buffer[IN_BUFSIZE];
    --- 230,236 ----
          double first_received_at, last_received_at;
          double first_sent_at, last_sent_at;
          double start_time, end_time;
    !     double delta = 0;
          int interactive, maxfd;
          char *cptr;
          char buffer[IN_BUFSIZE];
    ***************
    *** 237,242 ****
    --- 237,243 ----
          fd_set rset;
          struct timeval alarm;
          FILE *fp;
    +  char *p, from[25], to[11];
gwlib_init();
          setup_signal_handlers();
    ***************
    *** 245,251 ****
mptr = get_and_set_debugs(argc, argv, check_args);
          num_msgs = argc - mptr;
! interactive = 0;
          msgs = NULL;
          fp = NULL;
    --- 246,252 ----
mptr = get_and_set_debugs(argc, argv, check_args);
          num_msgs = argc - mptr;
! interactive = 0;
          msgs = NULL;
          fp = NULL;
    ***************
    *** 282,288 ****
          last_sent_at = 0;
/* infinitely loop */
    !     while (1) {
/* Are we on interactive mode? */ if (interactive == 1) {
                  /* Check if we need to clean things up beforehand */
    --- 283,289 ----
          last_sent_at = 0;
/* infinitely loop */
    !     while (interactive || delta >= 0) {
/* Are we on interactive mode? */ if (interactive == 1) {
                  /* Check if we need to clean things up beforehand */
    ***************
    *** 325,335 ****
                      panic(0, "write failed");
++num_sent;
                  if (num_sent == max_send)
    !                 info(0, "fakesmsc: sent message %ld", num_sent);
                  else
    !                 debug("send", 0, "fakesmsc: sent message %ld",
    num_sent);
! if (rnd > 0)
                      octstr_destroy(msg);
--- 326,340 ----
                      panic(0, "write failed");
++num_sent;
    +     strncpy(from, octstr_get_cstr(msg), 24);
    +     p = strchr(from, ' ');
    +     *p = '\0';
    +     strncpy(to, ++p, 10);
    +     if ((p = strchr(to, ' '))) *p = '\0';
                  if (num_sent == max_send)
    !                 info(0, "fakesmsc: Sent msg %ld <%s %s>",
    num_sent, to, from);
                  else
    !                 debug("send", 0, "fakesmsc: Sent msg %ld <%s
    %s>", num_sent, to, from);
                  if (rnd > 0)
                      octstr_destroy(msg);
***************
    *** 344,350 ****
                      delta = 0;
                  if (num_sent >= max_send)
                      delta = -1;
    !             conn_wait(server, delta);
                  if (conn_error(server) || conn_eof(server) ||
    sigint_received)
                      goto over;
--- 349,355 ----
                      delta = 0;
                  if (num_sent >= max_send)
                      delta = -1;
    !     if (delta > 0) conn_wait(server, delta);
                  if (conn_error(server) || conn_eof(server) ||
    sigint_received)
                      goto over;
***************
    *** 353,369 ****
                      last_received_at = get_current_time();
                      if (first_received_at == 0)
                          first_received_at = last_received_at;
    !                 ++num_received;
    !                 if (num_received == max_send) {
    !                     info(0, "Got message %ld: <%s>", num_received,
    !                            octstr_get_cstr(line));
    !                 } else {
    !                     debug("receive", 0, "Got message %ld: <%s>",
    num_received,
    !                           octstr_get_cstr(line));
    !                 }
                      octstr_destroy(line);
                  }
    !         } while (delta > 0 || num_sent >= max_send);
          }
over:
    --- 358,378 ----
                      last_received_at = get_current_time();
                      if (first_received_at == 0)
                          first_received_at = last_received_at;
    !       if (strstr(octstr_get_cstr(line), to))
    !       {
    !        ++num_received;
    !        if (num_received == max_send) {
    !          info(0, "Got message %ld: <%s>", num_received,
    !           octstr_get_cstr(line));
    !           break;
    !        } else {
    !          debug("receive", 0, "fakesmsc: Got msg %ld: <%s>",
    num_received,
    !            octstr_get_cstr(line));
    !        }
    !       }
                      octstr_destroy(line);
                  }
    !         } while (delta > 0 || num_received < num_sent);
          }
over:
    ***************
    *** 394,397 ****
return 0;
      }
    <fakesmsc.diff>



Reply via email to