GNUnet  0.11.x
testing_api_cmd_netjail_start_testsystem.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2021 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_testing_ng_lib.h"
29 #include "testing_cmds.h"
30 
31 #define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
32 
33 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
34 
38 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
39 
45 {
46 
51 
56 
60  uint16_t bytes_msg;
61 
62  /* Followed by @e bytes_msg of msg.*/
63 };
64 
65 
70 struct NetJailState
71 {
77 
82 
87 
91  const struct GNUNET_HELPER_Handle **helper;
92 
97  unsigned int n_helper;
98 
103  unsigned int local_m;
104 
109  unsigned int global_n;
110 
115  unsigned int known;
116 
117 
123 
129 
135 
141 
146  char *plugin_name;
147 
151  unsigned int *read_file;
152 
157 
162 
167 };
168 
174 {
179 
184 
189 
194  unsigned int count;
195 
200  struct NetJailState *ns;
201 
206 };
207 
213 static void
215 {
216  struct NetJailState *ns = cls;
217 
218  GNUNET_free (ns);
219 }
220 
221 
226 static enum GNUNET_GenericReturnValue
227 netjail_exec_traits (void *cls,
228  const void **ret,
229  const char *trait,
230  unsigned int index)
231 {
232  struct NetJailState *ns = cls;
233  const struct GNUNET_HELPER_Handle **helper = ns->helper;
234 
235 
236  struct GNUNET_TESTING_Trait traits[] = {
239  };
240 
241  return GNUNET_TESTING_get_trait (traits,
242  ret,
243  trait,
244  index);
245 }
246 
247 
256 static void
257 clear_msg (void *cls, int result)
258 {
259  struct TestingSystemCount *tbc = cls;
260 
261  GNUNET_assert (NULL != tbc->shandle);
262  /*GNUNET_free (tbc->shandle);
263  tbc->shandle = NULL;*/
264  GNUNET_free (tbc->msg);
265  tbc->msg = NULL;
266 }
267 
268 
269 static void
271  unsigned int i,
272  unsigned int j,
273  struct NetJailState *ns,
274  struct GNUNET_MessageHeader *header
275  )
276 {
277  const struct GNUNET_HELPER_Handle *helper;
278  struct TestingSystemCount *tbc;
279 
281  "send message of type %u to locals\n",
282  header->type);
283  tbc = GNUNET_new (struct TestingSystemCount);
284  tbc->ns = ns;
285  // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone.
286  if (0 == i)
287  tbc->count = j; // + total_number;
288  else
289  tbc->count = (i - 1) * ns->local_m + j + ns->known; // + total_number ;
290 
291  helper = ns->helper[tbc->count - 1];// - total_number];
292 
293 
294 
296  (struct GNUNET_HELPER_Handle *) helper,
297  header,
298  GNUNET_NO,
299  &clear_msg,
300  tbc);
301 
302  tbc->shandle = sh;
303  // GNUNET_array_append (tbc->shandle, tbc->n_shandle, sh);
304 }
305 
306 
307 static void
308 send_all_local_tests_prepared (unsigned int i, unsigned int j, struct
309  NetJailState *ns)
310 {
312  size_t msg_length;
313 
314 
315  msg_length = sizeof(struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED);
317  reply->header.type = htons (
319  reply->header.size = htons ((uint16_t) msg_length);
320 
321  send_message_to_locals (i, j, ns, &reply->header);
322 }
323 
324 
325 static void
326 send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns)
327 {
328 
329  struct GNUNET_CMDS_ALL_PEERS_STARTED *reply;
330  size_t msg_length;
331 
332 
333  msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED);
334  reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED);
335  reply->header.type = htons (
337  reply->header.size = htons ((uint16_t) msg_length);
338 
339  send_message_to_locals (i, j, ns, &reply->header);
340 }
341 
342 
355 static int
356 helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
357 {
358  // struct TestingSystemCount *tbc = cls;
359  struct NetJailState *ns = cls;
360  unsigned int total_number = ns->local_m * ns->global_n + ns->known;
361  uint16_t message_type = ntohs (message->type);
362 
363  switch (message_type)
364  {
366  ns->number_of_testsystems_started++;
367  break;
369  ns->number_of_peers_started++;
370  if (ns->number_of_peers_started == total_number)
371  {
372  for (int i = 1; i <= ns->known; i++)
373  {
374  send_all_peers_started (0,i, ns);
375  }
376  for (int i = 1; i <= ns->global_n; i++)
377  {
378  for (int j = 1; j <= ns->local_m; j++)
379  {
380  send_all_peers_started (i,j, ns);
381  }
382  }
383  ns->number_of_peers_started = 0;
384  }
385  break;
387  ns->number_of_local_tests_prepared++;
388  if (ns->number_of_local_tests_prepared == total_number)
389  {
390  for (int i = 1; i <= ns->known; i++)
391  {
393  }
394 
395  for (int i = 1; i <= ns->global_n; i++)
396  {
397  for (int j = 1; j <= ns->local_m; j++)
398  {
400  }
401  }
402  }
403  break;
405  ns->number_of_local_tests_finished++;
406  if (ns->number_of_local_tests_finished == total_number)
407  {
408  GNUNET_SCHEDULER_cancel (ns->timeout_task);
410  }
411  break;
412  default:
413  // We received a message we can not handle.
414  GNUNET_assert (0);
415  }
416  /*if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
417  {
418  ns->number_of_testsystems_started++;
419  }
420  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
421  message->type))
422  {
423  ns->number_of_peers_started++;
424  if (ns->number_of_peers_started == total_number)
425  {
426  for (int i = 1; i <= ns->known; i++)
427  {
428  send_all_peers_started (0,i, ns);
429  }
430 
431  for (int i = 1; i <= ns->global_n; i++)
432  {
433  for (int j = 1; j <= ns->local_m; j++)
434  {
435  send_all_peers_started (i,j, ns);
436  }
437  }
438  ns->number_of_peers_started = 0;
439  }
440  }
441  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs (
442  message->type))
443  {
444  ns->number_of_local_tests_prepared++;
445  if (ns->number_of_local_tests_prepared == total_number)
446  {
447  for (int i = 1; i <= ns->known; i++)
448  {
449  send_all_local_tests_prepared (0,i, ns);
450  }
451 
452  for (int i = 1; i <= ns->global_n; i++)
453  {
454  for (int j = 1; j <= ns->local_m; j++)
455  {
456  send_all_local_tests_prepared (i,j, ns);
457  }
458  }
459  }
460  }
461  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs (
462  message->type))
463  {
464  ns->number_of_local_tests_finished++;
465  if (ns->number_of_local_tests_finished == total_number)
466  {
467  GNUNET_TESTING_async_finish (&ns->ac);
468  }
469  }
470  else
471  {
472  // We received a message we can not handle.
473  GNUNET_assert (0);
474  }*/
475 
476 
478  "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
479  total_number,
480  ns->number_of_testsystems_started,
481  ns->number_of_peers_started,
482  ns->number_of_local_tests_prepared,
483  ns->number_of_local_tests_finished,
484  ns->local_m,
485  ns->global_n,
486  ns->known);
487 
488 
489 
490 
491  return GNUNET_OK;
492 }
493 
494 
499 static void
500 exp_cb (void *cls)
501 {
502  struct TestingSystemCount *tbc = cls;
503 
504  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
506  GNUNET_TESTING_async_fail (&(tbc->ns->ac));
507 }
508 
509 
516 static struct GNUNET_CMDS_HelperInit *
518 {
519  struct GNUNET_CMDS_HelperInit *msg;
520  uint16_t plugin_name_len;
521  uint16_t msg_size;
522 
523  GNUNET_assert (NULL != plugin_name);
524  plugin_name_len = strlen (plugin_name);
525  msg_size = sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_len;
526  msg = GNUNET_malloc (msg_size);
527  msg->header.size = htons (msg_size);
529  msg->plugin_name_size = htons (plugin_name_len);
530  GNUNET_memcpy ((char *) &msg[1],
531  plugin_name,
532  plugin_name_len);
533  return msg;
534 }
535 
536 
541 static void
543  unsigned int m,
544  unsigned int n)
545 {
546  struct GNUNET_HELPER_Handle *helper;
547  struct GNUNET_CMDS_HelperInit *msg;
548  struct TestingSystemCount *tbc;
549  char *m_char;
550  char *n_char;
551  char *global_n_char;
552  char *local_m_char;
553  char *known_char;
554  char *node_id;
555  char *plugin;
556  char *read_file;
557  pid_t pid;
558  unsigned int script_num;
559  struct GNUNET_ShortHashCode *hkey;
560  struct GNUNET_HashCode hc;
561  struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
562  struct GNUNET_TESTING_NetjailNode *node;
563  struct GNUNET_TESTING_NetjailNamespace *namespace;
564  char *data_dir;
565  char *script_name;
566 
567 
568  if (0 == n)
569  script_num = m - 1;
570  else
571  script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known;
572  pid = getpid ();
573 
574  GNUNET_asprintf (&m_char, "%u", m);
575  GNUNET_asprintf (&n_char, "%u", n);
576  GNUNET_asprintf (&local_m_char, "%u", ns->local_m);
577  GNUNET_asprintf (&global_n_char, "%u",ns->global_n);
578  GNUNET_asprintf (&known_char, "%u",ns->known);
579  GNUNET_asprintf (&node_id, "%06x-%08x\n",
580  pid,
581  script_num);
582  // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
583  GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
584 
586  GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_EXEC_SCRIPT);
587  unsigned int helper_check = GNUNET_OS_check_helper_binary (
588  script_name,
589  GNUNET_YES,
590  NULL);
591 
592  tbc = GNUNET_new (struct TestingSystemCount);
593  tbc->ns = ns;
594 
595  if (GNUNET_NO == helper_check)
596  {
598  "No SUID for %s!\n",
599  script_name);
601  }
602  else if (GNUNET_NO == helper_check)
603  {
605  "%s not found!\n",
606  script_name);
608  }
609 
611  "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
612  ns->number_of_testsystems_started,
613  ns->number_of_peers_started,
614  ns->number_of_local_tests_prepared,
615  ns->number_of_local_tests_finished,
616  ns->local_m,
617  ns->global_n,
618  ns->known);
619  {
620  char *const script_argv[] = {script_name,
621  m_char,
622  n_char,
625  global_n_char,
626  local_m_char,
627  node_id,
628  read_file,
629  ns->topology_data,
630  NULL};
631  helper = GNUNET_HELPER_start (
632  GNUNET_YES,
633  script_name,
634  script_argv,
635  &helper_mst,
636  &exp_cb,
637  ns);
638  GNUNET_array_append (ns->helper, ns->n_helper, helper);
639  }
640 
641  tbc->count = ns->n_helper;
642  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
643 
644  plugin = topology->plugin;
645 
646  if (0 == m)
647  {
648 
649  GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
650  memcpy (hkey,
651  &hc,
652  sizeof (*hkey));
653  if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_globals,
654  hkey))
655  {
656  node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
657  hkey);
658  if (NULL != node->plugin)
659  plugin = node->plugin;
660  }
661 
662  }
663  else
664  {
665  GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
666  memcpy (hkey,
667  &hc,
668  sizeof (*hkey));
669  if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_namespaces,
670  hkey))
671  {
672  namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
673  hkey);
674  GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
675  memcpy (hkey,
676  &hc,
677  sizeof (*hkey));
678  if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes,
679  hkey))
680  {
681  node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
682  hkey);
683  if (NULL != node->plugin)
684  plugin = node->plugin;
685  }
686  }
687 
688 
689  }
690 
692 
693  // GNUNET_array_append (tbc->shandle, tbc->n_shandle,
694  tbc->shandle = GNUNET_HELPER_send (
695  helper,
696  &msg->header,
697  GNUNET_NO,
698  &clear_msg,
699  tbc); // );
700 
701  if (NULL == tbc->shandle)// [tbc->count - 1])
702  {
704  "Send handle is NULL!\n");
705  GNUNET_free (msg);
707  }
708  GNUNET_free (hkey);
709 }
710 
711 
717 static void
718 do_timeout (void *cls)
719 {
720  struct NetJailState *ns = cls;
721  struct GNUNET_TESTING_Command *cmd;
722 
723  ns->timeout_task = NULL;
725  "Terminating cmd due to global timeout\n");
728 }
729 
730 
738 static void
741 {
742  struct NetJailState *ns = cls;
743 
744  ns->is = is;
745  for (int i = 1; i <= ns->known; i++)
746  {
747  start_helper (ns,
748  i,
749  0);
750  }
751 
752  for (int i = 1; i <= ns->global_n; i++)
753  {
754  for (int j = 1; j <= ns->local_m; j++)
755  {
756  start_helper (ns,
757  j,
758  i);
759  }
760  }
762  "Adding timeout %s\n",
764  ns->timeout_task
765  = GNUNET_SCHEDULER_add_delayed (ns->timeout,
766  &do_timeout,
767  ns);
768 }
769 
770 
783  const char *label,
785  unsigned int *read_file,
786  char *topology_data,
788 {
789  struct NetJailState *ns;
790 
791  ns = GNUNET_new (struct NetJailState);
792  ns->local_m = topology->nodes_m;
793  ns->global_n = topology->namespaces_n;
794  ns->known = topology->nodes_x;
795  ns->plugin_name = topology->plugin;
796  ns->topology = topology;
797  ns->read_file = read_file;
798  ns->topology_data = topology_data;
800 
801  struct GNUNET_TESTING_Command cmd = {
802  .cls = ns,
803  .label = label,
804  .run = &netjail_exec_run,
805  .ac = &ns->ac,
806  .cleanup = &netjail_exec_cleanup,
807  .traits = &netjail_exec_traits
808  };
809 
810  return cmd;
811 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gnunet-abd.c:61
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
struct Plugin * plugin
The process handle to the testbed service.
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
static int result
Global testing status.
static char * plugin_name
Name of our plugin.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_helper_handles(const struct GNUNET_HELPER_Handle **value)
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" trait.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Extract a trait.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
struct GNUNET_HELPER_SendHandle * GNUNET_HELPER_send(struct GNUNET_HELPER_Handle *h, const struct GNUNET_MessageHeader *msg, int can_drop, GNUNET_HELPER_Continuation cont, void *cont_cls)
Send an message to the helper.
Definition: helper.c:661
struct GNUNET_HELPER_Handle * GNUNET_HELPER_start(int with_control_pipe, const char *binary_name, char *const binary_argv[], GNUNET_MessageTokenizerCallback cb, GNUNET_HELPER_ExceptionCallback exp_cb, void *cb_cls)
Starts a helper and begins reading from it.
Definition: helper.c:495
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary(const char *binary, bool check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY
The reply message from gnunet-cmds-helper.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_INIT
The initialization message towards gnunet-cmds-helper.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1269
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition: time.c:572
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:543
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:70
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED.
Definition: testing_cmds.h:103
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED.
Definition: testing_cmds.h:77
Initialization message for gnunet-cmds-testbed to start cmd binary.
Definition: testing_cmds.h:38
The handle to a helper process.
Definition: helper.c:79
Entry in the queue of messages we need to transmit to the helper.
Definition: helper.c:37
A 512-bit hashcode.
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Entry in list of pending tasks.
Definition: scheduler.c:135
A 256-bit hashcode.
State each asynchronous command must have in its closure.
A command to be run by the interpreter.
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.
Node in the netjail topology.
char * plugin
Plugin for the test case to be run on this node.
unsigned int index
Index number associated with the trait.
Time for relative time used by GNUnet, in microseconds.
Struct to store messages send/received by the helper into a DLL.
struct HelperMessage * prev
Kept in a DLL.
uint16_t bytes_msg
Size of the original message.
struct HelperMessage * next
Kept in a DLL.
Struct to hold information for callbacks.
unsigned int number_of_local_tests_finished
Number of local tests finished.
unsigned int n_helper
Size of the array NetJailState::helper.
struct GNUNET_TESTING_NetjailTopology * topology
The complete topology information.
char * topology_data
String with topology data or name of topology file.
char * plugin_name
Name of the test case plugin the helper will load.
unsigned int number_of_peers_started
Number of peers started.
unsigned int local_m
Number of nodes in a natted subnet.
struct GNUNET_TESTING_Interpreter * is
Global state of the interpreter, used by a command to access information about other commands.
unsigned int number_of_testsystems_started
Number of test environments started.
unsigned int * read_file
Shall we read the topology from file, or from a string.
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes.
unsigned int known
Number of global known nodes.
unsigned int global_n
Number of natted subnets.
unsigned int number_of_local_tests_prepared
Number of local tests prepared to finish.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
struct GNUNET_TIME_Relative timeout
Time after this cmd has to finish.
struct GNUNET_SCHEDULER_Task * timeout_task
Timeout task.
Struct containing the number of the test environment and the NetJailState which will be handed to cal...
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
unsigned int count
The number of the test environment.
struct GNUNET_MessageHeader * msg
The messages send to the helper.
struct TestingSystemCount * next
Kept in a DLL.
struct TestingSystemCount * prev
Kept in a DLL.
struct NetJailState * ns
Struct to store information handed over to callbacks.
static void exp_cb(void *cls)
Callback called if there was an exception during execution of the helper.
static void clear_msg(void *cls, int result)
Continuation function from GNUNET_HELPER_send()
static struct GNUNET_CMDS_HelperInit * create_helper_init_msg_(const char *plugin_name)
Function to initialize a init message for the helper.
static void do_timeout(void *cls)
Function run when the cmd terminates (good or bad) with timeout.
static void netjail_exec_cleanup(void *cls)
Code to clean up resource this cmd used.
static void netjail_exec_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function starts a helper process for each node.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_testing_system(const char *label, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int *read_file, char *topology_data, struct GNUNET_TIME_Relative timeout)
Create command.
static enum GNUNET_GenericReturnValue netjail_exec_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void start_helper(struct NetJailState *ns, unsigned int m, unsigned int n)
Function which start a single helper process.
static void send_message_to_locals(unsigned int i, unsigned int j, struct NetJailState *ns, struct GNUNET_MessageHeader *header)
static void send_all_peers_started(unsigned int i, unsigned int j, struct NetJailState *ns)
static void send_all_local_tests_prepared(unsigned int i, unsigned int j, struct NetJailState *ns)
static int helper_mst(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
#define LOG(kind,...)
Generic logging shortcut.
Message formats for communication between testing cmds helper and testcase plugins.
#define HELPER_CMDS_BINARY
Definition: testing_cmds.h:30