]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Commenting test sequence is working fine
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 6 May 2025 13:23:40 +0000 (09:23 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Tue, 6 May 2025 13:23:40 +0000 (09:23 -0400)
Makefile
app/feeder.c
data-tst/feed00.tst

index 04588e3ac19cd2b3e9da3d130610e2193b6e83ab..d3dcf3718f003412dcb2f460e3b0e7401e1dd41c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -57,11 +57,11 @@ onefeed     :  debug
           @ bin/feeder                                 \
                        -f                              \
                        -d2                             \
-                       -i 127.63.31.15                 \
                        -c ./conf/feeder.conf.dvl       \
                        $(TESTIP)                       \
                        $(TESTPORT)                     \
                        $(DATATST)/feed00.tst
+                       # -i 127.63.31.15
 
 #direct test
 tstfeed        :  debug
index 2b73132092bd270c62848a8268906ccc3f01a008..9fc75517026a49a572a76f9eafebca4c49c88f99 100644 (file)
@@ -30,10 +30,18 @@ static  char testname[100];     //dest description
 typedef struct  {
         char *destip;           //IP to connect to
         char *destport;         //Port to connect to
-        char *srcip;            //Ip to be used as source
+        char *srcip;            //IP to be used as source
+        _Bool commented;        //feed in comment mode
         SOCPTR *socptr;         //connection socket
         }FEEDTYP;
 
+typedef enum    {               //List of command
+        cmd_gotls,              //going in tls mode
+        cmd_restart,            //restart connection with remote server
+        cmd_wait,               //delay exchange with remote
+        cmd_comment,            //Test sequence in int/out comment mode
+        cmd_unknown
+        }CMDTYP;
 /*
 \f
 */
@@ -94,6 +102,31 @@ return count;
 */
 /************************************************/
 /*                                             */
+/*     procedure to set feed scan in comment   */
+/*      mode.                                   */
+/*                                             */
+/************************************************/
+static _Bool setcomment(FEEDTYP *fd,char *action)
+
+{
+_Bool done;
+_Bool flag;
+
+done=false;
+flag=false;
+if (strcmp("START",action)==0)
+  flag=true;
+if (flag!=fd->commented) {
+  fd->commented=flag;
+  done=true;
+  }
+return done;
+}
+/*
+^L
+*/
+/************************************************/
+/*                                             */
 /*     procedure to set the link in TLS mode   */
 /*                                             */
 /************************************************/
@@ -163,14 +196,16 @@ static struct   {
       int code;
       const char *cmd;
       }cmdavail[]={
-            {1,"GOTLS"},
-            {2,"SLEEP"},
-            {0,(const char *)0}
+            {cmd_comment,"COMMENT"},
+            {cmd_gotls,"GOTLS"},
+            {cmd_restart,"RESTART"},
+            {cmd_wait,"WAIT"},
+            {cmd_unknown,(const char *)0}
             };
 
 int code;
 
-code=0;
+code=cmd_unknown;
 for (int i=0;cmdavail[i].cmd!=(const char *)0;i++) {
   if (strcasecmp(cmdavail[i].cmd,command)==0) {
     code=cmdavail[i].code;
@@ -188,7 +223,7 @@ return code;
 /*      protocol.                                       */
 /*                                                     */
 /********************************************************/
-static _Bool docommand(SOCPTR *socptr,int numline,char *line)
+static _Bool docommand(FEEDTYP *fd,int numline,char *line)
 
 {
 _Bool status;
@@ -200,11 +235,11 @@ if ((param=strchr(line,' '))!=(char *)0) {
   param++;              //pointer on parameter
   }
 switch (getcmd(line)) {
-  case 1        :       //GOTLS
-    if ((status=gomodetls(socptr))==false)
+  case cmd_gotls        :       //GOTLS
+    if ((status=gomodetls(fd->socptr))==false)
       (void) report(numline,line,"Unable to set TLS mode");
     break;
-  case 2        :       //SLEEP
+  case cmd_wait         :       //SLEEP mode
     if (param!=(char *)0)
       (void) sleep(atoi(param));
     else {
@@ -212,6 +247,20 @@ switch (getcmd(line)) {
       status=false;
       }
     break;
+  case cmd_restart      :       //restart link
+     fd->socptr=soc_closefeedsock(fd->socptr);
+     (void) usleep(100000); //wait 10 millisec
+     fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport);
+     if (fd->socptr==(SOCPTR *)0) {
+       (void) report(numline,line,"Unable to restart feed socket!");
+       status=false;
+       }
+    break;
+  case cmd_comment      :       //restart link
+    if (setcomment(fd,param)==false)
+      (void) report(numline,line,"Unable to set comment mode");
+    break;
+  case cmd_unknown      :
   default       :
     (void) report(numline,line,"Unknown command");
     status=false;
@@ -352,17 +401,7 @@ while (proceed==true) {
     case 2      :       //discarding comment
       switch (action) {
         case 'C'        :       //command to execute
-          status=docommand(fd->socptr,numline,line);
-          break;
-        case 'L'        :       //Restart Session
-          fd->socptr=soc_closefeedsock(fd->socptr);
-          (void) usleep(100000); //wait 10 millisec
-          fd->socptr=soc_openfeedsock(pro_smtp,fd->srcip,fd->destip,fd->destport);
-          if (fd->socptr==(SOCPTR *)0) {
-            (void) report(numline,line,"Unable to restart feed socket!");
-            status=false;
-            phase=999;          //Aborting feed job
-            }
+          status=docommand(fd,numline,line);
           break;
         case 'R'        :       //Receiving data
           status=doincoming(fd->socptr,numline,line);
@@ -373,9 +412,6 @@ while (proceed==true) {
         case 'T'        :       //Get the test titre
           status=strncpy(testname,line,sizeof(testname));
           break;
-        case 'W'        :       //Wait X second
-          (void) sleep(atoi(line));
-          break;
         default         :       //Unexpected
           line-=2;
           (void) report(numline,line,"Unexpected directive");
@@ -453,6 +489,8 @@ while (proceed==true) {
         numline++;
         while ((ptr=strrchr(line,'\n'))!=(char *)0)
           *ptr='\000';
+        if ((fd->commented==true)&&(strncmp(line,"C:",2)!=0))
+          continue; 
         if (scanline(fd,numline,line)==false) {
           phase=999;    //Trouble trouble exiting
           break;
index cfb240719b2ffccb0ac089c553c324967f99a083..d91e38e7fe550019bbe6395c7195c20f71741727 100644 (file)
 # T: Test titre or Info
 C:COMMENT START
 #====================================================
-#Please update /etc/hosts with
+#Please update /etc/hosts with with following
+#start of /etc/host addon
 #----------------------------------------------------
 #Definition to validate mailleur daemon (emlrcvr) server
 #The test serveur itself
 127.127.10.25                   mailleur.example.com    mailleur
 #remote access
-#127.168.0.1                    no reverss detection
+#127.168.0.1                    no reverss address detection
 127.168.10.1                    foreign1.badserver.tld  foreign1
 #----------------------------------------------------
+#end of /etc/host addon
 #====================================================
 C:COMMENT STOP
 #====================================================