From 2078dd1bfbf942d36923d24836a29e40ff24989a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 17 Nov 2021 21:03:13 +0100 Subject: -fix FTBFS in testing/ --- src/testing/testing_api_loop.c | 170 +++++++---------------------------------- 1 file changed, 27 insertions(+), 143 deletions(-) (limited to 'src/testing/testing_api_loop.c') diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 868a2d750..d8d32f6df 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -36,49 +36,6 @@ */ static struct GNUNET_DISK_PipeHandle *sigpipe; - -const struct TALER_TESTING_Command * -lookup_helper (const struct TALER_TESTING_Command *cmd, - const char *label) -{ -#define BATCH_INDEX 1 - struct TALER_TESTING_Command *batch; - struct TALER_TESTING_Command *current; - struct TALER_TESTING_Command *icmd; - const struct TALER_TESTING_Command *match; - - current = TALER_TESTING_cmd_batch_get_current (cmd); - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_cmd (cmd, - BATCH_INDEX, - &batch)); - /* We must do the loop forward, but we can find the last match */ - match = NULL; - for (unsigned int j = 0; - NULL != (icmd = &batch[j])->label; - j++) - { - if (TALER_TESTING_cmd_is_batch (icmd)) - { - const struct TALER_TESTING_Command *imatch; - - imatch = lookup_helper (icmd, - label); - if (NULL != imatch) - match = imatch; - } - if ( (current != icmd) && - (NULL != icmd->label) && - (0 == strcmp (icmd->label, - label)) ) - match = icmd; - if (current == icmd) - break; - } - return match; -} - - /** * Lookup command by label. * @@ -109,12 +66,30 @@ TALER_TESTING_interpreter_lookup_command (struct TALER_TESTING_Interpreter *is, if (TALER_TESTING_cmd_is_batch (cmd)) { - const struct TALER_TESTING_Command *ret; - - ret = lookup_helper (cmd, - label); - if (NULL != ret) - return ret; + struct TALER_TESTING_Command **batch; + struct TALER_TESTING_Command *current; + struct TALER_TESTING_Command *icmd; + const struct TALER_TESTING_Command *match; + + current = TALER_TESTING_cmd_batch_get_current (cmd); + GNUNET_assert (GNUNET_OK == + TALER_TESTING_get_trait_batch_cmds (cmd, + &batch)); + /* We must do the loop forward, but we can find the last match */ + match = NULL; + for (unsigned int j = 0; + NULL != (icmd = &(*batch)[j])->label; + j++) + { + if (current == icmd) + break; /* do not go past current command */ + if ( (NULL != icmd->label) && + (0 == strcmp (icmd->label, + label)) ) + match = icmd; + } + if (NULL != match) + return match; } } GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -143,15 +118,6 @@ TALER_TESTING_interpreter_get_fakebank (struct TALER_TESTING_Interpreter *is) } -/** - * Run tests starting the "fakebank" first. The "fakebank" - * is a C minimalist version of the human-oriented Python bank, - * which is also part of the Taler project. - * - * @param is pointer to the interpreter state - * @param commands the list of commands to execute - * @param bank_url the url the fakebank is supposed to run on - */ void TALER_TESTING_run_with_fakebank (struct TALER_TESTING_Interpreter *is, struct TALER_TESTING_Command *commands, @@ -189,9 +155,6 @@ static void interpreter_run (void *cls); -/** - * Current command is done, run the next one. - */ void TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) { @@ -203,9 +166,7 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) return; /* ignore, we already failed! */ if (TALER_TESTING_cmd_is_batch (cmd)) { - TALER_TESTING_cmd_batch_next (is, - NULL, - cmd); + TALER_TESTING_cmd_batch_next (is); } else { @@ -228,11 +189,6 @@ TALER_TESTING_interpreter_next (struct TALER_TESTING_Interpreter *is) } -/** - * Current command failed, clean up and fail the test case. - * - * @param is interpreter of the test - */ void TALER_TESTING_interpreter_fail (struct TALER_TESTING_Interpreter *is) { @@ -253,11 +209,6 @@ TALER_TESTING_interpreter_fail (struct TALER_TESTING_Interpreter *is) } -/** - * Create command array terminator. - * - * @return a end-command. - */ struct TALER_TESTING_Command TALER_TESTING_cmd_end (void) { @@ -268,9 +219,6 @@ TALER_TESTING_cmd_end (void) } -/** - * Obtain current label. - */ const char * TALER_TESTING_interpreter_get_current_label (struct TALER_TESTING_Interpreter *is) @@ -418,17 +366,8 @@ maint_child_death (void *cls) enum GNUNET_OS_ProcessStatusType type; unsigned long code; - if (TALER_TESTING_cmd_is_batch (cmd)) - { - struct TALER_TESTING_Command *batch_cmd; - - GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_cmd (cmd, - 0, - &batch_cmd)); - cmd = batch_cmd; - } - + while (TALER_TESTING_cmd_is_batch (cmd)) + cmd = TALER_TESTING_cmd_batch_get_current (cmd); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got SIGCHLD for `%s'.\n", cmd->label); @@ -441,7 +380,6 @@ maint_child_death (void *cls) sizeof (c))); if (GNUNET_OK != TALER_TESTING_get_trait_process (cmd, - 0, &processp)) { GNUNET_break (0); @@ -494,12 +432,6 @@ maint_child_death (void *cls) } -/** - * Wait until we receive SIGCHLD signal. - * Then obtain the process trait of the current - * command, wait on the the zombie and continue - * with the next command. - */ void TALER_TESTING_wait_for_sigchld (struct TALER_TESTING_Interpreter *is) { @@ -516,16 +448,6 @@ TALER_TESTING_wait_for_sigchld (struct TALER_TESTING_Interpreter *is) } -/** - * Run the testsuite. Note, CMDs are copied into - * the interpreter state because they are _usually_ - * defined into the "run" method that returns after - * having scheduled the test interpreter. - * - * @param is the interpreter state - * @param commands the list of command to execute - * @param timeout how long to wait - */ void TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is, struct TALER_TESTING_Command *commands, @@ -555,15 +477,6 @@ TALER_TESTING_run2 (struct TALER_TESTING_Interpreter *is, } -/** - * Run the testsuite. Note, CMDs are copied into - * the interpreter state because they are _usually_ - * defined into the "run" method that returns after - * having scheduled the test interpreter. - * - * @param is the interpreter state - * @param commands the list of command to execute - */ void TALER_TESTING_run (struct TALER_TESTING_Interpreter *is, struct TALER_TESTING_Command *commands) @@ -622,16 +535,6 @@ sighandler_child_death (void) } -/** - * "Canonical" cert_cb used when we are connecting to the - * Exchange. - * - * @param cls closure, typically, the "run" method containing - * all the commands to be run, and a closure for it. - * @param hr HTTP response details - * @param keys the exchange's keys. - * @param compat protocol compatibility information. - */ void TALER_TESTING_cert_cb (void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, @@ -900,25 +803,6 @@ load_urls (struct TALER_TESTING_Interpreter *is) } -/** - * Install signal handlers plus schedules the main wrapper - * around the "run" method. - * - * @param main_cb the "run" method which contains all the - * commands. - * @param main_cb_cls a closure for "run", typically NULL. - * @param cfg configuration to use - * @param exchanged exchange process handle: will be put in the - * state as some commands - e.g. revoke - need to send - * signal to it, for example to let it know to reload the - * key state.. if NULL, the interpreter will run without - * trying to connect to the exchange first. - * @param exchange_connect #GNUNET_YES if the test should connect - * to the exchange, #GNUNET_NO otherwise - * @return #GNUNET_OK if all is okay, != #GNUNET_OK otherwise. - * non-GNUNET_OK codes are #GNUNET_SYSERR most of the - * times. - */ int TALER_TESTING_setup (TALER_TESTING_Main main_cb, void *main_cb_cls, -- cgit v1.2.3