GNUnet 0.21.0
testing_api_loop.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021-2023 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
28#include "platform.h"
29#include "gnunet_util_lib.h"
34#include "testing.h"
35
41{
46
51
56
60 void *rc_cls;
61
66
71
76
81
86
90 unsigned int cmds_n;
91
95 unsigned int n_helper;
96
102 int ip;
103
108
113
114};
115
116
125static const struct GNUNET_TESTING_Command *
127 const char *label,
128 bool future)
129{
130 int start_i = future ? is->cmds_n - 1 : is->ip;
131 int end_i = future ? is->ip + 1 : 0;
132
134 "start_i: %u end_i: %u\n",
135 start_i,
136 end_i);
137 if (NULL == label)
138 {
140 "Attempt to lookup command for empty label\n");
141 return NULL;
142 }
143 for (int i = start_i; i >= end_i; i--)
144 {
145 const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
146
147 if (NULL != cmd->run)
149 "label to compare %s\n",
150 cmd->label.value);
151 /* Give precedence to top-level commands. */
152 if ( (NULL != cmd->run) &&
153 (0 == strcmp (cmd->label.value,
154 label)) )
155 return cmd;
156
158 {
159 struct GNUNET_TESTING_Command **batch;
160 struct GNUNET_TESTING_Command *current;
161 const struct GNUNET_TESTING_Command *icmd;
162 const struct GNUNET_TESTING_Command *match;
163
167 &batch));
168 /* We must do the loop forward, but we can find the last match */
169 match = NULL;
170 for (unsigned int j = 0;
171 NULL != (icmd = &(*batch)[j])->run;
172 j++)
173 {
174 if (current == icmd)
175 break; /* do not go past current command */
176 if ( (NULL != icmd->run) &&
177 (0 == strcmp (icmd->label.value,
178 label)) )
179 match = icmd;
180 }
181 if (NULL != match)
182 return match;
183 }
184 }
186 "Command `%s' not found\n",
187 label);
188 return NULL;
189}
190
191
192const struct GNUNET_TESTING_Command *
195 const char *label)
196{
197 return get_command (is,
198 label,
199 true);
200}
201
202
203const struct GNUNET_TESTING_Command *
206 const char *label)
207{
208 return get_command (is,
209 label,
210 false);
211}
212
213
214const struct GNUNET_TESTING_Command *
217 const char *label)
218{
219 const struct GNUNET_TESTING_Command *cmd;
220
221 cmd = get_command (is,
222 label,
223 false);
224 if (NULL == cmd)
225 cmd = get_command (is,
226 label,
227 true);
228 return cmd;
229}
230
231
240static void
243{
245}
246
247
255static void
257 const char *barrier_name,
258 unsigned int global_node_number)
259{
260 struct CommandBarrierCrossable *adm;
261 size_t msg_length;
262 size_t name_len;
263
265 "send barrier crossable for barrier `%s'\n",
266 barrier_name);
267 name_len = strlen (barrier_name);
268 msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
269 adm = GNUNET_malloc (msg_length);
271 adm->header.size = htons ((uint16_t) msg_length);
272 memcpy (&adm[1], barrier_name, name_len);
274 "send message of type %u to locals\n",
275 ntohs (adm->header.type));
281 (struct GNUNET_HELPER_Handle *) is->helper[global_node_number - 1],
282 &adm->header,
283 GNUNET_NO,
284 &clear_msg,
285 NULL);
286 GNUNET_free (adm);
287}
288
289
294{
299
304};
305
306
309 const struct GNUNET_ShortHashCode *key,
310 void *value)
311{
312 struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls = cls;
313 struct GNUNET_TESTING_NetjailNode *node = value;
314 struct GNUNET_TESTING_Barrier *barrier = free_barrier_node_cb_cls->barrier;
315 struct GNUNET_TESTING_Interpreter *is = free_barrier_node_cb_cls->is;
316
318 "free_barrier_node_cb\n");
319 if (! is->finishing)
320 {
322 barrier->name,
323 node->node_number);
324 }
327 barrier->nodes,
328 key,
329 node));
330 return GNUNET_YES;
331}
332
333
334static void
336 struct GNUNET_TESTING_Barrier *barrier)
337{
338 struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = {
339 .barrier = barrier,
340 .is = is
341 };
342
343 if (NULL == barrier->nodes)
344 return;
347 &free_barrier_node_cb_cls);
349 barrier->nodes = NULL;
350}
351
352
355 const struct GNUNET_ShortHashCode *key,
356 void *value)
357{
358 struct GNUNET_TESTING_Interpreter *is = cls;
359 struct GNUNET_TESTING_Barrier *barrier = value;
360 struct CommandListEntry *pos;
361
363 barrier);
364 while (NULL != (pos = barrier->cmds_head))
365 {
367 barrier->cmds_tail,
368 pos);
369 GNUNET_free (pos);
370 }
371 GNUNET_free (barrier);
372 return GNUNET_YES;
373}
374
375
381static void
382finish_test (void *cls)
383{
384 struct GNUNET_TESTING_Interpreter *is = cls;
385 struct GNUNET_TESTING_Command *cmd;
386 const char *label;
387
388 is->finishing = true;
389 is->final_task = NULL;
391 if (NULL == is->commands[is->ip].run)
392 label = "END";
394 "Interpreter finishes at `%s' with status %d\n",
395 label,
396 is->result);
397 for (unsigned int j = 0;
398 NULL != (cmd = &is->commands[j])->run;
399 j++)
400 {
402 "Cleaning up cmd %s\n",
403 cmd->label.value);
404 cmd->cleanup (cmd->cls);
406 "Cleaned up cmd %s\n",
407 cmd->label.value);
408 }
409 if (NULL != is->task)
410 {
412 is->task = NULL;
413 }
414 if (NULL != is->timeout_task)
415 {
417 is->timeout_task = NULL;
418 }
419 if (NULL != is->send_handle)
420 {
422 is->send_handle = NULL;
423 }
425 is->rc (is->rc_cls,
426 is->result);
429 is);
432 GNUNET_free (is);
433}
434
435
441static void
442interpreter_run (void *cls);
443
444
448static void
450{
451 struct GNUNET_TESTING_Interpreter *is = cls;
452 static unsigned long long ipc;
453 static struct GNUNET_TIME_Absolute last_report;
454 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
455
456 if (GNUNET_SYSERR == is->result)
457 return; /* ignore, we already failed! */
459 if ( (! GNUNET_TESTING_cmd_is_batch_ (cmd)) ||
461 is->ip++;
462 if (0 == (ipc % 1000))
463 {
464 if (0 != ipc)
466 "Interpreter executed 1000 instructions in %s\n",
469 GNUNET_YES));
470 last_report = GNUNET_TIME_absolute_get ();
471 }
472 ipc++;
474 is);
475}
476
477
478void
480{
481 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
482
483 if (GNUNET_SYSERR == is->result)
484 {
485 GNUNET_break (0);
486 return; /* ignore, we already failed! */
487 }
488 if (NULL != cmd)
489 {
491 "Failed at command `%s'\n",
492 cmd->label.value);
493 while (GNUNET_TESTING_cmd_is_batch_ (cmd))
494 {
497 "Failed in batch at command `%s'\n",
498 cmd->label.value);
499 }
500 }
501 else
502 {
504 "Failed with CMD being NULL!\n");
505 }
507 GNUNET_assert (NULL == is->final_task);
509 is);
510}
511
512
513void
515{
519 if (NULL != ac->cont)
520 {
521 ac->cont (ac->cont_cls);
522 ac->cont = NULL;
523 }
524}
525
526
527void
529{
532 if (NULL != ac->cont)
533 {
534 ac->cont (ac->cont_cls);
535 ac->cont = NULL;
536 }
537}
538
539
550{
551 return &is->commands[is->ip];
552}
553
554
560static void
562{
563 struct GNUNET_TESTING_Interpreter *is = cls;
564 struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
565
566 is->task = NULL;
567 if (NULL == cmd->run)
568 {
570 "Running command END\n");
572 finish_test (is);
573 return;
574 }
576 "Running command `%s'\n",
577 cmd->label.value);
579 "start time of %p expected 0 is `%" PRIu64 "'\n",
580 cmd,
582 cmd->start_time
583 = cmd->last_req_time
585 cmd->num_tries = 1;
586 if (NULL != cmd->ac)
587 {
588 cmd->ac->is = is;
589 cmd->ac->cont = &interpreter_next;
590 cmd->ac->cont_cls = is;
591 cmd->ac->finished = false;
592 }
593 cmd->run (cmd->cls,
594 is);
595 if (NULL == cmd->ac)
596 {
598 }
599 else if ( (cmd->asynchronous_finish) &&
600 (NULL != cmd->ac->cont) )
601 {
602 cmd->ac->cont = NULL;
604 }
605}
606
607
613static void
615{
616 struct GNUNET_TESTING_Interpreter *is = cls;
617
618 is->timeout_task = NULL;
620 "Terminating test due to global timeout\n");
622 finish_test (is);
623}
624
625
630 void *rc_cls)
631{
633 unsigned int i;
634
636 is->rc = rc;
637 is->rc_cls = rc_cls;
639 false);
640 /* get the number of commands */
641 for (i = 0; NULL != commands[i].run; i++)
642 ;
643 is->cmds_n = i + 1;
645 "Got %u commands\n",
646 i);
647 is->commands = GNUNET_malloc_large ( (i + 1)
648 * sizeof (struct
650 GNUNET_assert (NULL != is->commands);
651 memcpy (is->commands,
652 commands,
653 sizeof (struct GNUNET_TESTING_Command) * i);
656 &do_timeout,
657 is);
659 is);
660
661 return is;
662}
663
664
667 const char *label,
672{
673 struct GNUNET_TESTING_Command cmd = {
674 .cls = cls,
675 .run = run,
676 .ac = ac,
677 .cleanup = cleanup,
678 .traits = traits
679 };
680
681 GNUNET_assert (NULL != run);
682 if (NULL != label)
684 label);
685 return cmd;
686}
687
688
689void
691 const char *value)
692{
693 size_t len;
694
695 len = strlen (value);
696 GNUNET_assert (len <=
698 memcpy (label->value,
699 value,
700 len + 1);
701}
702
703
704
707{
708 struct GNUNET_TESTING_Command cmd = {
709 .run = NULL
710 };
711
712 return cmd;
713}
714
715
720{
721
726
731
735 int rv;
736};
737
738
745static void
746handle_result (void *cls,
748{
749 struct MainParams *mp = cls;
750
752 "Test exits with status %d\n",
753 rv);
754 if (GNUNET_OK != rv)
755 mp->rv = EXIT_FAILURE;
757}
758
759
765static void
766loop_run (void *cls)
767{
768 struct MainParams *mp = cls;
769
771 mp->timeout,
773 mp);
774}
775
776
777int
780{
781 struct MainParams mp = {
783 .timeout = timeout,
784 .rv = EXIT_SUCCESS
785 };
786
788 &mp);
789 return mp.rv;
790}
791
792
793void
795 const struct GNUNET_HELPER_Handle *helper)
796{
798 is->n_helper,
799 helper);
800}
801
802
805 const char *barrier_name)
806{
807 struct GNUNET_HashCode hc;
808 struct GNUNET_ShortHashCode create_key;
809
810 GNUNET_CRYPTO_hash (barrier_name,
811 strlen (barrier_name),
812 &hc);
813 memcpy (&create_key,
814 &hc,
815 sizeof (create_key));
817 &create_key);
818}
819
820
827void
829 struct GNUNET_TESTING_Barrier *barrier)
830{
831 struct GNUNET_HashCode hc;
832 struct GNUNET_ShortHashCode create_key;
833
835 "Adding barrier %s locally\n",
836 barrier->name);
837 GNUNET_CRYPTO_hash (barrier->name,
838 strlen (barrier->name),
839 &hc);
840 memcpy (&create_key,
841 &hc,
842 sizeof (create_key));
844 &create_key,
845 barrier,
847}
848
849
850void
852 const char *barrier_name)
853{
854 struct CommandListEntry *pos;
855 struct GNUNET_TESTING_Barrier *barrier;
856
858 barrier_name);
859 if (NULL == barrier)
860 return;
861 while (NULL != (pos = barrier->cmds_head))
862 {
864 "command label %s\n",
865 pos->command->label.value);
866 if ( (GNUNET_NO == pos->command->ac->finished) &&
868 {
870 "command label %s finish\n",
871 pos->command->label.value);
873 }
874 else if (GNUNET_NO == pos->command->ac->finished)
875 {
877 }
879 barrier->cmds_tail,
880 pos);
882 "command entry label %s removed\n",
883 pos->command->label.value);
884 GNUNET_free (pos);
886 "command entry freed\n");
887 }
889 barrier);
890}
891
892
893/* end of testing_api_loop.c */
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
Definition: gnunet-arm.c:917
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:119
struct GNUNET_TESTING_Interpreter * is
static struct VoipCommand commands[]
List of supported commands.
struct GNUNET_HashCode key
The key used in the DHT.
static void cleanup(void *cls)
Disconnect and shutdown.
Definition: gnunet-did.c:131
static char * value
Value of the record to add/remove.
static int result
Global testing status.
API to manage barriers.
void(* GNUNET_TESTING_CommandRunRoutine)(void *cls, struct GNUNET_TESTING_Interpreter *is)
Signature of a function used to start executing a command of a test.
void(* GNUNET_TESTING_CommandCleanupRoutine)(void *cls)
Signature of a function used to clean up resources allocated by a command.
void(* GNUNET_TESTING_ResultCallback)(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
enum GNUNET_GenericReturnValue(* GNUNET_TESTING_CommandGetTraits)(void *cls, const void **ret, const char *trait, unsigned int index)
Signature of a function used to extract traits exposed by a command.
#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
Central interpreter and command loop for writing an interpreter to test asynchronous systems.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
@ 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...
void GNUNET_HELPER_send_cancel(struct GNUNET_HELPER_SendHandle *sh)
Cancel a GNUNET_HELPER_send operation.
Definition: helper.c:653
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,...)
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#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.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720
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_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1299
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
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:436
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_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
Message send to a child loop to inform the child loop about a barrier being advanced.
Definition: testing.h:35
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE.
Definition: testing.h:39
struct GNUNET_TESTING_Command * command
Definition: testing.h:148
Closure for free_barrier_node_cb().
struct GNUNET_TESTING_Interpreter * is
The interpreter.
struct GNUNET_TESTING_Barrier * barrier
The barrier from which the nodes are freed.
Internal representation of the hash map.
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.
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.
GNUNET_SCHEDULER_TaskCallback cont
Function to call when done.
void * cont_cls
Closure for cont.
struct GNUNET_TESTING_Interpreter * is
Interpreter we are part of.
enum GNUNET_GenericReturnValue finished
Indication if the command finished (GNUNET_OK).
const char * name
Name of the barrier.
Definition: testing.h:182
struct GNUNET_CONTAINER_MultiShortmap * nodes
Hash map containing the global known nodes which are not natted.
Definition: testing.h:177
struct CommandListEntry * cmds_tail
Tail of the DLL with local commands the barrier is attached too.
Definition: testing.h:172
struct CommandListEntry * cmds_head
Head of the DLL with local commands the barrier is attached too.
Definition: testing.h:167
Structure with storage space for a label.
A command to be run by the interpreter.
GNUNET_TESTING_CommandCleanupRoutine cleanup
Clean up after the command.
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TIME_Absolute last_req_time
When did we start the last run of this command? Delta to finish_time gives the latency for the last s...
struct GNUNET_TESTING_AsyncContext * ac
Pointer to the asynchronous context in the command's closure.
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
GNUNET_TESTING_CommandGetTraits traits
Extract information from a command that is useful for other commands.
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
unsigned int num_tries
How often did we try to execute this command? (In case it is a request that is repated....
struct GNUNET_TIME_Absolute start_time
When did the execution of this command start?
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.
GNUNET_TESTING_ResultCallback rc
Function to call with the test result.
struct GNUNET_CONTAINER_MultiShortmap * barriers
Map with barriers for this loop.
unsigned int cmds_n
Number of GNUNET_TESTING_Command in commands.
unsigned int n_helper
Size of the array helper.
void * rc_cls
Closure for rc.
struct GNUNET_SCHEDULER_Task * final_task
Final task that returns the result.
struct GNUNET_SCHEDULER_Task * timeout_task
Task run on timeout.
int ip
Instruction pointer.
struct GNUNET_HELPER_SendHandle * send_handle
Handle to a send op.
struct GNUNET_SCHEDULER_Task * task
Interpreter task (if one is scheduled).
const struct GNUNET_HELPER_Handle ** helper
Array with handles of helper processes for communication with netjails.
struct GNUNET_TESTING_Command * commands
Commands the interpreter will run.
bool finishing
Is the interpreter finishing?
enum GNUNET_GenericReturnValue result
Result of the testcases, GNUNET_OK on success.
Node in the netjail topology.
unsigned int node_number
The overall number of the node in the whole test system.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
Closure for loop_run().
int rv
Set to #EXIT_FAILURE on error.
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
struct GNUNET_TESTING_Command * GNUNET_TESTING_cmd_batch_get_current_(const struct GNUNET_TESTING_Command *cmd)
Obtain what command the batch is at.
bool GNUNET_TESTING_cmd_batch_next_(void *cls)
Advance internal pointer to next command.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.
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_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.
static void free_barrier_nodes(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
static void do_timeout(void *cls)
Function run when the test terminates (good or bad) with timeout.
static void interpreter_run(void *cls)
Run the main interpreter loop that performs exchange operations.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_future_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
static void interpreter_next(void *cls)
Current command is done, run the next one.
struct GNUNET_TESTING_Interpreter * GNUNET_TESTING_run(const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, GNUNET_TESTING_ResultCallback rc, void *rc_cls)
Run the testsuite.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
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.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
static enum GNUNET_GenericReturnValue free_barriers_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static void send_barrier_crossable(struct GNUNET_TESTING_Interpreter *is, const char *barrier_name, unsigned int global_node_number)
Send message to a netjail node that a barrier can be crossed.
void GNUNET_TESTING_add_netjail_helper_(struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_HELPER_Handle *helper)
Adding a helper handle to 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_Command GNUNET_TESTING_cmd_end(void)
Create command array terminator.
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command_all(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
void GNUNET_TESTING_set_label(struct GNUNET_TESTING_CommandLabel *label, const char *value)
Set label to value.
static const struct GNUNET_TESTING_Command * get_command(struct GNUNET_TESTING_Interpreter *is, const char *label, bool future)
Lookup command by label.
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
static enum GNUNET_GenericReturnValue free_barrier_node_cb(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the interpreter.
static void finish_test(void *cls)
Finish the test run, return the final result.
static void loop_run(void *cls)
Main function to run the test cases.
int GNUNET_TESTING_main(struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout)
Start a GNUnet scheduler event loop and run the testsuite.
static void clear_msg(void *cls, enum GNUNET_GenericReturnValue result)
Continuation function from GNUNET_HELPER_send()