GNUnet 0.21.0
testing_api_cmd_netjail_start_cmds_helper.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"
31#include "testing.h"
32#include "testing_cmds.h"
33
34#define NETJAIL_EXEC_SCRIPT "netjail_exec.sh"
35
36#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
37
41#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
42
48{
49
54
59
63 uint16_t bytes_msg;
64
65 /* Followed by @e bytes_msg of msg.*/
66};
67
68
73struct NetJailState
74{
80
85
90
95
100 unsigned int n_helper;
101
106 unsigned int local_m;
107
112 unsigned int global_n;
113
118 unsigned int known;
119
120
126
132
138
144
150
154 unsigned int *read_file;
155
160
165
170};
171
177{
182
187
192
197
203
208};
209
210
216static void
218{
219 struct NetJailState *ns = cls;
220 GNUNET_free (ns);
221}
222
223
230 const void **ret,
231 const char *trait,
232 unsigned int index)
233{
234 struct NetJailState *ns = cls;
235 const struct GNUNET_HELPER_Handle **helper = ns->helper;
236
237
238 struct GNUNET_TESTING_Trait traits[] = {
241 };
242
243 return GNUNET_TESTING_get_trait (traits,
244 ret,
245 trait,
246 index);
247}
248
249
258static void
259clear_msg (void *cls, int result)
260{
261 struct TestingSystemCount *tbc = cls;
262
263 GNUNET_assert (NULL != tbc->shandle);
264 // GNUNET_free (tbc->shandle);
265 GNUNET_free (tbc->plugin);
266 tbc->shandle = NULL;
267 GNUNET_free (tbc);
268}
269
270
271static void
273 unsigned int i,
274 unsigned int j,
275 struct NetJailState *ns,
276 struct GNUNET_MessageHeader *header
277 )
278{
279 const struct GNUNET_HELPER_Handle *helper;
280 struct TestingSystemCount *tbc;
281 unsigned int count;
282
284 "send message of type %u to locals\n",
285 header->type);
286 tbc = GNUNET_new (struct TestingSystemCount);
287 tbc->ns = ns;
288 if (0 == i)
289 count = j;
290 else
291 count = (i - 1) * ns->local_m + j + ns->known;
292
293 helper = ns->helper[count - 1];
294
295
297 (struct GNUNET_HELPER_Handle *) helper,
298 header,
299 GNUNET_NO,
300 &clear_msg,
301 tbc);
302
303 tbc->shandle = sh;
304}
305
306
307static void
308send_all_local_tests_prepared (unsigned int i, unsigned int j, struct
310{
312 size_t msg_length;
313
314
315 msg_length = sizeof(struct GNUNET_TESTING_CommandAllLocalTestsPrepared);
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 GNUNET_free (reply);
323}
324
325
326static void
327send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns)
328{
330 size_t msg_length;
331
332 msg_length = sizeof(struct GNUNET_TESTING_CommandAllPeersStarted);
334 reply->header.type = htons (
336 reply->header.size = htons ((uint16_t) msg_length);
337
338 send_message_to_locals (i, j, ns, &reply->header);
339 GNUNET_free (reply);
340}
341
342
343void
344barrier_attached (struct NetJailState *ns, const struct
345 GNUNET_MessageHeader *message)
346{
347 struct CommandBarrierAttached *am;
348 struct GNUNET_TESTING_NetjailNode *node;
349 struct GNUNET_TESTING_Barrier *barrier;
351 struct GNUNET_HashCode hc;
352 const char *barrier_name;
353
354 am = (struct CommandBarrierAttached *) message;
355 barrier_name = (const char *) &am[1];
356 barrier = GNUNET_TESTING_get_barrier_ (ns->is,
357 barrier_name);
358 GNUNET_assert (NULL != barrier);
359 node = GNUNET_TESTING_barrier_get_node (barrier,
360 am->node_number);
361 if (NULL == node)
362 {
364 node->node_number = am->node_number;
365
366 GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
367 memcpy (&key, &hc, sizeof (key));
369 &key,
370 node,
372 }
374 barrier->expected_reaches = barrier->expected_reaches + am->expected_reaches;
375}
376
377
378void
380 const struct GNUNET_MessageHeader *message)
381{
382 struct GNUNET_TESTING_Barrier *barrier;
383 const char *barrier_name;
385
386 rm = (const struct GNUNET_TESTING_CommandBarrierReached *) message;
387 barrier_name = (const char *) &rm[1];
388 barrier = GNUNET_TESTING_get_barrier_ (ns->is,
389 barrier_name);
390 GNUNET_assert (NULL != barrier);
392 "barrier %s reached %p %u\n",
393 barrier_name,
394 barrier,
395 barrier->reached);
396 barrier->reached++;
398 "%u %p\n",
399 barrier->reached,
400 barrier);
402 {
404 "%s can be crossed\n",
405 barrier_name);
407 barrier->name);
408 }
410 "barrier %s reached finished\n",
411 barrier_name);
412}
413
414
427static int
428helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
429{
430 struct NetJailState *ns = cls;
431 unsigned int total_number = ns->local_m * ns->global_n + ns->known;
432 uint16_t message_type = ntohs (message->type);
434
435 switch (message_type)
436 {
438 barrier_attached (ns, message);
439 break;
441 barrier_reached (ns, message);
442 break;
444 ns->number_of_testsystems_started++;
445 break;
447 ns->number_of_peers_started++;
448 if (ns->number_of_peers_started == total_number)
449 {
450 for (int i = 1; i <= ns->known; i++)
451 {
453 }
454 for (int i = 1; i <= ns->global_n; i++)
455 {
456 for (int j = 1; j <= ns->local_m; j++)
457 {
459 }
460 }
461 ns->number_of_peers_started = 0;
462 }
463 break;
465 ns->number_of_local_tests_prepared++;
466 if (ns->number_of_local_tests_prepared == total_number)
467 {
468 for (int i = 1; i <= ns->known; i++)
469 {
471 }
472
473 for (int i = 1; i <= ns->global_n; i++)
474 {
475 for (int j = 1; j <= ns->local_m; j++)
476 {
478 }
479 }
480 }
481 break;
483 lf = (struct GNUNET_TESTING_CommandLocalFinished *) message;
484
485 ns->number_of_local_tests_finished++;
486 if (GNUNET_OK != lf->rv)
487 {
489 }
490 else if (ns->number_of_local_tests_finished == total_number)
491 {
492 GNUNET_SCHEDULER_cancel (ns->timeout_task);
493 ns->timeout_task = NULL;
495 }
496 break;
497 default:
498 // We received a message we can not handle.
499 GNUNET_assert (0);
500 }
501
503 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
504 total_number,
505 ns->number_of_testsystems_started,
506 ns->number_of_peers_started,
507 ns->number_of_local_tests_prepared,
508 ns->number_of_local_tests_finished,
509 ns->local_m,
510 ns->global_n,
511 ns->known);
512
513
514 return GNUNET_OK;
515}
516
517
522static void
523exp_cb (void *cls)
524{
525 struct NetJailState *ns = cls;
526
527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
528 if (NULL != ns->timeout_task)
529 GNUNET_SCHEDULER_cancel (ns->timeout_task);
531}
532
533
542{
544 uint16_t plugin_name_len;
545 uint16_t msg_size;
546
547 GNUNET_assert (NULL != plugin_name);
548 plugin_name_len = strlen (plugin_name);
549 msg_size = sizeof(struct GNUNET_TESTING_CommandHelperInit) + plugin_name_len;
550 msg = GNUNET_malloc (msg_size);
551 msg->header.size = htons (msg_size);
553 msg->plugin_name_size = htons (plugin_name_len);
554 GNUNET_memcpy ((char *) &msg[1],
556 plugin_name_len);
557 return msg;
558}
559
560
565static void
567 unsigned int m,
568 unsigned int n)
569{
570 struct TestcasePlugin *plugin;
571 struct GNUNET_HELPER_Handle *helper;
573 struct TestingSystemCount *tbc;
574 char *m_char;
575 char *n_char;
576 char *global_n_char;
577 char *local_m_char;
578 char *known_char;
579 char *node_id;
580 char *plugin_name;
581 char *read_file;
582 pid_t pid;
583 unsigned int script_num;
584 struct GNUNET_ShortHashCode *hkey;
586 struct GNUNET_HashCode hc;
587 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
588 struct GNUNET_TESTING_NetjailNode *node;
589 struct GNUNET_TESTING_NetjailNode *barrier_node;
590 struct GNUNET_TESTING_NetjailNamespace *namespace;
591 char *data_dir;
592 char *script_name;
594 struct GNUNET_TESTING_Barrier *barrier;
595 struct GNUNET_TESTING_BarrierList *barriers;
596 unsigned int node_num;
597 char *binary_path;
598
599 if (0 == n)
600 {
601 node_num = m;
602 script_num = m - 1;
603 }
604 else
605 {
606 node_num = (n - 1) * ns->local_m + m + ns->known;
607 script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known;
608 }
609 pid = getpid ();
610
611 GNUNET_asprintf (&m_char, "%u", m);
612 GNUNET_asprintf (&n_char, "%u", n);
613 GNUNET_asprintf (&local_m_char, "%u", ns->local_m);
614 GNUNET_asprintf (&global_n_char, "%u",ns->global_n);
615 GNUNET_asprintf (&known_char, "%u",ns->known);
616 GNUNET_asprintf (&node_id, "%s%06x-%06x\n",
617 "if",
618 pid,
619 script_num);
620 // GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
622 "%u",
623 *(ns->read_file));
624
626 GNUNET_asprintf (&script_name,
627 "%s%s",
628 data_dir,
630 unsigned int helper_check = GNUNET_OS_check_helper_binary (
631 script_name,
633 NULL);
634
635 tbc = GNUNET_new (struct TestingSystemCount);
636 tbc->ns = ns;
637
638 if (GNUNET_NO == helper_check)
639 {
641 "No SUID for %s!\n",
642 script_name);
644 // FIXME: why continue here, instead of returning?
645 }
646 else if (GNUNET_NO == helper_check)
647 {
649 "%s not found!\n",
650 script_name);
652 }
653
655
657 "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
658 ns->number_of_testsystems_started,
659 ns->number_of_peers_started,
660 ns->number_of_local_tests_prepared,
661 ns->number_of_local_tests_finished,
662 ns->local_m,
663 ns->global_n,
664 ns->known);
665 {
666 char *const script_argv[] = {script_name,
667 m_char,
668 n_char,
669 binary_path,
670 global_n_char,
671 local_m_char,
672 node_id,
673 read_file,
674 ns->topology_data,
675 NULL};
676 helper = GNUNET_HELPER_start (
678 script_name,
679 script_argv,
680 &helper_mst,
681 &exp_cb,
682 ns);
683 GNUNET_array_append (ns->helper,
684 ns->n_helper,
685 helper);
686 }
688 helper);
689 plugin_name = topology->plugin;
690
691 hkey = GNUNET_new (struct GNUNET_ShortHashCode);
692 node = NULL;
693 if (0 == n)
694 {
696 sizeof(m),
697 &hc);
698 memcpy (hkey,
699 &hc,
700 sizeof (*hkey));
702 hkey))
703 {
705 hkey);
706 if (NULL != node->plugin)
707 plugin_name = node->plugin;
708 }
709 }
710 else
711 {
712 GNUNET_CRYPTO_hash (&n, sizeof(n), &hc);
713 memcpy (hkey,
714 &hc,
715 sizeof (*hkey));
717 hkey))
718 {
719 namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces,
720 hkey);
721 GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
722 memcpy (hkey,
723 &hc,
724 sizeof (*hkey));
725 if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes,
726 hkey))
727 {
728 node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes,
729 hkey);
730 if (NULL != node->plugin)
731 plugin_name = node->plugin;
732 }
733 }
734
735
736 }
737 GNUNET_assert (NULL != node);
738 node->node_number = node_num;
741 NULL);
742 barriers = plugin->api->get_waiting_for_barriers ();
743
744
745 for (pos = barriers->head; NULL != pos; pos = pos->next)
746 {
747 barrier = GNUNET_TESTING_get_barrier_ (ns->is,
748 pos->barrier_name);
749 if (NULL == barrier)
750 {
751 barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
752 barrier->name = pos->barrier_name;
753 barrier->shadow = GNUNET_YES;
755 barrier);
756 }
757 barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
758 barrier_node->node_number = node->node_number;
759 barrier_node->expected_reaches = pos->expected_reaches;
760 barrier->expected_reaches = barrier->expected_reaches
761 + pos->expected_reaches;
762 if (GNUNET_YES == barrier->shadow)
763 barrier->number_to_be_reached++;
765 "Adding barrier %p %s node %u with reach target %u\n",
766 barrier,
767 pos->barrier_name,
768 node->node_number,
769 barrier->number_to_be_reached);
771 sizeof(node->node_number),
772 &hc);
773 memcpy (&key, &hc, sizeof (key));
774 if (NULL == barrier->nodes)
775 barrier->nodes
777 GNUNET_NO);
779 &key,
780 barrier_node,
782 }
783
784 tbc->plugin = plugin;
787 helper,
788 &msg->header,
789 GNUNET_NO,
790 &clear_msg,
791 tbc);
792
793 if (NULL == tbc->shandle)
794 {
796 "Send handle is NULL!\n");
798 }
799 GNUNET_free (pos);
800 GNUNET_free (binary_path);
801 GNUNET_free (hkey);
803 GNUNET_free (m_char);
804 GNUNET_free (n_char);
805 GNUNET_free (local_m_char);
806 GNUNET_free (global_n_char);
807 GNUNET_free (known_char);
808 GNUNET_free (node_id);
810 GNUNET_free (data_dir);
811 GNUNET_free (script_name);
812 GNUNET_free (barriers);
813}
814
815
821static void
822do_timeout (void *cls)
823{
824 struct NetJailState *ns = cls;
825 struct GNUNET_TESTING_Command *cmd;
826
827 ns->timeout_task = NULL;
829 "Terminating cmd due to global timeout\n");
832}
833
834
842static void
845{
846 struct NetJailState *ns = cls;
847
848 ns->is = is;
849 for (int i = 1; i <= ns->known; i++)
850 {
852 "i %u\n",
853 i);
855 i,
856 0);
857 }
858
859 for (int i = 1; i <= ns->global_n; i++)
860 {
861 for (int j = 1; j <= ns->local_m; j++)
862 {
864 "i %u j %u\n",
865 i,
866 j);
868 j,
869 i);
870 }
871 }
873 "Adding timeout %s\n",
875 ns->timeout_task
877 &do_timeout,
878 ns);
879}
880
881
894 const char *label,
895 struct GNUNET_TESTING_NetjailTopology *topology,
896 unsigned int *read_file,
897 char *topology_data,
899{
900 struct NetJailState *ns;
901
902 ns = GNUNET_new (struct NetJailState);
903 ns->local_m = topology->nodes_m;
904 ns->global_n = topology->namespaces_n;
905 ns->known = topology->nodes_x;
906 ns->plugin_name = topology->plugin;
907 ns->topology = topology;
908 ns->read_file = read_file;
909 ns->topology_data = topology_data;
911
912 return GNUNET_TESTING_command_new (ns, label,
916 &ns->ac);
917}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static int ret
Final status code.
Definition: gnunet-arm.c:94
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
struct TestcasePlugin * plugin
The process handle to the testbed service.
struct GNUNET_TESTING_Interpreter * is
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
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.
void lf(char *msg)
Definition: gnunet_gst.c:587
API to manage barriers.
void GNUNET_TESTING_async_finish(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has finished.
void GNUNET_TESTING_async_fail(struct GNUNET_TESTING_AsyncContext *ac)
The asynchronous command of ac has failed.
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_helper_handles(const struct GNUNET_HELPER_Handle **value)
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
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
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).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
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:460
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:613
#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.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#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_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
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.
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:198
#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_BARRIER_REACHED
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
#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:975
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:1272
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
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:603
enum GNUNET_GenericReturnValue read_file(char const *const filename, char **buffer)
Definition: pabc_helper.c:71
Message send by a child loop to inform the master loop how much GNUNET_CMDS_BARRIER_REACHED messages ...
Definition: testing.h:49
uint32_t expected_reaches
How often the child loop will reach the barrier.
Definition: testing.h:58
uint32_t node_number
The number of the node the barrier is running on.
Definition: testing.h:63
The handle to a helper process.
Definition: helper.c:77
Entry in the queue of messages we need to transmit to the helper.
Definition: helper.c:35
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:136
A 256-bit hashcode.
State each asynchronous command must have in its closure.
An entry for a barrier list FIXME: why is this in the public API!??!
unsigned int expected_reaches
Number of commands attached to the barrier.
struct GNUNET_TESTING_BarrierListEntry * next
A list to hold barriers provided by plugins FIXME: why is this in the public API!?...
struct GNUNET_TESTING_BarrierListEntry * head
List head.
const char * name
Name of the barrier.
Definition: testing.h:182
unsigned int shadow
Definition: testing.h:214
unsigned int number_to_be_reached
Number of commands which need to reach the barrier to change state.
Definition: testing.h:209
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
Definition: testing.h:177
unsigned int reached
Number of commands which reached this barrier.
Definition: testing.h:197
unsigned int expected_reaches
Number of commands attached to this barrier.
Definition: testing.h:192
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED.
Definition: testing_cmds.h:108
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED.
Definition: testing_cmds.h:78
Initialization message for gnunet-cmds-testbed to start cmd binary.
Definition: testing_cmds.h:39
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
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.
unsigned int node_number
The overall number of the node in the whole test system.
char * plugin
Plugin for the test case to be run on this node.
unsigned int expected_reaches
The number of cmds waiting for a specific barrier.
struct GNUNET_CONTAINER_MultiShortmap * map_globals
Hash map containing the global known nodes which are not natted.
char * plugin
Default plugin for the test case to be run on nodes.
unsigned int nodes_m
Number of nodes per subnet.
unsigned int nodes_x
Number of global known nodes.
unsigned int namespaces_n
Number of subnets.
struct GNUNET_CONTAINER_MultiShortmap * map_namespaces
Hash map containing the subnets (for natted nodes) of the topology.
GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS get_waiting_for_barriers
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
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.
Handle for a plugin.
Definition: testing.h:94
struct GNUNET_TESTING_PluginFunctions * api
Plugin API.
Definition: testing.h:103
Struct containing the number of the netjail node and the NetJailState which will be handed to callbac...
struct GNUNET_HELPER_SendHandle * shandle
The send handle for the helper.
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.
struct TestcasePlugin * plugin
The plugin correlated to this netjail node.
struct GNUNET_TESTING_Barrier * GNUNET_TESTING_get_barrier_(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Getting a barrier from the interpreter.
void GNUNET_TESTING_finish_barrier_(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name)
Finish all "barrier reached" commands attached to this barrier.
struct GNUNET_TESTING_NetjailNode * GNUNET_TESTING_barrier_get_node(struct GNUNET_TESTING_Barrier *barrier, unsigned int node_number)
Getting a node from a map by global node number.
bool GNUNET_TESTING_barrier_crossable_(struct GNUNET_TESTING_Barrier *barrier)
This function checks, if a barrier can be crossed, which actually means that the cmd representing the...
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the loop.
static struct GNUNET_TESTING_CommandHelperInit * create_helper_init_msg_(const char *plugin_name)
Function to initialize a init message for the helper.
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 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.
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.
void barrier_attached(struct NetJailState *ns, const struct GNUNET_MessageHeader *message)
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.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_netjail_start_cmds_helper(const char *label, struct GNUNET_TESTING_NetjailTopology *topology, unsigned int *read_file, char *topology_data, struct GNUNET_TIME_Relative timeout)
Create command.
#define LOG(kind,...)
Generic logging shortcut.
void barrier_reached(struct NetJailState *ns, const struct GNUNET_MessageHeader *message)
void GNUNET_TESTING_add_netjail_helper_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to the interpreter.
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
Message formats for communication between testing cmds helper and testcase plugins.
#define HELPER_CMDS_BINARY
Definition: testing_cmds.h:30