GNUnet  0.17.6
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 }
304 
305 
306 static void
307 send_all_local_tests_prepared (unsigned int i, unsigned int j, struct
308  NetJailState *ns)
309 {
311  size_t msg_length;
312 
313 
314  msg_length = sizeof(struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED);
316  reply->header.type = htons (
318  reply->header.size = htons ((uint16_t) msg_length);
319 
320  send_message_to_locals (i, j, ns, &reply->header);
321  GNUNET_free (reply);
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  GNUNET_free (reply);
341 }
342 
343 
356 static int
357 helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
358 {
359  // struct TestingSystemCount *tbc = cls;
360  struct NetJailState *ns = cls;
361  unsigned int total_number = ns->local_m * ns->global_n + ns->known;
362  uint16_t message_type = ntohs (message->type);
363 
364  switch (message_type)
365  {
367  ns->number_of_testsystems_started++;
368  break;
370  ns->number_of_peers_started++;
371  if (ns->number_of_peers_started == total_number)
372  {
373  for (int i = 1; i <= ns->known; i++)
374  {
375  send_all_peers_started (0,i, ns);
376  }
377  for (int i = 1; i <= ns->global_n; i++)
378  {
379  for (int j = 1; j <= ns->local_m; j++)
380  {
381  send_all_peers_started (i,j, ns);
382  }
383  }
384  ns->number_of_peers_started = 0;
385  }
386  break;
388  ns->number_of_local_tests_prepared++;
389  if (ns->number_of_local_tests_prepared == total_number)
390  {
391  for (int i = 1; i <= ns->known; i++)
392  {
394  }
395 
396  for (int i = 1; i <= ns->global_n; i++)
397  {
398  for (int j = 1; j <= ns->local_m; j++)
399  {
401  }
402  }
403  }
404  break;
406  ns->number_of_local_tests_finished++;
407  if (ns->number_of_local_tests_finished == total_number)
408  {
409  GNUNET_SCHEDULER_cancel (ns->timeout_task);
411  }
412  break;
413  default:
414  // We received a message we can not handle.
415  GNUNET_assert (0);
416  }
417  /*if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
418  {
419  ns->number_of_testsystems_started++;
420  }
421  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED == ntohs (
422  message->type))
423  {
424  ns->number_of_peers_started++;
425  if (ns->number_of_peers_started == total_number)
426  {
427  for (int i = 1; i <= ns->known; i++)
428  {
429  send_all_peers_started (0,i, ns);
430  }
431 
432  for (int i = 1; i <= ns->global_n; i++)
433  {
434  for (int j = 1; j <= ns->local_m; j++)
435  {
436  send_all_peers_started (i,j, ns);
437  }
438  }
439  ns->number_of_peers_started = 0;
440  }
441  }
442  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs (
443  message->type))
444  {
445  ns->number_of_local_tests_prepared++;
446  if (ns->number_of_local_tests_prepared == total_number)
447  {
448  for (int i = 1; i <= ns->known; i++)
449  {
450  send_all_local_tests_prepared (0,i, ns);
451  }
452 
453  for (int i = 1; i <= ns->global_n; i++)
454  {
455  for (int j = 1; j <= ns->local_m; j++)
456  {
457  send_all_local_tests_prepared (i,j, ns);
458  }
459  }
460  }
461  }
462  else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs (
463  message->type))
464  {
465  ns->number_of_local_tests_finished++;
466  if (ns->number_of_local_tests_finished == total_number)
467  {
468  GNUNET_TESTING_async_finish (&ns->ac);
469  }
470  }
471  else
472  {
473  // We received a message we can not handle.
474  GNUNET_assert (0);
475  }*/
476 
477 
479  "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
480  total_number,
481  ns->number_of_testsystems_started,
482  ns->number_of_peers_started,
483  ns->number_of_local_tests_prepared,
484  ns->number_of_local_tests_finished,
485  ns->local_m,
486  ns->global_n,
487  ns->known);
488 
489 
490 
491 
492  return GNUNET_OK;
493 }
494 
495 
500 static void
501 exp_cb (void *cls)
502 {
503  struct NetJailState *ns = cls;
504 
505  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
506  GNUNET_SCHEDULER_cancel (ns->timeout_task);
507  GNUNET_TESTING_async_fail (&(ns->ac));
508 }
509 
510 
517 static struct GNUNET_CMDS_HelperInit *
519 {
520  struct GNUNET_CMDS_HelperInit *msg;
521  uint16_t plugin_name_len;
522  uint16_t msg_size;
523 
524  GNUNET_assert (NULL != plugin_name);
525  plugin_name_len = strlen (plugin_name);
526  msg_size = sizeof(struct GNUNET_CMDS_HelperInit) + plugin_name_len;
527  msg = GNUNET_malloc (msg_size);
528  msg->header.size = htons (msg_size);
530  msg->plugin_name_size = htons (plugin_name_len);
531  GNUNET_memcpy ((char *) &msg[1],
532  plugin_name,
533  plugin_name_len);
534  return msg;
535 }
536 
537 
542 static void
544  unsigned int m,
545  unsigned int n)
546 {
547  struct GNUNET_HELPER_Handle *helper;
548  struct GNUNET_CMDS_HelperInit *msg;
549  struct TestingSystemCount *tbc;
550  char *m_char;
551  char *n_char;
552  char *global_n_char;
553  char *local_m_char;
554  char *known_char;
555  char *node_id;
556  char *plugin;
557  char *read_file;
558  pid_t pid;
559  unsigned int script_num;
560  struct GNUNET_ShortHashCode *hkey;
561  struct GNUNET_HashCode hc;
562  struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
563  struct GNUNET_TESTING_NetjailNode *node;
564  struct GNUNET_TESTING_NetjailNamespace *namespace;
565  char *data_dir;
566  char *script_name;
567 
568 
569  if (0 == n)
570  script_num = m - 1;
571  else
572  script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known;
573  pid = getpid ();
574 
575  GNUNET_asprintf (&m_char, "%u", m);
576  GNUNET_asprintf (&n_char, "%u", n);
577  GNUNET_asprintf (&local_m_char, "%u", ns->local_m);
578  GNUNET_asprintf (&global_n_char, "%u",ns->global_n);
579  GNUNET_asprintf (&known_char, "%u",ns->known);
580  GNUNET_asprintf (&node_id, "%06x-%08x\n",
581  pid,
582  script_num);
583  // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
584  GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
585 
587  GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_EXEC_SCRIPT);
588  unsigned int helper_check = GNUNET_OS_check_helper_binary (
589  script_name,
590  GNUNET_YES,
591  NULL);
592 
593  tbc = GNUNET_new (struct TestingSystemCount);
594  tbc->ns = ns;
595 
596  if (GNUNET_NO == helper_check)
597  {
599  "No SUID for %s!\n",
600  script_name);
602  }
603  else if (GNUNET_NO == helper_check)
604  {
606  "%s not found!\n",
607  script_name);
609  }
610 
612  "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
613  ns->number_of_testsystems_started,
614  ns->number_of_peers_started,
615  ns->number_of_local_tests_prepared,
616  ns->number_of_local_tests_finished,
617  ns->local_m,
618  ns->global_n,
619  ns->known);
620  {
621  char *const script_argv[] = {script_name,
622  m_char,
623  n_char,
626  global_n_char,
627  local_m_char,
628  node_id,
629  read_file,
630  ns->topology_data,
631  NULL};
632  helper = GNUNET_HELPER_start (
633  GNUNET_YES,
634  script_name,
635  script_argv,
636  &helper_mst,
637  &exp_cb,
638  ns);
639  GNUNET_array_append (ns->helper, ns->n_helper, helper);
640  }
641 
642  tbc->count = ns->n_helper;
643  hkey = GNUNET_new (struct GNUNET_ShortHashCode);
644 
645  plugin = topology->plugin;
646 
647  if (0 == m)
648  {
649 
650  GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
651  memcpy (hkey,
652  &hc,
653  sizeof (*hkey));
654  if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_globals,
655  hkey))
656  {
657  node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals,
658  hkey);
659  if (NULL != node->plugin)
660  plugin = node->plugin;
661  }
662 
663  }
664  else
665  {
666  GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
667  memcpy (hkey,
668  &hc,
669  sizeof (*hkey));
670  if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_namespaces,
671  hkey))
672  {
673  namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
674  hkey);
675  GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
676  memcpy (hkey,
677  &hc,
678  sizeof (*hkey));
679  if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes,
680  hkey))
681  {
682  node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
683  hkey);
684  if (NULL != node->plugin)
685  plugin = node->plugin;
686  }
687  }
688 
689 
690  }
691 
693 
694  // GNUNET_array_append (tbc->shandle, tbc->n_shandle,
695  tbc->shandle = GNUNET_HELPER_send (
696  helper,
697  &msg->header,
698  GNUNET_NO,
699  &clear_msg,
700  tbc); // );
701 
702  if (NULL == tbc->shandle)// [tbc->count - 1])
703  {
705  "Send handle is NULL!\n");
707  }
708  GNUNET_free (hkey);
709  GNUNET_free (msg);
710 }
711 
712 
718 static void
719 do_timeout (void *cls)
720 {
721  struct NetJailState *ns = cls;
722  struct GNUNET_TESTING_Command *cmd;
723 
724  ns->timeout_task = NULL;
726  "Terminating cmd due to global timeout\n");
729 }
730 
731 
739 static void
742 {
743  struct NetJailState *ns = cls;
744 
745  ns->is = is;
746  for (int i = 1; i <= ns->known; i++)
747  {
748  start_helper (ns,
749  i,
750  0);
751  }
752 
753  for (int i = 1; i <= ns->global_n; i++)
754  {
755  for (int j = 1; j <= ns->local_m; j++)
756  {
757  start_helper (ns,
758  j,
759  i);
760  }
761  }
763  "Adding timeout %s\n",
765  ns->timeout_task
766  = GNUNET_SCHEDULER_add_delayed (ns->timeout,
767  &do_timeout,
768  ns);
769 }
770 
771 
784  const char *label,
786  unsigned int *read_file,
787  char *topology_data,
789 {
790  struct NetJailState *ns;
791 
792  ns = GNUNET_new (struct NetJailState);
793  ns->local_m = topology->nodes_m;
794  ns->global_n = topology->namespaces_n;
795  ns->known = topology->nodes_x;
796  ns->plugin_name = topology->plugin;
797  ns->topology = topology;
798  ns->read_file = read_file;
799  ns->topology_data = topology_data;
801 
802  struct GNUNET_TESTING_Command cmd = {
803  .cls = ns,
804  .label = label,
805  .run = &netjail_exec_run,
806  .ac = &ns->ac,
807  .cleanup = &netjail_exec_cleanup,
808  .traits = &netjail_exec_traits
809  };
810 
811  return cmd;
812 }
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.
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_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:96
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
#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:957
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:1254
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:602
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:570
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