GNUnet 0.22.2
testing_api_main.c File Reference
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
Include dependency graph for testing_api_main.c:

Go to the source code of this file.

Data Structures

struct  MainParams
 Closure for loop_run(). More...
 

Functions

static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv)
 Function called with the final result of the test. More...
 
static void do_shutdown (void *cls)
 
static void loop_run (void *cls)
 Main function to run the test cases. More...
 
int GNUNET_TESTING_main (const struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout)
 Start a GNUnet scheduler event loop and run the testsuite. More...
 

Function Documentation

◆ handle_result()

static void handle_result ( void *  cls,
enum GNUNET_GenericReturnValue  rv 
)
static

Function called with the final result of the test.

Parameters
clsthe struct MainParams
rvGNUNET_OK if the test passed

Definition at line 68 of file testing_api_main.c.

70{
71 struct MainParams *mp = cls;
72
73 mp->is = NULL;
74 switch (rv)
75 {
76 case GNUNET_OK:
77 mp->rv = EXIT_SUCCESS;
78 break;
79 case GNUNET_NO:
80 mp->rv = 77;
81 break;
82 case GNUNET_SYSERR:
83 mp->rv = EXIT_FAILURE;
84 break;
85 }
87 "Test exits with status %d\n",
88 mp->rv);
90}
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_INFO
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
Closure for loop_run().
int rv
Set to #EXIT_FAILURE on error.
struct GNUNET_TESTING_Interpreter * is
The interpreter.

References GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, MainParams::is, and MainParams::rv.

Referenced by loop_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Definition at line 94 of file testing_api_main.c.

95{
96 struct MainParams *mp = cls;
97
98 if (NULL != mp->is)
99 {
101 "Terminating test due to shutdown\n");
103 }
104}
void GNUNET_TESTING_interpreter_fail(struct GNUNET_TESTING_Interpreter *is)
Current command failed, clean up and fail the test case.
@ GNUNET_ERROR_TYPE_WARNING

References GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_TESTING_interpreter_fail(), and MainParams::is.

Referenced by loop_run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loop_run()

static void loop_run ( void *  cls)
static

Main function to run the test cases.

Parameters
clsa struct MainParams *

Definition at line 113 of file testing_api_main.c.

114{
115 struct MainParams *mp = cls;
116
117 mp->is = GNUNET_TESTING_run (mp->commands,
118 mp->timeout,
120 mp);
122 mp);
123}
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.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1339
const struct GNUNET_TESTING_Command * commands
NULL-label terminated array of commands.
struct GNUNET_TIME_Relative timeout
Global timeout for the test.
static void handle_result(void *cls, enum GNUNET_GenericReturnValue rv)
Function called with the final result of the test.
static void do_shutdown(void *cls)

References MainParams::commands, do_shutdown(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTING_run(), handle_result(), MainParams::is, and MainParams::timeout.

Referenced by GNUNET_TESTING_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TESTING_main()

int GNUNET_TESTING_main ( const struct GNUNET_TESTING_Command commands,
struct GNUNET_TIME_Relative  timeout 
)

Start a GNUnet scheduler event loop and run the testsuite.

Return 0 upon success. Expected to be called directly from main().

Parameters
commandsthe list of command to execute
timeouthow long to wait for each command to execute
Returns
EXIT_SUCCESS on success, EXIT_FAILURE on failure

Definition at line 127 of file testing_api_main.c.

130{
131 struct MainParams mp = {
133 .timeout = timeout,
134 .rv = EXIT_SUCCESS
135 };
136
138 &mp);
139 return mp.rv;
140}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:118
static struct VoipCommand commands[]
List of supported commands.
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:725
static void loop_run(void *cls)
Main function to run the test cases.

References commands, MainParams::commands, GNUNET_SCHEDULER_run(), loop_run(), MainParams::rv, and timeout.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: