gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 02/02: fix jumps


From: gnunet
Subject: [gnunet] 02/02: fix jumps
Date: Sun, 19 May 2024 21:01:20 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit ec694204b034b8add38dace561196319e46eba9b
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 19 21:01:14 2024 +0200

    fix jumps
---
 src/include/gnunet_testing_lib.h       |  8 ++++++--
 src/lib/testing/test_testing_api.c     | 19 ++++++++++++++++++-
 src/lib/testing/testing_api_cmd_stat.c | 10 +++++-----
 src/lib/testing/testing_api_loop.c     | 18 +++---------------
 4 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index b7182a06f..815ac14cf 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -692,11 +692,15 @@ GNUNET_TESTING_cmd_exec_va (
 
 /**
  * Make the instruction pointer point to @a target_label
- * only if @a counter is greater than zero.
+ * only if @a counter is greater than zero.  Note that
+ * the command that will be executed next in this case
+ * is the one AFTER @a target_label, as the command we
+ * jump to is skipped by the advancing IP after the
+ * rewind.
  *
  * @param label command label
  * @param target_label label of the new instruction pointer's destination 
after the jump;
- *                     must be before the current instruction
+ *                     must be before the current instruction (and the command 
at the @a target_label itself will not be run, but the one afterwards)
  * @param counter counts how many times the rewinding is to happen.
  */
 struct GNUNET_TESTING_Command
diff --git a/src/lib/testing/test_testing_api.c 
b/src/lib/testing/test_testing_api.c
index 04de91ce8..edf8187ec 100644
--- a/src/lib/testing/test_testing_api.c
+++ b/src/lib/testing/test_testing_api.c
@@ -35,11 +35,28 @@ main (int argc,
     { .prefix = NULL }
   };
   struct GNUNET_TESTING_Command batch[] = {
+    GNUNET_TESTING_cmd_exec_va ("batch-echo-once",
+                                GNUNET_OS_PROCESS_EXITED,
+                                0,
+                                "echo",
+                                "-n",
+                                "LI",
+                                NULL),
+    GNUNET_TESTING_cmd_exec_va ("batch-echo",
+                                GNUNET_OS_PROCESS_EXITED,
+                                0,
+                                "echo",
+                                "-n",
+                                "LA",
+                                NULL),
     GNUNET_TESTING_cmd_end ()
   };
   struct GNUNET_TESTING_Command commands[] = {
     GNUNET_TESTING_cmd_batch ("batch",
                               batch),
+    GNUNET_TESTING_cmd_rewind_ip ("rewind",
+                                  "batch-echo-once",
+                                  2),
     GNUNET_TESTING_cmd_barrier_create ("barrier",
                                        1),
     GNUNET_TESTING_cmd_barrier_reached ("barrier-reached",
@@ -89,7 +106,7 @@ main (int argc,
                                 "LA",
                                 NULL),
     GNUNET_TESTING_cmd_rewind_ip ("rewind",
-                                  "echo",
+                                  "wait-sleep",
                                   4),
     GNUNET_TESTING_cmd_end ()
   };
diff --git a/src/lib/testing/testing_api_cmd_stat.c 
b/src/lib/testing/testing_api_cmd_stat.c
index d429dda43..f751a01d0 100644
--- a/src/lib/testing/testing_api_cmd_stat.c
+++ b/src/lib/testing/testing_api_cmd_stat.c
@@ -115,10 +115,10 @@ do_stat (void *cls,
       return;
     }
     for (unsigned int j = 0;
-         NULL != bcmd[j]->run;
+         NULL != (*bcmd)[j].run;
          j++)
       do_stat (timings,
-               bcmd[j]);
+               &(*bcmd)[j]);
     return;
   }
   stat_cmd (timings,
@@ -140,9 +140,9 @@ stat_run (void *cls,
   struct GNUNET_TESTING_Timer *timings = cls;
 
   GNUNET_TESTING_interpreter_commands_iterate (is,
-                          true,
-                          &do_stat,
-                          timings);
+                                               true,
+                                               &do_stat,
+                                               timings);
 }
 
 
diff --git a/src/lib/testing/testing_api_loop.c 
b/src/lib/testing/testing_api_loop.c
index ebb527760..7317dc115 100644
--- a/src/lib/testing/testing_api_loop.c
+++ b/src/lib/testing/testing_api_loop.c
@@ -842,7 +842,6 @@ seek_batch (struct GNUNET_TESTING_Interpreter *is,
   const struct GNUNET_TESTING_Command *current;
   const struct GNUNET_TESTING_Command *icmd;
   bool found = false;
-  bool in_batch = false;
 
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_TESTING_get_trait_cmd (cmd,
@@ -871,7 +870,6 @@ seek_batch (struct GNUNET_TESTING_Interpreter *is,
         return GNUNET_SYSERR; /* failure! */
       if (GNUNET_OK == ret)
       {
-        in_batch = true;
         found = true;
         break;
       }
@@ -886,12 +884,8 @@ seek_batch (struct GNUNET_TESTING_Interpreter *is,
     GNUNET_TESTING_interpreter_fail (is);
     return GNUNET_SYSERR;
   }
-  if (in_batch)
-    GNUNET_TESTING_cmd_batch_set_current_ (cmd,
-                                           new_ip);
-  else
-    GNUNET_TESTING_cmd_batch_set_current_ (cmd,
-                                           new_ip - 1);
+  GNUNET_TESTING_cmd_batch_set_current_ (cmd,
+                                         new_ip);
   return GNUNET_OK;
 }
 
@@ -911,7 +905,6 @@ rewind_ip_run (void *cls,
   const struct GNUNET_TESTING_Command *target;
   const struct GNUNET_TESTING_Command *icmd;
   unsigned int new_ip;
-  bool in_batch = false;
   bool found = false;
 
   if (0 == ris->counter)
@@ -951,7 +944,6 @@ rewind_ip_run (void *cls,
       if (GNUNET_OK == ret)
       {
         /* counter subtraction below for batch */
-        in_batch = true;
         found = true;
         break;
       }
@@ -970,11 +962,7 @@ rewind_ip_run (void *cls,
     GNUNET_TESTING_interpreter_fail (is);
     return;
   }
-  if (in_batch)
-    is->ip = new_ip;
-  else
-    is->ip = new_ip - 1;
-  /* -1 because the interpreter_next function will advance by one */
+  is->ip = new_ip;
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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